Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (dr_panther, 7th_zorro), 1,203 guests, and 2 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
Getting the matView and matProj of a view #95302
10/21/06 21:45
10/21/06 21:45
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline OP
Expert
Excessus  Offline OP
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
I'd like to see a function for getting the matView and matProj of a view.

I need this for a shadow mapping shader I'm writing. To project the depth map onto the scene, it uses a matrix that is the product of the models world matrix, the lights matView and matProj matrices (a camera is placed at the light position) and a TexAdjust matrix. The problem is that there is no way to get the matView and matProj of the light in the ENABLE_RENDER (where the models matWorld is available).

I tried saving matView and matProj in the ENABLE_VIEW of the DepthRender material but it doesn't work because I also use another material event (ENABLE_TREE, for switching the material depending on the view) and there is no way to determine what triggered the event (unknown parameter EVENT_TREE).

Re: Getting the matView and matProj of a view [Re: Excessus] #95303
10/23/06 08:47
10/23/06 08:47
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
I think I don't understand your request. Can you explain which problem you have with the current implementation of matView and matProj?

Re: Getting the matView and matProj of a view [Re: jcl] #95304
10/23/06 09:04
10/23/06 09:04
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline OP
Expert
Excessus  Offline OP
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
I'm writing a shadow mapping shader, it works like this:

1) Render the depth of the scene, as seen from the light's position to a 32-bit floating point red texture. (Done, works)
2) Render the scene from the camera's point of view and project the depthmap onto the scene (like normal projective texturing). Then I compare the depth stored in the depth texture to the distance from the pixel to the light. If the distance to the light is greater than the value stored in the depthmap, the pixel is shadowed (since this point isn't visible from the light's point of view).

To project the depthmap, a matrix is used to calculate UV coordinates on the depthmap for every vertex. This matrix is the product of the matWorld of the mesh, the matView and matProj of the lightsource and a scale and bias matrix(I can calculate the last one).

What I need is the matView and matProj of viewA (the view placed at the light) while rendering the scene from viewB (the normal camera).

As stated in my first post, I couldn't find a way to somehow store the matrix when the light/depth view is rendered.

Re: Getting the matView and matProj of a view [Re: Excessus] #95305
10/23/06 09:16
10/23/06 09:16
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Yes, I understand that so far, but matView and matProj are both among the predefined matrices (manual -> Engine functions -> matrix calculations). So you can just copy them to your material matrix (matMtl), or to matEffect, and use it in subsequent shaders.

For deciding whether an event is triggered by ENABLE_TREE or ENABLE_VIEW you could use the my pointer, which should be zero in an ENABLE_VIEW event. Or even easier, use a dummy material that only has a view event that copies the matrices.

Re: Getting the matView and matProj of a view [Re: jcl] #95306
10/24/06 20:54
10/24/06 20:54
Joined: Oct 2000
Posts: 1,543
Germany
A
Alexander Esslinger Offline
Senior Developer
Alexander Esslinger  Offline
Senior Developer
A

Joined: Oct 2000
Posts: 1,543
Germany
When using a material event for storing the view- and project-matrix, they may lag one frame behind.

Example:
material mat1 {..} // uses stored matrices
material mat2 {..} // stores matrices of view2
view view1 {..} // shows an entity with mat1
view view2 {..} // shows an entity with mat2
view view3 {..} // rendered last, for not allowing you to say "use matView/matProj in mat1"

If view2 is rendered after view1, the matrices used are from the previous frame.

None the less, functions like get_viewMatrix(view*), get_projMatrix(view*) or get_worldMatrix(entity*) would make sense. I guess the matrices are "precalculated" and stored inside the objects anyway.


Moderated by  aztec, 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