How do you display shadows on invisible surfaces

Posted By: Orange Brat

How do you display shadows on invisible surfaces - 06/12/07 15:14

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.
Posted By: Orange Brat

Re: How do you display shadows on invisible surfac - 07/15/07 05:58

I'm still lacking a solution for this problem. I've been busy out in the real world (marriage, moving, etc), so I haven't had a lot of time to keep up with 3DGS goings on. Anyone?
Posted By: Felixsg

Re: How do you display shadows on invisible surfac - 07/15/07 08:54

I don't know because I not check but with a transparent targa texture the stencil shadow are still over the model?
Or with the overlay option and a black texture?
Posted By: Orange Brat

Re: How do you display shadows on invisible surfac - 07/15/07 09:31

The feature isn't possible right now. According to jcl though:

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.





Scripting the FFP effect is what I cannot do, since I have zero experience in this field. The effect should allow the stencil shadow to display on an invisible or none surface. The old non-stencil shadows do render on invisible surfaces, but they don't contour to non-horizontal surfaces, so they are useless.
Posted By: frazzle

Re: How do you display shadows on invisible surfac - 07/15/07 18:33

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
Posted By: Orange Brat

Re: How do you display shadows on invisible surfac - 07/15/07 20:08

I'm trying to stay away from shaders. I'm not using a standard 3D level. My visible level will consist of handrawn art. The art will will be textures that are mapped onto a series of parallel camera facing planes. However, given I want the shadows to interact with these flat surfaces, I will include some invisible collision/shadow geometry for the shadows to contour to. Think of the levels as hand drawn backdrops except they have actual 3D depth to them.

This is a standard issue 2.5D adventure game shadow method. Wintermute Engine does it, but I'm not using Wintermute because I don't have access to a realtime camera. I could achieve everything else I wanted in that engine except the realtime camera which I'd use to move the camera into and out of levels.
Posted By: xXxGuitar511

Re: How do you display shadows on invisible surfac - 07/16/07 00:51

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!...
Posted By: Orange Brat

Re: How do you display shadows on invisible surfac - 07/16/07 02:15

I suppose it's worth investigation. I think I'm going to write the author of the Wintermute engine and see he does it.

EDIT: ...and in fact I have. Somehow, I don't think shaders are the answer, and it's probably something very simple.
Posted By: frazzle

Re: How do you display shadows on invisible surfac - 07/16/07 11:07

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
Posted By: Orange Brat

Re: How do you display shadows on invisible surfac - 07/16/07 11:20

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.
Posted By: frazzle

Re: How do you display shadows on invisible surfac - 07/16/07 12:18

So in overal, you need to place a model or a geometry block which is invisible and represents your total scene where as there needs to be a collison detection with the invisible scene and your realtime models their collision hulls so eventually the shadows can be calculated and the models will still have collision. At the place of the invisible scene, you map your hand drawn art on a parallel plane so it looks like the shadows interact (contour for example) with the planes but actually it's an illusion.

But I'm still wondering why you won't use the sprites as hand drawn art together with the stencil shadows ^^ ??

Cheers

Frazzle
Posted By: Orange Brat

Re: How do you display shadows on invisible surfac - 07/16/07 12:59

You have the concept correct; however:

Quote:

But I'm still wondering why you won't use the sprites as hand drawn art together with the stencil shadows




What do you mean by this? How is the stencil shadow going to interact with a bitmap and contour to it's details? It can't which is why the invisible collision hull must be in place and anyplace the player's shadow can touch much closely match the 2D sections.

Here are a couple of quotes from a very famous adventure game artist/designer working on the adventure game A Vampyre Story. They're using the exact same technique I'm stealing from them. Perhaps, his explanation will be better. There are two of them taken from two different posts:

Quote:


So AVS will be in 3d BUT,,,,not the way you think. I am a big fan of the early Disney movies, and one Oscar winning short in particular really influenced me. It was called The Old Mill. http://disney.go.com/vault/archives/movies/oldmill/oldmill.html It was mood film, meaning it didn’t really have plot, but for good reason. It was a test film for a new technique called multiplane camera. So we are going to do is make a virtual multiplane camera using your PC’s 3d card. The backgrounds will be painted in 2d but placed on 3d planes. This will allow us to keep the backgrounds looking 2d and hand painted, but we get to create the illusion of depth and perspective.





