PBR properly normalize tangent frame
This commit is contained in:
parent
c00407da33
commit
97fe9cc49c
@ -91,8 +91,10 @@ void main(){
|
|||||||
vec2 newTexCoord;
|
vec2 newTexCoord;
|
||||||
vec3 viewDir = normalize(g_CameraPosition - wPosition);
|
vec3 viewDir = normalize(g_CameraPosition - wPosition);
|
||||||
|
|
||||||
|
vec3 norm = normalize(wNormal);
|
||||||
#if defined(NORMALMAP) || defined(PARALLAXMAP)
|
#if defined(NORMALMAP) || defined(PARALLAXMAP)
|
||||||
mat3 tbnMat = mat3(wTangent.xyz, wTangent.w * cross( (wNormal), (wTangent.xyz)), wNormal.xyz);
|
vec3 tan = normalize(wTangent.xyz);
|
||||||
|
mat3 tbnMat = mat3(tan, wTangent.w * cross( (norm), (tan)), norm);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined(PARALLAXMAP) || (defined(NORMALMAP_PARALLAX) && defined(NORMALMAP)))
|
#if (defined(PARALLAXMAP) || (defined(NORMALMAP_PARALLAX) && defined(NORMALMAP)))
|
||||||
@ -162,7 +164,7 @@ void main(){
|
|||||||
normal = normalize(tbnMat * normal);
|
normal = normalize(tbnMat * normal);
|
||||||
//normal = normalize(normal * inverse(tbnMat));
|
//normal = normalize(normal * inverse(tbnMat));
|
||||||
#else
|
#else
|
||||||
vec3 normal = normalize(wNormal);
|
vec3 normal = norm;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float specular = 0.5;
|
float specular = 0.5;
|
||||||
@ -250,7 +252,7 @@ void main(){
|
|||||||
rv = invRadius * (wPosition - g_LightProbeData.xyz) +rv;
|
rv = invRadius * (wPosition - g_LightProbeData.xyz) +rv;
|
||||||
|
|
||||||
//horizon fade from http://marmosetco.tumblr.com/post/81245981087
|
//horizon fade from http://marmosetco.tumblr.com/post/81245981087
|
||||||
float horiz = dot(rv, wNormal.xyz);
|
float horiz = dot(rv, norm);
|
||||||
float horizFadePower = 1.0 - Roughness;
|
float horizFadePower = 1.0 - Roughness;
|
||||||
horiz = clamp( 1.0 + horizFadePower * horiz, 0.0, 1.0 );
|
horiz = clamp( 1.0 + horizFadePower * horiz, 0.0, 1.0 );
|
||||||
horiz *= horiz;
|
horiz *= horiz;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user