|
|
texture2d in glsl issue
I am trying to manually choose the mipmap for a texture in my fragment
shader
My fragment shader code is this:
uniform sampler2D tex0;
uniform float mipmap_level;
void main(){
gl_FragColor = texture2D(tex0,vec2(gl_TexCoord[0].st), mipmap_level);
}
I specify the value for "mipmap_level" thru glUniform but opengl always
uses the 0th mipmap. I have checked the value in mipmap_level by using
glGetUniform. It is the same as the one i had passed still the level 0
mipmap is used
Iam using GL_NEAREST for both my mag and min filter
|
|
0
|
|
|
|
Reply
|
shirsoft (12)
|
7/26/2005 7:34:45 PM |
|
shirsoft@gmail.com wrote:
> I am trying to manually choose the mipmap for a texture in my fragment
> shader
>
> My fragment shader code is this:
>
> uniform sampler2D tex0;
> uniform float mipmap_level;
>
> void main(){
> gl_FragColor = texture2D(tex0,vec2(gl_TexCoord[0].st), mipmap_level);
> }
>
> I specify the value for "mipmap_level" thru glUniform but opengl always
> uses the 0th mipmap. I have checked the value in mipmap_level by using
> glGetUniform. It is the same as the one i had passed still the level 0
> mipmap is used
> Iam using GL_NEAREST for both my mag and min filter
It seems that the problem is that you aren't using mip-mapping in the
first place. Assuming this is the problem, the solution is very simple.
GL_NEAREST means that when a pixel covers more or fewer than one texel,
OpenGL selects the texel that it is closest* to to use. So there's no
mip-mapping here.
So I suspect, that if you use GL_NEAREST_MIPMAP_NEAREST (or some
variation
on that, provided that it uses mip-mapping), and of course also provide
mipmaps to OpenGL -- a function gluBuild2DMipmaps -- can do this, then
things should start working in the shader.
I hope that I'm not barking up the wrong tree and that this helps.
Nicholas
p.s.*Although it isn't really relevant, above closest is defined in
terms of the so-called Manhattan distance. Which, between two (2d)
points, is the sum in of the absolute values of the differences in the
two points coordinates)
|
|
0
|
|
|
|
Reply
|
Nicholas
|
7/28/2005 11:15:03 AM
|
|
|
1 Replies
233 Views
(page loaded in 0.022 seconds)
Similiar Articles: How does a single GLSL shader use a texture unit that can be 2D ...How does a single GLSL shader use a texture unit that ... if (textureMode == 1) color = texture2D(tex2D, gl ... Why would that be a problem? > Because I hadn't thought ... GLSL, fragment shader, shadow2D and texture unit - comp.graphics ...... 20 in the previous texture unit AND those textures are accessed in GLSL=20 (texture2D(...)). ... on GeForce ... tuples to the vertex shader. How does GLSL deal with this issue ... renderbuffer objects - comp.graphics.api.openglYou can read about those in the GLSL Language ... I would like to come back to the depth texture issues. ... vec2 texCoord; void main(){ float depth = texture2D ... Mutltitexturing - comp.graphics.api.openglThe problem is, that I need to have 3 loaded textures ... sampler2D testTex2 void main() { vec4 color1 = texture2D ... GLSL: Multitexturing particular cases... - comp ... GLSL : common mistakes - OpenGL.orgThe problem is that for count, you set it to 4 while it should ... With GLSL 1.20, it becomes legal. float texel = texture2D(tex, texcoord); texture2D in GLSL fragment shader - opengl - Mofeel GroupsGLSL, fragment shader, shadow2D and texture unit. 4. GLSL texture2D Radeon Problem. uniform sampler2D bTexture,tTexture,lTexture; vec4 tColor1,tColor2,lColor; tColor1 ... 7/22/2012 6:57:46 AM
|
|
|
|
|
|
|
|
|