Skip to content

Commit

Permalink
Implement Settings To Control Rendering (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
datacrystals committed Jun 23, 2022
1 parent 4ff0104 commit d302144
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions Source/EditorAssets/Projects/DefaultProject/10041.ERS
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,27 @@ float ShadowCalculation(STRUCT_PointLight Light)
// now get current linear depth as the length between the fragment and light position
float currentDepth = length(fragToLight);
// test for shadows
float bias = 0.05; // we use a much larger bias since depth is now in [near_plane, far_plane] range
float shadow = currentDepth - bias > closestDepth ? 1.0 : 0.0;

// Generate Shadow Map Bias
int TextureSize = textureSize(DepthMapCubeArray, 0).x;
float BiasMax = 0.005f;
if (TextureSize <= 512) {
BiasMax = 0.075;
} else if (TextureSize <= 1024) {
BiasMax = 0.05;
} else if (TextureSize <= 2048) {
BiasMax = 0.03;
} else if (TextureSize <= 4096) {
BiasMax = 0.02;
} else if (TextureSize <= 8192) {
BiasMax = 0.015;
} else if (TextureSize <= 16384) {
BiasMax = 0.01;
}

float Bias = max(0.00 * (1.0 - dot(Object.Normal, normalize(fragToLight))), BiasMax);

float shadow = currentDepth - Bias > closestDepth ? 1.0 : 0.0;
// display closestDepth as debug (to visualize depth cubemap)
// FragColor = vec4(vec3(closestDepth / Light.MaxDistance), 1.0);

Expand Down Expand Up @@ -733,5 +752,6 @@ void main() {






0 comments on commit d302144

Please sign in to comment.