Jump to content
  • Advertisement
Sign in to follow this  
Xadja

Render to Texture and Shader

This topic is 4354 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 created a volume fog shader, i have 2 passes where i need to render depth of object to textures. How i can pass render targets from DX to shader? simple: effect.BeginPass(1); effect.SetValue("back_Tex", backTex); effect.SetValue("ViewProjection", device.Transform.World * device.Transform.View * device.Transform.Projection); mainMesh.DrawSubset(0); effect.EndPass(); dont work :(

Share this post


Link to post
Share on other sites
Advertisement
in Direct3D you would use IDirect3DDevice9::SetRenderTarget(n, surface) with the surface associated with your texture.
A HLSL pixel shader normally outputs to COLOR, which is the same as COLOR0. COLORn refers to the index of the render target you used in the call to SetRenderTarget.
So all in all you just set the render targets and then render as normal. But remember to store a pointer to the back buffer using IDirect3DDevice9::GetRenderTarget(0, ...) before setting you´re own render targets, because you have to set the back buffer as render target again after you filled your own RTs.

Look up SetRenderTarget in the SDK docs if you´re using Direct3D. If you´re using OpenGL (no experience with that) I can´t help you, sry.

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!