Quote:


We draw the backgrounds on paper then scan that in and paint the set layers in Photoshop, with each plane on its own separate PSD layer. Then we save the separate layers as TGAs (Targa files) and turn them into textures, along with their alpha channels (transparent matted areas) in Maya, and then UV map the layers on to flat parallel polygons in Maya. Export that file into our engine, test it make sure it works. Then add particle affects and UV scrolling areas. Add the dynamic lights for the sets and 3d Character models. Import a separate set of geometry for the walk boxes, test that out. Then add all the interactive objects like doors and buttons and things like that. We use Maya to build the character meshes, rig them and to animate them. Nothing really exotic in this process. They only thing unusual is that we aren’t building 3d models for use as our sets, just 2d planes.





Go here: http://www.adventuregamers.com/screenshot.php?id=6823 to see some screens from this game. The bottom 8 are the new ones. All of those screens are broken up into layers (the parallel planes), so it's a 2D game but because of these layers, it will have depth. It's like parallax scrolling in the old 16-bit days, but a bit more advanced in the execution because of the use of a full, realtime engine. This will allow for zooming in/out and moving the camera into the scene or out as necessary. The technique will be more apparent in exterior scenes. Anyway, I will need my shadows to interact with my backgrounds or else it just won't be as convincing an effect.
Posted By: HeelX

Re: How do you display shadows on invisible surfac - 07/16/07 13:16

Uhm, I think you can set these renderstates in a FFP with SMEE2. I will give it a try.

Though - unfortunately - I can't get this "render a panel behind a view if it has a negative layer"-feature with the current A7 beta to work. No one confirmed/denied this yet and I simply made a panel with a large background bitmap and a negative layer (look into the beta forum!). So.. if this doesnt work, well... whatever.

Cu later..
Posted By: frazzle

Re: How do you display shadows on invisible surfac - 07/16/07 15:01

@ OB:

Well, I see your problem and the quote you've copied expains how it can be achieve in theory. The practical side is quite more complex I guess. A plugin like I mentioned could be the answer. Like HeelX suggested, SMEE2 could be a potential solution. I will keep on testing with the shadow mapping shader, if you might need it, just ask. Because of the faqt that you can't integrate any other solution, a shader could be the only option... But this is someting we'll see later on in the future

But to refer to your question:

Quote:


What do you mean by this? How is the stencil shadow going to interact with a bitmap and contour to it's details? It can't which is why the invisible collision hull must be in place and anyplace the player's shadow can touch much closely match the 2D sections.





What I ment by this, why not just a simple sprite that represents your art.
Then set the shadow_stencil var to on where as the shadow will interact (contour) with your scene (geometry blocks,sprites, models). Here's a picture where I simple programmed the shadow_stencil veriable in c-script to on and setted the shadow flag and the cast flag in wed for the model. The green sprite hasn't got anything attached qua action or flag:


@ HeelX:

Good luck

Cheers

Frazzle
Posted By: Orange Brat

Re: How do you display shadows on invisible surfac - 07/16/07 15:01

Actually, the negative layer panel feature won't have anything to do with this. It'll be useful for pure 2.5D games, but my game is still set in a completely 3D world except everything is 2D planes (or sprites) with the real geometry hidden.

The only visible real 3D will be the characters; however I'm even thinking about making them 2D. I'd need to render out a bunch of frames, but it would free up the poly budget. I haven't thought that one through, though because it would take A LOT of frames. I'd need my standard 8 directions for both walking and running, the in-betweens when turning, idles, special case renders for moody, Noirish lighting, the same frames for different camera angles, etc. This would lead to another potential problem.... Can stencil shadows cast from an invisible model? I know they won't work if the model is transparent. I'd want to use a low poly version of the model used for the 2D sprites to cast shadows with. If this is impossible then I guess I'm screwed. I want to focus on this shadow problem first, though.

Why do I have to be so unorhtodox?
Posted By: Orange Brat

