News UnrealEd Files Mods FragBU Liandri Archives
BeyondUnreal Forums

Go Back   BeyondUnreal Forums > Unreal Development > Coding

Reply
 
Thread Tools Display Modes
Old 19th Jul 2003, 06:35 PM   #1
inio
many fauceted scarlet emerald
 
inio's Avatar
 
Join Date: Feb. 8th, 2002
Location: CA, USA
Posts: 105
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.
inio is offline   Reply With Quote
Old 19th Jul 2003, 08:28 PM   #2
X
Soul on Ice
 
X's Avatar
 
Join Date: Apr. 24th, 2000
Location: ON,CA
Posts: 368
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.
X is offline   Reply With Quote
Old 19th Jul 2003, 08:30 PM   #3
inio
many fauceted scarlet emerald
 
inio's Avatar
 
Join Date: Feb. 8th, 2002
Location: CA, USA
Posts: 105
Quote:
Originally Posted by X
unless you want to do some coding
I was expecting it to involve some UnrealScript, but I couldn't find the variables that determine the shadow direction.
__________________
"He who breaks a thing to find out what it is, has left the path of wisdom."
- Gandalf the Gray-Hat
inio is offline   Reply With Quote
Old 20th Jul 2003, 10:58 AM   #4
Dr. Nick
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.
Dr. Nick is offline   Reply With Quote
Old 21st Jul 2003, 01:51 PM   #5
inio
many fauceted scarlet emerald
 
inio's Avatar
 
Join Date: Feb. 8th, 2002
Location: CA, USA
Posts: 105
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
inio is offline   Reply With Quote
Old 22nd Jul 2003, 06:39 AM   #6
inio
many fauceted scarlet emerald
 
inio's Avatar
 
Join Date: Feb. 8th, 2002
Location: CA, USA
Posts: 105
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.
inio is offline   Reply With Quote
Old 22nd Jul 2003, 06:56 AM   #7
Mychaeel
 
Join Date: Oct. 3rd, 2001
Location: Frankfurt/Main, Germany
Posts: 3,829
Wow---this is extremely cool.

Mind putting that on the Wiki?
Mychaeel is offline   Reply With Quote
Old 22nd Jul 2003, 07:17 AM   #8
inio
many fauceted scarlet emerald
 
inio's Avatar
 
Join Date: Feb. 8th, 2002
Location: CA, USA
Posts: 105
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
inio is offline   Reply With Quote
Old 22nd Jul 2003, 07:56 AM   #9
Mychaeel
 
Join Date: Oct. 3rd, 2001
Location: Frankfurt/Main, Germany
Posts: 3,829
I think [Sourced Player Shadows]? would be better.

Sleep well.
Mychaeel is offline   Reply With Quote
Old 22nd Jul 2003, 07:32 PM   #10
[SAS]Solid Snake
Registered User
 
[SAS]Solid Snake's Avatar
 
Join Date: Jun. 7th, 2002
Location: New Zealand
Posts: 2,633
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]
__________________
I make the impossible possible ... ... ... to some extent.

Digital Confectioners

Last edited by [SAS]Solid Snake; 22nd Jul 2003 at 07:39 PM.
[SAS]Solid Snake is offline   Reply With Quote
Old 22nd Jul 2003, 11:10 PM   #11
MythOpus
You Have Witnessed The MythMaster @ Work
 
MythOpus's Avatar
 
Join Date: Jul. 22nd, 2003
Location: Canada
Posts: 19
Quote:
Originally Posted by inio
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!

........
Hey Inio. This thing does look cool and when all the bugs are squished out of it, it'll give us mappers a whole new depth of realism to work with Oh and BTW thx for making me want to reply so badly to make me want to get an account on BuF
MythOpus is offline   Reply With Quote
Old 23rd Jul 2003, 01:26 AM   #12
[SAS]Solid Snake
Registered User
 
[SAS]Solid Snake's Avatar
 
Join Date: Jun. 7th, 2002
Location: New Zealand
Posts: 2,633
BTW, I found out that if you use this for all the objects in the map, it runs super slow...
__________________
I make the impossible possible ... ... ... to some extent.

