From 9cedd1c3a3b92303934b190e5d9ed2b33ebbc143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elvar=20O=CC=88rn=20Unn=C3=BEo=CC=81rsson?= Date: Thu, 16 Apr 2020 12:50:17 +0200 Subject: [PATCH 1/3] Disabling speedtree warning about pow and vector truncation --- .../Shaders/Nature/SpeedTree7BillboardPasses.hlsl | 3 ++- .../Shaders/Nature/SpeedTree7CommonPasses.hlsl | 4 ++++ .../Shaders/Nature/SpeedTree7Passes.hlsl | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7BillboardPasses.hlsl b/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7BillboardPasses.hlsl index d0a554c8b2c..80d30b4ae84 100644 --- a/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7BillboardPasses.hlsl +++ b/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7BillboardPasses.hlsl @@ -1,8 +1,9 @@ #ifndef UNIVERSAL_SPEEDTREE7BILLBOARD_PASSES_INCLUDED #define UNIVERSAL_SPEEDTREE7BILLBOARD_PASSES_INCLUDED -#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" #include "SpeedTree7CommonPasses.hlsl" +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" + void InitializeData(inout SpeedTreeVertexInput input, out half2 outUV, out half outHueVariation) { diff --git a/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7CommonPasses.hlsl b/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7CommonPasses.hlsl index 2965f6143e7..89b11d6e577 100644 --- a/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7CommonPasses.hlsl +++ b/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7CommonPasses.hlsl @@ -1,6 +1,10 @@ #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 diff --git a/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7Passes.hlsl b/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7Passes.hlsl index 6223222d4e5..efb4adf9523 100644 --- a/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7Passes.hlsl +++ b/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7Passes.hlsl @@ -1,8 +1,8 @@ #ifndef UNIVERSAL_SPEEDTREE7_PASSES_INCLUDED #define UNIVERSAL_SPEEDTREE7_PASSES_INCLUDED -#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" #include "SpeedTree7CommonPasses.hlsl" +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" void InitializeData(inout SpeedTreeVertexInput input, float lodValue) { From d0182a198cf13d2105aa523b3c15d8ed5ae3046b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elvar=20O=CC=88rn=20Unn=C3=BEo=CC=81rsson?= Date: Fri, 24 Apr 2020 22:16:58 +0200 Subject: [PATCH 2/3] Modifying my solution based on review comments [skip ci] --- .../Shaders/Nature/SpeedTree7BillboardPasses.hlsl | 9 +++++++-- .../Shaders/Nature/SpeedTree7CommonPasses.hlsl | 4 ---- .../Shaders/Nature/SpeedTree7Passes.hlsl | 7 +++++-- .../Shaders/Nature/SpeedTree8Passes.hlsl | 5 +++++ 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7BillboardPasses.hlsl b/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7BillboardPasses.hlsl index 80d30b4ae84..462b52b0964 100644 --- a/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7BillboardPasses.hlsl +++ b/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7BillboardPasses.hlsl @@ -1,8 +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) @@ -14,7 +14,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; @@ -32,7 +32,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. In majority of our calls to pow we know f is not negative + #pragma warning (disable : 3571) billboardPos = GlobalWind(billboardPos, worldPos, true, _ST_WindVector.xyz, input.texcoord1.w); + #pragma warning (enable : 3571) + } #endif input.vertex.xyz += billboardPos; diff --git a/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7CommonPasses.hlsl b/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7CommonPasses.hlsl index 89b11d6e577..2965f6143e7 100644 --- a/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7CommonPasses.hlsl +++ b/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7CommonPasses.hlsl @@ -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 diff --git a/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7Passes.hlsl b/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7Passes.hlsl index efb4adf9523..941af9f3f4d 100644 --- a/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7Passes.hlsl +++ b/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7Passes.hlsl @@ -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) { @@ -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. In majority of our calls to pow we know f is not negative + #pragma warning (disable : 3571) finalPosition = GlobalWind(finalPosition, treePos, true, rotatedWindVector, _ST_WindGlobal.x); + #pragma warning (enable : 3571) } #endif diff --git a/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree8Passes.hlsl b/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree8Passes.hlsl index 7281bf24e52..a29391950b7 100644 --- a/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree8Passes.hlsl +++ b/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree8Passes.hlsl @@ -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. In majority of our calls to pow we know f is not negative + #pragma warning (disable : 3571) windyPosition = GlobalWind(windyPosition, treePos, true, rotatedWindVector, globalWindTime); + #pragma warning (enable : 3571) + input.vertex.xyz = windyPosition; } #endif From af4c925276cb363be690b23d16f7a0929d1a2ed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elvar=20O=CC=88rn=20Unn=C3=BEo=CC=81rsson?= Date: Fri, 24 Apr 2020 22:20:44 +0200 Subject: [PATCH 3/3] Minor tweaks --- .../Shaders/Nature/SpeedTree7BillboardPasses.hlsl | 3 +-- .../Shaders/Nature/SpeedTree7Passes.hlsl | 2 +- .../Shaders/Nature/SpeedTree8Passes.hlsl | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7BillboardPasses.hlsl b/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7BillboardPasses.hlsl index 462b52b0964..549615da9c2 100644 --- a/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7BillboardPasses.hlsl +++ b/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7BillboardPasses.hlsl @@ -4,7 +4,6 @@ #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" #include "SpeedTree7CommonPasses.hlsl" - void InitializeData(inout SpeedTreeVertexInput input, out half2 outUV, out half outHueVariation) { // assume no scaling & rotation @@ -33,7 +32,7 @@ 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. In majority of our calls to pow we know f is not negative + // 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) diff --git a/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7Passes.hlsl b/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7Passes.hlsl index 941af9f3f4d..199cde43ab6 100644 --- a/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7Passes.hlsl +++ b/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7Passes.hlsl @@ -90,7 +90,7 @@ void InitializeData(inout SpeedTreeVertexInput input, float lodValue) // global wind if (windQuality > WIND_QUALITY_NONE) { - // Disabling "pow(f,e) will not work for negative f"; warnings. In majority of our calls to pow we know f is not negative + // 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) diff --git a/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree8Passes.hlsl b/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree8Passes.hlsl index a29391950b7..90e44bee5bb 100644 --- a/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree8Passes.hlsl +++ b/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree8Passes.hlsl @@ -147,7 +147,7 @@ void InitializeData(inout SpeedTreeVertexInput input, float lodValue) globalWindTime += UNITY_ACCESS_INSTANCED_PROP(STWind, _GlobalWindTime); #endif - // Disabling "pow(f,e) will not work for negative f"; warnings. In majority of our calls to pow we know f is not negative + // 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)