English 中文(简体)
Reading 32-bit RGBA float values in GLSL
原标题:

I m trying send some 32 bit float data to a shader, but the results are erratic. If I test with full white (1,1,1,1) the values are all zero. This is my code for creating the texture:

gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA32F_ARB, 512, 512, 0, GL.GL_RGBA, GL.GL_FLOAT, data);

and reading from it in GLSL:

uniform sampler2D u_tex1;

varying vec2 v_uv;

void main()
{
    gl_FragColor = texture2D(u_tex1, v_uv);
}

If i set the texture to random values something shows up, but it s not correct. Is this the correct way to read from an RGBA32F texture or am I missing something?

最佳回答

You re not giving much info on the things you did< The code you show is correct though.

Some things I can think of that may be wrong:

  • your data does not have the right data in (are there floats in there?)
  • your texture is not filtered properly (since you only provide 1 mip level, you need to disable mipmapping)
  • your texture is not bound to the texture unit for the sampler u_tex1 (so you may not be fetching from it).
  • your texture coordinates are not what you think they are (and, depending on your clamping/wrapping mode, this can lead to a texel that is not white. Use GL_CLAMP_TO_EDGE or GL_REPEAT to not interact with the texture border)

There are lots of ways to not have texturing working, I hope I hit the correct one in this list!

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签