Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add vertex light support #382

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 45 additions & 4 deletions crest/Assets/Crest/Crest/Shaders/Ocean.shader
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,16 @@ Shader "Crest/Ocean"
// enabled on the OceanRenderer to generate flow data.
[Toggle] _Flow("Enable", Float) = 0

[Header(Lights)]
// How much the light will fill its sphere of influence
_LightsSubSurfaceBase("Sub Surface Base Mul", Range(0.0, 4.0)) = 1.0
// Strength of specular lighting response
_LightsSpecular("Specular", Range(0.0, 1000.0)) = 31.0
// Light strength on foam. Also depends on _WaveFoamLightScale.
_LightsScaleWaveFoam("Foam Lights Scale", Range(0.0, 1000.0)) = 5.0
// Controls harshness of Fresnel behaviour for lights.
_LightsFresnelPower("Fresnel Power", Range(1.0, 20.0)) = 10.0

[Header(Clip Surface)]
// Discards ocean surface pixels. Requires 'Create Clip Surface Data' enabled on OceanRenderer script.
[Toggle] _ClipSurface("Enable", Float) = 0
Expand Down Expand Up @@ -217,6 +227,8 @@ Shader "Crest/Ocean"
#pragma multi_compile_fog
#pragma multi_compile_instancing

#pragma multi_compile _ VERTEXLIGHT_ON

#pragma shader_feature_local _APPLYNORMALMAPPING_ON
#pragma shader_feature_local _COMPUTEDIRECTIONALLIGHT_ON
#pragma shader_feature_local _DIRECTIONALLIGHTVARYROUGHNESS_ON
Expand Down Expand Up @@ -268,6 +280,9 @@ Shader "Crest/Ocean"
half3 debugtint : TEXCOORD8;
#endif
half4 grabPos : TEXCOORD9;
#if defined(VERTEXLIGHT_ON)
half4 uvLightsAtten : TEXCOORD10;
#endif // VERTEXLIGHT_ON

UNITY_FOG_COORDS(3)

Expand All @@ -276,11 +291,16 @@ Shader "Crest/Ocean"

UNITY_DECLARE_SCREENSPACE_TEXTURE(_CameraDepthTexture);

#if defined(VERTEXLIGHT_ON)
uniform sampler2D _LightTextureB0;
#endif // VERTEXLIGHT_ON

#include "OceanConstants.hlsl"
#include "OceanGlobals.hlsl"
#include "OceanInputsDriven.hlsl"
#include "OceanHelpersNew.hlsl"
#include "OceanVertHelpers.hlsl"
#include "OceanLightingHelpers.hlsl"

// Argument name is v because some macros like COMPUTE_EYEDEPTH require it.
Varyings Vert(Attributes v)
Expand Down Expand Up @@ -413,6 +433,12 @@ Shader "Crest/Ocean"
// to get the right results, every time.
o.grabPos = ComputeGrabScreenPos(o.positionCS);
o.foam_screenPosXYW.yzw = ComputeScreenPos(o.positionCS).xyw;

// Calculate vertex light attenuation here to save on performance
#if defined(VERTEXLIGHT_ON)
CalculateVertexLightsAttenuation(o.uvLightsAtten, o.worldPos);
#endif // VERTEXLIGHT_ON

return o;
}

Expand Down Expand Up @@ -496,6 +522,13 @@ Shader "Crest/Ocean"
float sceneZ = LinearEyeDepth(sceneZ01);

float3 lightDir = WorldSpaceLightDir(input.worldPos);
half3 lightsCol = 0.0;

// Calculate
#if defined(VERTEXLIGHT_ON)
lightsCol = CalculateVertexLightsColor(input.uvLightsAtten, input.worldPos, _LightTextureB0);
#endif // VERTEXLIGHT_ON

