Skip to content

[8.x.x Backport] Disabling speedtree warnings about pow and vector truncation (Part 2) #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#ifndef UNIVERSAL_SPEEDTREE7BILLBOARD_PASSES_INCLUDED
#define UNIVERSAL_SPEEDTREE7BILLBOARD_PASSES_INCLUDED

#include "SpeedTree7CommonPasses.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"

#include "SpeedTree7CommonPasses.hlsl"

void InitializeData(inout SpeedTreeVertexInput input, out half2 outUV, out half outHueVariation)
{
Expand All @@ -14,7 +13,7 @@ void InitializeData(inout SpeedTreeVertexInput input, out half2 outUV, out half
float3 eyeVec = normalize(unity_BillboardCameraPosition - worldPos);
float3 billboardTangent = normalize(float3(-eyeVec.z, 0, eyeVec.x)); // cross(eyeVec, {0,1,0})
float3 billboardNormal = float3(billboardTangent.z, 0, -billboardTangent.x); // cross({0,1,0},billboardTangent)
float3 angle = atan2(billboardNormal.z, billboardNormal.x); // signed angle between billboardNormal to {0,0,1}
float angle = atan2(billboardNormal.z, billboardNormal.x); // signed angle between billboardNormal to {0,0,1}
angle += angle < 0 ? 2 * SPEEDTREE_PI : 0;
#else
float3 billboardTangent = unity_BillboardTangent;
Expand All @@ -32,7 +31,12 @@ void InitializeData(inout SpeedTreeVertexInput input, out half2 outUV, out half

#ifdef ENABLE_WIND
if (_WindQuality * _WindEnabled > 0)
{
// Disabling "pow(f,e) will not work for negative f"; warnings.
#pragma warning (disable : 3571)
billboardPos = GlobalWind(billboardPos, worldPos, true, _ST_WindVector.xyz, input.texcoord1.w);
#pragma warning (enable : 3571)
}
#endif

input.vertex.xyz += billboardPos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#ifndef UNIVERSAL_SPEEDTREE7COMMON_PASSES_INCLUDED
#define UNIVERSAL_SPEEDTREE7COMMON_PASSES_INCLUDED

// Disable warnings we aren't interested in
#pragma warning (disable : 3571) // "pow(f,e) will not work for negative f"; however in majority of our calls to pow we know f is not negative
#pragma warning (disable : 3206) // implicit truncation of vector type

#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"

struct SpeedTreeVertexInput
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef UNIVERSAL_SPEEDTREE7_PASSES_INCLUDED
#define UNIVERSAL_SPEEDTREE7_PASSES_INCLUDED

#include "SpeedTree7CommonPasses.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
#include "SpeedTree7CommonPasses.hlsl"

void InitializeData(inout SpeedTreeVertexInput input, float lodValue)
{
Expand Down Expand Up @@ -87,10 +87,13 @@ void InitializeData(inout SpeedTreeVertexInput input, float lodValue)
}
#endif

// global wind
if (windQuality > WIND_QUALITY_NONE)
{
// global wind
// Disabling "pow(f,e) will not work for negative f"; warnings.
#pragma warning (disable : 3571)
finalPosition = GlobalWind(finalPosition, treePos, true, rotatedWindVector, _ST_WindGlobal.x);
#pragma warning (enable : 3571)
}
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ void InitializeData(inout SpeedTreeVertexInput input, float lodValue)
#if defined(EFFECT_BILLBOARD) && defined(UNITY_INSTANCING_ENABLED)
globalWindTime += UNITY_ACCESS_INSTANCED_PROP(STWind, _GlobalWindTime);
#endif

// Disabling "pow(f,e) will not work for negative f"; warnings.
#pragma warning (disable : 3571)
windyPosition = GlobalWind(windyPosition, treePos, true, rotatedWindVector, globalWindTime);
#pragma warning (enable : 3571)

input.vertex.xyz = windyPosition;
}
#endif
Expand Down