Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | spotlessapple |
I’m attempting to write a spatial fragment shader that makes half of an object one color, and the other half another color. I’ve tried the following below, but the results aren’t what I expected:
shader_type spatial;
void fragment() {
if(UV.x < 0.5) {
ALBEDO = vec3(0.35, 0.83, 0.32);
ALPHA = 0.75;
EMISSION = vec3(0.35, 0.83, 0.32);
}
else {
ALBEDO = vec3(250, 250, 0);
}
}
This resulted in the following:
Now, I want the color of this green rectangle to match the exact color of the one further back in the picture. The albedo, alpha, and emission colors are set exactly the same, but the image is still not the same color.
In addition to this, the color is not split evenly across the rectangle. You’ll notice the front strip of the rectangle is green instead of half green and half yellow.
For some additional context, the green rectangle in the background has the follow properties set (not with a custom spatial shader, just through the GUI):
Flags Transparent: True
Albedo RGBA: (0.35, 0.83, 0.32, 0.75)
Emission Enabled: True
Emission RGB: (0.35, 0.83, 0.32)
Any help is greatly appreciated, thanks!