When a mesh has no base color texture nor metallic roughness texture, but has a normal map or an emission map, the texture stage mode of the fallback base color texture is wrongly set to M_selector. This is due to the fact that the same fallback texture info record is used for both base color and metallic roughness. As the metallic roughness is configured after the base color, the texture stage mode of the fallback info record associated with the base color is overridden with the metallic roughness texture stage mode.
The following debug line in load_material()
print("CREATE STAGE", i, texstage.get_mode(), texdata)
gives :
CREATE STAGE 0 14 2d_texture pbr-fallback
2-d, 1 x 1 pixels, each 4 bytes, srgb_alpha
sampler wrap(u=repeat, v=repeat, w=repeat, border=0 0 0 1) filter(min=default, mag=default, aniso=0) lod(min=-1000, max=1000, bias=0) 4 bytes in ram, compression off
CREATE STAGE 1 14 2d_texture pbr-fallback
2-d, 1 x 1 pixels, each 4 bytes, srgb_alpha
sampler wrap(u=repeat, v=repeat, w=repeat, border=0 0 0 1) filter(min=default, mag=default, aniso=0) lod(min=-1000, max=1000, bias=0) 4 bytes in ram, compression off
CREATE STAGE 2 9 2d_texture foil_n.png
2-d, 512 x 512 pixels, each 4 bytes, rgba
sampler wrap(u=repeat, v=repeat, w=repeat, border=0 0 0 1) filter(min=default, mag=default, aniso=0) lod(min=-1000, max=1000, bias=0) 1048576 bytes in ram, compression off
CREATE STAGE 3 16 2d_texture emission-fallback
2-d, 1 x 1 pixels, each 1 bytes, luminance
sampler wrap(u=repeat, v=repeat, w=repeat, border=0 0 0 1) filter(min=default, mag=default, aniso=0) lod(min=-1000, max=1000, bias=0) no ram image
TextureAttrib:on 0:pbr-fallback 1:pbr-fallback 2:foil_n.png 3:emission-fallback
With this PR, the fallback info record are no longer shared and the texture stage mode is correct :
CREATE STAGE 0 0 2d_texture pbr-fallback
2-d, 1 x 1 pixels, each 4 bytes, srgb_alpha
sampler wrap(u=repeat, v=repeat, w=repeat, border=0 0 0 1) filter(min=default, mag=default, aniso=0) lod(min=-1000, max=1000, bias=0) 4 bytes in ram, compression off
CREATE STAGE 1 14 2d_texture pbr-fallback
2-d, 1 x 1 pixels, each 4 bytes, srgb_alpha
sampler wrap(u=repeat, v=repeat, w=repeat, border=0 0 0 1) filter(min=default, mag=default, aniso=0) lod(min=-1000, max=1000, bias=0) 4 bytes in ram, compression off
CREATE STAGE 2 9 2d_texture foil_n.png
2-d, 512 x 512 pixels, each 4 bytes, rgba
sampler wrap(u=repeat, v=repeat, w=repeat, border=0 0 0 1) filter(min=default, mag=default, aniso=0) lod(min=-1000, max=1000, bias=0) 1048576 bytes in ram, compression off
CREATE STAGE 3 16 2d_texture emission-fallback
2-d, 1 x 1 pixels, each 1 bytes, luminance
sampler wrap(u=repeat, v=repeat, w=repeat, border=0 0 0 1) filter(min=default, mag=default, aniso=0) lod(min=-1000, max=1000, bias=0) no ram image
TextureAttrib:on 0:pbr-fallback 1:pbr-fallback 2:foil_n.png 3:emission-fallback
When a mesh has no base color texture nor metallic roughness texture, but has a normal map or an emission map, the texture stage mode of the fallback base color texture is wrongly set to M_selector. This is due to the fact that the same fallback texture info record is used for both base color and metallic roughness. As the metallic roughness is configured after the base color, the texture stage mode of the fallback info record associated with the base color is overridden with the metallic roughness texture stage mode.
The following debug line in
load_material()
gives :
With this PR, the fallback info record are no longer shared and the texture stage mode is correct :