Move glossmap formula to getspecular shader
This commit is contained in:
parent
60cde7e63d
commit
23b781e7dd
@ -52,7 +52,7 @@ void main(void)
|
||||
float specval = texture(ntex, uv).z;
|
||||
// From http://graphics.cs.williams.edu/papers/EnvMipReport2013/
|
||||
int texSize = textureSize(tex, 0).x;
|
||||
float lodval = clamp(log2(texSize * sqrt(3.)) - .5 * log2(specval + 1.), 0., 10.);
|
||||
float lodval = clamp(log2(texSize * sqrt(3.)) - (5. * specval + 1.), 0., 10.);
|
||||
vec4 specular = textureLod(tex, sampleDirection, lodval);
|
||||
Spec = max(specular, vec4(0.));
|
||||
}
|
||||
|
@ -31,5 +31,5 @@ void main()
|
||||
|
||||
vec3 FragmentNormal = TS_normal.x * Frag_tangent + TS_normal.y * Frag_bitangent - TS_normal.z * Frag_normal;
|
||||
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(FragmentNormal)) + 0.5;
|
||||
EncodedNormal.z = exp2(10. * gloss + 1.);
|
||||
EncodedNormal.z = gloss;
|
||||
}
|
||||
|
@ -19,5 +19,5 @@ void main(void)
|
||||
float glossmap = texture(glosstex, uv).x;
|
||||
#endif
|
||||
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
|
||||
EncodedNormal.z = exp2(10. * glossmap + 1.);
|
||||
EncodedNormal.z = glossmap;
|
||||
}
|
||||
|
@ -24,6 +24,6 @@ void main() {
|
||||
if (col.a < 0.5)
|
||||
discard;
|
||||
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
|
||||
EncodedNormal.z = exp2(10. * glossmap + 1.);
|
||||
EncodedNormal.z = glossmap;
|
||||
}
|
||||
|
||||
|
@ -25,5 +25,5 @@ void main()
|
||||
|
||||
vec3 FragmentNormal = TS_normal.x * Frag_tangent + TS_normal.y * Frag_bitangent - TS_normal.z * Frag_normal;
|
||||
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(FragmentNormal)) + 0.5;
|
||||
EncodedNormal.z = exp2(10. * (1. - alpha) + 1.);
|
||||
EncodedNormal.z = 1. - alpha;
|
||||
}
|
||||
|
@ -19,5 +19,5 @@ void main(void)
|
||||
{
|
||||
float glossmap = texture(tex, uv).x;
|
||||
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
|
||||
EncodedNormal.z = exp2(10. * glossmap + 1.);
|
||||
EncodedNormal.z = glossmap;
|
||||
}
|
||||
|
@ -24,6 +24,6 @@ void main() {
|
||||
discard;
|
||||
float glossmap = texture(glosstex, uv).x;
|
||||
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
|
||||
EncodedNormal.z = exp2(10. * glossmap + 1.);
|
||||
EncodedNormal.z = glossmap;
|
||||
}
|
||||
|
||||
|
@ -2,10 +2,11 @@
|
||||
|
||||
vec3 getSpecular(vec3 normal, vec3 eyedir, vec3 lightdir, vec3 color, float roughness)
|
||||
{
|
||||
float exponentroughness = exp2(10. * roughness + 1.);
|
||||
// Half Light View direction
|
||||
vec3 H = normalize(eyedir + lightdir);
|
||||
float NdotH = max(0., dot(normal, H));
|
||||
float normalisationFactor = (roughness + 2.) / 8.;
|
||||
float normalisationFactor = (exponentroughness + 2.) / 8.;
|
||||
vec3 FresnelSchlick = color + (1.0f - color) * pow(1.0f - max(0., (dot(eyedir, H))), 5);
|
||||
return max(pow(NdotH, roughness) * FresnelSchlick * normalisationFactor, vec3(0.));
|
||||
return max(pow(NdotH, exponentroughness) * FresnelSchlick * normalisationFactor, vec3(0.));
|
||||
}
|
Loading…
Reference in New Issue
Block a user