Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Ayumi), 884 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Realtime shadow mapping #95651
10/24/06 11:10
10/24/06 11:10
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
Hi,



This is a shot from my realtime shadowmapping shader. Some info:

-The cube in the top left is the lightsource.
-All objects can cast and recieve shadows.
-The shadows aren't smooth yet, I'm planning to add a smoothing method I have come up with. If it doesn't work or produces other problems I will implement percentage-closer filtering.
-Requires vs 1.1 and ps 2.0.
-No plugins.

Re: Realtime shadow mapping [Re: Excessus] #95652
10/24/06 11:17
10/24/06 11:17
Joined: Jun 2005
Posts: 4,875
broozar Offline
Expert
broozar  Offline
Expert

Joined: Jun 2005
Posts: 4,875
thumbs up how does it work? does the light source have to have special parameters? or the block (like _litAndShodow)? can we set if a surface can receive shadows? is it hardware independent (nvidia/ati/volari/s3)?

Re: Realtime shadow mapping [Re: Excessus] #95653
10/24/06 11:18
10/24/06 11:18
Joined: Nov 2004
Posts: 7,121
Potsdam, Brandenburg, Germany
Machinery_Frank Offline
Senior Expert
Machinery_Frank  Offline
Senior Expert

Joined: Nov 2004
Posts: 7,121
Potsdam, Brandenburg, Germany
Great work, Excessus. Please talk with JCL about this topic. Maybe he can add your excellent shaders into the upcoming shader template package?

Regards,
Frank


Models, Textures and Games from Dexsoft
Re: Realtime shadow mapping [Re: Excessus] #95654
10/24/06 11:22
10/24/06 11:22
Joined: Oct 2002
Posts: 8,939
planet.earth
ello Offline
Senior Expert
ello  Offline
Senior Expert

Joined: Oct 2002
Posts: 8,939
planet.earth
good job! maybe you use the light/depth information for adding a blur .. what about multiple lights?

Re: Realtime shadow mapping [Re: broozar] #95655
10/24/06 11:46
10/24/06 11:46
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
Thanks for your comments.

Quote:

how does it work?



1) The scene is rendered from the lightsource with a shader that outputs the depth.
2) The scene is then rendered with the normal camera and the depth texture is projected from the lightsource onto the scene. I then check the depth in the depth texture to the distance from pixel to the lightsource. If the pixel's distance to the light is greater than the depth stored in the depth texture, it is in shadow.

Quote:

does the light source have to have special parameters? or the block (like _litAndShodow)?



The light source is basicly a view, so you can set it's position, angle, arc, etc. The occluder/reciever doesn't need anything, it just needs to be a mesh.

Right now the scene is only rendered once from the camera but I'm planning to change it so that the camera is first rendered with the normal shaders, and then with a shader that only draws the shadows (with the other areas transparent) and overlay that on the first render. That way, you can still use your normal shaders.

This also allows to use a simple screenspace blur on the shadow texture. However this will result in dark halos around the silhouette of the model. I will try to prevent that by using the differntial of the neighbouring pixels on the shadow map (Don't blur if neighbouring pixels are much 'deeper'). If that doesn't work I will use percentage closer filtering: check how many points near this pixel are in shadow to decide shadow darkness. The drawback of PCF is that a smoother shadow will require more samples (thus slower rendering).

Quote:

can we set if a surface can receive shadows?



Everything casts and recieves shadows by default. You can use a different material in the depth-pass that doesn't render the object so that it is 'ignored'.

Quote:

Please talk with JCL about this topic. Maybe he can add your excellent shaders into the upcoming shader template package?



When the shader is done, I'll talk to JCL about this.

Quote:

what about multiple lights?



Not yet supported, I'll have to think about the implications of adding another light but it should be possible.

I think implementing this shader in your project could be as easy as including a script and passing a vector pointer to a function. You can then set that vector to any position and angle you want. You will probably also have to add two lines of code to all your materials for switching to a depth material when rendering from the lightsource.

Re: Realtime shadow mapping [Re: Excessus] #95656
10/24/06 12:44
10/24/06 12:44
Joined: May 2002
Posts: 2,541
Berlin
EX Citer Offline
Expert
EX Citer  Offline
Expert

Joined: May 2002
Posts: 2,541
Berlin
Interesting... If you do multiple lights, could you try to make the shadow the more transparent the closer they are to the light. It would be good if a second light source is within the shadow of another lightsource it would lighten up around the light the closer the "part" of the shadow is.


:L
Re: Realtime shadow mapping [Re: EX Citer] #95657
10/24/06 18:46
10/24/06 18:46
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
frazzle Offline
Expert
frazzle  Offline
Expert

Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
This looks very intriguing and interesting !!
It looks like the effect you create is very realistic
Het goede oude Hollandse verstand, wa zouden we zonder

Mooie werk Excessus

Cheers

Frazzle


Antec® Case
Intel® X58 Chipset
Intel® i7 975 Quad Core
8 GB RAM DDR3
SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB
NVIDIA® GeForce GTX 295 Memory 1795GB
Re: Realtime shadow mapping [Re: frazzle] #95658
01/20/07 16:33
01/20/07 16:33
Joined: Oct 2005
Posts: 4,771
Bay City, MI
lostclimate Offline
Expert
lostclimate  Offline
Expert

Joined: Oct 2005
Posts: 4,771
Bay City, MI
how are you getting the z-buffer info? are they allowing access to it in a6.54?

Re: Realtime shadow mapping [Re: lostclimate] #95659
01/20/07 17:56
01/20/07 17:56
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
Even if you could get access to the zbuffer (and I think this would be possible in a dll), it would be useless. You need the depth as seen from the light's position, not the camera's. On top of that, the bit depth would be a problem. I'm using a floating point texture and bit depth is already a major problem (huge artifacts on large scenes).

To get the depth, the scene is rendered with a shader that outputs the (linearized) depth of the pixels. You can use a render event to set the material to this depth-material when the current view is the light-view.

Re: Realtime shadow mapping [Re: Excessus] #95660
01/21/07 02:58
01/21/07 02:58
Joined: Oct 2005
Posts: 4,771
Bay City, MI
lostclimate Offline
Expert
lostclimate  Offline
Expert

Joined: Oct 2005
Posts: 4,771
Bay City, MI
have no idea what you just said, so ill just leave you with, got it

Page 1 of 2 1 2

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