3d - How can I render the same texture with different colors? -
i have simple texture of white shape on black background, , want ability specify different color white part, without changing source texture:
is there built-in way in libgdx, or have write custom shader (and if so, best way that)?
note: i'm using 3d api, question in context of modelbatch, materials, , how used render 3d geometry.
as turns out, if material has textureattribute.diffuse, , colorattribute.diffuse, color value derived texture multiplied value defined color attribute, can seen in default fragment shader:
#elif defined(diffusetextureflag) && defined(diffusecolorflag) vec4 diffuse = texture2d(u_diffusetexture, v_diffuseuv) * u_diffusecolor;
so, case, can set value of color attribute, , produce desired results -> black portions of texture remain unchanged, because 0 (black) multiplied x result in zero; white portions of texture change whatever color set via color attribute, because 1 (white) multiplied x result in x.
Comments
Post a Comment