Re: How do you display shadows on invisible surfac - 07/16/07 15:07

@frazzle:

So, can shadows contour to sprites? If I read your explanation correctly, that green area is just a sprite and the stencil shadow is bending up it? I'll try and reread what you wrote and see if I can better interpret it. Regardless, I'd still like the ability for the shadows to render on invisible surfaces just to have it in the engine for any ol' thing I might want it for (or for others who might think of something cool to do with it).
Posted By: frazzle

Re: How do you display shadows on invisible surfac - 07/16/07 15:15

Oke, ask if you have any other question regarding my explanation OB
But your unorthadox way is a way to achieve something quite unique in 3DGS, I'm quite interested in it too Like I mentioned, I'll try to go the shader way but FFP effects require abit of knowledge into assembly programming which isn't easy to get familiar with when never used before.

Cheers

Frazzle
Posted By: Orange Brat

Re: How do you display shadows on invisible surfac - 07/16/07 15:31

That's all right. I've provided the WME info to jcl in my original request thread from a couple months back. I'm going to see is we can get some kind of new flag in WED that would function as a special kind of invisible/none. Any surface with this flag set to on will be invisible but receive the shadow. Here's that thread:

http://www.coniserver.net/ubbthreads/showflat.php/Cat/0/Number/769508/

I'll keep my fingers crossed.
Posted By: Orange Brat

Re: How do you display shadows on invisible surfac - 07/16/07 15:40

@frazzle and everyone else:

Take a look at this animation short. It's an FLV file, so you'll need a Flash player to view it (I use this free player):

http://www.mediafire.com/?9wxxn2xh4om

Certain parts of this feature showcase the 2D yet still 3D effect I'm talking about. Here's the original Disney short that inspired the creator of A Vampyre Story:

http://www.youtube.com/watch?v=UMwa3ZwTwyA

It also uses the layered 3Dish effect and was Disney's first foray into that technology. They used it a lot in Snow White and throughout many of their features and shorts ever since. It's nothing revolutionary in the world of animation (anime features Akira and Ghost in the Shel, as well as Batman The Animated Series used it a lot), but you don't see it a lot in 2D or 2.5D games. It's usually more along the lines of your standard parallax scrolling effect seen in side scrollers. A good example of that would be the Limbo trailer. That forest stuff at the beginning feature your run of the mill parallax scrolling; however it's still very similar to what I'm wanting to do:

http://www.limbogame.org
Posted By: frazzle

Re: How do you display shadows on invisible surfac - 07/16/07 16:29

I'll cross my fingers too
The video's show indeed what you're trying to achieve but like you've mentioned it's not shader related so I hope jcl will manage to include this special feature

Cheers

Frazzle
Posted By: xXxGuitar511

Re: How do you display shadows on invisible surfac - 07/16/07 18:53

I'm going to stick with my idea and give it a try when I get home.

My plan is to create my level lik I normally would, but using models and no blocks for the level. Make all models as high qality as possible, high-res textures, parallax oclusion mapping, whatever... but only render all that for one frame of every scene, then save that image as a TGA. Then all materials wil switch to the "special shader", and the last scene will be drawn on all models. The textures of the model will switch to a small 8x8 blank tex. I'll have all the quality I can get without the slow-down. I'll have an interactive 3D world as well...

We'll see how it goes...
Posted By: frazzle

Re: How do you display shadows on invisible surfac - 07/16/07 19:08

Sounds quite promising, good luck Guitar but you know that the theoretical side is always easy in opposite with the practical side
I'll try to go for shadow mapping

Cheers

Frazzle
Posted By: HeelX

Re: How do you display shadows on invisible surfac - 07/17/07 10:10

Well, it works: on the left side without FFP material applied, on the right with the FFP material.



But I am not able to clip the warlock model behind the dummy mesh..

Here is the FFP I'm using, it just implements the flags which are mentioned by that guy from WME:

Code:
material orangeBrat
{
effect = "technique orangeBrat
{
pass p0
{
SrcBlend = Zero;
DestBlend = One;
AlphaBlendEnable = true;
}
};";
}



Just apply the material to every dummy mesh. I will see if I can clip the overlapped parts of the warlock model.

Cheers!
Posted By: frazzle

Re: How do you display shadows on invisible surfac - 07/17/07 12:46

Nice results HeelX, OB will be quite pleased so far
The mesh problem is like Mnemonic at Wintermute mentioned:

Quote:


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





I guess this can be resolved with the methode OB is trying to use and the quote I copied. Just place the parallel planes at the right position which match the position of the invisible scene where than the hand drawn art will be mapped on those planes and OB his problem should be resolved

Cheers

Frazzle
Posted By: xXxGuitar511

Re: How do you display shadows on invisible surfac - 07/17/07 17:39

What about the addition of some other flags, such as:

zEnable
alphaBlendEnable
zWriteEnable
alphaTest
- I need to lookup these flags on MSDN and larn exactly how each works.

And have you tried removing the alphaBlendEnable from the above test? I'm wondering if it's necesary or not.
Posted By: HeelX

Re: How do you display shadows on invisible surfac - 07/17/07 17:53

Well, I didn't succeeded any further..

AlphaBlendEnable is necessary for making the dummy mesh invisible. I played with zEnable and zWriteEnable but this wasn't the key, too. I also tried to create a material for the warlock character model, but there were also no fruitful results at all.
Posted By: frazzle

Re: How do you display shadows on invisible surfac - 07/17/07 18:31

I guess that setting these render states is the only way, according to this reply from WinterMute which I qouted from one of the replies OB maded:

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





The red part is how it would be setted within D3D which is identical qua functionality to the code snippet HeelX posted. I've read about information that zEnable, zWriteEnable,alphaTest and alphaBlendEnable won't make any difference. Here's the information from msdn regarding render states:

msdn link

To make this error dissapear, you'll have to 'cheat' towards realtime rendering That is the only option AFAIK to resolve this problem until now. Maybe shadow mapping or shadow volumes via shaders won't be affected by invisible scene geometry but on the other hand, OB wants to avoid the shader way but I'll give it a shot though

Cheers

Frazzle
Posted By: xXxGuitar511

Re: How do you display shadows on invisible surfac - 07/17/07 19:11

Quote:

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). />




I'm going to stick with my method.
1) Create the scene in 3D using models
2) render one frame with full quality to a target bmap
3) save the map with the name of the camera pos
4) use a special shader that renders the background image onto the models.
*) I'll have all the geometry without the invisible render crap.
Posted By: frazzle

Re: How do you display shadows on invisible surfac - 07/17/07 19:52

Well like I said, good luck
Btw, I've been testing with the depth buffer and the results I'm getting are good but not perfect. I'll post something when I get some decent result ^^

Cheers

Frazzle
Posted By: frazzle

Re: How do you display shadows on invisible surfac - 07/17/07 21:35

Post deleted by Frazzle

Edit: wrong result, the code wasn't a solutions for the clipping issue. It just sloved the problem I noticed that when the model came close to the object with the material HeelX posted attached to it, the model became invisible but when setting the passable flag off this works as well because that way you can't penetrate the object and can't get invisible ^^

Cheers

Frazzle
Posted By: Orange Brat

Re: How do you display shadows on invisible surfac - 07/18/07 01:32

@Heelx: That looks like the right track, although shouldn't the non-clipping be taken care of if you place the 2D sprite that represents the block at the correct point in the level to match up with the invisible hull? The wall and floor would be the background layer and the small block a sprite that is in front of it.

I'll play around with this code this week when I have time and am not so tired. I'm too exhausted right now and am going to sleep at a normal hour for once. Thanks to you and everyone else (XxX snapshot method sounds intriguing but would eliminate a huge chunk of the target market for the genre given the advanced shaders).
Posted By: Matt_Aufderheide

Re: How do you display shadows on invisible surfac - 07/18/07 04:54

There should be no reason you can't simply solve this problem. Make sure sure the model or geometry has NO alpha channel in its texture. Turn on zwriteenable and zenable. Turn off alphablend and alphatest. Then turn off color writes like this colorwriteenable=alpha

This ought to achieve what you want. Let me know if you try it and it works.
Posted By: HeelX

