PDA

View Full Version : 2D Pixel exact collision through GPU



_ShaderRookie_
02-05-2011, 02:54 AM
#version 150

uniform sampler2D TextureID;

smooth in vec4 theColor;
smooth in vec2 theTextureCoord;

out vec4 outputColor;

void main()
{
vec4 value = texture2D(TextureID, theTextureCoord);

if ( value.a <= 0.01 )
discard;

outputColor = value;
}


That is my Fragment Shader. As you see, I do a simple AlphaTest. Now I want to read back the final image which is rendered for doing a Collision Test on the pixels.
At least thats my idea.
How can I do that? Or is my approach wrong?