Skip to content
Snippets Groups Projects
Commit 2c2c2184 authored by Alexander Gauggel's avatar Alexander Gauggel
Browse files

[#82] Minor brdf change to reduce aliasing

parent 21e6fb98
Branches
Tags
1 merge request!70Resolve "Voxel cone tracing"
...@@ -14,14 +14,14 @@ vec3 fresnelSchlick(float cosTheta, vec3 f0){ ...@@ -14,14 +14,14 @@ vec3 fresnelSchlick(float cosTheta, vec3 f0){
float GGXDistribution(float r, float NoH){ float GGXDistribution(float r, float NoH){
float r2 = r * r; float r2 = r * r;
float denom = pi * pow(NoH * NoH * (r2 - 1) + 1, 2); float denom = pi * pow(NoH * NoH * (r2 - 1) + 1, 2);
return r2 / max(denom, 0.000001); return r2 / max(denom, 0.00001);
} }
float GGXSmithShadowingPart(float r, float cosTheta){ float GGXSmithShadowingPart(float r, float cosTheta){
float nom = cosTheta * 2; float nom = cosTheta * 2;
float r2 = r * r; float r2 = r * r;
float denom = cosTheta + sqrt(r2 + (1 - r2) * cosTheta * cosTheta); float denom = cosTheta + sqrt(r2 + (1 - r2) * cosTheta * cosTheta);
return nom / max(denom, 0.000001); return nom / max(denom, 0.00001);
} }
float GGXSmithShadowing(float r, float NoV, float NoL){ float GGXSmithShadowing(float r, float NoV, float NoL){
......
...@@ -38,11 +38,12 @@ vec3 cookTorrance(vec3 f0, float r, vec3 N, vec3 V, vec3 L){ ...@@ -38,11 +38,12 @@ vec3 cookTorrance(vec3 f0, float r, vec3 N, vec3 V, vec3 L){
float NoH = clamp(dot(N, H), 0, 1); float NoH = clamp(dot(N, H), 0, 1);
float NoL = clamp(dot(N, L), 0, 1); float NoL = clamp(dot(N, L), 0, 1);
float NoV = clamp(dot(N, V), 0, 1); float NoV = clamp(abs(dot(N, V)), 0, 1); // abs to account for wrong visibility caused by normal mapping
vec3 F = fresnelSchlick(NoH, f0); vec3 F = fresnelSchlick(NoH, f0);
float D = GGXDistribution(r, NoH); float D = GGXDistribution(r, NoH);
float G = GGXSmithShadowing(r, NoV, NoL); float G = GGXSmithShadowing(r, NoV, NoL);
return (F * D * G) / max(4 * NoV * NoL, 0.000001); return (F * D * G) / max(4 * NoV * NoL, 0.000001);
} }
......
...@@ -70,10 +70,10 @@ float reduceLightBleeding(float shadow, float amount) ...@@ -70,10 +70,10 @@ float reduceLightBleeding(float shadow, float amount)
} }
float shadowTest(vec3 worldPos, LightInfo lightInfo, texture2D shadowMap, sampler shadowMapSampler, vec2 offset){ float shadowTest(vec3 worldPos, LightInfo lightInfo, texture2D shadowMap, sampler shadowMapSampler, vec2 offset){
vec4 lightPos = lightInfo.lightMatrix * vec4(worldPos, 1); vec4 lightPos = lightInfo.lightMatrix * vec4(worldPos, 1);
lightPos /= lightPos.w; lightPos /= lightPos.w;
lightPos.xy = lightPos.xy * 0.5 + 0.5; lightPos.xy = lightPos.xy * 0.5 + 0.5;
lightPos.xy += offset; lightPos.xy += offset;
if(any(lessThan(lightPos.xy, vec2(0))) || any(greaterThan(lightPos.xy, vec2(1)))){ if(any(lessThan(lightPos.xy, vec2(0))) || any(greaterThan(lightPos.xy, vec2(1)))){
return 1; return 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment