[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4787: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4789: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4790: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4791: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
InsideQC Forums • View topic - Stencil shadow deformation based on lighting direction

Stencil shadow deformation based on lighting direction

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

Stencil shadow deformation based on lighting direction

Postby Jay Dolan » Mon Nov 25, 2013 4:56 am

I posted this on SO, but this might actually be the best crowd to run this by. I've calculated an average light direction for my mesh entities, and I'd like to deform their stencil shadows away from the light source. Here's the issue I posted on StackOverflow:

http://stackoverflow.com/questions/2018 ... ght-source

Any insight you guys can share would be much appreciated!
User avatar
Jay Dolan
 
Posts: 59
Joined: Tue Jan 22, 2008 7:16 pm
Location: Naples, FL

Re: Stencil shadow deformation based on lighting direction

Postby Spike » Mon Nov 25, 2013 6:56 am

I assume you're after projected shadows and not shadow volumes?

something like http://www.opengl.org/archives/resource ... sld021.htm ? you'll still need to combine that with a model and projection matrix, probably by multiplying that matrix into the (model)view matrix at some point.

z-pass shadow volumes need just the sides, which requires that only some verts are extruded based upon the light position. z-fail needs front+back as well, but if you're already generating sides then its simpler to keep the front+back caps as part of the same mesh/batch. aside from you calling it 'stencil shadows', your matrix stuff seems unrelated...
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Stencil shadow deformation based on lighting direction

Postby Irritant » Sat Nov 30, 2013 4:24 pm

Jay, CRX used to have exactly the code you're looking for, where the stencil shadows were stretched/deformed based on light direction, for a very fast, simple method of shadowing. I think that code was in the engine in SVN around 2006-2010, it was pretty efficient and fast, which is what I assume you're going for. Only issue was of course that it didn't project on walls, or get clipped on the edges of brushes, etc, but that was the tradeoff for speed vs true shadow volumes.
http://red.planetarena.org - Alien Arena and the CRX engine
Irritant
 
Posts: 250
Joined: Mon May 19, 2008 2:54 pm
Location: Maryland

Re: Stencil shadow deformation based on lighting direction

Postby Knightmare » Sun Dec 01, 2013 6:48 pm

Knightmare
 
Posts: 63
Joined: Thu Feb 09, 2012 1:55 am

Re: Stencil shadow deformation based on lighting direction

Postby jitspoe » Sun Dec 01, 2013 10:51 pm

What many engines refer to as "stencil shadows" are the planar shadows, but rendered to the stencil buffer to avoid the ugly zfighting the original shadows had.

jitspoe
 
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: Stencil shadow deformation based on lighting direction

Postby Knightmare » Mon Dec 02, 2013 7:09 am

Last edited by Knightmare on Wed Dec 04, 2013 5:20 am, edited 2 times in total.
Knightmare
 
Posts: 63
Joined: Thu Feb 09, 2012 1:55 am

Re: Stencil shadow deformation based on lighting direction

Postby Barnes » Tue Dec 03, 2013 8:36 am

User avatar
Barnes
 
Posts: 232
Joined: Thu Dec 24, 2009 2:26 pm
Location: Russia, Moscow

Re: Stencil shadow deformation based on lighting direction

Postby Knightmare » Wed Dec 04, 2013 5:22 am

It originally came from Quake2Max, right?

BTW, KMQ2 does all 3 variants: static planar, dynamic planar, and volume projection shadows.
Knightmare
 
Posts: 63
Joined: Thu Feb 09, 2012 1:55 am

Re: Stencil shadow deformation based on lighting direction

Postby Barnes » Wed Dec 04, 2013 8:51 am

User avatar
Barnes
 
Posts: 232
Joined: Thu Dec 24, 2009 2:26 pm
Location: Russia, Moscow

Re: Stencil shadow deformation based on lighting direction

Postby leileilol » Thu Dec 05, 2013 1:41 am

I think even Quake3 does this with cg_shadows 2.
leileilol
 
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Re: Stencil shadow deformation based on lighting direction

Postby Barnes » Thu Dec 05, 2013 8:22 am

cg_shadows 1 - planar blob shadow
cg_shadows 2 - projective shadow volumes (zpass) shadows hit through the walls
cg_shadows 3 - opacity projective planar shadow
User avatar
Barnes
 
Posts: 232
Joined: Thu Dec 24, 2009 2:26 pm
Location: Russia, Moscow


Re: Stencil shadow deformation based on lighting direction

Postby Barnes » Fri Dec 06, 2013 10:45 am

Very nice, but i'm don't understand one thing - it's not shadow volumes, right?
User avatar
Barnes
 
Posts: 232
Joined: Thu Dec 24, 2009 2:26 pm
Location: Russia, Moscow


Re: Stencil shadow deformation based on lighting direction

Postby Spike » Fri Dec 06, 2013 2:30 pm

gl3+ method (according to docs. seems to fail on nvidia):
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_STENCIL, GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE, &someinteger);
deprecated method (which fails on a core context):
glGetIntegerv(GL_STENCIL_BITS, &someinteger);

with d3d10+, microsoft document:
DXGI_FORMAT_D32_FLOAT_S8X24_UINT
DXGI_FORMAT_D32_FLOAT
DXGI_FORMAT_D24_UNORM_S8_UINT
DXGI_FORMAT_D16_UNORM
which means they don't consider that hardware could support any sorts of depthstencil configuration with stencil bits other than 0 or 8bit.
of course, there's nothing stopping you from asking for more than 8 bits from gl. you probably won't get it though.
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Next

Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 2 guests