// Soft shadow, hard shadow
fixed2 shadow = (fixed2)1.0
#if _SHADOWS_ON
Expand Down Expand Up @@ -536,16 +569,24 @@ Shader "Crest/Ocean"
#if _FOAM_ON
half4 whiteFoamCol;
#if !_FLOW_ON
ComputeFoam(input.foam_screenPosXYW.x, input.lodAlpha_worldXZUndisplaced_oceanDepth.yz, input.worldPos.xz, n_pixel, pixelZ, sceneZ, view, lightDir, shadow.y, lodAlpha, bubbleCol, whiteFoamCol, cascadeData0, cascadeData1);
ComputeFoam(input.foam_screenPosXYW.x, input.lodAlpha_worldXZUndisplaced_oceanDepth.yz, input.worldPos.xz, n_pixel, pixelZ, sceneZ, view, lightDir, shadow.y, lodAlpha, bubbleCol, whiteFoamCol, lightsCol, cascadeData0, cascadeData1);
#else
ComputeFoamWithFlow(input.flow_shadow.xy, input.foam_screenPosXYW.x, input.lodAlpha_worldXZUndisplaced_oceanDepth.yz, input.worldPos.xz, n_pixel, pixelZ, sceneZ, view, lightDir, shadow.y, lodAlpha, bubbleCol, whiteFoamCol, cascadeData0, cascadeData1);
ComputeFoamWithFlow(input.flow_shadow.xy, input.foam_screenPosXYW.x, input.lodAlpha_worldXZUndisplaced_oceanDepth.yz, input.worldPos.xz, n_pixel, pixelZ, sceneZ, view, lightDir, shadow.y, lodAlpha, bubbleCol, whiteFoamCol, lightsCol, cascadeData0, cascadeData1);
#endif // _FLOW_ON
#endif // _FOAM_ON

// Compute color of ocean - in-scattered light + refracted scene
half3 sssLightsCol = lightsCol;
#if defined(VERTEXLIGHT_ON)
if (underwater)
{
// Apply depth fog to light colour. Otherwise, there will light patches visible from far away.
sssLightsCol *= saturate(exp(-_DepthFogDensity.xyz * pixelZ));
}
#endif
const float baseCascadeScale = _CrestCascadeData[0]._scale;
const float meshScaleLerp = instanceData._meshScaleLerp;
half3 scatterCol = ScatterColour(input.lodAlpha_worldXZUndisplaced_oceanDepth.w, _WorldSpaceCameraPos, lightDir, view, shadow.x, underwater, true, sss, meshScaleLerp, baseCascadeScale, cascadeData0);
half3 scatterCol = ScatterColour(input.lodAlpha_worldXZUndisplaced_oceanDepth.w, _WorldSpaceCameraPos, lightDir, view, shadow.x, underwater, true, sss, sssLightsCol, meshScaleLerp, baseCascadeScale, cascadeData0);
half3 col = OceanEmission(view, n_pixel, lightDir, input.grabPos, pixelZ, uvDepth, sceneZ, sceneZ01, bubbleCol, _Normals, underwater, scatterCol, cascadeData0, cascadeData1);

// Light that reflects off water surface
Expand All @@ -567,7 +608,7 @@ Shader "Crest/Ocean"
else
#endif
{
ApplyReflectionSky(view, n_pixel, lightDir, shadow.y, input.foam_screenPosXYW.yzzw, pixelZ, reflAlpha, col);
ApplyReflectionSky(view, n_pixel, lightDir, shadow.y, input.foam_screenPosXYW.yzzw, pixelZ, reflAlpha, col, lightsCol);
}

// Override final result with white foam - bubbles on surface
Expand Down
9 changes: 8 additions & 1 deletion crest/Assets/Crest/Crest/Shaders/OceanEmission.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ uniform half3 _SubSurfaceColour;
uniform half _SubSurfaceBase;
uniform half _SubSurfaceSun;
uniform half _SubSurfaceSunFallOff;
#if defined(VERTEXLIGHT_ON)
uniform half _LightsSubSurfaceBase;
#endif // VERTEXLIGHT_ON
#endif // _SUBSURFACESCATTERING_ON

