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):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
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);
|
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...