I read some pages on google but still confused about working of multisample textures.
Can anyone explain this concept? If possible please explain it with source code.
Thanks.
I read some pages on google but still confused about working of multisample textures.
Can anyone explain this concept? If possible please explain it with source code.
Thanks.
Are you planning to use shaders or immediate mode?
Ok, that easier. You need to supply a uv for each texture in the vertex bindings (you can of course shared one uv for multiple textures. Then bind each texture to a sampler in the fragment shader. Fetch the texture pixels in the fragment shader and apply them as you see fit. I will post a little example - I am off to a boxing day do![]()
example
Code :vertex shader layout(location = VERTEX_BINDINGS_POSITION) in vec3 Position; layout(location = VERTEX_BINDINGS_TEXTURE0) in vec2 Texture0; layout(location = VERTEX_BINDINGS_TEXTURE1) in vec2 Texture1; out vec2 texture0; out vec2 texture1; void main() { texture0 = Texture0; texture1 = Texture1; gl_Position = CameraProjection * CameraModelView * vec4(Position,1); } fragment in vec2 texture0; in vec2 texture1; uniform sampler2D Image0; uniform sampler2D Image1; layout(location = 0, index = 0) out vec4 fFragColour; void main() { vec4 c0 = texture2D(Image0,p_Texture0.st); vec4 c1 = texture2D(Image1,p_Texture1.st); vec4 colour = mix(c0,c1,c1.a); // some blend function fFragColour = colour; }
i want to use multisampled textures.
What will be the fragment shader and how to pass multiple samplers to shader?
Also, which API can be used to load texel data ?
I want to use default FBO for this.
Typically you would pass these into a shader via a sampler2DMS and sample them via texelFetch(). Web search those and you'll come up with some good sample code. There's some in the archives of these forums as well (see the search box above).
And please don't cross-post. I re-merged your threads.
Last edited by Dark Photon; 12-27-2012 at 02:51 PM.
wops - mis-read that here is a sample
Code :uniform sampler2DMS u_2DMS; uniform float u_Translucency; layout(location = 0, index = 0) out vec4 fFragColour; void main() { ivec2 st = ivec2(vData.texture0.st * u_Screen.xy); vec4 colour = texelFetch(u_2DMS,st,gl_SampleID); colour.w *= u_Translucency; fFragColour = colour; }