get application surface texture to use it in shader

Navidrct

Member
hi
i want to get application surface texture and pass it to shader so i can use it there to make my sprite transparen by shader

so in draw function of my sprite that i want use

GML:
var _time =  shader_get_uniform(shd_test,"time");
glassshader_bgsampler = shader_get_sampler_index(shd_test, "s_BackgroundSampler")
spr = surface_get_texture(application_surface);


shader_set(shd_test);
shader_set_uniform_f(_time,current_time/3000);
texture_set_stage(glassshader_bgsampler, spr);
draw_self();
shader_reset();
at line 2 you see that i get sampler index and at line 3 i try to get application surface texture to pass it to shader as sampler2d

in shader test

C:
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;

uniform float time;
uniform sampler2D s_BackgroundSampler ;

void main()
{
    vec4 color = texture2D(s_BackgroundSampler,v_vTexcoord);
  
    gl_FragColor = color;
}
and in here i try to use application surface sampler with v_vTexcoord and texture2D function i try to draw application surface instead of my sprite so it will be transparent
what did i do wrong?
im sure everywhere but please if someone know how to do that tell me
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
ARe you doing this in the Draw GUI event or in a regular draw event? If it's the regular draw it won't owrk as the application surface is still being targetted for drawing. Any time you need to use the app surface for something, it has to be after the Draw Begin, Draw, and Draw End events. The diagram in the manual shows exactly why this is:
 

Navidrct

Member
ARe you doing this in the Draw GUI event or in a regular draw event? If it's the regular draw it won't owrk as the application surface is still being targetted for drawing. Any time you need to use the app surface for something, it has to be after the Draw Begin, Draw, and Draw End events. The diagram in the manual shows exactly why this is:
Thanks a lot for response . What I want to do is that I want to use application surface in shader of another object shader
Not application surface shader.
I think I found out how to do that but I'm not sure
If I find out I'll post it here
Thanks a lot man
 
Top