Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Render targets don't work... ...just one pass

(Visual C++ 2010, DirectX)

Hi there,

I ran into problems in my new project where I want to apply a gaussian blur shader. I've already done it before and it worked perfectly, so I just pretty much copied/pasted it, but it doesn't work, but in a very strange way...

It is simple - shader "white" takes care of classic 3d space transformations and lighting, "blurh" blurs image horizontally and "blurv" blurs it vertically, so I just want to
1) render 3D scene to a viewport-sized texture,
2) render this texture to a quad and blur it horizontally,
3) blur this texture to a quad and blur it vertically.

I am assigning trender target to the device by calling Dev->SetRenderTarget(0,surface) and I am properly setting the chain of textures. But even if I am in step 3 assigning texture of the quad to the texture in which I rendered in step 2, it seems like it always sets itself to the texture in which I was rendering in step 1 (the result is same if I paste there t0.tex or t1.tex). I have compared this code to the code of project where it is working. It does exactly the same thing, aet it doesn't assign the texture correctly.

If I comment out the rendering in step two, framerate incereses rapidly, so it actually is rendering somewhere. I tried switching textures or shaders, few different ways - it stills ignore everything in the second step. I don't have a clue, what is causing it. There's no logic in it, every texture or its surface looks right - and if it didn't, it would call an error and not set some other random texture. I even debugged the textures, they have different pointers, so they are not the same.

Here is the code (without tranformations settings and rendering):
[code]Dev->SetRenderTarget(0,t0.surf); //t0.surf = t0.tex surface level
Dev->BeginScene();

//transformations+testures...

eff_white->SetMatrix("worldViewProj",&transf);
eff_white->SetTechnique("white");
eff_white->Begin(0,0);
eff_white->BeginPass(0);
//rendering mesh...
eff_white->End();

Dev->EndScene();
Dev->SetRenderTarget(0,t1.surf); //t1.surf = t1.tex surface level
Dev->BeginScene();

eff_quad->SetTechnique("blurh");
eff_quad->Begin(0,0);
eff_quad->BeginPass(0);
eff_quad->SetTexture(tex0,t0.tex);
//rendering screen quad...
eff_quad->End();

Dev->EndScene();
Dev->SetRenderTarget(0,backbuf); //backbuf = back buffer surface
Dev->BeginScene();

eff_quad->SetTechnique("blurv");
eff_quad->Begin(0,0);
eff_quad->BeginPass(0);[/code]

Could you please take a look at it and tell me, what could be wrong? I am done with ideas here... :( And sorry for my English, if it is too crappy...
Sign In or Register to comment.