Majkl

Hi, I have a problem. I've searched the net (hope I did) but didn't find anything useful for my work :-( I would like to know, how to create texture and fill it with my own vectors. For example I have a list of about 1000 vectors (x,y,z) and I would like to create a texture from these numbers (each pixel will represent 1 vector - R = X, G = y, B = z). After that, I would like to render this texture to another new texture with use of my own vertex and pixel shader. Pixel shader should do some mathematical operations with vectors. I don't need a code for shader, I would like to know how do in c# and direct x:

- create and fill own texture
- render to another new texture with own vertex and pixel shader
- how to change render targets

Thank you for your comments because Im a little bit stressed :-)


Re: Game Technologies: Graphics directx 9 + c# + HLSL + render to texture?

E.Jordan

You should create a texture that has the render target flag set, then before you run your rendering code that does the rendering of the mesh and the effects, you should get a copy of the current render target (so you don't destroy it, then set your texture as the render target (through the device class, there is a method to do that Device.SetRenderTarget and Device.GetRenderTarget does the setting and retrieving the render target), now, it depends on what you want to do, 1 display the texture onto an object, then you need a second texture and you¡¯ll need to copy the render target texture surface to that texture since render targets can not be used for rendering. 2 if you want to save the render target to a file well, just save it.

What ever you do, if you intent to have all your rendered objects to be display in the texture and also in the screen you will need to restore the render target and redraw all over again.

Hope this helps

Erik

www.ManagedGames.com

Administrator

P.D If you want the code for that drop me a replay, here and when I get home I'll drop the code here on the forum.