Re: How do you display shadows on invisible surfac - 07/18/07 09:37

This works on the geometry, right. But the problem is, that the the lower part of the warlock in my testcase (see images above) are NOT clipped. I don't get the reason why it is'nt clipped, although the geometry writes into the zBuffer. I also tried to fiddle with zFunc and so on, but it doesn't help.

Misteriously, the self shadowing parts of the warlock behind the box aren't rendered..
Posted By: frazzle

Re: How do you display shadows on invisible surfac - 07/18/07 12:13

@ Matt:

Your code snippet would work on level geometry like HeelX mentioned but that doesn't solve the clipping issue.

@ HeelX:

I think I know a way to solve the clipping issue. Matt his code snippet doens't work on stencil shadows combined with alphablending on models so it's just a matter of finding the right balance and mix between zbuffer and stencil buffer shadows
I did some tests and it seems that when using stencil shadows, the model with alpha blending doens't clip the model's mesh behind it's own. There for, you need to set the stencil shadow variable at a global scope in your script and only enable the cast flag for your warlock itself and not for the box. The warlock has got stencil shadows so they will still contour with the level geometry but the box had got z buffer shadows because the cast flag isn't set so there will be a depth test and the result is writin to the z buffer via z write. Now combining the z buffer with alpha blending, it makes sure that the model will not be visible behind the box's mesh, voila the sorting issue is solved.
I'll show it in the practical way:
Code:
 

var shadow_stencil = on;
var shadow_lod = 3; // increasing the shadows quality

material box // apply this to your box which you knew already, set the shadow flag but don't set the cast flag to avoid stencil shadows.
{
effect =
"technique test
{
pass p0
{
AlphaBlendEnable = True;
SrcBlend = Zero;
DestBlend = One;
}
};";
}

material geometry // Matt his code snippet
{
effect =
"technique test
{
pass p0
{
AlphaBlendEnable = True;
SrcBlend = Zero;
DestBlend = One;
zwriteenable = true;
zenable = true;
colorwriteenable=alpha;
colorwriteenable1=alpha;
colorwriteenable2=alpha;
colorwriteenable3=alpha;
}
};";
}

// Set the cast flag and the shadow flag for the warlock to enable stencil shadow which allows the shadow to contour with the level geometry.



This is the result but mind that I didn't applied any material towards the level geometry which wasn't neccesairy in these images:




Btw, the problem HeelX had, could also be solved via a sprite which should match the geomety of the scene. This is the methode OB original wanted ^^

Cheers

Frazzle
Posted By: Orange Brat

Re: How do you display shadows on invisible surfac - 07/18/07 16:36

