Shaders Surface-Shader Issue

C

Carbiner

Guest
Hello!

I'm having trouble getting one of my shaders to play nice with one of my surfaces.

The shader is supposed to make colors, pop, shall we say, and it's pretty simple. The problem is, I'm trying to use it with my lighting surface.

The lighting surface is drawn over the application surface, and subtracts from it. The lights are drawn onto the surface, and subtract from just a dark mask over the whole surface.

I want the lights to be drawn with brighter colors, but neither of place that seems obvious to put the shader works as intended.

I thought I could draw the surface to itself using the shader, but then this happened:
Screenshot (33).jpg
It seems to be drawing the texture page over the surface. Which I think is weird.

If you can help me, thank you.

My shader code, fragment only. Vertex isn't changed from default.
Code:
//
// Popin Shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;

float rand( vec2 p)
{
    return fract( cos( dot( p, vec2(5.237,6.378)))*8463.648);
}

void main()
{
    // The pixel we're working with
    vec4 v4_oColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
    
    // Setting stuff up
    float f_nRed = 2.0*v4_oColor.r;
    float f_nGreen = 2.0*v4_oColor.g;
    float f_nBlue = 2.0*v4_oColor.b;
    float f_nAlpha = v4_oColor.a;
    
    // Creating the new color
    vec4 v4_nColor = vec4(f_nRed,f_nGreen,f_nBlue,f_nAlpha);
    
    // Output
    gl_FragColor = v4_nColor;
}
My lighting object end step event, where it draws everything to the surface:
Code:
if(application_surface_is_enabled())
    {
    var vpos_x = camera_get_view_x(view_camera[0]);
    var vpos_y = camera_get_view_y(view_camera[0]);
    var vpos_w = camera_get_view_width(view_camera[0]);
    var vpos_h = camera_get_view_height(view_camera[0]);
    if(!surface_exists(global.light))
        {
        global.light = surface_create(vpos_w,vpos_h);
        global.ref_surface_count++;
        }
    if(!surface_exists(global.SS))
        {
        global.SS = surface_create(vpos_w,vpos_h);
        global.ref_surface_count++;
        }
    surface_set_target(global.light);
    draw_set_color(c_ltgray);
    draw_rectangle(0,0,vpos_w,vpos_h,false);
    if(pause)
        {
        draw_set_alpha(0.5);
        part_particles_clear(global.ps);
        draw_rectangle_color(0,0,vpos_w,vpos_h,cl1,cl2,cl3,cl4,false);
        draw_set_halign(fa_center);
        draw_set_font(ft_menu);
        draw_set_alpha(1);
        if(!instance_exists(mu_game))
            {
            draw_text(vpos_w/2,vpos_h/2,string_hash_to_newline("Game Paused#Control P to#Unpause"));
            }
        draw_set_font(ft_game);
        }
    gpu_set_blendmode(bm_subtract);
    with(par_ent)
        {
        draw_circle_color((x-1)-vpos_x,(y-1)-vpos_y,size,cc,c_black,false);
        }
    gpu_set_blendmode(bm_normal);
    surface_reset_target();
    }
And my current lighting object draw code, with the error:
Code:
var vpos_x = camera_get_view_x(view_camera[0]);
var vpos_y = camera_get_view_y(view_camera[0]);
surface_set_target(global.light);
shader_set(shd_rainbow);
draw_surface(global.light,0,0);
surface_reset_target();
shader_reset();
gpu_set_blendmode(bm_subtract);
draw_surface(global.light,vpos_x,vpos_y);
gpu_set_blendmode(bm_normal);
draw_surface(global.SS,vpos_x,vpos_y);
Thank you!
 
Top