Would it be possible to create a shader that would flag certain colors in a 3d texture as transparent or emissive without the need for creating masks or emission maps?
Example:
Would it be possible to create a shader that would flag certain colors in a 3d texture as transparent or emissive without the need for creating masks or emission maps?
Example:
Yes.
The specifics are another thing entirely. Are you talking about like a color in a palette being transparent or emissive?
Modern computers can handle more than 1 texture. Computers from 20 years ago were able to too. A palette would reduce performance on the modern shader pipeline used by GPUs.
But you can combine different textures into channels, then in the shader use r,g,b,a for using each channel for emission, alpha, etc. And scissor has the same performance as an opaque material.
So don't reinvent the wheel, it's not worth it.
Edit: in shaders you use math, you don't want to use conditionals. What you could do is use a "palette" texture and use the color rg
of your albedo sampler2D as coordinates, that could do what you are looking for.
Edit2:
vec4 alb = texture(albedo_tex, UV);
ALBEDO= alb.rgb;
vec4 spcs = texture(palette_tex, alb.rg);
EMISSION = spcs.r;
ALPHA = spcs.g;
Then you need to look at your colors 1-0 rgb values, convert them to coordinates and paint them in a palette texture.
You could however have problems with LOD and float precission, but that depends on your colors and texture resolution and maybe the color correction used by godot, It would help to keep it simple.
Thanks for the reply, I unfortunately don't really have any coding skills myself, so I will have to find someone who can work on the rest of the shader.
© 2022 - 2025 — McMap. All rights reserved.