mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
more fooling around
This commit is contained in:
parent
1e3a55d9d2
commit
a649d9edb0
4 changed files with 16 additions and 11 deletions
|
@ -65,7 +65,7 @@ DeferredFragment unpackDeferredFragment(vec2 texcoord) {
|
|||
frag.diffuse = frag.diffuseVal.xyz;
|
||||
frag.opacity = frag.diffuseVal.w;
|
||||
frag.specular = frag.specularVal.xyz;
|
||||
frag.gloss = frag.specularVal.w * 128.0; // bring back gloss to [0, 128]
|
||||
frag.gloss = frag.specularVal.w;
|
||||
|
||||
return frag;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ void packDeferredFragment(vec3 normal, float alpha, vec3 diffuse, vec3 specular,
|
|||
} else {
|
||||
gl_FragData[1] = vec4(bestFitNormal(normal), 1.0);
|
||||
}
|
||||
gl_FragData[2] = vec4(specular, shininess / 128.0);
|
||||
gl_FragData[2] = vec4(specular, shininess / 100.0);
|
||||
}
|
||||
|
||||
void packDeferredFragmentLightmap(vec3 normal, float alpha, vec3 diffuse, vec3 specular, float shininess, vec3 emissive) {
|
||||
|
|
|
@ -92,14 +92,18 @@ vec3 evalAmbienSphereGlobalColor(float shadowAttenuation, vec3 position, vec3 no
|
|||
vec3 fragNormal = normalize(vec3(invViewMat * vec4(normal, 0.0)));
|
||||
vec4 fragEyeVector = invViewMat * vec4(-position, 0.0);
|
||||
vec3 fragEyeDir = normalize(fragEyeVector.xyz);
|
||||
|
||||
vec3 ambientNormal = fragNormal.xyz;
|
||||
vec3 color = diffuse.rgb * evalSphericalLight(ambientSphere, ambientNormal).xyz * getLightAmbientIntensity(light);
|
||||
|
||||
vec3 ambientLight = diffuse.rgb * evalSphericalLight(ambientSphere, fragNormal).xyz * getLightAmbientIntensity(light);
|
||||
|
||||
vec4 shading = evalFragShading(fragNormal, -getLightDirection(light), fragEyeDir, specular, gloss);
|
||||
|
||||
color += vec3(diffuse + shading.rgb) * shading.w * shadowAttenuation * getLightColor(light) * getLightIntensity(light);
|
||||
vec3 lightIrradiance = (getLightColor(light)) * getLightIntensity(light);
|
||||
|
||||
vec3 diffuseLight = (diffuse * (vec3(1.0) - specular) + specular) * shading.w * shadowAttenuation * lightIrradiance;
|
||||
|
||||
vec3 specularLight = shading.rgb * shading.w * shadowAttenuation * lightIrradiance;
|
||||
|
||||
vec3 color = ambientLight + diffuseLight + specularLight;
|
||||
return color;
|
||||
}
|
||||
|
||||
|
@ -116,11 +120,11 @@ vec3 evalSkyboxGlobalColor(float shadowAttenuation, vec3 position, vec3 normal,
|
|||
vec4 shading = evalFragShading(fragNormal, -getLightDirection(light), fragEyeDir, specular, gloss);
|
||||
|
||||
vec3 reflectedDir = reflect(-fragEyeDir, fragNormal);
|
||||
vec3 skyTexel = evalSkyboxLight(reflectedDir, 1 - gloss/128).xyz;
|
||||
vec3 skyTexel = evalSkyboxLight(reflectedDir, 1 - gloss).xyz;
|
||||
|
||||
vec3 lightIrradiance = (getLightColor(light)) * getLightIntensity(light);
|
||||
|
||||
vec3 diffuseLight = diffuse * shading.w * shadowAttenuation * lightIrradiance;
|
||||
vec3 diffuseLight = (diffuse * (vec3(1.0) - specular) + skyTexel * specular) * shading.w * shadowAttenuation * lightIrradiance;
|
||||
|
||||
vec3 specularLight = shading.rgb * skyTexel * shading.w * shadowAttenuation * lightIrradiance;
|
||||
|
||||
|
|
|
@ -22,13 +22,14 @@ vec4 evalPBRShading(vec3 fragNormal, vec3 fragLightDir, vec3 fragEyeDir, vec3 sp
|
|||
vec3 halfDir = normalize(fragEyeDir + fragLightDir);
|
||||
|
||||
// float specularPower = pow(facingLight * max(0.0, dot(halfDir, fragNormal)), gloss * 128.0);
|
||||
float specularPower = pow(max(0.0, dot(halfDir, fragNormal)), gloss);
|
||||
specularPower *= (gloss * 0.125 + 0.25);
|
||||
float thegloss = pow(2.0, 13.0 * gloss);
|
||||
float specularPower = pow(max(0.0, dot(halfDir, fragNormal)), thegloss);
|
||||
specularPower *= (thegloss * 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 = specular + (vec3(1.0) - specular) * shlickPower5 / (4.0 - 3.0 * gloss);
|
||||
vec3 reflect = specularPower * schlick;
|
||||
|
||||
return vec4(reflect, diffuse);
|
||||
|
|
Loading…
Reference in a new issue