Jump to content
  • Advertisement
Sign in to follow this  
Christoph

fast (!) writing to texturs

This topic is 4809 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 have some textures in which a great amount of texels changes every frame. How do I best apply these changes? Using pixel shaders? Constantly locking (dynamic) textures? thx for solutions!

Share this post


Link to post
Share on other sites
Advertisement
Assuming you can generate the data in a pixel-shader, definatly. This is the best solution for noise type textures.

On the other hand, if you can't actually generate the data on the GPU, it's gonna have to get to it from the CPU one way or another, so unless this could be reduced massively (like, if you wanted to make a gradient texture, or something similar) I'd recommend you just lock and memcpy, though performance might be a problem.

Hope this helps :).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
currently the noise() function (HSLS) can only be used during Texture creation: NOT during pixelrendering...

Share this post


Link to post
Share on other sites
Thanx for your answers.
I'm not using a noise function, so the pixel data is generated on GPU and is stored in an array of colours. Is it still possible to use pixel shaders or should I memcpy the pixels?
(if pixel shaders are possible, can you please post an example how to copy the pixels to the texture?)

Share this post


Link to post
Share on other sites
Quote:
Original post by Christoph
Thanx for your answers.
I'm not using a noise function, so the pixel data is generated on GPU and is stored in an array of colours. Is it still possible to use pixel shaders or should I memcpy the pixels?
(if pixel shaders are possible, can you please post an example how to copy the pixels to the texture?)

You can use a pixel shader if the generated value of a texel does not depend on values of other texels. In such a case, you can pack any globals needed for the calculation into pixel shader constants. If your generation depends on the position of a texel in the texture, pass the position through the vertex shader in a texture interpolator.

Share this post


Link to post
Share on other sites
The texels do not depend on each other. They are precalculated in CPU (it's a clipmap, in case you wanna know). So as I am new to shaders, can you please post an example how I can apply, let's say, an 8x8-array of colours to an 8x8-texture using a shader?
THX!

Share this post


Link to post
Share on other sites
Quote:
Original post by Christoph
The texels do not depend on each other. They are precalculated in CPU (it's a clipmap, in case you wanna know). So as I am new to shaders, can you please post an example how I can apply, let's say, an 8x8-array of colours to an 8x8-texture using a shader?
THX!

If your values are already precalculated on the CPU, using a pixel shader won't do you good. Lock a dynamic texture and write them.

When we mentioned using pixel shaders, we meant generating your data in the pixel shader itself (i.e. writing the computation code inside the pixel shader).

Share this post


Link to post
Share on other sites
If you do not need texture use texture shader
The instruction FillTexture works.
A texture shader is a shader like this

float4 Main(float3 position:POSITION,float3 psize:PSIZE):COLOR0{
here the code
}

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!