Skip to content

Commit

Permalink
TxN => NxT and convert texture_normal to [-1,1]
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsr committed Mar 26, 2021
1 parent 38eb4cd commit eb8d788
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/bevy_pbr/src/render_graph/pbr_pipeline/pbr.frag
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ void main() {
vec3 N = normalize(v_WorldNormal);

# ifdef STANDARDMATERIAL_NORMAL_MAP
vec3 T = v_WorldTangent.xyz;
vec3 B = cross(T, N) * sign(v_WorldTangent.w);
vec3 T = normalize(v_WorldTangent.xyz);
vec3 B = cross(N, T) * v_WorldTangent.w;
# endif

# ifdef STANDARDMATERIAL_DOUBLE_SIDED
Expand All @@ -316,7 +316,7 @@ void main() {

# ifdef STANDARDMATERIAL_NORMAL_MAP
mat3 TBN = mat3(T, B, N);
N = normalize(TBN * texture(sampler2D(StandardMaterial_normal_map, StandardMaterial_normal_map_sampler), v_Uv).rgb);
N = TBN * normalize(texture(sampler2D(StandardMaterial_normal_map, StandardMaterial_normal_map_sampler), v_Uv).rgb * 2.0 - 1.0);
# endif

# ifdef STANDARDMATERIAL_OCCLUSION_TEXTURE
Expand Down

0 comments on commit eb8d788

Please sign in to comment.