mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 23:57:13 +02:00
Keep pushing and debugging ambient lighting
This commit is contained in:
parent
8584d80bb8
commit
a804bc723f
1 changed files with 18 additions and 9 deletions
|
@ -30,9 +30,8 @@ vec3 fresnelSchlickAmbient(vec3 fresnelColor, vec3 lightDir, vec3 halfDir, float
|
||||||
<$declareSkyboxMap()$>
|
<$declareSkyboxMap()$>
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
|
||||||
vec3 evalAmbientSpecularIrradiance(LightAmbient ambient, vec3 fragEyeDir, vec3 fragNormal, float roughness, vec3 fresnel) {
|
vec3 evalAmbientSpecularIrradiance(LightAmbient ambient, vec3 fragEyeDir, vec3 fragNormal, float roughness) {
|
||||||
vec3 direction = -reflect(fragEyeDir, fragNormal);
|
vec3 direction = -reflect(fragEyeDir, fragNormal);
|
||||||
vec3 ambientFresnel = fresnelSchlickAmbient(fresnel, fragEyeDir, fragNormal, 1.0 - roughness);
|
|
||||||
vec3 specularLight;
|
vec3 specularLight;
|
||||||
<@if supportIfAmbientMapElseAmbientSphere@>
|
<@if supportIfAmbientMapElseAmbientSphere@>
|
||||||
if (getLightHasAmbientMap(ambient))
|
if (getLightHasAmbientMap(ambient))
|
||||||
|
@ -53,7 +52,7 @@ vec3 evalAmbientSpecularIrradiance(LightAmbient ambient, vec3 fragEyeDir, vec3 f
|
||||||
}
|
}
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
|
||||||
return specularLight * ambientFresnel;
|
return specularLight;
|
||||||
}
|
}
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
||||||
|
@ -74,16 +73,26 @@ void evalLightingAmbient(out vec3 diffuse, out vec3 specular, LightAmbient ambie
|
||||||
<@endif@>
|
<@endif@>
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// Diffuse from ambient
|
// Fresnel
|
||||||
diffuse = (1.0 - metallic) * sphericalHarmonics_evalSphericalLight(getLightAmbientSphere(ambient), normal).xyz;
|
vec3 ambientFresnel = fresnelSchlickAmbient(fresnel, eyeDir, normal, 1.0 - roughness);
|
||||||
|
|
||||||
if (gl_FragCoord.x > 300) {
|
// Diffuse from ambient
|
||||||
vec3 ambientFresnelDiffuse = vec3 (1.0) - fresnelSchlickAmbient(fresnel, eyeDir, normal, 1.0 - roughness);
|
diffuse = (1.0 - metallic) * (vec3 (1.0) - ambientFresnel);
|
||||||
diffuse *= ambientFresnelDiffuse;
|
|
||||||
|
if (gl_FragCoord.x > 600) {
|
||||||
|
float levels = getLightAmbientMapNumMips(ambient);
|
||||||
|
float lod = min(floor((roughness)* levels), levels);
|
||||||
|
diffuse *= evalSkyboxLight(normal, lod).xyz;
|
||||||
|
} else {
|
||||||
|
diffuse *= sphericalHarmonics_evalSphericalLight(getLightAmbientSphere(ambient), normal).xyz;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gl_FragCoord.y > 600) {
|
||||||
|
diffuse *= 1.0 / 3.14;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specular highlight from ambient
|
// Specular highlight from ambient
|
||||||
specular = evalAmbientSpecularIrradiance(ambient, eyeDir, normal, roughness, fresnel);
|
specular = evalAmbientSpecularIrradiance(ambient, eyeDir, normal, roughness) * ambientFresnel;
|
||||||
|
|
||||||
|
|
||||||
<@if supportScattering@>
|
<@if supportScattering@>
|
||||||
|
|
Loading…
Reference in a new issue