|
How do you display shadows on invisible surfaces
#135959
06/12/07 15:14
06/12/07 15:14
|
Joined: Aug 2000
Posts: 7,490
Orange Brat
OP
Senior Expert
|
OP
Senior Expert
Joined: Aug 2000
Posts: 7,490
|
This request is carried over from a thread I started in The Future. Jcl says it can already be done without any additional new features; however this one moves into territory beyond my means. Here's my original request thread: http://www.coniserver.net/ubbthreads/showflat.php/Cat/0/Number/741148/Here's jcl's comment: Quote:
Shadows on invisible models should be possible by using nontransparent models with an FFP effect that renders only into the z buffer, but nothing to the screen buffer. I haven't tried it, though.
That quote came from this thread:
http://www.coniserver.net/ubbthreads/showflat.php/Cat/0/Number/747240/
It's an entirely different subject involving a request to place panels behind the view and has since been implemented into the newest private beta (thanks jcl); however these two features are related.
In a 2.5D game, the backgrounds are either prerendered or made by hand (drawn, painted, etc). The player and NPCs; however are realtime. In order to interact with these 2D backgrounds, an invisible, 3D collision hull has to be constructed and has to match the background. If there are two wooden crates in the middle of the screen, you have to place a collision block there so the player won't walk through the crates. There is also some layer_sorting effects that have to be done, but that's beyond the scope of this thread.
Anyway, using that crate example above, let's say the player's stencil shadow covered the crates. Since 3DGS won't allow the shadow to appear on my invisible collision geometry, it's not going to look right. If the feature were implemented, the shadow would wrap itself around the crates just like they would in a full realtime game. It's a fancy pants illusion, and according to jcl (see above), it can already be accomplished.
Here's a screenshot from the Resident Evil remake on Gamecube. You can see the player/zombie shadows going up the wall on the left. This is a prerendered background, so there is invisible collision geometry in place and the shadow is contouring to that and when combined with the 2D plate, the illusion is complete:
This is where I need help. Using jcl's comment or using a different method (if you know of one), I'm requesting that someone help me out with writing this particular effect. Thanks.
My User Contributions master list - my initial post links are down but scroll down page to find list to active links
|
|
|
Re: How do you display shadows on invisible surfac
[Re: Orange Brat]
#135963
07/15/07 18:33
07/15/07 18:33
|
Joined: Mar 2006
Posts: 2,758 Antwerp,Belgium
frazzle
Expert
|
Expert
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
|
I think this can be achieved with shadow mapping or with shadow volumes via a shader. The advantage of shadow mapping is that it is independent of scene geometry while usings shadow volumes, this is a required option. With shadow volumes you'll need a dll were you should create the object's silhouette which helps to locate level geometry in relationship with the shader where it should than create the shadow with a certain volume adapted to the level geometry. But where there are advantages, there are alos disadvantages. Shadow mapping may not require any information related the scene geometry but it seems to cast out much more pixelised shadows, where as shadow volumes have a moiré effect. Hope that gave you an overal idea OB But it's off course a nice theory but the practical side is as you've mentioned, far from easy. I'm trying to achieve shadow mapping through a shader with 3dgs because I'm not very familiar when it comes to writing a dll or sort like I'll post a topic which will be related to this one in the 'far' future. 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: How do you display shadows on invisible surfac
[Re: Orange Brat]
#135965
07/16/07 00:51
07/16/07 00:51
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
Same thing resident evil did...
Hey, I thik I've just found a solution. Sweet. Lets see f this still sounds do-able as a write/think...
WHAT IF, the model wasn't invisible, but simply drew exactly what was behind it (The model being collision geometry, using models with polygon flag, etc). I could use the same shader I used for portals to draw an image onto the model, but instead of reading from the texture from the models tex-coord, Ill read from the pixels position on the screen. Since pixel shaders draw by the amount of visible pixels on screen, and not by texture size, it won't lose quality!
Ok, there's the end of my ramble, and I still havn't found a downside. Yes, shaders are a bit slower, but this shader requires VERY LITTLE math, so the shader should run very quickly. The hardest part is adjusting the position and size of the image for differnt screen resolutions, but once the formula for this is found, it shouldn't be a problem.
Since stencil-shadows are displayed onto models (even with shaders), you should have a perfect result! You could probably even add dyn. lights to the scene for brightening the shadows in certain areas....
I won't be back home until the 25th, so I can't really begin on this idea now, but if someone else wants to give it a try, please do!
Let me know what you guys think!...
xXxGuitar511 - Programmer
|
|
|
Re: How do you display shadows on invisible surfac
[Re: Orange Brat]
#135967
07/16/07 11:07
07/16/07 11:07
|
Joined: Mar 2006
Posts: 2,758 Antwerp,Belgium
frazzle
Expert
|
Expert
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
|
I think Guitar his idea seems logical enough to work such as mine but the problem is the shader. But when relating to jcl his answer, while using a FFP effect (Transform & Lighting and Multitexturing) you should remind that shaders( VS,GS,PS) are nowadays quite hard to avoid from the OpenGl/D3D pipeline. But for making it clear, you're trying to make collision detection for shadows between a predefined sprite (your hand drawn art) and a realtime model. So that not only the shadow is aware of the scene 'invisible' geometry but to make sure that there is a 'contour effect' while the shadow interacts with it. But why not using a realtime sprite which represents your hand drawn art, works perfectly 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: How do you display shadows on invisible surfac
[Re: frazzle]
#135968
07/16/07 11:20
07/16/07 11:20
|
Joined: Aug 2000
Posts: 7,490
Orange Brat
OP
Senior Expert
|
OP
Senior Expert
Joined: Aug 2000
Posts: 7,490
|
A shader shouldn't be necessary because this is just something that is part of the stencil shadow crap in DirectX. I got a response from Mnemonic at Wintermute. He's basically saying jcl is on the right track, and here's the msssage: Quote:
Hi Ryan,
the hidden geometry indeed needs to be rendered into the depth buffer, so that the shadow volume is properly mapped onto it. In Direct3D the following render states should do the trick:
Code:
m_Device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); m_Device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO); m_Device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
This unfortunately also means the hidden geometry must closely match the 2D image, otherwise the depth buffer will mask the 3D character (like on this screenshot: http://www.dead-code.org/blog/wp-content/shadow2.png).
JN
So, if someone knows what that means, then this is the key or at least an entry into what I need.
@frazzle: The parallel, camera facing planes are going to have the art on them. I could just as easily make them regular sprites if I wanted. The shadow can only interact with the invisible collision hull (block, model, whatever...it's separate from the sprite art or the plane with the art mapped on it..whichever I use), so it has to exist for not only this shadow stuff but also for collision for the player. The 2D art is placed within the level at the approximate place the collision hull is at. If every matches, then the shadows should appear to contour around the elements in the art. You can see this in the screenshot in my first post. The shadow is going up the wall, but that's just a 2D bitmap background. It's really contouring to the collision hull.
|
|
|
|