Jump to content
  • Advertisement
Sign in to follow this  
ekba89

writing data to texture

This topic is 2554 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

I'm implementing particle system in gpu and now i want to save some of particle's data which can change into a texture. But the problem is i don't know how can i select correct pixel to write since rendering in pixel shader is not controlled by us. Any ideas how can i do this? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
You can create a texture with size 5x1, so you can store 5 different colors (values). If you want to write a value to the first pixel set the viewport to (0,0), width = 1 and height = 1, if you want to replace the value in the second pixel set viewport to position (1,0) and so on.

Share this post


Link to post
Share on other sites
But i want to update texture when i update particle. I mean i'm updating particle in vertex shader and there are some of it's attributes that can change. So when in pixel shader i want to save them.

Share this post


Link to post
Share on other sites
What version of API are you using? And what kind of attributes (life time/position/velocity) do you want to store?

If you use DirectX 10, you can use Geometry shader stream-output to store particles attributes in vertex buffers... Like explained in this whitepaper. If you need some help ask for it :lol:

Share this post


Link to post
Share on other sites
I'm using directx 9. And what i want to save is how much a particle moved. Let me show you the code.


float3 position = inPos.xyz;

float3 positionDelta = (velocityAndAge.xyz * xTotalGameTime);

position += positionDelta;


Here i'm finding positionDelta with total game time and i want to change it to float3 positionDelta = (velocityAndAge.xyz * elapsedTime); where elapsed time is time between two frames and want to save position delta to a texture. Also i'm open to new ways of doing this i mean i'm not sure if saving data like this possible. But as you mentioned if there is a way to store output to vertex buffer from shader for dx9 it is what i'm looking for i think. Thanks.

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!