F
Forestherd
Guest
Hello!
I'm creating a lighting system that supports multiple colours and it uses the build in bm_add blend mode to merge lights together that I later posterize to get a layered, almost gel like light system. Everything seems to work fine, but there is this one oddity that is driving me insane. Namely, for whatever reason, bm_add does not want to blend the red channels. I've attached some pictures of the problem to this post. Here is the code that draws each individual circle of light:
The shader used is a simple fragment shader that removes the outer dark color of each circle (since I use draw_circle_colour):
The weirdest part is that it only happens when red tries to mix with either green or blue. Every other color seems to work just fine as far as I can tell. I'm pretty sure that I have the red channel updating (otherwise the red light wouldn't even appear to begin it) so I honestly have no idea whats messing it up. It worked perfectly this morning!
Any help or feedback is really appreciated.
PS: Two of the screenshots have the posterization shader active so that it is a lot more apparent that the colors arent blending correctly.
I'm creating a lighting system that supports multiple colours and it uses the build in bm_add blend mode to merge lights together that I later posterize to get a layered, almost gel like light system. Everything seems to work fine, but there is this one oddity that is driving me insane. Namely, for whatever reason, bm_add does not want to blend the red channels. I've attached some pictures of the problem to this post. Here is the code that draws each individual circle of light:
Code:
surface_set_target(sf_light)
draw_clear_alpha(c_black,1)
shader_set(shd_value_to_opacity)
draw_set_blend_mode(bm_add)
with(obj_light) {
draw_circle_colour(x-view_xview[0],y-view_yview[0],light_radius,light_color,c_black,false)
}
draw_set_blend_mode(bm_normal)
shader_reset()
surface_reset_target();
Code:
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform float shadowMax;
void main()
{
vec4 originalColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
float Cmax = max(originalColor.r,max(originalColor.g,originalColor.b));
originalColor.a = Cmax-0.1;
gl_FragColor = originalColor;
}
Any help or feedback is really appreciated.
PS: Two of the screenshots have the posterization shader active so that it is a lot more apparent that the colors arent blending correctly.
Attachments
-
117.6 KB Views: 10
-
117.1 KB Views: 9
-
116.9 KB Views: 9
-
97.8 KB Views: 9