mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
introducing PBR shading
This commit is contained in:
parent
469ee29f0b
commit
48fca4c11d
3 changed files with 17 additions and 4 deletions
|
@ -79,12 +79,18 @@ vec3 evalAmbienSphereGlobalColor(float shadowAttenuation, vec3 position, vec3 no
|
|||
vec4 fragEyeVector = invViewMat * vec4(-position, 0.0);
|
||||
vec3 fragEyeDir = normalize(fragEyeVector.xyz);
|
||||
|
||||
vec3 color = diffuse.rgb * 0.5 * evalSphericalLight(ambientSphere, fragNormal).xyz;
|
||||
vec3 ambientNormal = normal;
|
||||
|
||||
vec3 color = diffuse.rgb * 0.5 * evalSphericalLight(ambientSphere, ambientNormal).xyz;
|
||||
|
||||
vec4 shading = evalFragShading(fragNormal, -getLightDirection(light), fragEyeDir, specular, gloss);
|
||||
|
||||
color += vec3(diffuse + shading.rgb) * shading.w * shadowAttenuation * getLightColor(light) * getLightIntensity(light);
|
||||
|
||||
if (gl_FragCoord.x > 1000) {
|
||||
return vec3(shading.rgb);
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,8 +21,15 @@ vec4 evalFragShading(vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir, vec3 s
|
|||
// Specular Lighting depends on the half vector and the gloss
|
||||
vec3 halfDir = normalize(fragEyeDir + fragLightDir);
|
||||
|
||||
float specularPower = facingLight * max(0.0, dot(fragEyeDir, halfDir));
|
||||
vec3 reflect = pow(specularPower, gloss * 128.0) * specular;
|
||||
float specularPower = pow(facingLight * max(0.0, dot(halfDir, fragNormal)), gloss * 128.0);
|
||||
specularPower *= (gloss * 128.0 * 0.125 + 0.25);
|
||||
|
||||
float shlickPower = (1.0 - dot(fragLightDir,halfDir));
|
||||
float shlickPower2 = shlickPower * shlickPower;
|
||||
float shlickPower5 = shlickPower2 * shlickPower2 * shlickPower;
|
||||
// vec3 schlick = specular * (1.0 - shlickPower5) + vec3(shlickPower5);
|
||||
vec3 schlick = vec3(0.21) * (1.0 - shlickPower5) + vec3(shlickPower5);
|
||||
vec3 reflect = specularPower * schlick;
|
||||
|
||||
return vec4(reflect, diffuse);
|
||||
}
|
||||
|
|
|
@ -425,7 +425,7 @@ void DeferredLightingEffect::render() {
|
|||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
freeFBO->release();
|
||||
// glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
// glDisable(GL_FRAMEBUFFER_SRGB);
|
||||
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
|
|
Loading…
Reference in a new issue