Unsolved mysteries about extra textures and materials

If a render target texture is setup like this

render.enable_texture(0, self.my_target, render.BUFFER_COLOR_BIT)

Should I then be able to use it like so in a shader program?

uniform lowp sampler2D TEX0;

void main() {	
    gl_FragColor = texture2D(TEX0, var_texcoord0.xy);
}

If so then will this work with multiple textures? Is there a max?

render.enable_texture(0, self.my_target, render.BUFFER_COLOR_BIT)
render.enable_texture(1, self.my_target, render.BUFFER_COLOR_BIT)
render.enable_texture(2, self.my_target, render.BUFFER_COLOR_BIT)

uniform lowp sampler2D TEX0;
uniform lowp sampler2D TEX1;
uniform lowp sampler2D TEX3;

void main() {	
    gl_FragColor = ...
}

So if that works then I can’t think of any other way of getting a extra loaded texture into a shader (minus the normal one) other than making a sprite with an exclusive render predicate, rendering it to a numbered texture in the render script, and then using that texture in whatever shader where multiple textures would really be useful.

Can I get official confirmation if this should work or if it won’t at all? Is there another unsaid way to get other textures into shaders?

I believe there is a limit to 8 texture units in GLES 2.0.

For model components all samplers that are set up in the material will appear and can be set in the editor:

2 Likes

Thank you for the info! To restate,

  1. Can’t be a sprite component, needs to be a model with a quad, that’s fine, would probably be handy to be able to add naked textures to sprite components too in similar way as models with the intent for those extra textures to be used in its material, but otherwise for it to behave like a sprite
  2. First add a sampler to a material already associated with the model, then you can specify a texture in the properties of the selected model
  3. Then can use name of sampler texture in shader to use linked texture data

Being able to overwrite fragment constant defaults of the material in the properties of the selected model / sprite would be really useful for designers