#if _SUBSURFACESHALLOWCOLOUR_ON
Expand Down Expand Up @@ -50,7 +53,7 @@ uniform half3 _DiffuseShadow;
half3 ScatterColour(
in const half i_surfaceOceanDepth, in const float3 i_cameraPos,
in const half3 i_lightDir, in const half3 i_view, in const fixed i_shadow,
in const bool i_underwater, in const bool i_outscatterLight, half sss,
in const bool i_underwater, in const bool i_outscatterLight, half sss, half3 lightsCol,
in const float i_meshScaleLerp, in const float i_scaleBase,
in const CascadeParams cascadeData0)
{
Expand Down Expand Up @@ -118,6 +121,10 @@ half3 ScatterColour(
// light
// use the constant term (0th order) of SH stuff - this is the average. it seems to give the right kind of colour
col *= half3(unity_SHAr.w, unity_SHAg.w, unity_SHAb.w);
// Apply vertex lights if available
#if defined(VERTEXLIGHT_ON)
col += lightsCol * _LightsSubSurfaceBase;
#endif // VERTEXLIGHT_ON

// Approximate subsurface scattering - add light when surface faces viewer. Use geometry normal - don't need high freqs.
half towardsSun = pow(max(0., dot(i_lightDir, -i_view)), _SubSurfaceSunFallOff);
Expand Down
20 changes: 16 additions & 4 deletions crest/Assets/Crest/Crest/Shaders/OceanFoam.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ uniform half _WaveFoamNormalStrength;
uniform half _WaveFoamSpecularFallOff;
uniform half _WaveFoamSpecularBoost;
uniform half _WaveFoamLightScale;
#if defined(VERTEXLIGHT_ON)
uniform half _LightsScaleWaveFoam;
#endif // VERTEXLIGHT_ON

half3 AmbientLight()
{
Expand Down Expand Up @@ -52,7 +55,7 @@ half BubbleFoamTexture(float2 i_worldXZ, float2 i_worldXZUndisplaced, half3 i_n,
}

void ComputeFoam(half i_foam, float2 i_worldXZUndisplaced, float2 i_worldXZ, half3 i_n, float i_pixelZ, float i_sceneZ, half3 i_view,
float3 i_lightDir, half i_shadow, half lodVal, out half3 o_bubbleCol, out half4 o_whiteFoamCol,
float3 i_lightDir, half i_shadow, half lodVal, out half3 o_bubbleCol, out half4 o_whiteFoamCol, half3 lightsCol,
in const CascadeParams cascadeData0, in const CascadeParams cascadeData1)
{
half foamAmount = i_foam;
Expand All @@ -63,6 +66,9 @@ void ComputeFoam(half i_foam, float2 i_worldXZUndisplaced, float2 i_worldXZ, hal
// Additive underwater foam - use same foam texture but add mip bias to blur for free
half bubbleFoamTexValue = BubbleFoamTexture(i_worldXZ, i_worldXZUndisplaced, i_n, i_view, lodVal, cascadeData0, cascadeData1);
o_bubbleCol = (half3)bubbleFoamTexValue * _FoamBubbleColor.rgb * saturate(i_foam * _WaveFoamBubblesCoverage) * AmbientLight();
#if defined(VERTEXLIGHT_ON)
o_bubbleCol *= lightsCol;
#endif // VERTEXLIGHT_ON

// White foam on top, with black-point fading
half whiteFoam = WhiteFoamTexture(foamAmount, i_worldXZUndisplaced, lodVal, cascadeData0, cascadeData1);
Expand All @@ -79,16 +85,22 @@ void ComputeFoam(half i_foam, float2 i_worldXZUndisplaced, float2 i_worldXZ, hal
// do simple NdL and phong lighting
half foamNdL = max(0., dot(fN, i_lightDir));
o_whiteFoamCol.rgb = _FoamWhiteColor.rgb * (AmbientLight() + _WaveFoamLightScale * _LightColor0 * foamNdL * i_shadow);
#if defined(VERTEXLIGHT_ON)
o_whiteFoamCol.rgb += lightsCol * _WaveFoamLightScale * _LightsScaleWaveFoam;
#endif // VERTEXLIGHT_ON
half3 refl = reflect(-i_view, fN);
o_whiteFoamCol.rgb += pow(max(0., dot(refl, i_lightDir)), _WaveFoamSpecularFallOff) * _WaveFoamSpecularBoost * _LightColor0 * i_shadow;
#else // _FOAM3DLIGHTING_ON
o_whiteFoamCol.rgb = _FoamWhiteColor.rgb * (AmbientLight() + _WaveFoamLightScale * _LightColor0 * i_shadow);
#if defined(VERTEXLIGHT_ON)
o_whiteFoamCol.rgb += lightsCol * _WaveFoamLightScale * _LightsScaleWaveFoam;
#endif // VERTEXLIGHT_ON
#endif // _FOAM3DLIGHTING_ON

o_whiteFoamCol.a = _FoamWhiteColor.a * whiteFoam;
}

void ComputeFoamWithFlow(half2 flow, half i_foam, float2 i_worldXZUndisplaced, float2 i_worldXZ, half3 i_n, float i_pixelZ, float i_sceneZ, half3 i_view, float3 i_lightDir, half i_shadow, half lodVal, out half3 o_bubbleCol, out half4 o_whiteFoamCol,
void ComputeFoamWithFlow(half2 flow, half i_foam, float2 i_worldXZUndisplaced, float2 i_worldXZ, half3 i_n, float i_pixelZ, float i_sceneZ, half3 i_view, float3 i_lightDir, half i_shadow, half lodVal, out half3 o_bubbleCol, out half4 o_whiteFoamCol, half3 lightsCol,
in const CascadeParams cascadeData0, in const CascadeParams cascadeData1)
{
const float half_period = 1;
Expand All @@ -107,8 +119,8 @@ void ComputeFoamWithFlow(half2 flow, half i_foam, float2 i_worldXZUndisplaced, f
half3 o_bubbleCol2 = half3(0, 0, 0);
half4 o_whiteFoamCol2 = half4(0, 0, 0, 0);

ComputeFoam(i_foam, i_worldXZUndisplaced - (flow * sample1_offset), i_worldXZ, i_n, i_pixelZ, i_sceneZ, i_view, i_lightDir, i_shadow, lodVal, o_bubbleCol1, o_whiteFoamCol1, cascadeData0, cascadeData1);
ComputeFoam(i_foam, i_worldXZUndisplaced - (flow * sample2_offset), i_worldXZ, i_n, i_pixelZ, i_sceneZ, i_view, i_lightDir, i_shadow, lodVal, o_bubbleCol2, o_whiteFoamCol2, cascadeData0, cascadeData1);
ComputeFoam(i_foam, i_worldXZUndisplaced - (flow * sample1_offset), i_worldXZ, i_n, i_pixelZ, i_sceneZ, i_view, i_lightDir, i_shadow, lodVal, o_bubbleCol1, o_whiteFoamCol1, lightsCol, cascadeData0, cascadeData1);
ComputeFoam(i_foam, i_worldXZUndisplaced - (flow * sample2_offset), i_worldXZ, i_n, i_pixelZ, i_sceneZ, i_view, i_lightDir, i_shadow, lodVal, o_bubbleCol2, o_whiteFoamCol2, lightsCol, cascadeData0, cascadeData1);
o_bubbleCol = (sample1_weight * o_bubbleCol1) + (sample2_weight * o_bubbleCol2);
o_whiteFoamCol = (sample1_weight * o_whiteFoamCol1) + (sample2_weight * o_whiteFoamCol2);
}
Expand Down
29 changes: 29 additions & 0 deletions crest/Assets/Crest/Crest/Shaders/OceanLightingHelpers.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Crest Ocean System

// This file is subject to the MIT License as seen in the root of this folder structure (LICENSE)

// Improved attenuation for vertex lights. Call this routine in the vertex shader to save on performance.
// Shade4PointLights produces tiling even though it applies attenuation.
// https://forum.unity.com/threads/point-light-in-v-f-shader.499717/#post-3250481
void CalculateVertexLightsAttenuation(out half4 uv, in const float3 positionWS)
{
for (int index = 0; index < 4; index++)
{
float3 lightPosition = float3(unity_4LightPosX0[index], unity_4LightPosY0[index], unity_4LightPosZ0[index]);
float range = (0.005 * sqrt(1000000 - unity_4LightAtten0[index])) / sqrt(unity_4LightAtten0[index]);
uv[index] = distance(lightPosition, positionWS.xyz) / range;
}
}

// Returns vertex light colour with custom attenuation. Call in fragment shader.
half3 CalculateVertexLightsColor(in const half4 uv, in const float3 positionWS, in const sampler2D lightsTexture)
{
half3 lightsColor = 0;
for (int index = 0; index < 4; index++)
{
float3 lightPosition = float3(unity_4LightPosX0[index], unity_4LightPosY0[index], unity_4LightPosZ0[index]);
float attenuation = tex2D(lightsTexture, (uv[index] * uv[index]).xx).UNITY_ATTEN_CHANNEL;
lightsColor.rgb += unity_LightColor[index].rgb * (1 / distance(lightPosition, positionWS.xyz)) * attenuation;
}
return lightsColor;
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 17 additions & 6 deletions crest/Assets/Crest/Crest/Shaders/OceanReflection.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ uniform half _FresnelPower;
uniform float _RefractiveIndexOfAir;
uniform float _RefractiveIndexOfWater;

#if defined(VERTEXLIGHT_ON)
uniform half _LightsSpecular;
uniform half _LightsFresnelPower;
#endif // VERTEXLIGHT_ON

#if _COMPUTEDIRECTIONALLIGHT_ON
uniform half _DirectionalLightFallOff;
Expand All @@ -55,17 +59,17 @@ uniform half _DirectionalLightFallOffFar;
uniform half _DirectionalLightBoost;
#endif

float CalculateFresnelReflectionCoefficient(float cosTheta)
float CalculateFresnelReflectionCoefficient(float cosTheta, half fresnelPower)
{
// Fresnel calculated using Schlick's approximation
// See: http://www.cs.virginia.edu/~jdl/bib/appearance/analytic%20models/schlick94b.pdf
// reflectance at facing angle
float R_0 = (_RefractiveIndexOfAir - _RefractiveIndexOfWater) / (_RefractiveIndexOfAir + _RefractiveIndexOfWater); R_0 *= R_0;
const float R_theta = R_0 + (1.0 - R_0) * pow(max(0.,1.0 - cosTheta), _FresnelPower);
const float R_theta = R_0 + (1.0 - R_0) * pow(max(0.,1.0 - cosTheta), fresnelPower);
return R_theta;
}

void ApplyReflectionSky(in const half3 i_view, in const half3 i_n_pixel, in const half3 i_lightDir, in const half i_shadow, in const half4 i_screenPos, in const float i_pixelZ, in const half i_weight, inout half3 io_col)
void ApplyReflectionSky(in const half3 i_view, in const half3 i_n_pixel, in const half3 i_lightDir, in const half i_shadow, in const half4 i_screenPos, in const float i_pixelZ, in const half i_weight, inout half3 io_col, float3 lightsCol)
{
// Reflection
half3 refl = reflect(-i_view, i_n_pixel);
Expand Down Expand Up @@ -129,8 +133,15 @@ void ApplyReflectionSky(in const half3 i_view, in const half3 i_n_pixel, in cons
#endif

// Fresnel
float R_theta = CalculateFresnelReflectionCoefficient(max(dot(i_n_pixel, i_view), 0.0));
float R_theta = CalculateFresnelReflectionCoefficient(max(dot(i_n_pixel, i_view), 0.0), _FresnelPower);
io_col = lerp(io_col, skyColour, R_theta * _Specular * i_weight);

// Placing this here for now. Could be in its own routine
// Use lights specific fresnel for nicer effects
#if VERTEXLIGHT_ON
float R_theta2 = CalculateFresnelReflectionCoefficient(max(dot(i_n_pixel, i_view), 0.0), _LightsFresnelPower);
io_col = lerp(io_col, io_col + lightsCol, R_theta2 * _Specular * _LightsSpecular * i_weight);
#endif // VERTEXLIGHT_ON
}

#if _UNDERWATER_ON
Expand All @@ -146,7 +157,7 @@ void ApplyReflectionUnderwater(in const half3 i_view, in const half3 i_n_pixel,
// have to calculate the incident angle of incoming light to water
// surface based on how it would be refracted so as to hit the camera
const float cosIncomingAngle = cos(asin(clamp( (_RefractiveIndexOfWater * sin(acos(cosOutgoingAngle))) / _RefractiveIndexOfAir, -1.0, 1.0) ));
const float reflectionCoefficient = CalculateFresnelReflectionCoefficient(cosIncomingAngle) * i_weight;
const float reflectionCoefficient = CalculateFresnelReflectionCoefficient(cosIncomingAngle, _FresnelPower) * i_weight;
io_col *= (1.0 - reflectionCoefficient);
io_col = max(io_col, 0.0);
}
Expand All @@ -155,7 +166,7 @@ void ApplyReflectionUnderwater(in const half3 i_view, in const half3 i_n_pixel,
{
// angle of incident is angle of reflection
const float cosIncomingAngle = cosOutgoingAngle;
const float reflectionCoefficient = CalculateFresnelReflectionCoefficient(cosIncomingAngle) * i_weight;
const float reflectionCoefficient = CalculateFresnelReflectionCoefficient(cosIncomingAngle, _FresnelPower) * i_weight;
io_col += (underwaterColor * reflectionCoefficient);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Shader "Crest/Underwater Curtain"

#pragma multi_compile_instancing

#pragma multi_compile _ VERTEXLIGHT_ON

// Use multi_compile because these keywords are copied over from the ocean material. With shader_feature,
// the keywords would be stripped from builds. Unused shader variants are stripped using a build processor.
#pragma multi_compile_local __ _SUBSURFACESCATTERING_ON
Expand All @@ -64,11 +66,16 @@ Shader "Crest/Underwater Curtain"
UNITY_DECLARE_SCREENSPACE_TEXTURE(_CameraDepthTexture);

#include "../OceanEmission.hlsl"
#include "../OceanLightingHelpers.hlsl"

#define MAX_OFFSET 5.0

sampler2D _Normals;

#if defined(VERTEXLIGHT_ON)
uniform sampler2D _LightTextureB0;
#endif // VERTEXLIGHT_ON

struct Attributes
{
float3 positionOS : POSITION;
Expand All @@ -84,6 +91,9 @@ Shader "Crest/Underwater Curtain"
half4 foam_screenPos : TEXCOORD1;
half4 grabPos : TEXCOORD2;
float3 positionWS : TEXCOORD3;
#if defined(VERTEXLIGHT_ON)
half4 uvLightsAtten : TEXCOORD4;
#endif // VERTEXLIGHT_ON

UNITY_VERTEX_OUTPUT_STEREO
};
Expand Down Expand Up @@ -176,6 +186,11 @@ Shader "Crest/Underwater Curtain"

o.uv = input.uv;

// Calculate vertex light attenuation here to save on performance
#if defined(VERTEXLIGHT_ON)
CalculateVertexLightsAttenuation(o.uvLightsAtten, o.positionWS);
#endif // VERTEXLIGHT_ON

return o;
}

Expand Down Expand Up @@ -208,9 +223,18 @@ Shader "Crest/Underwater Curtain"
const float depth = 0.0;
const half shadow = 1.0;

half3 lightsCol = 0.0;

// Calculate vertex lights colour
#if defined(VERTEXLIGHT_ON)
lightsCol = CalculateVertexLightsColor(input.uvLightsAtten, input.positionWS, _LightTextureB0);
// Apply depth fog to light colour. Otherwise, there will light patches visible from far away.
lightsCol *= exp(-_DepthFogDensity.xyz * sceneZ);
#endif // VERTEXLIGHT_ON

const float meshScaleLerp = _CrestPerCascadeInstanceData[_LD_SliceIndex]._meshScaleLerp;
const float baseCascadeScale = _CrestCascadeData[0]._scale;
const half3 scatterCol = ScatterColour(depth, _WorldSpaceCameraPos, lightDir, view, shadow, true, true, sss, meshScaleLerp, baseCascadeScale, cascadeData0);
const half3 scatterCol = ScatterColour(depth, _WorldSpaceCameraPos, lightDir, view, shadow, true, true, sss, lightsCol, meshScaleLerp, baseCascadeScale, cascadeData0);

half3 sceneColour = UNITY_SAMPLE_SCREENSPACE_TEXTURE(_BackgroundTexture, input.grabPos.xy / input.grabPos.w).rgb;

Expand Down