I have a scene that is transmitted to the texture via FBO, and I take it from the fragment shader, drawing its areas with primitives, and not drawing a full-screen square: I save resources, creating only the fragments I need.
To test this, I give out the same geometry as my texture rendering, which means that the created rasterization template should be exactly the same: when my fragment shader looks through its texture with the changing coordinate that it gave, it should blend perfectly with the other meanings he gave.
This is how I pass my fragment to the coordinate shader for automatic geometry texture using a full-screen texture:
uniform mat4 proj_modelview_mat;
out vec2 f_sceneCoord;
void main(void) {
gl_Position = proj_modelview_mat * vec4(in_pos,0.0,1.0);
f_sceneCoord = (gl_Position.xy + vec2(1,1)) * 0.5;
}
I work in 2D, so I do not deal with the decomposition of perspective here. I simply set the value of sceneCoord using the clip space position scaled backward from [-1.1] to [0.1].
uniform sampler2D scene;
in vec2 f_sceneCoord;
in float f_alpha;
out vec4 out_fragColor;
void main (void) {
vec4 color = texture(scene,f_sceneCoord);
if (color.a == f_alpha) {
out_fragColor = vec4(color.rgb,1);
} else
out_fragColor = vec4(1,0,0,1);
}
Notice that I spat out a red fragment if my alpha does not match. The texture handler sets the alpha for each rendered object to a specific index, so I know what matches what matches.
Sorry, I don’t have an image to display, but it’s very clear that my pixels are off (0.5,0.5): I get a thin red border around my objects on their bottom and left sides, which appears on and off. This is a pretty “temporary" look. The giveaway is that it is displayed only on the bottom and left sides of the objects.
, , texelFetch: , . , texture , , . , , ? !
: , , , : , gl_Position.xy+vec2(1,1))*0.5 trick , -. ... . ? , . , -, , .

- , , .