Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1390776 Posts in 66778 Topics- by 59517 Members - Latest Member: Kettu18

April 12, 2021, 04:35:48 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Making the shadows
Pages: [1]
Print
Author Topic: Making the shadows  (Read 3807 times)
DanDanger
Level 0
**



View Profile
« on: November 29, 2007, 09:42:42 AM »

I want some nice shadows in my game, and ive decided that I likes the look of stencil shadows rather than shadow volumes, because they are much easier to implement and I cant be bothered with all the silohouete edge calculation shenanigans.

Was wondering if anyone had implemented stencil shadows before and had any advice for ome ^_^
Logged
Bad Sector
Level 3
***


View Profile WWW
« Reply #1 on: November 29, 2007, 11:52:37 AM »

Stencil shadows = shadow volumes, usually :-P.

Another option would be to project the geometry of your object on the plane you wish to receive the shadow (yes, this can be used only with planes), clear your stencil buffer to zero, enable stencilling, set your stencil function to GL_ALWAYS with ref=1, set your stencil operator to GL_REPLACE, render the projected shadow geometry, set your stencil operator to GL_ZERO, set your stencil function to GL_EQUAL with ref=1 and mask=1, draw a semi transparent quad over the screen, disable stencilling and you're ok.

Note 1: when i'm talking about stencil operator, i'm talking about the success operator. Use the default values for the rest of the arguments.

Note 2: prefer the glStencil<blah>Separate over non-separate with GL_FRONT_AND_BACK where available.

Note 3: make sure you put a small polygon offset value with glPolygonOffset before rendering the projected geometry, to avoid zfighting with the existing geometry on the plane.

Note 4: if you don't mess with the stencil more than this, you may not need to clear your stencil buffer in each frame because the GL_ZERO operation will clear it anyway.

Note 5: you don't need to do this for every light; just project the geometries for all lights - this should look good, unless an object is affected by two lights, in which case the area that is not affected by both lights won't be darker).

Note 6: i just came up with the whole thing, it might not work :-)
Logged

~bs~
moi
Level 10
*****


DILF SANTA


View Profile WWW
« Reply #2 on: November 30, 2007, 09:00:01 AM »

Are you sure you want to create your own engine? there are a couple of not so bad existing engines with nice shadowing, check out C4 for example.
Logged

subsystems   subsystems   subsystems
Bad Sector
Level 3
***


View Profile WWW
« Reply #3 on: November 30, 2007, 01:10:53 PM »

I wouldn't recommend C4, it's *very* slow for what it provides. The only system where it could produce "playable" framerate was the GeForce 8800 GTS equipped Pentium 4 c2duo machine i have at work.
Logged

~bs~
PoV
Level 5
*****


Click on the eye and something might happen..maybe


View Profile WWW
« Reply #4 on: November 30, 2007, 02:18:22 PM »

Well, if volumes come up again, there's an interesting article I've stolen from the "Bump Mapping Pixel Art" post on 2D Soft Shadows. 

http://www.gamedev.net/reference/programming/features/2dsoftshadow/


Are you sure you want to create your own engine?

Play Keith goes PaintingWink
Logged

Mike Kasprzak | Sykhronics Entertainment - Smiles (HD), PuffBOMB, towlr, Ludum Dare - Blog
DanDanger
Level 0
**



View Profile
« Reply #5 on: December 01, 2007, 05:04:47 AM »

Thanks for the replies, I sometimes think it takes me talking about something to get me to actually make the dam thing ^_^

I have been looking at the ogre 3d engine and fine it looks, however using a new graphics engine is a big change and all i really want is some shadows.

Im making a kind of 3d platform game but it is viewed from the side giving a kind of 2d feeling to the whole thing. Kind of like on of those cross section diagrams you get of old castles and submarines and such.

I want my world to look "super solid" and a good shadow system is key to that i believe. Well that and good lighting.

The game im working on (keith goes painting 2) was originally entirely in 2d but I have changed it so the player can move in and out of the screen (so entirely 3d really) I am also having to change me 2d physics system (based on the fantastic box2d) to a 3d one and I am looking at the Bullet physics system which seems pretty well used.
Logged
Golds
Loves Juno
Level 9
*


Juno sucks


View Profile WWW
« Reply #6 on: December 01, 2007, 07:09:34 AM »

I tried both a stencil and shadow mapping method for Rotrix.  The volume stencil buffer method was quicker to implement, but the disadvantage is that you're stuck with a uniform colored shadow (for each light) with no soft edges.

Stencil Shadows


In Rotrix, I wanted the shadows to always get cast "down", from an imaginary light source to help convey depth orientation for the player.  I raycast down for each pixel in a texture map for each platform that can receive a shadow to see whether or not to paint it.  Each platform gets it's own appropriately sized texture map for shadows, and you can draw to them with blending and such for variance in intensity.  At the moment soft edges come as a side effect from scaling up la low resolution texture in opengl, but you could also run a blur over your shadow textures as well.

Shadow Maps


You might be able to do something like this for your game if I'm imagining it right from your description.  Mario Galaxy always always renders shadows in the direction of gravity, so you'd be in good company.

Anyway, the Wikipedia articles on both techniques helped me: Stencil Shadow Volumes, Shadow Mapping

Logged

@doomlaser, mark johns
moi
Level 10
*****


DILF SANTA


View Profile WWW
« Reply #7 on: December 01, 2007, 07:24:25 AM »

For those who use Blitz3D (which I know the OP probably doesn't) there are a couple of very sweet stencil(?) shadow system third party libraries, I recomend Devil's shadow system (free). He also made a physic engine.
Logged

subsystems   subsystems   subsystems
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic