Gamer-15
Member
Why is the output of the following codes not the same?
Test1:
Draw event:
Test2:
Create Event:
Draw event:
Fragment Shader:
So in test2 I am just trying to draw this vertical gradient as can be seen in test1, but this time I am passing it as an sampler to a shader.
Test1:
Draw event:
Code:
draw_rectangle_color(0,0,room_width,room_height,c_blue,c_blue,c_red,c_red,0);
Test2:
Create Event:
Code:
surface_gradient=-1;
sampler_gradient = shader_get_sampler_index(test_shader,"sampler_gradient");
Code:
if !surface_exists(surface_gradient)
surface_gradient = surface_create(room_width,room_height);
if surface_exists(surface_gradient)
{
surface_set_target(surface_gradient);
draw_rectangle_color(0,0,room_width,room_height,c_blue,c_blue,c_red,c_red,0);
surface_reset_target();
texture_gradient = surface_get_texture(surface_gradient);
shader_set(test_shader);
texture_set_stage(sampler_gradient,texture_gradient);
draw_rectangle(0,0,room_width,room_height,0);
shader_reset();
}
Code:
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform sampler2D sampler_gradient;
void main()
{
gl_FragColor = texture2D(sampler_gradient,v_vTexcoord);
}
So in test2 I am just trying to draw this vertical gradient as can be seen in test1, but this time I am passing it as an sampler to a shader.