diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Templates/ShaderPass.template b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Templates/ShaderPass.template index aface15986a..e26fe67edcc 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Templates/ShaderPass.template +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/Templates/ShaderPass.template @@ -24,14 +24,21 @@ Pass $splice(PassKeywords) $splice(GraphKeywords) + // -------------------------------------------------- // Defines + + // Lighting Material only (will not affect unlit) $DisableDecals: #define _DISABLE_DECALS 1 $DisableSSR: #define _DISABLE_SSR 1 $DisableSSRTransparent: #define _DISABLE_SSR_TRANSPARENT 1 + $BlendMode.PreserveSpecular: #define _BLENDMODE_PRESERVE_SPECULAR_LIGHTING 1 + + // Precomputed velocity is used for alembic $AddPrecomputedVelocity: #define _ADD_PRECOMPUTED_VELOCITY $TransparentWritesMotionVec: #define _TRANSPARENT_WRITES_MOTION_VEC 1 $DepthOffset: #define _DEPTHOFFSET_ON 1 - $BlendMode.PreserveSpecular: #define _BLENDMODE_PRESERVE_SPECULAR_LIGHTING 1 + + // Attribute $AttributesMesh.normalOS: #define ATTRIBUTES_NEED_NORMAL $AttributesMesh.tangentOS: #define ATTRIBUTES_NEED_TANGENT $AttributesMesh.uv0: #define ATTRIBUTES_NEED_TEXCOORD0 @@ -65,10 +72,12 @@ Pass #endif #endif + #ifndef SHADER_UNLIT // We need isFontFace when using double sided #if defined(_DOUBLESIDED_ON) && !defined(VARYINGS_NEED_CULLFACE) #define VARYINGS_NEED_CULLFACE #endif + #endif // Translate transparent motion vector define #if defined(_TRANSPARENT_WRITES_MOTION_VEC) && defined(_SURFACE_TYPE_TRANSPARENT) @@ -83,7 +92,7 @@ Pass // Includes $splice(PreGraphIncludes) - // Used by SceneSelectionPass + // Properties used by SceneSelectionPass #ifdef SCENESELECTIONPASS int _ObjectId; int _PassValue; @@ -256,6 +265,7 @@ Pass void GetSurfaceAndBuiltinData(FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData RAY_TRACING_OPTIONAL_PARAMETERS) { + #ifndef SHADER_UNLIT // Don't dither if displaced tessellation (we're fading out the displacement instead to match the next LOD) #if !defined(SHADER_STAGE_RAY_TRACING) && !defined(_TESSELLATION_DISPLACEMENT) #ifdef LOD_FADE_CROSSFADE // enable dithering LOD transition if user select CrossFade transition in LOD group @@ -270,6 +280,7 @@ Pass #endif ApplyDoubleSidedFlipOrMirror(fragInputs, doubleSidedConstants); // Apply double sided flip on the vertex normal + #endif // SHADER_UNLIT SurfaceDescriptionInputs surfaceDescriptionInputs = FragInputsToSurfaceDescriptionInputs(fragInputs, V); SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs); @@ -287,6 +298,7 @@ Pass $DepthOffset: ApplyDepthOffsetPositionInput(V, surfaceDescription.DepthOffset, GetViewForwardDir(), GetWorldToHClipMatrix(), posInput); #endif + #ifndef SHADER_UNLIT float3 bentNormalWS; BuildSurfaceData(fragInputs, surfaceDescription, V, posInput, surfaceData, bentNormalWS); @@ -294,6 +306,21 @@ Pass // For back lighting we use the oposite vertex normal InitBuiltinData(posInput, surfaceDescription.Alpha, bentNormalWS, -fragInputs.tangentToWorld[2], fragInputs.texCoord1, fragInputs.texCoord2, builtinData); + #else + BuildSurfaceData(fragInputs, surfaceDescription, V, posInput, surfaceData); + + ZERO_INITIALIZE(BuiltinData, builtinData); // No call to InitBuiltinData as we don't have any lighting + builtinData.opacity = surfaceDescription.Alpha; + + #if defined(DEBUG_DISPLAY) + // Light Layers are currently not used for the Unlit shader (because it is not lit) + // But Unlit objects do cast shadows according to their rendering layer mask, which is what we want to + // display in the light layers visualization mode, therefore we need the renderingLayers + builtinData.renderingLayers = _EnableLightLayers ? asuint(unity_RenderingLayer.x) : DEFAULT_LIGHT_LAYERS; + #endif + + #endif // SHADER_UNLIT + #ifdef _ALPHATEST_ON // Used for sharpening by alpha to mask $DoAlphaTest: builtinData.alphaClipTreshold = surfaceDescription.AlphaClipThreshold; @@ -302,12 +329,28 @@ Pass $DoAlphaTestShadow: builtinData.alphaClipTreshold = surfaceDescription.AlphaClipThresholdShadow; #endif - // override sampleBakedGI: + // override sampleBakedGI - not used by Unlit $LightingGI: builtinData.bakeDiffuseLighting = surfaceDescription.BakedGI; $BackLightingGI: builtinData.backBakeDiffuseLighting = surfaceDescription.BakedBackGI; $SurfaceDescription.Emission: builtinData.emissiveColor = surfaceDescription.Emission; + #ifndef SHADER_UNLIT + // TODO: need to implement for shader graph raytracing + /* + // Raytracing specific code to remove Emissive color from the pass to avoid double contribution + // To avoid to have double lighting (once from the light source and once from the light itself) + #if SHADERPASS == SHADERPASS_RAYTRACING_INDIRECT || SHADERPASS == SHADERPASS_RAYTRACING_GBUFFER + builtinData.emissiveColor *= _IncludeIndirectLighting; + #elif SHADERPASS == SHADERPASS_RAYTRACING_FORWARD || SHADERPASS == SHADERPASS_PATH_TRACING + if (rayCone.spreadAngle < 0.0) + { + builtinData.emissiveColor *= _IncludeIndirectLighting; + } + #endif + */ + #endif // SHADER_UNLIT + // Note this will not fully work on transparent surfaces (can check with _SURFACE_TYPE_TRANSPARENT define) // We will always overwrite vt feeback with the nearest. So behind transparent surfaces vt will not be resolved // This is a limitation of the current MRT approach. @@ -321,7 +364,12 @@ Pass builtinData.distortionBlur = surfaceDescription.DistortionBlur; #endif + #ifndef SHADER_UNLIT + // PostInitBuiltinData call ApplyDebugToBuiltinData PostInitBuiltinData(V, posInput, surfaceData, builtinData); + #else + ApplyDebugToBuiltinData(builtinData); + #endif RAY_TRACING_OPTIONAL_ALPHA_TEST_PASS } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitPass.template b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitPass.template deleted file mode 100644 index f89d07d5885..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitPass.template +++ /dev/null @@ -1,180 +0,0 @@ -Pass -{ - $splice(PassName) - Tags - { - $splice(LightMode) - } - - // Render State - $splice(RenderState) - - // Debug - $splice(Debug) - - // -------------------------------------------------- - // Pass - - HLSLPROGRAM - - // Pragmas - $splice(PassPragmas) - - // Keywords - $splice(PassKeywords) - $splice(GraphKeywords) - - // Defines - $AddPrecomputedVelocity: #define _ADD_PRECOMPUTED_VELOCITY - $EnableShadowMatte: #define _ENABLE_SHADOW_MATTE - $AttributesMesh.normalOS: #define ATTRIBUTES_NEED_NORMAL - $AttributesMesh.tangentOS: #define ATTRIBUTES_NEED_TANGENT - $AttributesMesh.uv0: #define ATTRIBUTES_NEED_TEXCOORD0 - $AttributesMesh.uv1: #define ATTRIBUTES_NEED_TEXCOORD1 - $AttributesMesh.uv2: #define ATTRIBUTES_NEED_TEXCOORD2 - $AttributesMesh.uv3: #define ATTRIBUTES_NEED_TEXCOORD3 - $AttributesMesh.color: #define ATTRIBUTES_NEED_COLOR - $VaryingsMeshToPS.positionRWS: #define VARYINGS_NEED_POSITION_WS - $VaryingsMeshToPS.normalWS: #define VARYINGS_NEED_TANGENT_TO_WORLD - $VaryingsMeshToPS.texCoord0: #define VARYINGS_NEED_TEXCOORD0 - $VaryingsMeshToPS.texCoord1: #define VARYINGS_NEED_TEXCOORD1 - $VaryingsMeshToPS.texCoord2: #define VARYINGS_NEED_TEXCOORD2 - $VaryingsMeshToPS.texCoord3: #define VARYINGS_NEED_TEXCOORD3 - $VaryingsMeshToPS.color: #define VARYINGS_NEED_COLOR - $VaryingsMeshToPS.cullFace: #define VARYINGS_NEED_CULLFACE - $features.graphVertex: #define HAVE_MESH_MODIFICATION - $splice(GraphDefines) - - #if defined(_ENABLE_SHADOW_MATTE) && SHADERPASS == SHADERPASS_FORWARD_UNLIT - #define LIGHTLOOP_DISABLE_TILE_AND_CLUSTER - #define HAS_LIGHTLOOP - #endif - - // Dots Instancing - $splice(DotsInstancingOptions) - - $splice(HybridV1InjectedBuiltinProperties) - - // Includes - $splice(PreGraphIncludes) - - // Used by SceneSelectionPass - int _ObjectId; - int _PassValue; - - // -------------------------------------------------- - // Structs and Packing - - $splice(PassStructs) - - $splice(InterpolatorPack) - - // -------------------------------------------------- - // Graph - - // Graph Properties - $splice(GraphProperties) - - // Graph Functions - $splice(GraphFunctions) - - // Graph Vertex - $splice(GraphVertex) - - // Graph Pixel - $splice(GraphPixel) - - // -------------------------------------------------- - // Build Graph Inputs - - $features.graphVertex: $include("VertexAnimation.template.hlsl") - $features.graphPixel: $include("SharedCode.template.hlsl") - - // -------------------------------------------------- - // Build Surface Data - - void BuildSurfaceData(FragInputs fragInputs, inout SurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData) - { - // setup defaults -- these are used if the graph doesn't output a value - ZERO_INITIALIZE(SurfaceData, surfaceData); - - // copy across graph values, if defined - $SurfaceDescription.BaseColor: surfaceData.color = surfaceDescription.BaseColor; - - #if defined(DEBUG_DISPLAY) - if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE) - { - // TODO - } - #endif - } - - void GetSurfaceAndBuiltinData(FragInputs fragInputs, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData RAY_TRACING_OPTIONAL_PARAMETERS) - { - SurfaceDescriptionInputs surfaceDescriptionInputs = FragInputsToSurfaceDescriptionInputs(fragInputs, V); - SurfaceDescription surfaceDescription = SurfaceDescriptionFunction(surfaceDescriptionInputs); - - // Perform alpha test very early to save performance (a killed pixel will not sample textures) - // TODO: split graph evaluation to grab just alpha dependencies first? tricky. - #ifdef _ALPHATEST_ON - $DoAlphaTest: GENERIC_ALPHA_TEST(surfaceDescription.Alpha, surfaceDescription.AlphaClipThreshold); - #endif - - BuildSurfaceData(fragInputs, surfaceDescription, V, posInput, surfaceData); - - #if defined(_ENABLE_SHADOW_MATTE) && SHADERPASS == SHADERPASS_FORWARD_UNLIT - HDShadowContext shadowContext = InitShadowContext(); - float shadow; - float3 shadow3; - posInput = GetPositionInput(fragInputs.positionSS.xy, _ScreenSize.zw, fragInputs.positionSS.z, UNITY_MATRIX_I_VP, UNITY_MATRIX_V); - float3 normalWS = normalize(fragInputs.tangentToWorld[1]); - uint renderingLayers = _EnableLightLayers ? asuint(unity_RenderingLayer.x) : DEFAULT_LIGHT_LAYERS; - ShadowLoopMin(shadowContext, posInput, normalWS, asuint(_ShadowMatteFilter), renderingLayers, shadow3); - shadow = dot(shadow3, float3(1.0f/3.0f, 1.0f/3.0f, 1.0f/3.0f)); - - float4 shadowColor = (1 - shadow)*surfaceDescription.ShadowTint.rgba; - float localAlpha = saturate(shadowColor.a + surfaceDescription.Alpha); - - // Keep the nested lerp - // With no Color (bsdfData.color.rgb, bsdfData.color.a == 0.0f), just use ShadowColor*Color to avoid a ring of "white" around the shadow - // And mix color to consider the Color & ShadowColor alpha (from texture or/and color picker) - #ifdef _SURFACE_TYPE_TRANSPARENT - surfaceData.color = lerp(shadowColor.rgb*surfaceData.color, lerp(lerp(shadowColor.rgb, surfaceData.color, 1 - surfaceDescription.ShadowTint.a), surfaceData.color, shadow), surfaceDescription.Alpha); - #else - surfaceData.color = lerp(lerp(shadowColor.rgb, surfaceData.color, 1 - surfaceDescription.ShadowTint.a), surfaceData.color, shadow); - #endif - localAlpha = ApplyBlendMode(surfaceData.color, localAlpha).a; - - surfaceDescription.Alpha = localAlpha; - #endif - - // Builtin Data - ZERO_INITIALIZE(BuiltinData, builtinData); // No call to InitBuiltinData as we don't have any lighting - builtinData.opacity = surfaceDescription.Alpha; - - #ifdef _ALPHATEST_ON - // Used for sharpening by alpha to mask - $DoAlphaTest: builtinData.alphaClipTreshold = surfaceDescription.AlphaClipThreshold; - #endif - - $SurfaceDescription.Emission: builtinData.emissiveColor = surfaceDescription.Emission; - - #if !defined(_SURFACE_TYPE_TRANSPARENT) - $SurfaceDescription.VTPackedFeedback: builtinData.vtPackedFeedback = surfaceDescription.VTPackedFeedback; - #endif - - #if (SHADERPASS == SHADERPASS_DISTORTION) - builtinData.distortion = surfaceDescription.Distortion; - builtinData.distortionBlur = surfaceDescription.DistortionBlur; - #endif - - RAY_TRACING_OPTIONAL_ALPHA_TEST_PASS - } - - // -------------------------------------------------- - // Main - - $splice(PostGraphIncludes) - - ENDHLSL -} diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitPass.template.meta b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitPass.template.meta deleted file mode 100644 index 007f9124890..00000000000 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitPass.template.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 425e773704fc9444786e8a6ccb88c5c7 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitSubTarget.cs b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitSubTarget.cs index e065e3e4ea9..25c0d263ffc 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitSubTarget.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitSubTarget.cs @@ -18,8 +18,7 @@ sealed partial class HDUnlitSubTarget : SurfaceSubTarget, IRequiresData displayName = "Unlit"; // Templates - protected override string templatePath => $"{HDUtils.GetHDRenderPipelinePath()}Editor/Material/Unlit/ShaderGraph/HDUnlitPass.template"; - protected override string templateMaterialDirectory => $"{HDUtils.GetHDRenderPipelinePath()}Editor/Material/ShaderGraph/Templates"; + protected override string templateMaterialDirectory => $"{HDUtils.GetHDRenderPipelinePath()}Editor/Material/Unlit/ShaderGraph/"; protected override ShaderID shaderID => HDShaderUtils.ShaderID.SG_Unlit; protected override string renderType => HDRenderTypeTags.HDUnlitShader.ToString(); protected override string subTargetAssetGuid => "4516595d40fa52047a77940183dc8e74"; // HDUnlitSubTarget diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/ShaderPass.template.hlsl b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/ShaderPass.template.hlsl new file mode 100644 index 00000000000..831b19c4b93 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/ShaderPass.template.hlsl @@ -0,0 +1,42 @@ +void BuildSurfaceData(FragInputs fragInputs, inout SurfaceDescription surfaceDescription, float3 V, PositionInputs posInput, out SurfaceData surfaceData) +{ + // setup defaults -- these are used if the graph doesn't output a value + ZERO_INITIALIZE(SurfaceData, surfaceData); + + // copy across graph values, if defined + $SurfaceDescription.BaseColor: surfaceData.color = surfaceDescription.BaseColor; + + #if defined(DEBUG_DISPLAY) + if (_DebugMipMapMode != DEBUGMIPMAPMODE_NONE) + { + // TODO + } + #endif + + #if defined(_ENABLE_SHADOW_MATTE) && SHADERPASS == SHADERPASS_FORWARD_UNLIT + HDShadowContext shadowContext = InitShadowContext(); + float shadow; + float3 shadow3; + // We need to recompute some coordinate not computed by default for shadow matte + posInput = GetPositionInput(fragInputs.positionSS.xy, _ScreenSize.zw, fragInputs.positionSS.z, UNITY_MATRIX_I_VP, UNITY_MATRIX_V); + float3 upWS = normalize(fragInputs.tangentToWorld[1]); + uint renderingLayers = _EnableLightLayers ? asuint(unity_RenderingLayer.x) : DEFAULT_LIGHT_LAYERS; + ShadowLoopMin(shadowContext, posInput, upWS, asuint(_ShadowMatteFilter), renderingLayers, shadow3); + shadow = dot(shadow3, float3(1.0 / 3.0, 1.0 / 3.0, 1.0 / 3.0)); + + float4 shadowColor = (1.0 - shadow) * surfaceDescription.ShadowTint.rgba; + float localAlpha = saturate(shadowColor.a + surfaceDescription.Alpha); + + // Keep the nested lerp + // With no Color (bsdfData.color.rgb, bsdfData.color.a == 0.0f), just use ShadowColor*Color to avoid a ring of "white" around the shadow + // And mix color to consider the Color & ShadowColor alpha (from texture or/and color picker) + #ifdef _SURFACE_TYPE_TRANSPARENT + surfaceData.color = lerp(shadowColor.rgb * surfaceData.color, lerp(lerp(shadowColor.rgb, surfaceData.color, 1.0 - surfaceDescription.ShadowTint.a), surfaceData.color, shadow), surfaceDescription.Alpha); + #else + surfaceData.color = lerp(lerp(shadowColor.rgb, surfaceData.color, 1.0 - surfaceDescription.ShadowTint.a), surfaceData.color, shadow); + #endif + localAlpha = ApplyBlendMode(surfaceData.color, localAlpha).a; + + surfaceDescription.Alpha = localAlpha; + #endif +} diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/ShaderPass.template.hlsl.meta b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/ShaderPass.template.hlsl.meta new file mode 100644 index 00000000000..0fd7dfeb2a9 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/ShaderPass.template.hlsl.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 214546ce427d79f4c8400e8dd0a72f0c +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/ShaderPassDefine.template.hlsl b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/ShaderPassDefine.template.hlsl new file mode 100644 index 00000000000..ad1b12f4ab6 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/ShaderPassDefine.template.hlsl @@ -0,0 +1,9 @@ +// Setup a define to say we are an unlit shader +#define SHADER_UNLIT +$EnableShadowMatte: #define _ENABLE_SHADOW_MATTE + +// Following Macro are only used by Unlit material +#if defined(_ENABLE_SHADOW_MATTE) && SHADERPASS == SHADERPASS_FORWARD_UNLIT +#define LIGHTLOOP_DISABLE_TILE_AND_CLUSTER +#define HAS_LIGHTLOOP +#endif diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/ShaderPassDefine.template.hlsl.meta b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/ShaderPassDefine.template.hlsl.meta new file mode 100644 index 00000000000..323a55b5db9 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/ShaderPassDefine.template.hlsl.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 88187413f0623e64da4e5f2c25f1002a +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/UnlitData.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/UnlitData.hlsl index 0d1cf8b876e..3803d36f4cc 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/UnlitData.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/UnlitData.hlsl @@ -69,5 +69,7 @@ void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs p } #endif + ApplyDebugToBuiltinData(builtinData); + RAY_TRACING_OPTIONAL_ALPHA_TEST_PASS } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Sky/HDRISky/HDRISky.shader b/com.unity.render-pipelines.high-definition/Runtime/Sky/HDRISky/HDRISky.shader index 6e7af9a23c7..fd9a819a9ef 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Sky/HDRISky/HDRISky.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Sky/HDRISky/HDRISky.shader @@ -257,8 +257,8 @@ Shader "Hidden/HDRP/Sky/HDRISky" float4 RenderSkyWithBackplate(Varyings input, float3 positionOnBackplate, float exposure, float3 originalDir, float blend, float depth) { // Reverse it to point into the scene - float3 offset = RotationUp(float3(_OffsetTexX, 0, _OffsetTexY), _CosSinPhiPlate); - float3 dir = positionOnBackplate - float3(0, _ProjectionDistance + _GroundLevel, 0) + offset; // No need for normalization + float3 offset = RotationUp(float3(_OffsetTexX, 0.0, _OffsetTexY), _CosSinPhiPlate); + float3 dir = positionOnBackplate - float3(0.0, _ProjectionDistance + _GroundLevel, 0.0) + offset; // No need for normalization PositionInputs posInput = GetPositionInput(input.positionCS.xy, _ScreenSize.zw, depth, UNITY_MATRIX_I_VP, UNITY_MATRIX_V); @@ -267,17 +267,17 @@ Shader "Hidden/HDRP/Sky/HDRISky" // Use uniform directly - The float need to be cast to uint (as unity don't support to set a uint as uniform) uint renderingLayers = _EnableLightLayers ? asuint(unity_RenderingLayer.x) : DEFAULT_LIGHT_LAYERS; float3 shadow3; - ShadowLoopMin(shadowContext, posInput, float3(0, 1, 0), _ShadowFilter, renderingLayers, shadow3); - shadow = dot(shadow3, float3(1.0f/3.0f, 1.0f/3.0f, 1.0f/3.0f)); + ShadowLoopMin(shadowContext, posInput, float3(0.0, 1.0, 0.0), _ShadowFilter, renderingLayers, shadow3); + shadow = dot(shadow3, float3(1.0 / 3.0, 1.0 / 3.0, 1.0 / 3.0)); - float3 shadowColor = ComputeShadowColor(shadow, _ShadowTint, 0.0f); + float3 shadowColor = ComputeShadowColor(shadow, _ShadowTint, 0.0); - float3 output = lerp( GetColorWithRotation(originalDir, exposure, _CosSinPhi).rgb, - shadowColor*GetColorWithRotation(RotationUp(dir, _CosSinPhiPlateTex), exposure, _CosSinPhi).rgb, blend); + float3 output = lerp( GetColorWithRotation(originalDir, exposure, _CosSinPhi).rgb, + shadowColor * GetColorWithRotation(RotationUp(dir, _CosSinPhiPlateTex), exposure, _CosSinPhi).rgb, blend); - float3 ao = GetScreenSpaceAmbientOcclusionForBackplate(posInput.positionSS, originalDir.z, 1.0f); + float3 ao = GetScreenSpaceAmbientOcclusionForBackplate(posInput.positionSS, originalDir.z, 1.0); - return float4(ao*output, exposure); + return float4(ao * output, exposure); } float4 FragBaking(Varyings input) : SV_Target