@@ -47,6 +47,9 @@ pub struct StandardMaterial {
47
47
/// defaults to 0.5 which is mapped to 4% reflectance in the shader
48
48
pub reflectance : f32 ,
49
49
pub normal_map_texture : Option < Handle < Image > > ,
50
+ /// Normal map textures authored for DirectX have their y-component flipped. Set this to flip
51
+ /// it to right-handed conventions.
52
+ pub flip_normal_map_y : bool ,
50
53
pub occlusion_texture : Option < Handle < Image > > ,
51
54
/// Support two-sided lighting by automatically flipping the normals for "back" faces
52
55
/// within the PBR lighting shader.
@@ -84,6 +87,7 @@ impl Default for StandardMaterial {
84
87
reflectance : 0.5 ,
85
88
occlusion_texture : None ,
86
89
normal_map_texture : None ,
90
+ flip_normal_map_y : false ,
87
91
double_sided : false ,
88
92
cull_mode : Some ( Face :: Back ) ,
89
93
unlit : false ,
@@ -124,6 +128,7 @@ bitflags::bitflags! {
124
128
const ALPHA_MODE_MASK = ( 1 << 7 ) ;
125
129
const ALPHA_MODE_BLEND = ( 1 << 8 ) ;
126
130
const TWO_COMPONENT_NORMAL_MAP = ( 1 << 9 ) ;
131
+ const FLIP_NORMAL_MAP_Y = ( 1 << 10 ) ;
127
132
const NONE = 0 ;
128
133
const UNINITIALIZED = 0xFFFF ;
129
134
}
@@ -262,6 +267,9 @@ impl RenderAsset for StandardMaterial {
262
267
}
263
268
_ => { }
264
269
}
270
+ if material. flip_normal_map_y {
271
+ flags |= StandardMaterialFlags :: FLIP_NORMAL_MAP_Y ;
272
+ }
265
273
}
266
274
// NOTE: 0.5 is from the glTF default - do we want this?
267
275
let mut alpha_cutoff = 0.5 ;
0 commit comments