Given my semi-technical mind (from a programmer's POV), this is all a bit overwhelming, but I get the gist of it.

The entities that should be casting stencil shadows are the player or any other NPC. Any hidden geometry for the Background/foreground scenery (the level) shouldn't be casting anything in a pre-rendered/hand drawn background. I noticed in Heelx's screens that the cube seems to be casting what appears to be a stencil shadow when only Mr. Warlock should.

Anyway, I think the issue is slowly or has already been resolved (not sure yet ). It's kind of nice to see some of the greater 3DGS programming minds working on this if for nothing more than to tackle the challenge of it. I'm not sure how many of you would actually use it, but I guess I sparked some inspiration.

Quote:

Btw, the problem HeelX had, could also be solved via a sprite which should match the geomety of the scene. This is the methode OB original wanted ^^




Yeah, I think I mentioned this in my last post. Placing the 2D element at the point of that cube should cover up areas we wouldn't see anyway (because they are covered up; thus that warlock can clip all it wants).

Now, it's just a matter of applying all this to a real level.
Posted By: frazzle

Re: How do you display shadows on invisible surfac - 07/18/07 17:03

Amen
Good luck applying it into your level OB !!

Cheers

Frazzle
Posted By: Orange Brat

Re: How do you display shadows on invisible surfac - 07/18/07 17:10

Fron another thread:

Quote:

Quote:

Finally, is it possible in DirectX to make an invisible model cast a stencil shadow and if so could you add this to the todo list, too (assuming it isn't already possible...I'm away from my regular PC, so I can't check).




You already can use, or even already use normally, the LOD of your charcter for the shadow in A6.
Just picked up this sentence, so it can be that this already had been mentioned.




Yep, I'm aware that we can use LOD for stencil shadows (Wintermute has this feature too); however I know that SS don't work when a model is transparent, so I was wondering if they worked if they were completely invisible (my.invisible = on;)? The manual states:

Quote:


Stencil shadows are only cast by completely non-transparent models. The model skin must not contain an alpha channel.





I wonder if there's a way to make a model cast the SS and still be completely 100% visible but not render. It sounds much like the hidden geometry issue doesn't it? If his would work, I'd use a lower poly model for the realtime model that projected shadows and attach a 2D animated character with a lot of frames (so it's smooth and looks like a highly detailed model without having to use a normalshader). I would get the visual results I'm after plus a working stencil shadow all within a 2.5ish world.

------------------------------------------------

New stuff related to the above post:

Is it possible to do something like this? I know that sounds contradictory, but the engine would think the model is visible and non-transparent, but we wouldn't be able to see it because of some flags settings.

I have reasons for wanting to combine a 2D animated character (constructed from a higher poly model or hand drawn) with a lower poly, non-rendered, realtime model. The sprite would appear at the location of the non-rendering model and all animation frames of both versions would match depending on user input. It would be easier to maintain with point and click input, but Intense Pathfinding will need some tweaking to use it (Larry is aware and one day he might resolve the issues according to a past post of his...he has bigger fish to fry right now).

1. One reason is speed and savings on poly count and lack of having to have to use a normalmapping shader. This will allow lower end systems to be able to run the game efficiently since they won't need the shaders technology plus there will be less 3D crap to render out.

2. I believe I've lost my animator. My modeler (Dan) is still onboard but having a run of bad luck, so his turnaround has been off. I'd still use his models for shadows. I have acquired a copy of Poser 7 and what I would do is create a unique character via morphing their base characters (or buying one that I like and doing it) that closely matches the characters that Dan is making for me. I'd use unique textures, of course. The program has animation features including a fantastic walk/run/talk generator (it actually works wonders) and you are allowed to use 2D renders or animated sprites for commercial purposes if you use their 3D models as the base of your art.

Anyway, it all sounds crazy, but it should work if I can get all of of these non-rendering things to work out right. The end result is a unique looking game with much less 3D mesh and geometry to render and higher visible detail to the level art but at the same time still have all the benefits and features of a realtime camera and world.
Posted By: frazzle

Re: How do you display shadows on invisible surfac - 07/18/07 18:15

So in overal, you're trying to achieve the following:
The realtime model, which isn't actually rendered because it's invisible plus additionally non-transparent should cast out a stencil shadow right ??
I've did some tests with this already in the past and my results were that the stencil shadow were rendered uncorrectly/unaccurate but I'll run some more tests to give a final view.
Btw, you really are unorthadox plus contradictorical

Cheers

Frazzle
Posted By: Orange Brat

Re: How do you display shadows on invisible surfac - 07/18/07 19:04

Quote:

The realtime model, which isn't actually rendered because it's invisible plus additionally non-transparent should cast out a stencil shadow right ??




Yep, but if it can be set so that the engine reads it as visible but can be made to not render to the screen that would be ideal. This way it should, in theory, still be able to display the stencil shadow since it isn't technically in any state of transparency (with invisible being totally transparent). I wonder if using the new z-fail method would eliminate artifacting if there is any?
Posted By: Orange Brat

Re: How do you display shadows on invisible surfac - 07/18/07 19:34

I suppose since the 2D animated sprite should always be in front of the 3D model and match its movement that it I could put a single colored texture on it (dark for dark scenes and light for light scenes) and keep the model visible. Unless, there's some clipping issues, you shouldn't ever see the model; thus this could work.

Quote:

Btw, you really are unorthadox plus contradictorical




Yes and no. I'm simply trying to come up with methods that aren't readily apparent or native to the engine. Wintermute can do all of this out of the box, but it's made esp. for this style of gameplay.
Posted By: frazzle

Re: How do you display shadows on invisible surfac - 07/18/07 20:30

I guess applying your original methode like you wanted plus the single colored texture will work, though, you would be cheating agains the rendering engine in one way
Btw, I said the unorthadox and the contradictorical stuff with a smile such as it would be like a joke

I'll run some more tests with the stencilzfail and etc. considering your request but I'll doubt if it's even possible. Within the SDK itself, you might be able to change it temporarily.

Cheers

Frazzle
Posted By: Orange Brat

Re: How do you display shadows on invisible surfac - 07/19/07 06:48

Keep me posted on your results.

I know you were joking, and if cheating will get me the results when it comes to this 2nd issue than so be it.
Posted By: xXxGuitar511

Re: How do you display shadows on invisible surfac - 07/19/07 18:57

The reason I wanted to use my method was because All the geometry is already there. It's as if I paused the rendering, and held the result without rerendering. On the release version, it won't use the shaders and such, just the generated images. The shader should be possible with FFP, so I may not even use any shaders in the release, but we'll see where I end up...

I'm writing a storyline now, I'm going to have my friend Mike help me make it more creative/interesting. I'll begin work once I get home...
Posted By: Orange Brat

Re: How do you display shadows on invisible surfac - 07/19/07 21:41

Now that we can use concave geometry in WED, I had thought about doing it this way some time ago. I'd just build a super complicated/detailed level complete with shaders or whatever else I need and take the appropriate screenshots. I'd take care of the collision hull by reducing the geometry and leaving in the more detailed sections for the shadows. If I want to get a render of specific sections for my layers then I just turn off the parts I don't want showing and do this for each individual layer.

After that it would be a process of using panels. Everything should line up nicely. However, using panels would cut out the ability to move a realtime camera into or out of a level. I suppose you could fake it by scaling panels in realtime to make it look like you're getting closer or farther away from certain sections, but that would probably look terrible. That's why I'd want the layers in the actual level itself and not use panels for background/foreground art. This is where the pain comes in because you have to manually line everything up and hope it's to scale. The background plate would be easy but the foreground elements or things you can walk in front of or behind are the tricky ones.
Posted By: ACKNEX007

Re: How do you display shadows on invisible surfac - 07/20/07 04:03

"I'm writing a storyline now, I'm going to have my friend Mike help me make it more creative/interesting. I'll begin work once I get home... " - Good Luck With This Project !
Posted By: frazzle

Re: How do you display shadows on invisible surfac - 07/23/07 12:46

I've run all of the test I could think of but none gave a perfect result.
I guess you'll have to keep the player visible, apply stencil shadows and cheat agains the rendering engine
Maybe Guitar can get better results using his idea.

Cheers

Frazzle
Posted By: Orange Brat

Re: How do you display shadows on invisible surfac - 07/23/07 14:44

Yep, that's what I've decided to do. I don't even know if it's possible to render a shadows at all if it's not completely visible. It might be a directx thing. Thanks for trying and for the effort. I've discussed this new use of realtime models with Dan, but I haven't heard from him, so I hope he's still on board.

To reiterate: I'm building a high poly representation of what I want in Poser 7 and saving out a large number of animation frames and attaching this to the lower poly model. This model will serve as my shadow caster. I'll have to place it a bit in front of the model to avoid clipping, and I just hope this doesn't look strange in regards to the shadow lining up wrong. I'll combine this with the results of the subject of this thread (I guess we got that working?).

Of course, if the model can cast an alternate shadow from a LOD model, why can't it cast a shadow from an invisible model?

Can someone who knows about these things post if it's possible for an invisible model to cast a stencil shadow? Is there some flag that can be set in a material?
Posted By: frazzle

Re: How do you display shadows on invisible surfac - 07/23/07 17:51

While testing, I discovered that z-buffer shadows can be rendered when a model is invisible. Stencil buffer shadows are rendered as well when a model is invisble with render state settings. However, the result isn't very pleasant and the reason is quite obvious.
I've ran some tests with alphablending, the model is invisible due to alphablending and the shadows are casted but while the shadows are situated at a range where the model is visible/invisible rendered , this leads up to some kind of distortion. Alphablending is a pain in the as* when it comes to stencil shadows because when the model itself is invisible due to alphablending, part of the shadow is not visible. Alhpablending doesn't allow stencil shadows to be completly visible when they are situated behing a model's mesh. Strange, because z-buffer shadows work just fine. Here are two pictures who prove it:




The pictures show a model with a standard alphablending render state and a stencil shadow.
The sun rotates to make the shadow move and mark the difference.
Picture one: The shadow is being covered up for +-20 percent by the model's mesh.
Picture two: The shadow is situated underneed the player but as I've mentioned, the shadow is being coverd up for +- 95 percent due to alphablending.
I guess you get the problem But the sad thing is that I can't get this solved, not even with the stencil render states. I think you're probably right that it's an DirectX (D3D) issue is.
Good luck on finding a potential solution and completing your game OB

Cheers

Frazzle
Posted By: xXxGuitar511

Re: How do you display shadows on invisible surfac - 07/23/07 21:15

Well, if we can make a model invisible for rendering, but keep it in the z-buffer, can we not do the opposite? Let it render, but keep it out of the z-buffer so that shadows are not cast onto it?

...of course this would probably not render correctly, and possibly on top of everything else
Posted By: Orange Brat

Re: How do you display shadows on invisible surfac - 07/24/07 22:20

@xXx:

Take a look at the game Secret Files: Tunguska. I'm not recommending it because of how it may or may not relate to the technology discussed in this thread, but instead as a heads up to a modern adventure game that gets the UI right. The mouse management and space bar hint system is 2nd to none. Just about every review of this game, whether it was positive or negative, was highly positive about these two particularly aspects.

Myself, I loved the hint system. All it did was when you pressed and held down the space bar, all of the available interactive spots and exits would be highlighted. In fact, if you check out the official site, it is a Flash site and uses one of the backgrounds, and if you press and hold down the space bar, it highlights everything (that was an awkward sentence ). The mouse management is probably the best implemented "smart cursor" I've ever seen in the the genre.

Anyway, there's a demo if you want to try it out first hand.

http://www.secretfiles-game.com/
Posted By: xXxGuitar511

Re: How do you display shadows on invisible surfac - 07/28/07 19:19

YES! I've got it running... it works.


Once I get more stuff in the level (fix a few bugs), I'll put a lil example up.

I also wrote a new shader (which I'll post in UC for free soon). Per Pixel lighting. 4 lights in one pass, the other 4 in the second pass, as well as sunlight. Soon I'll add NM to it. The shader also includes a variable for scaling light brrightness, which can give some nice effects...

I'm really happy with the results I'm getting. It looks just as if it were 3D (which it is, but you know what I mean)... Now I just need to improve my level design skills.
Posted By: frazzle

Re: How do you display shadows on invisible surfac - 07/28/07 21:37

Great to hear Guitar, I'm very curious to see the exactitude of your solution

Cheers

Frazzle
Posted By: Orange Brat

Re: How do you display shadows on invisible surfac - 07/28/07 21:46

Keep us posted. Is your UC going to contain all of the code for the subject of this thread?
Posted By: xXxGuitar511

Re: How do you display shadows on invisible surfac - 07/29/07 05:41

Unfortunatly, no (or at least not yet)...

I'm only planning on releasing the shader for now (but first I want to add some more features). And by shader, I mean a simple per-pixel shader. It's not much, but it looks great and is mainly designed for levels (or other objects with large faces). I'm going to first try and find a way to switch shademode without needing to shaders (just for simplicity's sake)...

I may release my 2.5D scripts (as a "sort-of" template. Once I get it mostly scripted, I'm going to add some panel for ease of use. I'm not sure if I'll release it for free or [try to] sell it though. If I decide to sell it, then it'll be cheap ($10 or less). While I do need the money, I try to be generous

I'll post any updates (maybe in this thread, possibly a new one, we'll see how far it's gotten)...


...I'll try to get a compiled demo soon.
Posted By: RyuMaster

Re: How do you display shadows on invisible surfaces - 09/12/08 14:21

Exccelent script, thanks! Very usefull for 2.5D games.
© 2024 lite-C Forums