![]() |
|
|
#1 |
|
controling the direction of player shadows
is it possible to control what direction player shadows are cast in and maybe even their opacity? I'm working on a map that has a few dark areas with just a general glow, and would like to be able to either make the shadows show up directly below the player, or make them much less contrasty. I also have a few areas with a bright light in the center of the room and it looks weird when the shadow of a player falls towards that light.
edit: Here's a screenshot to let new people know what this is about right off the bat. Scroll down for details.
__________________
"He who breaks a thing to find out what it is, has left the path of wisdom." - Gandalf the Gray-Hat Last edited by inio; 23rd Jul 2003 at 02:54 AM. |
|
|
|
|
|
|
#2 |
|
What you want isn't possible, the shadows for the player model are completly static, so unless you want to do some coding you'll just have to concider the shadows the same way most of us do, and that's useless and only there for show.
__________________
Illumination, not education will bring the blind sight. |
|
|
|
|
|
|
#3 | |
|
Quote:
__________________
"He who breaks a thing to find out what it is, has left the path of wisdom." - Gandalf the Gray-Hat |
||
|
|
|
|
|
#4 |
|
Registered User
Join Date: Oct. 5th, 2002
Location: GA
Posts: 169
|
There are variables that control the light source position that determine the projection of the shadow. Unfortunately I do not remember them, but I do know they exist because someone posted the variables and a picture of it being done in game. I think it had something to do with the shadow script itself. Have a look around at it.
(edit) Well a quick search of the source found the file. ShadowProjector.uc under engine\classes. Here are the variables: var() Actor ShadowActor; var() vector LightDirection; var() float LightDistance; var() bool RootMotion; var() bool bBlobShadow; var() bool bShadowActive; Last edited by Dr. Nick; 20th Jul 2003 at 11:09 AM. |
|
|
|
|
|
#5 |
|
Thanks. I was incorrectly assuming it was mostly done in the game engine, so I didn't look for extra classes. I've already got something working, but it has several issues I wanna resolve before I publish it.
__________________
"He who breaks a thing to find out what it is, has left the path of wisdom." - Gandalf the Gray-Hat |
|
|
|
|
|
|
#6 |
|
OK, here's what I have so far.
Not all the exposed variables do anything, and it probably still has some bugs, but at least it works: http://www.inio.org/~inio/dynamicshadows.zip That includes a map thats little demo, and source scripts. For some reason I didn't include the myLevel.u package to make it easy to include in your own maps, but I've got a workaround for that in a bit. If you're just in it for the tech demo, load up the map single player no bots and type "behindview 1" at the console. Now walk around and watch the shadows change to reflect the local lighting. Weeee! If you're thinking of using this tech in your own map, the most important thing to know is that each DynamicShadowVolume creates a shadow for each player within it, source at the most important ShadowCaster (typ. ShadowLight) with the same Tag. Each DynamicShadowVolume will create only one shadow for each player within it. As a side effect if you have multiple intersecting DynamicShadowVolumes, players within them will have multiple shadows. ShadowCaster exists to be subclassed. I didn't create a ShadowSpotLight yet, but it wouldn't be hard. To use this in your own map, first load the sample map into UnrealEd, then load your map. Now place a DynamicShadowVolume and a ShadowLight somewhere in your map. Always make sure before saving that there is at least one DynamicShadowVolume and one ShadowLight in the map. Loading the sample map as a script package is not advised, as I've had very odd behavior when I've done that in the past. Features: - Should be pretty easy for mappers to pick up and use. - Shadows fade out after leaving a zone. - Mapper can control shadow casting distance, whether shadows should fade as they approach parallel with the surface, and whether to draw the shadow using blob shadow mode. Ideas: - Add shadows to all actors with DrawType=DT_Mesh. This should be possible, but making it work reliably and not shadow the wrong things could be hard. - Add shadows for first-person. This would be harder from what I can tell, and would cause the odd effect of shadows from your nonexistent legs when you look down. - figure out a nice way of attaching a Light to a mover, as the code right now doesn't care if it's the light or the player that's moving. - (WiP) Make it so a single DynamicShadowVolume can create multiple shadows for an object up to some fixed maximum. This would reduce the number of volumes required but complicate the DSVShadowProjector script a bit and provide means for quality dropping. - colored shadows for colored lights. (maybe with some silly Material stuff?) - to reduce load in situations where you have 2 or more shadow sources close together to create shadows appropriate for a non-point light: share the shadow texture between them so it only gets rendered once. Known Issues: - If a player gets too close to a light the shadow doesn't behave quite right. This is due to a limit on the projector FOV. Without this there would be potential for enormous cpu load when an actor got too close to a light and the FOV of the shadow projector aproached 180, resulting in a slice of the level between the plane of the shadow projector and the plane at the trace distance being considered for shadow casting. Right now the FOV is limited to about 100 (not sure of the exact number). - (fixed) Shadows pop up when you enter a DynamicShadowVolume that has a light to close to it's edge. Same thing for the default shadow disappearing and reappearing when you enter and exit DynamicShadowVolumes (not visible in the sample map). - Right now there's still a few DefaultValues that need to be set to make mappers' lives easier. - (untested but I assume this is the case) If a player is occluded and therefore not drawn, their shadows will also not be drawn. While it would be really cool to use a ground light shining up at a wall to give a hint of player's locations without directly showing them, this could be a PITA to get working reliably. - Blob shadows don't fade Not possible? - shadows for particles (even if it were possible, it would be an enormous CPU hog). - blurry shadows for non-point light sources. (again, maybe a Material trick to get this working without being a CPU hog?). Maybe by setting a over-large FOV on the BitmapShadowTexture and using a raw material to scale that up to fill the shadow appropriate area? Questions - This shouldn't add any bandwidth overhead in net games as it happens entirely on the client side, but I'd like someone with more experience with replication to validate that.
__________________
"He who breaks a thing to find out what it is, has left the path of wisdom." - Gandalf the Gray-Hat Last edited by inio; 23rd Jul 2003 at 05:25 AM. |
|
|
|
|
|
|
#7 |
|
Join Date: Oct. 3rd, 2001
Location: Frankfurt/Main, Germany
Posts: 3,829
|
|
|
|
|
|
|
#8 |
|
Yeah, I was kinda struck by how cool it looks, even in the silly little testing environment. Btw, it definitely is going up on the wiki when I have time. (I already mention it in my dev journal). How does "Dynamic Shadows" sound for a title? Right now I need to sleep.
__________________
"He who breaks a thing to find out what it is, has left the path of wisdom." - Gandalf the Gray-Hat |
|
|
|
|
|
|
#9 |
|
Join Date: Oct. 3rd, 2001
Location: Frankfurt/Main, Germany
Posts: 3,829
|
|
|
|
|
|
|
#10 |
|
I did this a while back, in the early stages of my Stairs Dismount code. Anyways, I just used a vector before hand to simply place the location of the source. To get the shadow caster to move, because it extends the light class, it has bStatic and bNoDelete set so that the light doesn't delete and it doesn't move I believe. Since all your using the light for is to set certain values (the defs) and the location of it, you could just change it to a standard actor. I noticed that you also used some values from the light, one way to associate the shadow caster to the light is to get the mapper to set the tag.
Only other real problems with moving lights is that if the light casts raytraced shadows, they won't be affected since it is just a light map in the end... but for dynamic shadows it should work like a treat. Good work!!! I like it ... I figured out how to get the light to be sourced, but I couldn't figure out how to change some values like the FOV and the Darkness properly. Would it be alright if I made changes to my own light code [Credits of course to you] Last edited by [SAS]Solid Snake; 22nd Jul 2003 at 07:39 PM. |
|
|
|
|
|
|
#11 | |
|
Quote:
Oh and BTW thx for making me want to reply so badly to make me want to get an account on BuF
|
||
|
|
|
|
|
#12 |
|
BTW, I found out that if you use this for all the objects in the map, it runs super slow...
|
|
|
|
|
|
|
#13 | |
|
Quote:
One other thing that would be possible is to make explosions cast shadows. I specifically made the actual shadow logic separate from the DynamicShadowVolume stuff, so it's possible to cast shadows without a volume involved. Is there anything like SpawnNotify in UT2003? I was thinking I could watch for the explosion effect to be created and add a shadow caster for them and appropriate shadow projectors for visible actors? what's the "right way" to do this?
__________________
"He who breaks a thing to find out what it is, has left the path of wisdom." - Gandalf the Gray-Hat Last edited by inio; 23rd Jul 2003 at 02:42 AM. |
||
|
|
|
|
|
#14 |
|
Wait, I don't fully understand the features... Could you explain inio? Or add a screenshot showing it? Thanks.
|
|
|
|
|
|
|
#15 | |
|
Quote:
![]() Right now I'm working on a playable map (simple DM map) that will show it off in a more accessible way.
__________________
"He who breaks a thing to find out what it is, has left the path of wisdom." - Gandalf the Gray-Hat |
||
|
|
|
|
|
#16 |
|
woops ^_^
|
|
|
|
|
|
|
#17 |
|
Looks very cool, I'm waiting for your map example
|
|
|
|
|
|
|
#18 |
|
Here's another one:
![]() I know the shadow on the wall should be darker. I've got some ideas of how to get it darker (mostly turning off bGradient and tracking the MaxTraceDistance to match the first wall hit). Another slightly higher cpu- and gpu- load solution is to split it into two projectors, one that's bGradient=false for the first bit of distance, and another that's bGradient=true for the rest of it. There might be a visible seam between them though... Before I play with that though, I'm going to get multiple shadows per DSV working.
__________________
"He who breaks a thing to find out what it is, has left the path of wisdom." - Gandalf the Gray-Hat |
|
|
|
|
|
|
#19 |
|
It might be this value, http://udn.epicgames.com/pub/Content...ectOnBackfaces bProjectOnBackFaces.
|
|
|
|
|
|
|
#20 | |
|
Quote:
.
__________________
"He who breaks a thing to find out what it is, has left the path of wisdom." - Gandalf the Gray-Hat |
||
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|