Write-access to texture in shader?

Started by
3 comments, last by deathkrush 17 years, 7 months ago
Hello, I have implemented a shader which gets a sampler2DShadow texture as a uniform input. Is there a command which allows me to write to the texture in the shader (i. e. explicitly set the values of the texture) ? Thx a lot Icebraker
Advertisement
No, there is no such command because shaders are so embarassingly parallel. The only writable things are the interpolators (POSITION, NORMAL, COLOR etc semantics) and the target framebuffer. There isn't even a command to explicitly set the color of pixels in the framebuffer. The best you can do is set up a render to texture and for each pixel in the shadow texture you do some processing and output the pixel into the target texture.
deathkrushPS3/Xbox360 Graphics Programmer, Mass Media.Completed Projects: Stuntman Ignition (PS3), Saints Row 2 (PS3), Darksiders(PS3, 360)
Thx for your fast response.
Which commands do I need to render into a texture instead of rendering to the frambuffer? Could you give a little example how to write to a texture in the shader?

thx
there are several possibilities...

- render to framebuffer - like you do now and use glCopyTexImage to copy to texture
- use pixelbuffer (don't do it)
- use framebuffer objects - best solution for performance and the future.
NVidia has an awesome PDF presentation about FrameBuffer Objects. There are some code examples in there too.
deathkrushPS3/Xbox360 Graphics Programmer, Mass Media.Completed Projects: Stuntman Ignition (PS3), Saints Row 2 (PS3), Darksiders(PS3, 360)

This topic is closed to new replies.

Advertisement