Sign in to follow this  
Xadja

Render to Texture and Shader

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this