Adaug proiectul Unity

This commit is contained in:
2026-11-01 23:39:55 +02:00
parent cb14d9d37d
commit 863eac8f2c
23463 changed files with 5412601 additions and 0 deletions
@@ -0,0 +1,242 @@
Shader "Universal Render Pipeline/Nature/SpeedTree7"
{
Properties
{
_Color("Main Color", Color) = (1,1,1,1)
_HueVariation("Hue Variation", Color) = (1.0,0.5,0.0,0.1)
_MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
_DetailTex("Detail", 2D) = "black" {}
_BumpMap("Normal Map", 2D) = "bump" {}
_Cutoff("Alpha Cutoff", Range(0,1)) = 0.333
[MaterialEnum(Off,0,Front,1,Back,2)] _Cull("Cull", Int) = 2
[MaterialEnum(None,0,Fastest,1,Fast,2,Better,3,Best,4,Palm,5)] _WindQuality("Wind Quality", Range(0,5)) = 0
}
SubShader
{
Tags
{
"Queue" = "Geometry"
"IgnoreProjector" = "True"
"RenderType" = "Opaque"
"DisableBatching" = "LODFading"
"RenderPipeline" = "UniversalPipeline"
"UniversalMaterialType" = "SimpleLit"
}
LOD 400
Cull [_Cull]
Pass
{
Name "ForwardLit"
Tags { "LightMode" = "UniversalForward" }
AlphaToMask On
HLSLPROGRAM
#pragma vertex SpeedTree7Vert
#pragma fragment SpeedTree7Frag
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
#pragma multi_compile _ LOD_FADE_CROSSFADE
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile LOD_FADE_PERCENTAGE
#pragma multi_compile_fragment _ DEBUG_DISPLAY
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile _ _LIGHT_LAYERS
#pragma multi_compile _ _CLUSTER_LIGHT_LOOP
#pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX
#include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"
#pragma multi_compile_instancing
#pragma instancing_options renderinglayer assumeuniformscaling maxcount:50
#pragma shader_feature_local GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH
#pragma shader_feature_local EFFECT_BUMP
#pragma shader_feature_local EFFECT_HUE_VARIATION
#define ENABLE_WIND
#define VERTEX_COLOR
#if USE_DYNAMIC_BRANCH_FOG_KEYWORD && SHADER_API_VULKAN && SHADER_API_MOBILE
#define SKIP_SHADOWS_LIGHT_INDEX_CHECK 1
#endif
#include "SpeedTree7Input.hlsl"
#include "SpeedTree7Passes.hlsl"
ENDHLSL
}
Pass
{
Name "SceneSelectionPass"
Tags{"LightMode" = "SceneSelectionPass"}
HLSLPROGRAM
#pragma vertex SpeedTree7VertDepth
#pragma fragment SpeedTree7FragDepth
#pragma multi_compile_instancing
#pragma instancing_options assumeuniformscaling maxcount:50
#pragma shader_feature_local GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH
#define ENABLE_WIND
#define DEPTH_ONLY
#define SCENESELECTIONPASS
#include "SpeedTree7Input.hlsl"
#include "SpeedTree7Passes.hlsl"
ENDHLSL
}
Pass
{
Name "ShadowCaster"
Tags{"LightMode" = "ShadowCaster"}
ColorMask 0
HLSLPROGRAM
#pragma vertex SpeedTree7VertDepth
#pragma fragment SpeedTree7FragDepth
#pragma multi_compile _ LOD_FADE_CROSSFADE
#pragma multi_compile_vertex LOD_FADE_PERCENTAGE
#pragma multi_compile_instancing
#pragma instancing_options assumeuniformscaling maxcount:50
#pragma shader_feature_local GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH
#define ENABLE_WIND
#define DEPTH_ONLY
#define SHADOW_CASTER
// -------------------------------------
// Universal Pipeline keywords
// This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
#include "SpeedTree7Input.hlsl"
#include "SpeedTree7Passes.hlsl"
ENDHLSL
}
Pass
{
Name "GBuffer"
Tags{"LightMode" = "UniversalGBuffer"}
HLSLPROGRAM
#pragma target 4.5
// Deferred Rendering Path does not support the OpenGL-based graphics API:
// Desktop OpenGL, OpenGL ES 3.0, WebGL 2.0.
#pragma exclude_renderers gles3 glcore
#pragma vertex SpeedTree7Vert
#pragma fragment SpeedTree7Frag
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
//#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
//#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
#pragma multi_compile _ LOD_FADE_CROSSFADE
#pragma multi_compile LOD_FADE_PERCENTAGE
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
#pragma multi_compile_fragment _ _RENDER_PASS_ENABLED
#pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
#pragma multi_compile_instancing
#pragma instancing_options renderinglayer assumeuniformscaling maxcount:50
#pragma shader_feature_local GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH
#pragma shader_feature_local EFFECT_BUMP
#pragma shader_feature_local EFFECT_HUE_VARIATION
#define ENABLE_WIND
#define VERTEX_COLOR
#define GBUFFER
#include "SpeedTree7Input.hlsl"
#include "SpeedTree7Passes.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl"
ENDHLSL
}
Pass
{
Name "DepthOnly"
Tags{"LightMode" = "DepthOnly"}
ColorMask R
HLSLPROGRAM
#pragma vertex SpeedTree7VertDepth
#pragma fragment SpeedTree7FragDepth
#pragma multi_compile _ LOD_FADE_CROSSFADE
#pragma multi_compile_vertex LOD_FADE_PERCENTAGE
#pragma multi_compile_instancing
#pragma instancing_options assumeuniformscaling maxcount:50
#pragma shader_feature_local GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH
#define ENABLE_WIND
#define DEPTH_ONLY
#include "SpeedTree7Input.hlsl"
#include "SpeedTree7Passes.hlsl"
ENDHLSL
}
// This pass is used when drawing to a _CameraNormalsTexture texture
Pass
{
Name "DepthNormals"
Tags{"LightMode" = "DepthNormals"}
HLSLPROGRAM
#pragma vertex SpeedTree7VertDepthNormal
#pragma fragment SpeedTree7FragDepthNormal
#pragma multi_compile _ LOD_FADE_CROSSFADE
#pragma multi_compile_vertex LOD_FADE_PERCENTAGE
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
#pragma multi_compile_instancing
#pragma instancing_options assumeuniformscaling maxcount:50
#pragma shader_feature_local GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH
#pragma shader_feature_local EFFECT_BUMP
#define ENABLE_WIND
#include "SpeedTree7Input.hlsl"
#include "SpeedTree7Passes.hlsl"
ENDHLSL
}
}
Dependency "BillboardShader" = "Universal Render Pipeline/Nature/SpeedTree7 Billboard"
FallBack "Hidden/Universal Render Pipeline/FallbackError"
CustomEditor "SpeedTreeMaterialInspector"
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0f4122b9a743b744abe2fb6a0a88868b
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,174 @@
Shader "Universal Render Pipeline/Nature/SpeedTree7 Billboard"
{
Properties
{
_Color("Main Color", Color) = (1,1,1,1)
_HueVariation("Hue Variation", Color) = (1.0,0.5,0.0,0.1)
_MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
_BumpMap("Normal Map", 2D) = "bump" {}
_Cutoff("Alpha Cutoff", Range(0,1)) = 0.333
[MaterialEnum(None,0,Fastest,1)] _WindQuality("Wind Quality", Range(0,1)) = 0
}
SubShader
{
Tags
{
"Queue" = "AlphaTest"
"IgnoreProjector" = "True"
"RenderType" = "TransparentCutout"
"DisableBatching" = "LODFading"
"RenderPipeline" = "UniversalPipeline"
"UniversalMaterialType" = "SimpleLit"
}
LOD 400
Pass
{
Name "ForwardLit"
Tags { "LightMode" = "UniversalForward" }
HLSLPROGRAM
#pragma vertex SpeedTree7Vert
#pragma fragment SpeedTree7Frag
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
#pragma multi_compile _ _CLUSTER_LIGHT_LOOP
#include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl"
#pragma multi_compile __ BILLBOARD_FACE_CAMERA_POS
#pragma multi_compile __ LOD_FADE_CROSSFADE
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile_fragment _ DEBUG_DISPLAY
#pragma shader_feature_local EFFECT_BUMP
#pragma shader_feature_local EFFECT_HUE_VARIATION
#define ENABLE_WIND
#if USE_DYNAMIC_BRANCH_FOG_KEYWORD && SHADER_API_VULKAN && SHADER_API_MOBILE
#define SKIP_SHADOWS_LIGHT_INDEX_CHECK 1
#endif
#include "SpeedTree7BillboardInput.hlsl"
#include "SpeedTree7BillboardPasses.hlsl"
ENDHLSL
}
Pass
{
Name "ShadowCaster"
Tags{"LightMode" = "ShadowCaster"}
ColorMask 0
HLSLPROGRAM
#pragma vertex SpeedTree7VertDepth
#pragma fragment SpeedTree7FragDepth
#pragma multi_compile __ BILLBOARD_FACE_CAMERA_POS
#pragma multi_compile __ LOD_FADE_CROSSFADE
#define ENABLE_WIND
#define DEPTH_ONLY
#define SHADOW_CASTER
#include "SpeedTree7BillboardInput.hlsl"
#include "SpeedTree7BillboardPasses.hlsl"
ENDHLSL
}
Pass
{
Name "GBuffer"
Tags{"LightMode" = "UniversalGBuffer"}
HLSLPROGRAM
#pragma target 4.5
// Deferred Rendering Path does not support the OpenGL-based graphics API:
// Desktop OpenGL, OpenGL ES 3.0, WebGL 2.0.
#pragma exclude_renderers gles3 glcore
#pragma vertex SpeedTree7Vert
#pragma fragment SpeedTree7Frag
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
//#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
//#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
#pragma multi_compile __ BILLBOARD_FACE_CAMERA_POS
#pragma multi_compile __ LOD_FADE_CROSSFADE
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
#pragma multi_compile_fragment _ _RENDER_PASS_ENABLED
#pragma shader_feature_local EFFECT_BUMP
#pragma shader_feature_local EFFECT_HUE_VARIATION
#define ENABLE_WIND
#define GBUFFER
#include "SpeedTree7BillboardInput.hlsl"
#include "SpeedTree7BillboardPasses.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl"
ENDHLSL
}
Pass
{
Name "DepthOnly"
Tags{"LightMode" = "DepthOnly"}
ColorMask R
HLSLPROGRAM
#pragma vertex SpeedTree7VertDepth
#pragma fragment SpeedTree7FragDepth
#pragma multi_compile __ BILLBOARD_FACE_CAMERA_POS
#pragma multi_compile __ LOD_FADE_CROSSFADE
#define ENABLE_WIND
#define DEPTH_ONLY
#include "SpeedTree7BillboardInput.hlsl"
#include "SpeedTree7BillboardPasses.hlsl"
ENDHLSL
}
Pass
{
Name "DepthNormals"
Tags{"LightMode" = "DepthNormals"}
HLSLPROGRAM
#pragma vertex SpeedTree7VertDepthNormalBillboard
#pragma fragment SpeedTree7FragDepthNormalBillboard
#pragma shader_feature_local EFFECT_BUMP
#pragma multi_compile __ BILLBOARD_FACE_CAMERA_POS
#pragma multi_compile __ LOD_FADE_CROSSFADE
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
#define ENABLE_WIND
#include "SpeedTree7BillboardInput.hlsl"
#include "SpeedTree7BillboardPasses.hlsl"
ENDHLSL
}
}
FallBack "Hidden/Universal Render Pipeline/FallbackError"
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 5ec81c81908db34429b4f6ddecadd3bd
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,27 @@
#ifndef UNIVERSAL_SPEEDTREE7BILLBOARD_INPUT_INCLUDED
#define UNIVERSAL_SPEEDTREE7BILLBOARD_INPUT_INCLUDED
#define SPEEDTREE_PI 3.14159265359
#define SPEEDTREE_ALPHATEST
half _Cutoff;
#include "SpeedTree7CommonInput.hlsl"
CBUFFER_START(UnityBillboardPerCamera)
float3 unity_BillboardNormal;
float3 unity_BillboardTangent;
float4 unity_BillboardCameraParams;
#define unity_BillboardCameraPosition (unity_BillboardCameraParams.xyz)
#define unity_BillboardCameraXZAngle (unity_BillboardCameraParams.w)
CBUFFER_END
CBUFFER_START(UnityBillboardPerBatch)
float4 unity_BillboardInfo; // x: num of billboard slices; y: 1.0f / (delta angle between slices)
float4 unity_BillboardSize; // x: width; y: height; z: bottom
float4 unity_BillboardImageTexCoords[16];
CBUFFER_END
#define _Surface 0.0 // Speed Trees are always opaque
#endif
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 693515911c7346d448c10a3cfc4acf45
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,209 @@
#ifndef UNIVERSAL_SPEEDTREE7BILLBOARD_PASSES_INCLUDED
#define UNIVERSAL_SPEEDTREE7BILLBOARD_PASSES_INCLUDED
#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
float3 worldPos = input.vertex.xyz + float3(UNITY_MATRIX_M[0].w, UNITY_MATRIX_M[1].w, UNITY_MATRIX_M[2].w);
#ifdef BILLBOARD_FACE_CAMERA_POS
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)
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;
float3 billboardNormal = unity_BillboardNormal;
float angle = unity_BillboardCameraXZAngle;
#endif
float widthScale = input.texcoord1.x;
float heightScale = input.texcoord1.y;
float rotation = input.texcoord1.z;
float2 percent = input.texcoord.xy;
float3 billboardPos = (percent.x - 0.5f) * unity_BillboardSize.x * widthScale * billboardTangent;
billboardPos.y += (percent.y * unity_BillboardSize.y + unity_BillboardSize.z) * heightScale;
#ifdef ENABLE_WIND
float windEnabled = dot(_ST_WindVector.xyz, _ST_WindVector.xyz) > 0.0f ? 1.0f : 0.0f;
if (_WindQuality * windEnabled > 0)
{
billboardPos = GlobalWind(billboardPos, worldPos, true, _ST_WindVector.xyz, input.texcoord1.w);
}
#endif
input.vertex.xyz += billboardPos;
input.vertex.w = 1.0f;
input.normal = billboardNormal.xyz;
input.tangent = float4(billboardTangent.xyz, -1);
float slices = unity_BillboardInfo.x;
float invDelta = unity_BillboardInfo.y;
angle += rotation;
float imageIndex = fmod(floor(angle * invDelta + 0.5f), slices);
float4 imageTexCoords = unity_BillboardImageTexCoords[imageIndex];
if (imageTexCoords.w < 0)
{
outUV = imageTexCoords.xy - imageTexCoords.zw * percent.yx;
}
else
{
outUV = imageTexCoords.xy + imageTexCoords.zw * percent;
}
#ifdef EFFECT_HUE_VARIATION
float hueVariationAmount = frac(worldPos.x + worldPos.y + worldPos.z);
outHueVariation = saturate(hueVariationAmount * _HueVariation.a);
#else
outHueVariation = 0;
#endif
}
SpeedTreeVertexOutput SpeedTree7Vert(SpeedTreeVertexInput input)
{
SpeedTreeVertexOutput output = (SpeedTreeVertexOutput)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
// handle speedtree wind and lod
InitializeData(input, output.uvHueVariation.xy, output.uvHueVariation.z);
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.vertex.xyz);
half3 normalWS = input.normal; // Already calculated in world space. Can probably get rid of the world space transform in GetVertexPositionInputs too.
half3 vertexLight = VertexLighting(vertexInput.positionWS, normalWS);
half fogFactor = 0.0;
#if !defined(_FOG_FRAGMENT)
fogFactor = ComputeFogFactor(vertexInput.positionCS.z);
#endif
output.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS);
#ifdef EFFECT_BUMP
real sign = input.tangent.w * GetOddNegativeScale();
output.normalWS.xyz = TransformObjectToWorldNormal(input.normal);
output.tangentWS.xyz = TransformObjectToWorldDir(input.tangent.xyz);
output.bitangentWS.xyz = cross(output.normalWS.xyz, output.tangentWS.xyz) * sign;
// View dir packed in w.
output.normalWS.w = viewDirWS.x;
output.tangentWS.w = viewDirWS.y;
output.bitangentWS.w = viewDirWS.z;
#else
output.normalWS.xyz = TransformObjectToWorldNormal(input.normal);
output.viewDirWS = viewDirWS;
#endif
output.positionWS = vertexInput.positionWS;
output.clipPos = vertexInput.positionCS;
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
output.shadowCoord = GetShadowCoord(vertexInput);
#endif
return output;
}
SpeedTreeVertexDepthOutput SpeedTree7VertDepth(SpeedTreeVertexInput input)
{
SpeedTreeVertexDepthOutput output = (SpeedTreeVertexDepthOutput)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
// handle speedtree wind and lod
InitializeData(input, output.uvHueVariation.xy, output.uvHueVariation.z);
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.vertex.xyz);
#ifdef SHADOW_CASTER
half3 normalWS = TransformObjectToWorldNormal(input.normal);
#if _CASTING_PUNCTUAL_LIGHT_SHADOW
float3 lightDirectionWS = normalize(_LightPosition - vertexInput.positionWS);
#else
float3 lightDirectionWS = _LightDirection;
#endif
output.clipPos = TransformWorldToHClip(ApplyShadowBias(vertexInput.positionWS, normalWS, lightDirectionWS));
#else
output.clipPos = vertexInput.positionCS;
#endif
return output;
}
SpeedTreeVertexDepthNormalOutput SpeedTree7VertDepthNormalBillboard(SpeedTreeVertexInput input)
{
SpeedTreeVertexDepthNormalOutput output = (SpeedTreeVertexDepthNormalOutput)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
// handle speedtree wind and lod
InitializeData(input, output.uvHueVariation.xy, output.uvHueVariation.z);
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.vertex.xyz);
half3 normalWS = TransformObjectToWorldNormal(input.normal);
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS);
#ifdef EFFECT_BUMP
real sign = input.tangent.w * GetOddNegativeScale();
output.normalWS.xyz = normalWS;
output.tangentWS.xyz = TransformObjectToWorldDir(input.tangent.xyz);
output.bitangentWS.xyz = cross(output.normalWS.xyz, output.tangentWS.xyz) * sign;
// View dir packed in w.
output.normalWS.w = viewDirWS.x;
output.tangentWS.w = viewDirWS.y;
output.bitangentWS.w = viewDirWS.z;
#else
output.normalWS = normalWS;
output.viewDirWS = viewDirWS;
#endif
output.clipPos = vertexInput.positionCS;
return output;
}
half4 SpeedTree7FragDepthNormalBillboard(SpeedTreeVertexDepthNormalOutput input) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
half2 uv = input.uvHueVariation.xy;
half4 diffuse = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_MainTex, sampler_MainTex));
diffuse.a *= _Color.a;
#ifdef SPEEDTREE_ALPHATEST
AlphaDiscard(diffuse.a, _Cutoff);
#endif
#ifdef LOD_FADE_CROSSFADE
LODFadeCrossFade(input.clipPos);
#endif
#if defined(EFFECT_BUMP)
half3 normalTS = SampleNormal(uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap));
half3 normalWS = TransformTangentToWorld(normalTS, half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz)).xyz;
#else
half3 normalWS = input.normalWS.xyz;
#endif
#if defined(_GBUFFER_NORMALS_OCT)
float2 octNormalWS = PackNormalOctQuadEncode(normalize(float3(normalWS))); // values between [-1, +1], must use fp32 on some platforms.
float2 remappedOctNormalWS = saturate(octNormalWS * 0.5 + 0.5); // values between [ 0, 1]
return half4(PackFloat2To888(remappedOctNormalWS), 0.0); // values between [ 0, 1]
#else
return half4(NormalizeNormalPerPixel(normalWS), 0.0);
#endif
}
#endif
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 8ba36b6596e931145bbad992032afb1a
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,48 @@
#ifndef UNIVERSAL_SPEEDTREE7COMMON_INPUT_INCLUDED
#define UNIVERSAL_SPEEDTREE7COMMON_INPUT_INCLUDED
#if defined(SPEEDTREE_ALPHATEST)
#define _ALPHATEST_ON
#endif
#ifdef EFFECT_BUMP
#define _NORMALMAP
#endif
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl"
#ifdef ENABLE_WIND
#define WIND_QUALITY_NONE 0
#define WIND_QUALITY_FASTEST 1
#define WIND_QUALITY_FAST 2
#define WIND_QUALITY_BETTER 3
#define WIND_QUALITY_BEST 4
#define WIND_QUALITY_PALM 5
uniform half _WindQuality;
#define SPEEDTREE_8_WIND 1 // v7 & v8 use the same shader wind code
#include "SpeedTreeWind.cginc"
#endif
TEXTURE2D(_MainTex);
SAMPLER(sampler_MainTex);
float4 _MainTex_TexelSize;
#ifdef EFFECT_HUE_VARIATION
half4 _HueVariation;
#endif
half4 _Color;
// Shadow Casting Light geometric parameters. These variables are used when applying the shadow Normal Bias and are set by UnityEngine.Rendering.Universal.ShadowUtils.SetupShadowCasterConstantBuffer in com.unity.render-pipelines.universal/Runtime/ShadowUtils.cs
// For Directional lights, _LightDirection is used when applying shadow Normal Bias.
// For Spot lights and Point lights, _LightPosition is used to compute the actual light direction because it is different at each shadow caster geometry vertex.
float3 _LightDirection;
float3 _LightPosition;
UNITY_TEXTURE_STREAMING_DEBUG_VARS;
#endif
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 55e6929e00a20d64eadff49d59e097db
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,292 @@
#ifndef UNIVERSAL_SPEEDTREE7COMMON_PASSES_INCLUDED
#define UNIVERSAL_SPEEDTREE7COMMON_PASSES_INCLUDED
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutput.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderVariablesFunctions.hlsl"
#include "SpeedTreeUtility.hlsl"
#if defined(LOD_FADE_CROSSFADE)
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
#endif
struct SpeedTreeVertexInput
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float4 tangent : TANGENT;
float4 texcoord : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
float4 texcoord2 : TEXCOORD2;
float2 texcoord3 : TEXCOORD3;
half4 color : COLOR;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct SpeedTreeVertexOutput
{
#ifdef VERTEX_COLOR
half4 color : COLOR;
#endif
half3 uvHueVariation : TEXCOORD0;
#ifdef GEOM_TYPE_BRANCH_DETAIL
half3 detail : TEXCOORD1;
#endif
half4 fogFactorAndVertexLight : TEXCOORD2; // x: fogFactor, yzw: vertex light
#ifdef EFFECT_BUMP
half4 normalWS : TEXCOORD3; // xyz: normal, w: viewDir.x
half4 tangentWS : TEXCOORD4; // xyz: tangent, w: viewDir.y
half4 bitangentWS : TEXCOORD5; // xyz: bitangent, w: viewDir.z
#else
half3 normalWS : TEXCOORD3;
half3 viewDirWS : TEXCOORD4;
#endif
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
float4 shadowCoord : TEXCOORD6;
#endif
float3 positionWS : TEXCOORD7;
DECLARE_LIGHTMAP_OR_SH(lightmapUV, vertexSH, 8);
float4 clipPos : SV_POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
struct SpeedTreeVertexDepthOutput
{
half3 uvHueVariation : TEXCOORD0;
half3 viewDirWS : TEXCOORD1;
float4 clipPos : SV_POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
struct SpeedTreeVertexDepthNormalOutput
{
half3 uvHueVariation : TEXCOORD0;
float4 clipPos : SV_POSITION;
#ifdef GEOM_TYPE_BRANCH_DETAIL
half3 detail : TEXCOORD1;
#endif
#ifdef EFFECT_BUMP
half4 normalWS : TEXCOORD2; // xyz: normal, w: viewDir.x
half4 tangentWS : TEXCOORD3; // xyz: tangent, w: viewDir.y
half4 bitangentWS : TEXCOORD4; // xyz: bitangent, w: viewDir.z
#else
half3 normalWS : TEXCOORD2;
half3 viewDirWS : TEXCOORD3;
#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
void InitializeInputData(SpeedTreeVertexOutput input, half3 normalTS, out InputData inputData)
{
inputData = (InputData)0;
inputData.positionWS = input.positionWS.xyz;
inputData.positionCS = input.clipPos;
#ifdef EFFECT_BUMP
inputData.normalWS = TransformTangentToWorld(normalTS, half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz));
inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
inputData.viewDirectionWS = half3(input.normalWS.w, input.tangentWS.w, input.bitangentWS.w);
#else
inputData.normalWS = NormalizeNormalPerPixel(input.normalWS);
inputData.viewDirectionWS = input.viewDirWS;
#endif
inputData.viewDirectionWS = SafeNormalize(inputData.viewDirectionWS);
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
inputData.shadowCoord = input.shadowCoord;
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS);
#else
inputData.shadowCoord = float4(0, 0, 0, 0);
#endif
inputData.fogCoord = InitializeInputDataFog(float4(input.positionWS, 1.0), input.fogFactorAndVertexLight.x);
inputData.vertexLighting = input.fogFactorAndVertexLight.yzw;
// Billboards cannot use lightmaps.
#if !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2))
inputData.bakedGI = SAMPLE_GI(input.vertexSH,
GetAbsolutePositionWS(inputData.positionWS),
inputData.normalWS,
inputData.viewDirectionWS,
inputData.positionCS.xy,
input.probeOcclusion,
inputData.shadowMask);
#else
inputData.bakedGI = SAMPLE_GI(NOT_USED, input.vertexSH, inputData.normalWS);
#endif
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.clipPos);
inputData.shadowMask = half4(1, 1, 1, 1); // No GI currently.
#if defined(DEBUG_DISPLAY) && !defined(LIGHTMAP_ON)
inputData.vertexSH = input.vertexSH;
#endif
#if defined(_NORMALMAP)
inputData.tangentToWorld = half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz);
#endif
}
#ifdef GBUFFER
GBufferFragOutput SpeedTree7Frag(SpeedTreeVertexOutput input)
#else
half4 SpeedTree7Frag(SpeedTreeVertexOutput input) : SV_Target
#endif
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
half2 uv = input.uvHueVariation.xy;
half4 diffuse = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_MainTex, sampler_MainTex));
diffuse.a *= _Color.a;
#ifdef SPEEDTREE_ALPHATEST
diffuse.a = AlphaDiscard(diffuse.a, _Cutoff);
#endif
#ifdef LOD_FADE_CROSSFADE
LODFadeCrossFade(input.clipPos);
#endif
half3 diffuseColor = diffuse.rgb;
#ifdef GEOM_TYPE_BRANCH_DETAIL
half4 detailColor = tex2D(_DetailTex, input.detail.xy);
diffuseColor.rgb = lerp(diffuseColor.rgb, detailColor.rgb, input.detail.z < 2.0f ? saturate(input.detail.z) : detailColor.a);
#endif
#ifdef EFFECT_HUE_VARIATION
half3 shiftedColor = lerp(diffuseColor.rgb, _HueVariation.rgb, input.uvHueVariation.z);
half maxBase = max(diffuseColor.r, max(diffuseColor.g, diffuseColor.b));
half newMaxBase = max(shiftedColor.r, max(shiftedColor.g, shiftedColor.b));
maxBase /= newMaxBase;
maxBase = maxBase * 0.5f + 0.5f;
// preserve vibrance
shiftedColor.rgb *= maxBase;
diffuseColor.rgb = saturate(shiftedColor);
#endif
#ifdef EFFECT_BUMP
half3 normalTs = SampleNormal(uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap));
#ifdef GEOM_TYPE_BRANCH_DETAIL
half3 detailNormal = SampleNormal(input.detail.xy, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap));
normalTs = lerp(normalTs, detailNormal, input.detail.z < 2.0f ? saturate(input.detail.z) : detailColor.a);
#endif
#else
half3 normalTs = half3(0, 0, 1);
#endif
InputData inputData;
InitializeInputData(input, normalTs, inputData);
SETUP_DEBUG_TEXTURE_DATA(inputData, input.uvHueVariation.xy);
#ifdef VERTEX_COLOR
diffuseColor.rgb *= input.color.rgb;
#else
diffuseColor.rgb *= _Color.rgb;
#endif
SurfaceData surfaceData;
surfaceData.albedo = diffuseColor.rgb;
surfaceData.alpha = diffuse.a;
surfaceData.emission = half3(0, 0, 0);
surfaceData.metallic = 0;
surfaceData.occlusion = 1;
surfaceData.smoothness = 0;
surfaceData.specular = half3(0, 0, 0);
surfaceData.clearCoatMask = 0;
surfaceData.clearCoatSmoothness = 1;
surfaceData.normalTS = normalTs;
#ifdef GBUFFER
half4 color = half4(inputData.bakedGI * diffuseColor.rgb, diffuse.a);
surfaceData.occlusion = 1.0;
return PackGBuffersSurfaceData(surfaceData, inputData, color.rgb);
#else
half4 color = UniversalFragmentBlinnPhong(inputData, surfaceData);
color.rgb = MixFog(color.rgb, inputData.fogCoord);
color.a = OutputAlpha(color.a, _Surface);
return color;
#endif
}
half4 SpeedTree7FragDepth(SpeedTreeVertexDepthOutput input) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
half2 uv = input.uvHueVariation.xy;
half4 diffuse = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_MainTex, sampler_MainTex));
diffuse.a *= _Color.a;
#ifdef SPEEDTREE_ALPHATEST
AlphaDiscard(diffuse.a, _Cutoff);
#endif
#ifdef LOD_FADE_CROSSFADE
LODFadeCrossFade(input.clipPos);
#endif
#if defined(SCENESELECTIONPASS)
// We use depth prepass for scene selection in the editor, this code allow to output the outline correctly
return half4(_ObjectId, _PassValue, 1.0, 1.0);
#else
return half4(input.clipPos.z, 0, 0, 0);
#endif
}
half4 SpeedTree7FragDepthNormal(SpeedTreeVertexDepthNormalOutput input) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
half2 uv = input.uvHueVariation.xy;
half4 diffuse = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_MainTex, sampler_MainTex));
diffuse.a *= _Color.a;
#ifdef SPEEDTREE_ALPHATEST
AlphaDiscard(diffuse.a, _Cutoff);
#endif
#ifdef LOD_FADE_CROSSFADE
LODFadeCrossFade(input.clipPos);
#endif
#if defined(EFFECT_BUMP)
half3 normalTS = SampleNormal(uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap));
#ifdef GEOM_TYPE_BRANCH_DETAIL
half4 detailColor = tex2D(_DetailTex, input.detail.xy);
half3 detailNormal = SampleNormal(input.detail.xy, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap));
normalTS = lerp(normalTS, detailNormal, input.detail.z < 2.0f ? saturate(input.detail.z) : detailColor.a);
#endif
half3 normalWS = TransformTangentToWorld(normalTS, half3x3(input.tangentWS.xyz, input.bitangentWS.xyz, input.normalWS.xyz)).xyz;
#else
half3 normalWS = input.normalWS.xyz;
#endif
#if defined(_GBUFFER_NORMALS_OCT)
float2 octNormalWS = PackNormalOctQuadEncode(normalize(float3(normalWS))); // values between [-1, +1], must use fp32 on some platforms.
float2 remappedOctNormalWS = saturate(octNormalWS * 0.5 + 0.5); // values between [ 0, 1]
return half4(PackFloat2To888(remappedOctNormalWS), 0.0); // values between [ 0, 1]
#else
return half4(NormalizeNormalPerPixel(normalWS), 0.0);
#endif
}
#endif
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 85f7860cf76171b438c51eb5fcd238ce
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,29 @@
#ifndef UNIVERSAL_SPEEDTREE7_INPUT_INCLUDED
#define UNIVERSAL_SPEEDTREE7_INPUT_INCLUDED
#define SPEEDTREE_Y_UP
#ifdef GEOM_TYPE_BRANCH_DETAIL
#define GEOM_TYPE_BRANCH
#endif
#if defined(GEOM_TYPE_FROND) || defined(GEOM_TYPE_LEAF) || defined(GEOM_TYPE_FACING_LEAF)
#define SPEEDTREE_ALPHATEST
half _Cutoff;
#endif
#ifdef SCENESELECTIONPASS
int _ObjectId;
int _PassValue;
#endif
#include "SpeedTree7CommonInput.hlsl"
#ifdef GEOM_TYPE_BRANCH_DETAIL
sampler2D _DetailTex;
#endif
#define _Surface 0.0 // Speed Trees are always opaque
#endif
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 519469e5f151ddb40a650b66f48175cb
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,239 @@
#ifndef UNIVERSAL_SPEEDTREE7_PASSES_INCLUDED
#define UNIVERSAL_SPEEDTREE7_PASSES_INCLUDED
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
#include "SpeedTree7CommonPasses.hlsl"
void InitializeData(inout SpeedTreeVertexInput input, float lodValue)
{
float3 finalPosition = input.vertex.xyz;
#ifdef ENABLE_WIND
float windEnabled = dot(_ST_WindVector.xyz, _ST_WindVector.xyz) > 0.0f ? 1.0f : 0.0f;
half windQuality = _WindQuality * windEnabled;
float3 rotatedWindVector, rotatedBranchAnchor;
if (windQuality <= WIND_QUALITY_NONE)
{
rotatedWindVector = float3(0.0f, 0.0f, 0.0f);
rotatedBranchAnchor = float3(0.0f, 0.0f, 0.0f);
}
else
{
// compute rotated wind parameters
rotatedWindVector = normalize(mul(_ST_WindVector.xyz, (float3x3)UNITY_MATRIX_M));
rotatedBranchAnchor = normalize(mul(_ST_WindBranchAnchor.xyz, (float3x3)UNITY_MATRIX_M)) * _ST_WindBranchAnchor.w;
}
#endif
#if defined(GEOM_TYPE_BRANCH) || defined(GEOM_TYPE_FROND)
// smooth LOD
#ifdef LOD_FADE_PERCENTAGE
finalPosition = lerp(finalPosition, input.texcoord1.xyz, lodValue);
#endif
// frond wind, if needed
#if defined(ENABLE_WIND) && defined(GEOM_TYPE_FROND)
if (windQuality == WIND_QUALITY_PALM)
finalPosition = RippleFrond(finalPosition, input.normal, input.texcoord.x, input.texcoord.y, input.texcoord2.x, input.texcoord2.y, input.texcoord2.z);
#endif
#elif defined(GEOM_TYPE_LEAF)
// remove anchor position
finalPosition -= input.texcoord1.xyz;
bool isFacingLeaf = input.color.a == 0;
if (isFacingLeaf)
{
#ifdef LOD_FADE_PERCENTAGE
finalPosition *= lerp(1.0, input.texcoord1.w, lodValue);
#endif
// face camera-facing leaf to camera
float offsetLen = length(finalPosition);
finalPosition = mul(finalPosition.xyz, (float3x3)UNITY_MATRIX_IT_MV); // inv(MV) * finalPosition
finalPosition = normalize(finalPosition) * offsetLen; // make sure the offset vector is still scaled
}
else
{
#ifdef LOD_FADE_PERCENTAGE
float3 lodPosition = float3(input.texcoord1.w, input.texcoord3.x, input.texcoord3.y);
finalPosition = lerp(finalPosition, lodPosition, lodValue);
#endif
}
#ifdef ENABLE_WIND
// leaf wind
if (windQuality > WIND_QUALITY_FASTEST && windQuality < WIND_QUALITY_PALM)
{
float leafWindTrigOffset = input.texcoord1.x + input.texcoord1.y;
finalPosition = LeafWind(windQuality == WIND_QUALITY_BEST, input.texcoord2.w > 0.0, finalPosition, input.normal, input.texcoord2.x, float3(0,0,0), input.texcoord2.y, input.texcoord2.z, leafWindTrigOffset, rotatedWindVector);
}
#endif
// move back out to anchor
finalPosition += input.texcoord1.xyz;
#endif
#ifdef ENABLE_WIND
float3 treePos = float3(UNITY_MATRIX_M[0].w, UNITY_MATRIX_M[1].w, UNITY_MATRIX_M[2].w);
#ifndef GEOM_TYPE_MESH
if (windQuality >= WIND_QUALITY_BETTER)
{
// branch wind (applies to all 3D geometry)
finalPosition = BranchWind(windQuality == WIND_QUALITY_PALM, finalPosition, treePos, float4(input.texcoord.zw, 0, 0), rotatedWindVector, rotatedBranchAnchor);
}
#endif
// global wind
if (windQuality > WIND_QUALITY_NONE)
{
finalPosition = GlobalWind(finalPosition, treePos, true, rotatedWindVector, _ST_WindGlobal.x);
}
#endif
input.vertex.xyz = finalPosition;
}
SpeedTreeVertexOutput SpeedTree7Vert(SpeedTreeVertexInput input)
{
SpeedTreeVertexOutput output = (SpeedTreeVertexOutput)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
// handle speedtree wind and lod
InitializeData(input, unity_LODFade.x);
#ifdef VERTEX_COLOR
output.color = _Color;
output.color.rgb *= input.color.r; // ambient occlusion factor
#endif
output.uvHueVariation.xy = input.texcoord.xy;
#ifdef EFFECT_HUE_VARIATION
half hueVariationAmount = frac(UNITY_MATRIX_M[0].w + UNITY_MATRIX_M[1].w + UNITY_MATRIX_M[2].w);
hueVariationAmount += frac(input.vertex.x + input.normal.y + input.normal.x) * 0.5 - 0.3;
output.uvHueVariation.z = saturate(hueVariationAmount * _HueVariation.a);
#endif
#ifdef GEOM_TYPE_BRANCH_DETAIL
// The two types are always in different sub-range of the mesh so no interpolation (between detail and blend) problem.
output.detail.xy = input.texcoord2.xy;
output.detail.z = input.color.a == 0 ? input.texcoord2.z : 2.5; // stay out of Blend's .z range
#endif
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.vertex.xyz);
half3 normalWS = TransformObjectToWorldNormal(input.normal);
half3 vertexLight = VertexLighting(vertexInput.positionWS, normalWS);
half fogFactor = 0;
#if !defined(_FOG_FRAGMENT)
fogFactor = ComputeFogFactor(vertexInput.positionCS.z);
#endif
output.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS);
#ifdef EFFECT_BUMP
real sign = input.tangent.w * GetOddNegativeScale();
output.normalWS.xyz = normalWS;
output.tangentWS.xyz = TransformObjectToWorldDir(input.tangent.xyz);
output.bitangentWS.xyz = cross(output.normalWS.xyz, output.tangentWS.xyz) * sign;
// View dir packed in w.
output.normalWS.w = viewDirWS.x;
output.tangentWS.w = viewDirWS.y;
output.bitangentWS.w = viewDirWS.z;
#else
output.normalWS = normalWS;
output.viewDirWS = viewDirWS;
#endif
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
output.shadowCoord = GetShadowCoord(vertexInput);
#endif
output.positionWS = vertexInput.positionWS;
output.clipPos = vertexInput.positionCS;
OUTPUT_SH4(vertexInput.positionWS, output.normalWS.xyz, GetWorldSpaceNormalizeViewDir(vertexInput.positionWS), output.vertexSH, output.probeOcclusion);
return output;
}
SpeedTreeVertexDepthOutput SpeedTree7VertDepth(SpeedTreeVertexInput input)
{
SpeedTreeVertexDepthOutput output = (SpeedTreeVertexDepthOutput)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
// handle speedtree wind and lod
InitializeData(input, unity_LODFade.x);
output.uvHueVariation.xy = input.texcoord.xy;
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.vertex.xyz);
output.viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS);
#ifdef SHADOW_CASTER
half3 normalWS = TransformObjectToWorldNormal(input.normal);
#if _CASTING_PUNCTUAL_LIGHT_SHADOW
float3 lightDirectionWS = normalize(_LightPosition - vertexInput.positionWS);
#else
float3 lightDirectionWS = _LightDirection;
#endif
output.clipPos = TransformWorldToHClip(ApplyShadowBias(vertexInput.positionWS, normalWS, lightDirectionWS));
#else
output.clipPos = vertexInput.positionCS;
#endif
return output;
}
SpeedTreeVertexDepthNormalOutput SpeedTree7VertDepthNormal(SpeedTreeVertexInput input)
{
SpeedTreeVertexDepthNormalOutput output = (SpeedTreeVertexDepthNormalOutput)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
// handle speedtree wind and lod
InitializeData(input, unity_LODFade.x);
output.uvHueVariation.xy = input.texcoord.xy;
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.vertex.xyz);
half3 normalWS = TransformObjectToWorldNormal(input.normal);
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS);
#ifdef GEOM_TYPE_BRANCH_DETAIL
// The two types are always in different sub-range of the mesh so no interpolation (between detail and blend) problem.
output.detail.xy = input.texcoord2.xy;
output.detail.z = input.color.a == 0 ? input.texcoord2.z : 2.5; // stay out of Blend's .z range
#endif
#ifdef EFFECT_BUMP
real sign = input.tangent.w * GetOddNegativeScale();
output.normalWS.xyz = normalWS;
output.tangentWS.xyz = TransformObjectToWorldDir(input.tangent.xyz);
output.bitangentWS.xyz = cross(output.normalWS.xyz, output.tangentWS.xyz) * sign;
// View dir packed in w.
output.normalWS.w = viewDirWS.x;
output.tangentWS.w = viewDirWS.y;
output.bitangentWS.w = viewDirWS.z;
#else
output.normalWS = normalWS;
output.viewDirWS = viewDirWS;
#endif
output.clipPos = vertexInput.positionCS;
return output;
}
#endif
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: f3f941933e171854386001194281536f
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,278 @@
Shader "Universal Render Pipeline/Nature/SpeedTree8"
{
Properties
{
_MainTex ("Base (RGB) Transparency (A)", 2D) = "white" {}
_Color ("Color", Color) = (1,1,1,1)
[Toggle(EFFECT_HUE_VARIATION)] _HueVariationKwToggle("Hue Variation", Float) = 0
_HueVariationColor ("Hue Variation Color", Color) = (1.0,0.5,0.0,0.1)
[Toggle(EFFECT_BUMP)] _NormalMapKwToggle("Normal Mapping", Float) = 0
_BumpMap("Normal Map", 2D) = "bump" {}
_ExtraTex ("Smoothness (R), Metallic (G), AO (B)", 2D) = "(0.5, 0.0, 1.0)" {}
_Glossiness ("Smoothness", Range(0.0, 1.0)) = 0.5
_Metallic ("Metallic", Range(0.0, 1.0)) = 0.0
[Toggle(EFFECT_SUBSURFACE)] _SubsurfaceKwToggle("Subsurface", Float) = 0
_SubsurfaceTex ("Subsurface (RGB)", 2D) = "white" {}
_SubsurfaceColor ("Subsurface Color", Color) = (1,1,1,1)
_SubsurfaceIndirect ("Subsurface Indirect", Range(0.0, 1.0)) = 0.25
[Toggle(EFFECT_BILLBOARD)] _BillboardKwToggle("Billboard", Float) = 0
_BillboardShadowFade ("Billboard Shadow Fade", Range(0.0, 1.0)) = 0.5
[Enum(No,2,Yes,0)] _TwoSided ("Two Sided", Int) = 2 // enum matches cull mode
[KeywordEnum(None,Fastest,Fast,Better,Best,Palm)] _WindQuality ("Wind Quality", Range(0,5)) = 0
}
SubShader
{
Tags
{
"Queue"="AlphaTest"
"IgnoreProjector"="True"
"RenderType"="TransparentCutout"
"DisableBatching"="LODFading"
"RenderPipeline" = "UniversalPipeline"
"UniversalMaterialType" = "Lit"
}
LOD 400
Cull [_TwoSided]
Pass
{
Name "ForwardLit"
Tags { "LightMode" = "UniversalForward" }
AlphaToMask On
HLSLPROGRAM
#pragma vertex SpeedTree8Vert
#pragma fragment SpeedTree8Frag
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
#pragma multi_compile _ _LIGHT_LAYERS
#pragma multi_compile _ _CLUSTER_LIGHT_LOOP
#pragma multi_compile LOD_FADE_PERCENTAGE
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
#pragma multi_compile_fragment _ _REFLECTION_PROBE_ATLAS
#pragma multi_compile_fragment _ _SCREEN_SPACE_REFLECTION
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
#pragma multi_compile _ LOD_FADE_CROSSFADE
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile_fragment _ _LIGHT_COOKIES
#pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX
#include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"
#pragma multi_compile_fragment _ DEBUG_DISPLAY
#pragma multi_compile_instancing
#pragma instancing_options renderinglayer assumeuniformscaling maxcount:50
#pragma shader_feature_local_vertex _WINDQUALITY_NONE _WINDQUALITY_FAST _WINDQUALITY_BETTER _WINDQUALITY_BEST _WINDQUALITY_PALM
#pragma shader_feature_local EFFECT_BILLBOARD
#pragma shader_feature_local EFFECT_BUMP
#pragma shader_feature_local_fragment EFFECT_HUE_VARIATION
#pragma shader_feature_local_fragment EFFECT_SUBSURFACE
#pragma shader_feature_local_fragment EFFECT_EXTRA_TEX
#define ENABLE_WIND
#define EFFECT_BACKSIDE_NORMALS
#if USE_DYNAMIC_BRANCH_FOG_KEYWORD && SHADER_API_VULKAN && SHADER_API_MOBILE
#define SKIP_SHADOWS_LIGHT_INDEX_CHECK 1
#endif
#include "SpeedTree8Input.hlsl"
#include "SpeedTree8Passes.hlsl"
ENDHLSL
}
Pass
{
Name "SceneSelectionPass"
Tags{"LightMode" = "SceneSelectionPass"}
HLSLPROGRAM
#pragma vertex SpeedTree8VertDepth
#pragma fragment SpeedTree8FragDepth
#pragma multi_compile _ LOD_FADE_CROSSFADE
#pragma multi_compile_vertex LOD_FADE_PERCENTAGE
#pragma multi_compile_instancing
#pragma instancing_options assumeuniformscaling maxcount:50
#pragma shader_feature_local_vertex _WINDQUALITY_NONE _WINDQUALITY_FAST _WINDQUALITY_BETTER _WINDQUALITY_BEST _WINDQUALITY_PALM
#pragma shader_feature_local EFFECT_BILLBOARD
#define ENABLE_WIND
#define DEPTH_ONLY
#define SCENESELECTIONPASS
#include "SpeedTree8Input.hlsl"
#include "SpeedTree8Passes.hlsl"
ENDHLSL
}
Pass
{
Name "GBuffer"
Tags{"LightMode" = "UniversalGBuffer"}
HLSLPROGRAM
#pragma target 4.5
// Deferred Rendering Path does not support the OpenGL-based graphics API:
// Desktop OpenGL, OpenGL ES 3.0, WebGL 2.0.
#pragma exclude_renderers gles3 glcore
#pragma vertex SpeedTree8Vert
#pragma fragment SpeedTree8Frag
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
//#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
//#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
#pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
#pragma multi_compile _ LOD_FADE_CROSSFADE
#pragma multi_compile LOD_FADE_PERCENTAGE
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
#pragma multi_compile_fragment _ _RENDER_PASS_ENABLED
#pragma multi_compile _ _CLUSTER_LIGHT_LOOP
#pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
#pragma multi_compile_instancing
#pragma instancing_options renderinglayer assumeuniformscaling maxcount:50
#pragma shader_feature_local_vertex _WINDQUALITY_NONE _WINDQUALITY_FAST _WINDQUALITY_BETTER _WINDQUALITY_BEST _WINDQUALITY_PALM
#pragma shader_feature_local EFFECT_BILLBOARD
#pragma shader_feature_local EFFECT_BUMP
#pragma shader_feature_local_fragment EFFECT_HUE_VARIATION
#pragma shader_feature_local_fragment EFFECT_SUBSURFACE
#pragma shader_feature_local_fragment EFFECT_EXTRA_TEX
#define ENABLE_WIND
#define EFFECT_BACKSIDE_NORMALS
#define GBUFFER
#include "SpeedTree8Input.hlsl"
#include "SpeedTree8Passes.hlsl"
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl"
ENDHLSL
}
Pass
{
Name "ShadowCaster"
Tags{"LightMode" = "ShadowCaster"}
ColorMask 0
HLSLPROGRAM
#pragma vertex SpeedTree8VertDepth
#pragma fragment SpeedTree8FragDepth
#pragma multi_compile _ LOD_FADE_CROSSFADE
#pragma multi_compile_vertex LOD_FADE_PERCENTAGE
#pragma multi_compile_instancing
#pragma instancing_options assumeuniformscaling maxcount:50
#pragma shader_feature_local_vertex _WINDQUALITY_NONE _WINDQUALITY_FAST _WINDQUALITY_BETTER _WINDQUALITY_BEST _WINDQUALITY_PALM
#pragma shader_feature_local EFFECT_BILLBOARD
#define ENABLE_WIND
#define DEPTH_ONLY
#define SHADOW_CASTER
// -------------------------------------
// Universal Pipeline keywords
// This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
#include "SpeedTree8Input.hlsl"
#include "SpeedTree8Passes.hlsl"
ENDHLSL
}
Pass
{
Name "DepthOnly"
Tags{"LightMode" = "DepthOnly"}
ZWrite On
ColorMask R
HLSLPROGRAM
#pragma vertex SpeedTree8VertDepth
#pragma fragment SpeedTree8FragDepth
#pragma multi_compile _ LOD_FADE_CROSSFADE
#pragma multi_compile_vertex LOD_FADE_PERCENTAGE
#pragma multi_compile_instancing
#pragma instancing_options assumeuniformscaling maxcount:50
#pragma shader_feature_local_vertex _WINDQUALITY_NONE _WINDQUALITY_FAST _WINDQUALITY_BETTER _WINDQUALITY_BEST _WINDQUALITY_PALM
#pragma shader_feature_local EFFECT_BILLBOARD
#define ENABLE_WIND
#define DEPTH_ONLY
#include "SpeedTree8Input.hlsl"
#include "SpeedTree8Passes.hlsl"
ENDHLSL
}
// This pass is used when drawing to a _CameraNormalsTexture texture
Pass
{
Name "DepthNormals"
Tags{"LightMode" = "DepthNormals"}
ZWrite On
HLSLPROGRAM
#pragma vertex SpeedTree8VertDepthNormal
#pragma fragment SpeedTree8FragDepthNormal
#pragma shader_feature_local_vertex _WINDQUALITY_NONE _WINDQUALITY_FAST _WINDQUALITY_BETTER _WINDQUALITY_BEST _WINDQUALITY_PALM
#pragma shader_feature_local EFFECT_BUMP
#pragma shader_feature_local_fragment EFFECT_EXTRA_TEX
#pragma multi_compile _ LOD_FADE_CROSSFADE
#pragma multi_compile_instancing
#pragma multi_compile_vertex LOD_FADE_PERCENTAGE
#pragma multi_compile _ _WRITE_SMOOTHNESS
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
#pragma instancing_options assumeuniformscaling maxcount:50
#define ENABLE_WIND
#define EFFECT_BACKSIDE_NORMALS
#include "SpeedTree8Input.hlsl"
#include "SpeedTree8Passes.hlsl"
ENDHLSL
}
}
FallBack "Hidden/Universal Render Pipeline/FallbackError"
CustomEditor "SpeedTree8ShaderGUI"
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 99134b1f0c27d54469a840832a28fadf
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,71 @@
#ifndef UNIVERSAL_SPEEDTREE8_INPUT_INCLUDED
#define UNIVERSAL_SPEEDTREE8_INPUT_INCLUDED
#ifdef EFFECT_BUMP
#define _NORMALMAP
#endif
#define _ALPHATEST_ON
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/SurfaceInput.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl"
#if defined(ENABLE_WIND) && !defined(_WINDQUALITY_NONE)
#define SPEEDTREE_Y_UP
#define SPEEDTREE_8_WIND 1
#include "SpeedTreeWind.cginc"
UNITY_INSTANCING_BUFFER_START(STWind)
UNITY_DEFINE_INSTANCED_PROP(float, _GlobalWindTime)
UNITY_INSTANCING_BUFFER_END(STWind)
#endif
half4 _Color;
int _TwoSided;
#ifdef SCENESELECTIONPASS
int _ObjectId;
int _PassValue;
#endif
TEXTURE2D(_MainTex);
SAMPLER(sampler_MainTex);
float4 _MainTex_TexelSize;
#ifdef EFFECT_EXTRA_TEX
sampler2D _ExtraTex;
#else
half _Glossiness;
half _Metallic;
#endif
#ifdef EFFECT_HUE_VARIATION
half4 _HueVariationColor;
#endif
#ifdef EFFECT_BILLBOARD
half _BillboardShadowFade;
#endif
#ifdef EFFECT_SUBSURFACE
sampler2D _SubsurfaceTex;
half4 _SubsurfaceColor;
half _SubsurfaceIndirect;
#endif
// Shadow Casting Light geometric parameters. These variables are used when applying the shadow Normal Bias and are set by UnityEngine.Rendering.Universal.ShadowUtils.SetupShadowCasterConstantBuffer in com.unity.render-pipelines.universal/Runtime/ShadowUtils.cs
// For Directional lights, _LightDirection is used when applying shadow Normal Bias.
// For Spot lights and Point lights, _LightPosition is used to compute the actual light direction because it is different at each shadow caster geometry vertex.
float3 _LightDirection;
float3 _LightPosition;
#define GEOM_TYPE_BRANCH 0
#define GEOM_TYPE_FROND 1
#define GEOM_TYPE_LEAF 2
#define GEOM_TYPE_FACINGLEAF 3
#define _Surface 0.0 // Speed Trees are always opaque
UNITY_TEXTURE_STREAMING_DEBUG_VARS;
#endif
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e9fc1df17be32ac41a7186d571c669d5
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,623 @@
#ifndef UNIVERSAL_SPEEDTREE8_PASSES_INCLUDED
#define UNIVERSAL_SPEEDTREE8_PASSES_INCLUDED
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutput.hlsl"
#include "Packages/com.unity.shadergraph/ShaderGraphLibrary/Nature/SpeedTreeCommon.hlsl"
#include "SpeedTreeUtility.hlsl"
#if defined(LOD_FADE_CROSSFADE)
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
#endif
struct SpeedTreeVertexInput
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float4 tangent : TANGENT;
float4 texcoord : TEXCOORD0;
float4 texcoord1 : TEXCOORD1;
float4 texcoord2 : TEXCOORD2;
float4 texcoord3 : TEXCOORD3;
float4 color : COLOR;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct SpeedTreeVertexOutput
{
half2 uv : TEXCOORD0;
half4 color : TEXCOORD1;
half4 fogFactorAndVertexLight : TEXCOORD2; // x: fogFactor, yzw: vertex light
#ifdef EFFECT_BUMP
half4 normalWS : TEXCOORD3; // xyz: normal, w: viewDir.x
half4 tangentWS : TEXCOORD4; // xyz: tangent, w: viewDir.y
half4 bitangentWS : TEXCOORD5; // xyz: bitangent, w: viewDir.z
#else
half3 normalWS : TEXCOORD3;
half3 viewDirWS : TEXCOORD4;
#endif
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
float4 shadowCoord : TEXCOORD6;
#endif
float3 positionWS : TEXCOORD7;
DECLARE_LIGHTMAP_OR_SH(lightmapUV, vertexSH, 8);
float4 clipPos : SV_POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
struct SpeedTreeVertexDepthOutput
{
half2 uv : TEXCOORD0;
half4 color : TEXCOORD1;
half3 viewDirWS : TEXCOORD2;
float4 clipPos : SV_POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
struct SpeedTreeVertexDepthNormalOutput
{
half2 uv : TEXCOORD0;
half4 color : TEXCOORD1;
#ifdef EFFECT_BUMP
half4 normalWS : TEXCOORD2; // xyz: normal, w: viewDir.x
half4 tangentWS : TEXCOORD3; // xyz: tangent, w: viewDir.y
half4 bitangentWS : TEXCOORD4; // xyz: bitangent, w: viewDir.z
#else
half3 normalWS : TEXCOORD2;
half3 viewDirWS : TEXCOORD3;
#endif
float4 clipPos : SV_POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
struct SpeedTreeDepthNormalFragmentInput
{
SpeedTreeVertexDepthNormalOutput interpolated;
#ifdef EFFECT_BACKSIDE_NORMALS
FRONT_FACE_TYPE facing : FRONT_FACE_SEMANTIC;
#endif
};
struct SpeedTreeFragmentInput
{
SpeedTreeVertexOutput interpolated;
#ifdef EFFECT_BACKSIDE_NORMALS
FRONT_FACE_TYPE facing : FRONT_FACE_SEMANTIC;
#endif
};
void InitializeData(inout SpeedTreeVertexInput input, float lodValue)
{
#if !defined(EFFECT_BILLBOARD)
#if defined(LOD_FADE_PERCENTAGE)
UNITY_BRANCH if (unity_LODFade.w <= 1.0)
input.vertex.xyz = lerp(input.vertex.xyz, input.texcoord2.xyz, lodValue);
#endif
// geometry type
float geometryType = (int) (input.texcoord3.w + 0.25);
bool leafTwo = false;
if (geometryType > GEOM_TYPE_FACINGLEAF)
{
geometryType -= 2;
leafTwo = true;
}
// leaf facing
if (geometryType == GEOM_TYPE_FACINGLEAF)
{
float3 anchor = float3(input.texcoord1.zw, input.texcoord2.w);
input.vertex.xyz = DoLeafFacing(input.vertex.xyz, anchor);
}
#endif
// wind
#if defined(ENABLE_WIND) && !defined(_WINDQUALITY_NONE)
float windEnabled = dot(_ST_WindVector.xyz, _ST_WindVector.xyz) > 0.0f ? 1.0f : 0.0f;
if (windEnabled > 0)
{
float3 rotatedWindVector = mul(_ST_WindVector.xyz, (float3x3)UNITY_MATRIX_M);
float windLength = length(rotatedWindVector);
if (windLength < 1e-5)
{
// sanity check that wind data is available
return;
}
rotatedWindVector /= windLength;
float3 treePos = float3(UNITY_MATRIX_M[0].w, UNITY_MATRIX_M[1].w, UNITY_MATRIX_M[2].w);
float3 windyPosition = input.vertex.xyz;
#ifndef EFFECT_BILLBOARD
// leaves
if (geometryType > GEOM_TYPE_FROND)
{
// remove anchor position
float3 anchor = float3(input.texcoord1.zw, input.texcoord2.w);
windyPosition -= anchor;
// leaf wind
#if defined(_WINDQUALITY_FAST) || defined(_WINDQUALITY_BETTER) || defined(_WINDQUALITY_BEST)
#ifdef _WINDQUALITY_BEST
bool bBestWind = true;
#else
bool bBestWind = false;
#endif
float leafWindTrigOffset = anchor.x + anchor.y;
windyPosition = LeafWind(bBestWind, leafTwo, windyPosition, input.normal, input.texcoord3.x, float3(0,0,0), input.texcoord3.y, input.texcoord3.z, leafWindTrigOffset, rotatedWindVector);
#endif
// move back out to anchor
windyPosition += anchor;
}
// frond wind
bool bPalmWind = false;
#ifdef _WINDQUALITY_PALM
bPalmWind = true;
if (geometryType == GEOM_TYPE_FROND)
{
windyPosition = RippleFrond(windyPosition, input.normal, input.texcoord.x, input.texcoord.y, input.texcoord3.x, input.texcoord3.y, input.texcoord3.z);
}
#endif
// branch wind (applies to all 3D geometry)
#if defined(_WINDQUALITY_BETTER) || defined(_WINDQUALITY_BEST) || defined(_WINDQUALITY_PALM)
float3 rotatedBranchAnchor = normalize(mul(_ST_WindBranchAnchor.xyz, (float3x3)UNITY_MATRIX_M)) * _ST_WindBranchAnchor.w;
windyPosition = BranchWind(bPalmWind, windyPosition, treePos, float4(input.texcoord.zw, 0, 0), rotatedWindVector, rotatedBranchAnchor);
#endif
#endif // !EFFECT_BILLBOARD
// global wind
float globalWindTime = _ST_WindGlobal.x;
#if defined(EFFECT_BILLBOARD) && defined(UNITY_INSTANCING_ENABLED)
globalWindTime += UNITY_ACCESS_INSTANCED_PROP(STWind, _GlobalWindTime);
#endif
windyPosition = GlobalWind(windyPosition, treePos, true, rotatedWindVector, globalWindTime);
input.vertex.xyz = windyPosition;
}
#endif
#if defined(EFFECT_BILLBOARD)
float3 treePos = float3(UNITY_MATRIX_M[0].w, UNITY_MATRIX_M[1].w, UNITY_MATRIX_M[2].w);
// crossfade faces
bool topDown = (input.texcoord.z > 0.5);
float3 viewDir = UNITY_MATRIX_IT_MV[2].xyz;
float3 cameraDir = normalize(mul((float3x3)UNITY_MATRIX_M, _WorldSpaceCameraPos - treePos));
float viewDot = max(dot(viewDir, input.normal), dot(cameraDir, input.normal));
viewDot *= viewDot;
viewDot *= viewDot;
viewDot += topDown ? 0.38 : 0.18; // different scales for horz and vert billboards to fix transition zone
// if invisible, avoid overdraw
if (viewDot < 0.3333)
{
input.vertex.xyz = float3(0, 0, 0);
}
input.color = float4(1, 1, 1, clamp(viewDot, 0, 1));
// adjust lighting on billboards to prevent seams between the different faces
if (topDown)
{
input.normal += cameraDir;
}
else
{
half3 binormal = cross(input.normal, input.tangent.xyz) * input.tangent.w;
float3 right = cross(cameraDir, binormal);
input.normal = cross(binormal, right);
}
input.normal = normalize(input.normal);
#endif
}
SpeedTreeVertexOutput SpeedTree8Vert(SpeedTreeVertexInput input)
{
SpeedTreeVertexOutput output = (SpeedTreeVertexOutput)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
// handle speedtree wind and lod
InitializeData(input, unity_LODFade.x);
output.uv = input.texcoord.xy;
output.color = input.color;
// color already contains (ao, ao, ao, blend)
// put hue variation amount in there
#ifdef EFFECT_HUE_VARIATION
float3 treePos = float3(UNITY_MATRIX_M[0].w, UNITY_MATRIX_M[1].w, UNITY_MATRIX_M[2].w);
float hueVariationAmount = frac(treePos.x + treePos.y + treePos.z);
output.color.g = saturate(hueVariationAmount * _HueVariationColor.a);
#endif
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.vertex.xyz);
half3 normalWS = TransformObjectToWorldNormal(input.normal);
half3 vertexLight = VertexLighting(vertexInput.positionWS, normalWS);
half fogFactor = 0.0;
#if !defined(_FOG_FRAGMENT)
fogFactor = ComputeFogFactor(vertexInput.positionCS.z);
#endif
output.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS);
#ifdef EFFECT_BUMP
real sign = input.tangent.w * GetOddNegativeScale();
output.normalWS.xyz = normalWS;
output.tangentWS.xyz = TransformObjectToWorldDir(input.tangent.xyz);
output.bitangentWS.xyz = cross(output.normalWS.xyz, output.tangentWS.xyz) * sign;
// View dir packed in w.
output.normalWS.w = viewDirWS.x;
output.tangentWS.w = viewDirWS.y;
output.bitangentWS.w = viewDirWS.z;
#else
output.normalWS = normalWS;
output.viewDirWS = viewDirWS;
#endif
output.positionWS = vertexInput.positionWS;
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
output.shadowCoord = GetShadowCoord(vertexInput);
#endif
output.clipPos = vertexInput.positionCS;
OUTPUT_SH4(vertexInput.positionWS, output.normalWS.xyz, GetWorldSpaceNormalizeViewDir(vertexInput.positionWS), output.vertexSH, output.probeOcclusion);
return output;
}
SpeedTreeVertexDepthOutput SpeedTree8VertDepth(SpeedTreeVertexInput input)
{
SpeedTreeVertexDepthOutput output = (SpeedTreeVertexDepthOutput)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
// handle speedtree wind and lod
InitializeData(input, unity_LODFade.x);
output.uv = input.texcoord.xy;
output.color = input.color;
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.vertex.xyz);
output.viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS);
#ifdef SHADOW_CASTER
half3 normalWS = TransformObjectToWorldNormal(input.normal);
#if _CASTING_PUNCTUAL_LIGHT_SHADOW
float3 lightDirectionWS = normalize(_LightPosition - vertexInput.positionWS);
#else
float3 lightDirectionWS = _LightDirection;
#endif
float4 positionCS = TransformWorldToHClip(ApplyShadowBias(vertexInput.positionWS, normalWS, lightDirectionWS));
output.clipPos = positionCS;
#else
output.clipPos = vertexInput.positionCS;
#endif
return output;
}
void InitializeInputData(SpeedTreeFragmentInput input, half3 normalTS, out InputData inputData)
{
inputData = (InputData)0;
inputData.positionWS = input.interpolated.positionWS.xyz;
inputData.positionCS = input.interpolated.clipPos;
#ifdef EFFECT_BUMP
inputData.normalWS = TransformTangentToWorld(normalTS, half3x3(input.interpolated.tangentWS.xyz, input.interpolated.bitangentWS.xyz, input.interpolated.normalWS.xyz));
inputData.normalWS = NormalizeNormalPerPixel(inputData.normalWS);
inputData.viewDirectionWS = half3(input.interpolated.normalWS.w, input.interpolated.tangentWS.w, input.interpolated.bitangentWS.w);
#else
inputData.normalWS = NormalizeNormalPerPixel(input.interpolated.normalWS);
inputData.viewDirectionWS = input.interpolated.viewDirWS;
#endif
inputData.viewDirectionWS = SafeNormalize(inputData.viewDirectionWS);
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
inputData.shadowCoord = input.interpolated.shadowCoord;
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
inputData.shadowCoord = TransformWorldToShadowCoord(inputData.positionWS);
#else
inputData.shadowCoord = float4(0, 0, 0, 0);
#endif
inputData.fogCoord = InitializeInputDataFog(float4(input.interpolated.positionWS, 1.0), input.interpolated.fogFactorAndVertexLight.x);
inputData.vertexLighting = input.interpolated.fogFactorAndVertexLight.yzw;
#if !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2))
inputData.bakedGI = SAMPLE_GI(input.interpolated.vertexSH,
GetAbsolutePositionWS(inputData.positionWS),
inputData.normalWS,
inputData.viewDirectionWS,
inputData.positionCS.xy,
input.probeOcclusion,
inputData.shadowMask);
#else
inputData.bakedGI = SAMPLE_GI(NOT_USED, input.interpolated.vertexSH, inputData.normalWS);
#endif
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.interpolated.clipPos);
inputData.shadowMask = half4(1, 1, 1, 1); // No GI currently.
#if defined(DEBUG_DISPLAY) && !defined(LIGHTMAP_ON)
inputData.vertexSH = input.interpolated.vertexSH;
#endif
#if defined(_NORMALMAP)
inputData.tangentToWorld = half3x3(input.interpolated.tangentWS.xyz, input.interpolated.bitangentWS.xyz, input.interpolated.normalWS.xyz);
#endif
}
#ifdef GBUFFER
GBufferFragOutput SpeedTree8Frag(SpeedTreeFragmentInput input)
#else
half4 SpeedTree8Frag(SpeedTreeFragmentInput input) : SV_Target
#endif
{
UNITY_SETUP_INSTANCE_ID(input.interpolated);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input.interpolated);
half2 uv = input.interpolated.uv;
half4 diffuse = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_MainTex, sampler_MainTex)) * _Color;
half alpha = diffuse.a * input.interpolated.color.a;
alpha = AlphaDiscard(alpha, 0.3333);
#ifdef LOD_FADE_CROSSFADE
LODFadeCrossFade(input.interpolated.clipPos);
#endif
half3 albedo = diffuse.rgb;
half3 emission = 0;
half metallic = 0;
half smoothness = 0;
half occlusion = 0;
half3 specular = 0;
// hue variation
#ifdef EFFECT_HUE_VARIATION
half3 shiftedColor = lerp(albedo, _HueVariationColor.rgb, input.interpolated.color.g);
// preserve vibrance
half maxBase = max(albedo.r, max(albedo.g, albedo.b));
half newMaxBase = max(shiftedColor.r, max(shiftedColor.g, shiftedColor.b));
maxBase /= newMaxBase;
maxBase = maxBase * 0.5f + 0.5f;
shiftedColor.rgb *= maxBase;
albedo = saturate(shiftedColor);
#endif
// normal
#ifdef EFFECT_BUMP
half3 normalTs = SampleNormal(uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap));
#else
half3 normalTs = half3(0, 0, 1);
#endif
// flip normal on backsides
#ifdef EFFECT_BACKSIDE_NORMALS
normalTs.z = IS_FRONT_VFACE(input.facing, normalTs.z, -normalTs.z);
#endif
// adjust billboard normals to improve GI and matching
#ifdef EFFECT_BILLBOARD
normalTs.z *= 0.5;
normalTs = normalize(normalTs);
#endif
// extra
#ifdef EFFECT_EXTRA_TEX
half4 extra = tex2D(_ExtraTex, uv);
smoothness = extra.r;
metallic = extra.g;
occlusion = extra.b * input.interpolated.color.r;
#else
smoothness = _Glossiness;
metallic = _Metallic;
occlusion = input.interpolated.color.r;
#endif
InputData inputData;
InitializeInputData(input, normalTs, inputData);
SETUP_DEBUG_TEXTURE_DATA(inputData, input.interpolated.uv);
#if defined(GBUFFER) || defined(EFFECT_SUBSURFACE)
Light mainLight = GetMainLight(inputData.shadowCoord, inputData.positionWS, inputData.shadowMask);
#endif
// subsurface (hijack emissive)
#ifdef EFFECT_SUBSURFACE
half fSubsurfaceRough = 0.7 - smoothness * 0.5;
half fSubsurface = D_GGX(clamp(-dot(mainLight.direction.xyz, inputData.viewDirectionWS.xyz), 0, 1), fSubsurfaceRough);
float4 shadowCoord = TransformWorldToShadowCoord(inputData.positionWS);
half realtimeShadow = MainLightRealtimeShadow(shadowCoord);
float3 tintedSubsurface = tex2D(_SubsurfaceTex, uv).rgb * _SubsurfaceColor.rgb;
float3 directSubsurface = tintedSubsurface.rgb * mainLight.color.rgb * fSubsurface * realtimeShadow;
float3 indirectSubsurface = tintedSubsurface.rgb * inputData.bakedGI.rgb * _SubsurfaceIndirect;
emission = directSubsurface + indirectSubsurface;
#endif
#ifdef GBUFFER
// in LitForwardPass GlobalIllumination (and temporarily LightingPhysicallyBased) are called inside UniversalFragmentPBR
// in Deferred rendering we store the sum of these values (and of emission as well) in the GBuffer
BRDFData brdfData;
InitializeBRDFData(albedo, metallic, specular, smoothness, alpha, brdfData);
MixRealtimeAndBakedGI(mainLight, inputData.normalWS, inputData.bakedGI, inputData.shadowMask);
half3 color = GlobalIllumination(brdfData, (BRDFData)0, 0, inputData.bakedGI, occlusion, inputData.positionWS,
inputData.normalWS, inputData.viewDirectionWS, inputData.normalizedScreenSpaceUV);
return PackGBuffersBRDFData(brdfData, inputData, smoothness, emission + color, occlusion);
#else
SurfaceData surfaceData;
surfaceData.albedo = albedo;
surfaceData.specular = specular;
surfaceData.metallic = metallic;
surfaceData.smoothness = smoothness;
surfaceData.normalTS = normalTs;
surfaceData.emission = emission;
surfaceData.occlusion = occlusion;
surfaceData.alpha = alpha;
surfaceData.clearCoatMask = 0;
surfaceData.clearCoatSmoothness = 1;
#if defined(DEBUG_DISPLAY)
inputData.uv = uv;
#endif
half4 color = UniversalFragmentPBR(inputData, surfaceData);
color.rgb = MixFog(color.rgb, inputData.fogCoord);
color.a = OutputAlpha(color.a, _Surface);
return color;
#endif
}
half4 SpeedTree8FragDepth(SpeedTreeVertexDepthOutput input) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(input);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
half2 uv = input.uv;
half4 diffuse = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_MainTex, sampler_MainTex)) * _Color;
half alpha = diffuse.a * input.color.a;
AlphaDiscard(alpha, 0.3333);
#ifdef LOD_FADE_CROSSFADE
LODFadeCrossFade(input.clipPos);
#endif
#if defined(SCENESELECTIONPASS)
// We use depth prepass for scene selection in the editor, this code allow to output the outline correctly
return half4(_ObjectId, _PassValue, 1.0, 1.0);
#else
return half4(input.clipPos.z, 0, 0, 0);
#endif
}
SpeedTreeVertexDepthNormalOutput SpeedTree8VertDepthNormal(SpeedTreeVertexInput input)
{
SpeedTreeVertexDepthNormalOutput output = (SpeedTreeVertexDepthNormalOutput)0;
UNITY_SETUP_INSTANCE_ID(input);
UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
// handle speedtree wind and lod
InitializeData(input, unity_LODFade.x);
output.uv = input.texcoord.xy;
output.color = input.color;
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.vertex.xyz);
half3 normalWS = TransformObjectToWorldNormal(input.normal);
half3 viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS);
#ifdef EFFECT_BUMP
real sign = input.tangent.w * GetOddNegativeScale();
output.normalWS.xyz = normalWS;
output.tangentWS.xyz = TransformObjectToWorldDir(input.tangent.xyz);
output.bitangentWS.xyz = cross(output.normalWS.xyz, output.tangentWS.xyz) * sign;
// View dir packed in w.
output.normalWS.w = viewDirWS.x;
output.tangentWS.w = viewDirWS.y;
output.bitangentWS.w = viewDirWS.z;
#else
output.normalWS = normalWS;
output.viewDirWS = viewDirWS;
#endif
output.clipPos = vertexInput.positionCS;
return output;
}
half4 SpeedTree8FragDepthNormal(SpeedTreeDepthNormalFragmentInput input) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(input.interpolated);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input.interpolated);
half2 uv = input.interpolated.uv;
half4 diffuse = SampleAlbedoAlpha(uv, TEXTURE2D_ARGS(_MainTex, sampler_MainTex)) * _Color;
half alpha = diffuse.a * input.interpolated.color.a;
AlphaDiscard(alpha, 0.3333);
#ifdef LOD_FADE_CROSSFADE
LODFadeCrossFade(input.interpolated.clipPos);
#endif
// normal
#if defined(EFFECT_BUMP)
half3 normalTs = SampleNormal(uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap));
#else
half3 normalTs = half3(0, 0, 1);
#endif
// flip normal on backsides
#ifdef EFFECT_BACKSIDE_NORMALS
if (input.facing < 0.5)
{
normalTs.z = -normalTs.z;
}
#endif
// adjust billboard normals to improve GI and matching
#if defined(EFFECT_BILLBOARD)
normalTs.z *= 0.5;
normalTs = normalize(normalTs);
#endif
half outputAlpha = 0.0;
#ifdef _WRITE_SMOOTHNESS
#ifdef EFFECT_EXTRA_TEX
half4 extra = tex2D(_ExtraTex, uv);
outputAlpha = extra.r;
#else
outputAlpha = _Glossiness;
#endif
#endif
#if defined(EFFECT_BUMP)
float3 normalWS = TransformTangentToWorld(normalTs, half3x3(input.interpolated.tangentWS.xyz, input.interpolated.bitangentWS.xyz, input.interpolated.normalWS.xyz));
#else
float3 normalWS = input.interpolated.normalWS;
#endif
#if defined(_GBUFFER_NORMALS_OCT)
float2 octNormalWS = PackNormalOctQuadEncode(normalize(normalWS)); // values between [-1, +1], must use fp32 on some platforms.
float2 remappedOctNormalWS = saturate(octNormalWS * 0.5 + 0.5); // values between [ 0, 1]
return half4(PackFloat2To888(remappedOctNormalWS), outputAlpha); // values between [ 0, 1]
#else
return half4(NormalizeNormalPerPixel(normalWS), outputAlpha);
#endif
}
#endif
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0613a5abac2db2247bdcd7380e98bba1
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 9920c1f1781549a46ba081a2a15a16ec
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: cbd3e1cc4ae141c42a30e33b4d666a61
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
@@ -0,0 +1,32 @@
#ifndef UNIVERSAL_SPEEDTREE_UTILITY
#define UNIVERSAL_SPEEDTREE_UTILITY
uint2 ComputeFadeMaskSeed(float3 V, uint2 positionSS)
{
uint2 fadeMaskSeed;
// Is this a reasonable quality gate?
if (IsPerspectiveProjection())
{
// Start with the world-space direction V. It is independent from the orientation of the camera,
// and only depends on the position of the camera and the position of the fragment.
// Now, project and transform it into [-1, 1].
float2 pv = PackNormalOctQuadEncode(V);
// Rescale it to account for the resolution of the screen.
pv *= _ScreenParams.xy;
// The camera only sees a small portion of the sphere, limited by hFoV and vFoV.
// Therefore, we must rescale again (before quantization), roughly, by 1/tan(FoV/2).
pv *= UNITY_MATRIX_P._m00_m11;
// Truncate and quantize.
fadeMaskSeed = asuint((int2)pv);
}
else
{
// Can't use the view direction, it is the same across the entire screen.
fadeMaskSeed = positionSS;
}
return fadeMaskSeed;
}
#endif
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: c245162389fbe944dbc0d721bee26fe0
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant: