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, TedMar), 1,031 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
looking for "Z Buffer" Shadow #360544
02/24/11 20:41
02/24/11 20:41
Joined: May 2008
Posts: 301
Oxy Offline OP
Senior Member
Oxy  Offline OP
Senior Member

Joined: May 2008
Posts: 301
Hi,
Im looking for a simple Shadow Shader, that uses the
Z-Buffer technique.

Such as:
http://en.wikipedia.org/wiki/Shadow_mapping

The shadows dont need to have a good resolution.
They mainly need to be fast.

Just like this example:


Re: looking for "Z Buffer" Shadow [Re: Oxy] #360546
02/24/11 21:02
02/24/11 21:02
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
There is a shadow mapping example in the GStudio folder (samples/shadowmapping.c).


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: looking for "Z Buffer" Shadow [Re: Superku] #360549
02/24/11 21:04
02/24/11 21:04
Joined: May 2008
Posts: 301
Oxy Offline OP
Senior Member
Oxy  Offline OP
Senior Member

Joined: May 2008
Posts: 301
Ok, i will try that one.

Re: looking for "Z Buffer" Shadow [Re: Oxy] #360550
02/24/11 21:10
02/24/11 21:10
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
If you don't mind getting a little more complicated, there's a CSM tutorial on my website here. More specifically, it's how to adapt the shadowmapping.c code Superku pointed you to into Cascaded Shadow Mapping, which is relatively easy but effective over huge distances.

Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: looking for "Z Buffer" Shadow [Re: JibbSmart] #360554
02/24/11 21:37
02/24/11 21:37
Joined: May 2008
Posts: 301
Oxy Offline OP
Senior Member
Oxy  Offline OP
Senior Member

Joined: May 2008
Posts: 301
Cool, I will play around with the standard example, and
then look into your advancements.

Re: looking for "Z Buffer" Shadow [Re: Oxy] #360564
02/25/11 00:54
02/25/11 00:54
Joined: May 2008
Posts: 301
Oxy Offline OP
Senior Member
Oxy  Offline OP
Senior Member

Joined: May 2008
Posts: 301
The shadow rendering looks nice.
But is there a way to keep other material and lightsettings?
They are overwritten by the shadow material.
And the "bottom" (non lightened) parts of the
models are totally black.

Can the shadows be added / mixed to the scene with
the standard material/lightning?

Re: looking for "Z Buffer" Shadow [Re: Oxy] #360565
02/25/11 01:05
02/25/11 01:05
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
I believe my tutorial also makes the shadows mix more nicely with the standard lighting.

Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: looking for "Z Buffer" Shadow [Re: JibbSmart] #360569
02/25/11 01:37
02/25/11 01:37
Joined: May 2008
Posts: 301
Oxy Offline OP
Senior Member
Oxy  Offline OP
Senior Member

Joined: May 2008
Posts: 301
ok, I put in
return tex2D(TexSampler,inTex) * fShadow * max(0.15,fDiffuse);

to keep the bootoms from getting totally black.
(works for now)


Jibb, you example is cool for explanation.
Its just a bit slow with the 3 views.
Is it possible to only use the "widerange" view, but
then add other materials and lightemittions onto the map?

Re: looking for "Z Buffer" Shadow [Re: Oxy] #360572
02/25/11 02:06
02/25/11 02:06
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
It is possible to use fewer views. There is also room to make it faster, with functions that have been added since then in A8 (such as view_check). If you want to use just the widest view, it's mostly be just the same as the original shadowmapping.c example with a couple of changes.

If I were you, I'd use:
Code:
return tex2D(TexSampler,inTex) * min(fShadow, fDiffuse);

This will make a smooth transition from the cast shadow to the diffuse lighting. Then, if you need the shadow to be less dark, change fDark near the beginning of the .fx file.

The way it is set up, you'll need to add the shadow stuff into each different material manually if you want them to receive shadows.

Out of curiosity, what are your system specs? And what kind of framerate are you getting?

Jibb


Formerly known as JulzMighty.
I made KarBOOM!
Re: looking for "Z Buffer" Shadow [Re: JibbSmart] #360573
02/25/11 02:13
02/25/11 02:13
Joined: May 2008
Posts: 301
Oxy Offline OP
Senior Member
Oxy  Offline OP
Senior Member

Joined: May 2008
Posts: 301
its about 25 FPS on 1024x768 on your examplelevel.

on the original demo its about 130 FPS on 1024x768.
(I added a few models too, so its not the models themself)

I dont have a very new Computer, but (beeing conservative) I dont want to
see an FPS drop that early on.


Page 1 of 2 1 2

Moderated by  Blink, Hummel, Superku 

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