Jump to content
  • Advertisement
Sign in to follow this  
funkeejeffounet

Texture Access in Vertex Shaders

This topic is 4831 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm using in my fragment shader a loop to compute a certain numerical value. However, the quality of the result depends on the number of iterations that has been done. Due to the fact that loops are unrolled in fragment shaders, I am limited in term of iterations so I thought about doing the computation in the vertex shader(branching is possible, so no unrolling is needed) and the result will be passed as a varying variable to the fragment shader. The problem is that my vertex shader compiles and links fine, but the result is rubish. I am sure that my algorithm functions well (it has been tested over and over), so I was wondering if the texture access that is used in the loop (1D Texture) wasn't faulty here. Has anyone had any issues while accessing textures in a vertex shader? I would appreciate some help, Thanks in advance. Jeff.

Share this post


Link to post
Share on other sites
Advertisement
Well first of all you need to have a PS 3.0 compatible card to use textures within vertex shaders (I'm not entirely sure what this means in terms of GL extensions).

When I was using textures from a vertex shader in DirectX it only appeared to work when the texture was a floating point format, R32G32B32A32 to be specific (that's just a 32-bit float for all 4 components).

Also I remember reading somewhere that it was recomended to use a large array of constants in preference to a texture in a vertex shader if it's possible, and in your case where you're using a 1D texture it sounds like you can do it.

Share this post


Link to post
Share on other sites
I got a GeForce6600 so I have the PS3.0 Model (Driver 77.77).
My texture is GL_RGBA8 of unsigned byte with 256 texels, so you think I only can use Floating Points formats in a vertex shader?

Do you think I can pass to the vertex shader uniform array of 256 vec4 elements? It seems rather big...

Anyone can confirm if standard RGBA textures accesses are supported in vertex shaders?

Share this post


Link to post
Share on other sites
Well this PDF may shed some light on things. Whether you should use constants instead depends upon where that 1D texture is comming from, if it's just static constants you should just use vertex shader constants instead. From the PDF linked to above:

Quote:
Since vertex texture reads are much slower than constant reads (see previous section), we strongly advise against using vertex textures as constant memory.


[edit]Acording to the DX docs PS 3.0 capable cards have a minimum of 256 constant registers so you could probably have an array of 256 vec4s[/edit]

Share this post


Link to post
Share on other sites
Ok thanks guys, I've checked the paper and I also learned that linear filtering isn't supported (and I need it in fact). Also, only 2D textures are supported in OpenGL...

I've disassembled my code with NvShaderPerf and there is something bugging me : In fact with 128 iterations in my fragment shader, I only have 900 instructions. The limit being 65535 instructions, I don't understand why my code fails (in terms of execution, not compilation) with 256 or even 1024 iterations. Even disassembling the shader with more thant 128 iterations fails...

Someone had any GLSL / Driver77.77 issues?

Thanks,
Jeff.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!