@@ -25,22 +25,22 @@ uniform mat4 projection;
2525uniform mat4 projectionInverse;
2626uniform float lightAmbientBoostCutoff;
2727uniform float lightAmbientBoostScalar;
28- uniform int ssrEnabled ;
29- uniform float ssrIntensity ;
30- uniform float ssrDetail ;
31- uniform int ssrRefinementsMax ;
32- uniform float ssrRayThickness ;
33- uniform float ssrTowardEyeCutoff ;
34- uniform float ssrDepthCutoff ;
35- uniform float ssrDepthCutoffMargin ;
36- uniform float ssrDistanceCutoff ;
37- uniform float ssrDistanceCutoffMargin ;
38- uniform float ssrRoughnessCutoff ;
39- uniform float ssrRoughnessCutoffMargin ;
40- uniform float ssrSlopeCutoff ;
41- uniform float ssrSlopeCutoffMargin ;
42- uniform float ssrEdgeHorizontalMargin ;
43- uniform float ssrEdgeVerticalMargin ;
28+ uniform int ssrlEnabled ;
29+ uniform float ssrlIntensity ;
30+ uniform float ssrlDetail ;
31+ uniform int ssrlRefinementsMax ;
32+ uniform float ssrlRayThickness ;
33+ uniform float ssrlTowardEyeCutoff ;
34+ uniform float ssrlDepthCutoff ;
35+ uniform float ssrlDepthCutoffMargin ;
36+ uniform float ssrlDistanceCutoff ;
37+ uniform float ssrlDistanceCutoffMargin ;
38+ uniform float ssrlRoughnessCutoff ;
39+ uniform float ssrlRoughnessCutoffMargin ;
40+ uniform float ssrlSlopeCutoff ;
41+ uniform float ssrlSlopeCutoffMargin ;
42+ uniform float ssrlEdgeHorizontalMargin ;
43+ uniform float ssrlEdgeVerticalMargin ;
4444uniform sampler2D depthTexture;
4545uniform sampler2D albedoTexture;
4646uniform sampler2D materialTexture;
@@ -119,7 +119,7 @@ void computeSsr(float depth, vec4 position, vec3 albedo, float roughness, float
119119 vec3 normalView = mat3 (view) * normal;
120120 vec3 reflectionView = reflect (positionViewNormal, normalView);
121121 vec4 startView = vec4 (positionView.xyz, 1.0 );
122- vec4 stopView = vec4 (positionView.xyz + reflectionView * ssrDistanceCutoff , 1.0 );
122+ vec4 stopView = vec4 (positionView.xyz + reflectionView * ssrlDistanceCutoff , 1.0 );
123123 float eyeDistanceFromPlane = abs (dot (normalView, positionView.xyz));
124124
125125 // compute the fragment at which to start marching
@@ -147,7 +147,7 @@ void computeSsr(float depth, vec4 position, vec3 albedo, float roughness, float
147147 float marchHorizontal = stopFrag.x - startFrag.x;
148148 float marchVertical = stopFrag.y - startFrag.y;
149149 bool shouldMarchHorizontal = abs (marchHorizontal) >= abs (marchVertical);
150- float stepCount = abs (shouldMarchHorizontal ? marchHorizontal : marchVertical) * ssrDetail ;
150+ float stepCount = abs (shouldMarchHorizontal ? marchHorizontal : marchVertical) * ssrlDetail ;
151151 vec2 stepAmount = vec2 (marchHorizontal, marchVertical) / max (stepCount, 0.001 );
152152
153153 // march fragment
@@ -163,30 +163,30 @@ void computeSsr(float depth, vec4 position, vec3 albedo, float roughness, float
163163 currentPosition = depthToPosition(currentDepth, currentTexCoords);
164164 currentPositionView = view * currentPosition;
165165 currentProgressB = length (currentFrag - startFrag) / lengthFrag;
166- currentDepthView = - startView.z * - stopView.z / max (0.00001 , mix (- stopView.z, - startView.z, currentProgressB)); // NOTE: uses perspective correct interpolation for depth, but causes precision issues as ssrDistanceCutoff increases.
166+ currentDepthView = - startView.z * - stopView.z / max (0.00001 , mix (- stopView.z, - startView.z, currentProgressB)); // NOTE: uses perspective correct interpolation for depth, but causes precision issues as ssrlDistanceCutoff increases.
167167
168168 // compute depth delta and thickness based on view state
169169 float depthDelta = currentDepthView - - currentPositionView.z;
170- float thickness = max (- currentPositionView.z * ssrRayThickness, ssrRayThickness );
170+ float thickness = max (- currentPositionView.z * ssrlRayThickness, ssrlRayThickness );
171171
172172 // determine whether we hit geometry within acceptable thickness
173173 if (currentDepth != 0.0 && depthDelta >= 0.0 && depthDelta <= thickness)
174174 {
175175 // perform refinements within walk
176176 currentProgressB = currentProgressA + (currentProgressB - currentProgressA) * 0.5 ;
177- for (int j = 0 ; j < ssrRefinementsMax ; ++ j)
177+ for (int j = 0 ; j < ssrlRefinementsMax ; ++ j)
178178 {
179179 // advance frag values
180180 currentFrag = mix (startFrag, stopFrag, currentProgressB);
181181 currentTexCoords = currentFrag / texSize;
182182 currentDepth = texture(depthTexture, currentTexCoords).r;
183183 currentPosition = depthToPosition(currentDepth, currentTexCoords);
184184 currentPositionView = view * currentPosition;
185- currentDepthView = - startView.z * - stopView.z / max (0.00001 , mix (- stopView.z, - startView.z, currentProgressB)); // NOTE: uses perspective correct interpolation for depth, but causes precision issues as ssrDistanceCutoff increases.
185+ currentDepthView = - startView.z * - stopView.z / max (0.00001 , mix (- stopView.z, - startView.z, currentProgressB)); // NOTE: uses perspective correct interpolation for depth, but causes precision issues as ssrlDistanceCutoff increases.
186186
187187 // compute depth delta and thickness based on view state
188188 float depthDelta = currentDepthView - - currentPositionView.z;
189- float thickness = max (- currentPositionView.z * ssrRayThickness, ssrRayThickness );
189+ float thickness = max (- currentPositionView.z * ssrlRayThickness, ssrlRayThickness );
190190
191191 // determine whether we hit geometry within acceptable thickness
192192 if (currentDepth != 0.0 && depthDelta >= 0.0 && depthDelta <= thickness)
@@ -197,15 +197,15 @@ void computeSsr(float depth, vec4 position, vec3 albedo, float roughness, float
197197 vec3 h = normalize (v + normal);
198198 vec3 f = fresnelSchlick(max (dot (h, v), 0.0 ), f0);
199199 vec3 specularIntensity = f * (1.0 - roughness);
200- specularScreen = texture(lightAccumTexture, currentTexCoords).rgb * specularIntensity * ssrIntensity ;
200+ specularScreen = texture(lightAccumTexture, currentTexCoords).rgb * specularIntensity * ssrlIntensity ;
201201 specularScreenWeight =
202- (1.0 - smoothstep (1.0 - ssrRoughnessCutoffMargin , 1.0 , roughness / ssrRoughnessCutoff )) * // filter out as fragment reaches max roughness
203- (1.0 - smoothstep (1.0 - ssrDepthCutoffMargin , 1.0 , positionView.z / - ssrDepthCutoff )) * // filter out as fragment reaches max depth
204- (1.0 - smoothstep (1.0 - ssrDistanceCutoffMargin , 1.0 , length (currentPositionView - positionView) / ssrDistanceCutoff )) * // filter out as reflection point reaches max distance from fragment
205- (1.0 - smoothstep (1.0 - ssrSlopeCutoffMargin , 1.0 , slope / ssrSlopeCutoff )) * // filter out as slope nears cutoff
202+ (1.0 - smoothstep (1.0 - ssrlRoughnessCutoffMargin , 1.0 , roughness / ssrlRoughnessCutoff )) * // filter out as fragment reaches max roughness
203+ (1.0 - smoothstep (1.0 - ssrlDepthCutoffMargin , 1.0 , positionView.z / - ssrlDepthCutoff )) * // filter out as fragment reaches max depth
204+ (1.0 - smoothstep (1.0 - ssrlDistanceCutoffMargin , 1.0 , length (currentPositionView - positionView) / ssrlDistanceCutoff )) * // filter out as reflection point reaches max distance from fragment
205+ (1.0 - smoothstep (1.0 - ssrlSlopeCutoffMargin , 1.0 , slope / ssrlSlopeCutoff )) * // filter out as slope nears cutoff
206206 smoothstep (0.0 , 1.0 , eyeDistanceFromPlane) * // filter out as eye nears plane
207- smoothstep (0.0 , ssrEdgeHorizontalMargin , min (currentTexCoords.x, 1.0 - currentTexCoords.x)) *
208- smoothstep (0.0 , ssrEdgeVerticalMargin , min (currentTexCoords.y, 1.0 - currentTexCoords.y));
207+ smoothstep (0.0 , ssrlEdgeHorizontalMargin , min (currentTexCoords.x, 1.0 - currentTexCoords.x)) *
208+ smoothstep (0.0 , ssrlEdgeVerticalMargin , min (currentTexCoords.y, 1.0 - currentTexCoords.y));
209209 specularScreenWeight = clamp (specularScreenWeight, 0.0 , 1.0 );
210210 break ;
211211 }
@@ -278,7 +278,7 @@ void main()
278278 vec4 positionView = view * position;
279279 vec3 specularScreen = vec3 (0.0 );
280280 float specularScreenWeight = 0.0 ;
281- if (ssrEnabled == 1 && towardEye <= ssrTowardEyeCutoff && - positionView.z <= ssrDepthCutoff && roughness <= ssrRoughnessCutoff && slope <= ssrSlopeCutoff )
281+ if (ssrlEnabled == 1 && towardEye <= ssrlTowardEyeCutoff && - positionView.z <= ssrlDepthCutoff && roughness <= ssrlRoughnessCutoff && slope <= ssrlSlopeCutoff )
282282 {
283283 vec2 texSize = textureSize(depthTexture, 0 ).xy;
284284 float texelHeight = 1.0 / texSize.y;
0 commit comments