Digital Confectioners
[SAS]Solid Snake is offline   Reply With Quote
Old 23rd Jul 2003, 02:35 AM   #13
inio
many fauceted scarlet emerald
 
inio's Avatar
 
Join Date: Feb. 8th, 2002
Location: CA, USA
Posts: 105
Quote:
Originally Posted by [SAS]Solid Snake
BTW, I found out that if you use this for all the objects in the map, it runs super slow...
Yeah. You don't want to be doing more than probably a dozen or so projections per frame, especially if they're onto high-poly static meshes. I was also planning on using blob shadows for anything besides players, as the difference between a blob shadow of a grenade and a bitmap shadow of a grenade would be barely noticeable in-game. Looking at screenshots you could tell the difference, but that isn't what counts.

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.
inio is offline   Reply With Quote
Old 23rd Jul 2003, 03:07 AM   #14
Dark[NSF]
Northwest Secessionalist Forces
 
Dark[NSF]'s Avatar
 
Join Date: Mar. 12th, 2003
Location: Melbourne, Florida
Posts: 632
Wait, I don't fully understand the features... Could you explain inio? Or add a screenshot showing it? Thanks.
__________________
http://www.ReignofMilitias.com

webevolved.com || ICQ: 96970935
Dark[NSF] is offline   Reply With Quote
Old 23rd Jul 2003, 03:12 AM   #15
inio
many fauceted scarlet emerald
 
inio's Avatar
 
Join Date: Feb. 8th, 2002
Location: CA, USA
Posts: 105
Quote:
Originally Posted by Dark[NSF]
Wait, I don't fully understand the features... Could you explain inio? Or add a screenshot showing it? Thanks.
Just posted to the top of the thread, might as well post it to the bottom to:



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
inio is offline   Reply With Quote
Old 23rd Jul 2003, 04:24 AM   #16
Dark[NSF]
Northwest Secessionalist Forces
 
Dark[NSF]'s Avatar
 
Join Date: Mar. 12th, 2003
Location: Melbourne, Florida
Posts: 632
woops ^_^
__________________
http://www.ReignofMilitias.com

webevolved.com || ICQ: 96970935
Dark[NSF] is offline   Reply With Quote
Old 23rd Jul 2003, 04:42 AM   #17
punk129
!!!!!!!!!!!11111111111
 
punk129's Avatar
 
Join Date: Jan. 18th, 2003
Location: Germany
Posts: 172
Looks very cool, I'm waiting for your map example
punk129 is offline   Reply With Quote
Old 23rd Jul 2003, 05:08 AM   #18
inio
many fauceted scarlet emerald
 
inio's Avatar
 
Join Date: Feb. 8th, 2002
Location: CA, USA
Posts: 105
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
inio is offline   Reply With Quote
Old 23rd Jul 2003, 08:25 PM   #19
[SAS]Solid Snake
Registered User
 
[SAS]Solid Snake's Avatar
 
Join Date: Jun. 7th, 2002
Location: New Zealand
Posts: 2,633
It might be this value, http://udn.epicgames.com/pub/Content...ectOnBackfaces bProjectOnBackFaces.
__________________
I make the impossible possible ... ... ... to some extent.

Digital Confectioners
[SAS]Solid Snake is offline   Reply With Quote
Old 23rd Jul 2003, 10:00 PM   #20
inio
many fauceted scarlet emerald
 
inio's Avatar
 
Join Date: Feb. 8th, 2002
Location: CA, USA
Posts: 105
Quote:
Originally Posted by [SAS]Solid Snake
It might be this value, http://udn.epicgames.com/pub/Content...ectOnBackfaces bProjectOnBackFaces.
Way ahead of you there .
__________________
"He who breaks a thing to find out what it is, has left the path of wisdom."
- Gandalf the Gray-Hat
inio is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 04:29 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.

Copyright ©1998 - 2012, BeyondUnreal, Inc.
Privacy Policy | Terms of Use
Bandwidth provided by AtomicGamer