No, I was talking specifically about RenderStage
sampler_state = SamplerState()
sampler_state.set_magfilter(SamplerState.FT_linear_mipmap_linear)
sampler_state.set_minfilter(SamplerState.FT_linear_mipmap_linear)
albedo_texture = TexturePool.load_texture("pbr_maps/albedoMap.png")
albedo_texture.set_magfilter(SamplerState.FT_linear_mipmap_linear)
albedo_texture.set_minfilter(SamplerState.FT_linear_mipmap_linear)
albedo_stage = TextureStage('albedo_stage')
albedo_stage.set_mode(TextureStage.M_modulate)
normal_texture = TexturePool.load_texture("pbr_maps/normalMap.png")
normal_texture.set_magfilter(SamplerState.FT_linear_mipmap_linear)
normal_texture.set_minfilter(SamplerState.FT_linear_mipmap_linear)
normal_stage = TextureStage('normal_stage')
normal_stage.set_mode(TextureStage.M_normal)
selector_texture = TexturePool.load_texture("pbr_maps/selectorMap.png")
selector_texture.set_magfilter(SamplerState.FT_linear_mipmap_linear)
selector_texture.set_minfilter(SamplerState.FT_linear_mipmap_linear)
selector_stage = TextureStage('selector_stage')
selector_stage.set_mode(TextureStage.M_selector)
texture_attrib = TextureAttrib.make_default()
texture_slot_1 = texture_attrib.add_on_stage(albedo_stage, albedo_texture, sampler_state, 0)
texture_slot_2 = texture_slot_1.add_on_stage(normal_stage, normal_texture, sampler_state, 0)
texture_slot_3 = texture_slot_2.add_on_stage(selector_stage, selector_texture, sampler_state, 0)
material = Material("Test")
material.set_base_color(Vec4(1, 1, 1, 1))
material.set_emission(Vec4(0, 0, 0, 1))
material.set_roughness(1.0)
material.set_metallic(1.0)
render_state = RenderState.make_empty()
slot_1 = render_state.add_attrib(texture_slot_3, 1)
slot_2 = slot_1.add_attrib(MaterialAttrib.make(material), 1)
slot_3 = slot_2.add_attrib(TransparencyAttrib.make(TransparencyAttrib.M_alpha), 1)
file = BamFile()
file.open_write('plane.rstage')
writer = file.get_writer()
writer.write_object(slot_3)
writer.flush()
file.close()
Next, I just do this in the code and get ready assets.
file = BamFile()
file.open_read('plane.rstage')
file.get_reader()
render_state = file.read_object()
file.resolve()
plane = loader.load_model('plane.egg')
plane.set_state(render_state)
plane.reparent_to(render)
Everything works fine, the material settings, texture and transparency attribute are preserved, in this example I did not use a shader. I think the shader will work too.
But the problem with texture slots is present when using names, for example, there is nowhere to keep transparency. This needs to be done in a separate texture, since filtering is disabled individually, so that it does not act on translucency.
ADD:
I should clarify that I was talking about the exchange of assets between users. As for the input data for the shader, I think the indexed way remains relevant. We just need a blender plugin that will allow us to assign any number of stages to create textures of any type.
There are no problems with Egg in this regard. As for glTF 2.0, it will only allow exporting a simple pbr.
In fact, this is the problem that the glTF 2.0 format specification does not allow storing other stages of textures. Expanding the specification does not solve the problems, so it is unclear why then abandon the native format .bam or .egg
ADD:
Hmm, research has shown that when exporting to glTF 2.0, roughness and metallicity maps are always exported to png, even if they were originally .dds. In addition, the size changes to the largest according to the textures.
Which creates additional problems, png needs to be converted back to the desired format. Monitor the size of all roughness and metallicity textures so that it is the same. It looks like the Khronos specification only adds problems, there is no clarity why it is necessary to combine the textures of metalicity and roughness into one.
However, I have no doubt that this can only be fixed by our own exporters for the blender, using texture indexes is the most reliable way. However , for this you need to develop your own exporter for support .bam or .egg.
Alas, there is no other way out.