Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, ChrstphFr), 875 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
view.stage + NOPARTICLE and matrices #287327
08/31/09 12:43
08/31/09 12:43
Joined: Jun 2004
Posts: 655
to your left
BoH_Havoc Offline OP
User
BoH_Havoc  Offline OP
User

Joined: Jun 2004
Posts: 655
to your left
Here's the situation:
I have a view which renders the scene depth into a bmap, which is then used in a deferred shader to reconstruct the world position and do shadowmapping. That view is attached to the camera via
camera.stage = depthView;
set(depthView,CHILD);

So far, this is working just fine.

Now when i switch on the NOPARTICLES flag for depthView, my reconsturcted world position is wrong.

This is how it should look:


And this is how it looks with NOPARTICLES set:


I then figured out, that when NOPARTICLES is set, my matrix is rolled by 90° and tilted by 90°. So after applying a rotation matrix to my shader, it worked again. However this is just a workaround, as i cannot toggle NOPARTICLES without changing my shader again.

here's my matrix (doesn't matter if i calculate it in a material event or in a function, it's always messed up once i set NOPARTICLES for depthView):
Code:
mat_set(mtl.matrix,matWorld);
mat_multiply(mtl.matrix,matView);
mat_multiply(mtl.matrix,matProj);
mat_inverse(mtl.matrix,mtl.matrix);



And here's how i reconstruct the world position:
Code:
//compute world position
float4 vp = float4(inTex.xy * float2(2, -2) - float2(1, -1), depth, 1);
float4 v = mul(vp, matMtl);
float3 position = v.xyz/v.w;





But wait, there's more grin

If i don't attach the depth view to the camera via view.stage and CHILD, but by manually setting it's position,pan and arc to the camera, it works fine, no matter if i set NOPARTICLES or not. I would do it that way, but then my depthmap lags behind the current scene a little if i move the screen too fast and shadows get messed up.



So to sum it up:
- using stage, CHILD and NOPARTICLES = this messes up my matrix, it gets rolled and tilted by 90°
- manually attaching my depthview to the camera works just fine, but my depthmap then lags behind


Any ideas why NOPARTICLES could mess up my matrix?


Shade-C EVO Lite-C Shader Framework
Re: view.stage + NOPARTICLE and matrices [Re: BoH_Havoc] #287488
09/01/09 02:31
09/01/09 02:31
Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
Tobias Offline

Moderator
Tobias  Offline

Moderator

Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
I am pretty sure that particles are rendered after everything else, so the world matrix setup of the particles is the last one in the scene.

When you get a different matrix dependent on NOPARTICLES then your app seems to depend on the last world matrix setup, this could be a hint where to look for, like a missing initialization of the world matrix.

Re: view.stage + NOPARTICLE and matrices [Re: Tobias] #287558
09/01/09 12:02
09/01/09 12:02
Joined: Jun 2004
Posts: 655
to your left
BoH_Havoc Offline OP
User
BoH_Havoc  Offline OP
User

Joined: Jun 2004
Posts: 655
to your left
Hmmm...if this is true, then all my other shaders which depend on the worldmatrix would also not work. But they do. Everything works fine, even the depthmap is created correctly, no matter if NOPARTICLES is set or not. It's just the recreation of the worldposition by using the depthmap which won't work.

Anyway, I'll try to manually create a matWorldViewProjInverse matrix, pass that to the deferred shader and see if it works, just to be sure wink

Thanks for the tip!


Shade-C EVO Lite-C Shader Framework

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1