Shadow volume shader optimization

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Post Reply
Viz_Fuerte
Posts: 91
Joined: Sun Oct 19, 2008 5:29 pm
Location: Valencia (Spain)
Contact:

Shadow volume shader optimization

Post by Viz_Fuerte »

Hi.

It's becoming an obsession with the issue of how to get a good system of shadows with Irrlicht, since it is the best engine for easy handling and powerful, but don't have a system of shadows decent.

I am working in a volume shadow system, that you are using a lot of games and engines, using a shader for create the extruded. If all goes well, in the future, one could integrate.

Improvement:
Current shadow volume - 104 FPS with 5472 triangles
GPU shadow volume - 540 FPS with 5472 triangles

Here I leave a link to the example, is not definitive and needs many adjustments.
http://www.elcreadordavid.hostei.com/pr ... rusion.zip

There are several flaws and is not to be, so I hope your comments and maybe solutions Smile
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Cool, in my new system I will be adding some more options in the interface for shadowing types, so maybe I can integrate this and add GPU extrusion as an option.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Viz_Fuerte
Posts: 91
Joined: Sun Oct 19, 2008 5:29 pm
Location: Valencia (Spain)
Contact:

Post by Viz_Fuerte »

If this works, I would like to be integrated directly into the source code of the Irrlicht and not by any external system.

BlindSide@ I have nothing against your library, but is easier using the same command to generate the shadows as it is doing so far :wink:
DeM0nFiRe
Posts: 117
Joined: Thu Oct 16, 2008 11:59 pm

Post by DeM0nFiRe »

I tried it out, I actually get about 2,600 FPS constant, however, as you noted there are some flaws. The shadows were not continuous and there were some spots where shadows would not be cast at all. If you'd like, I can screenshot it, unless you already know about those two issues.

Oh, it might be relevant to note I am using ATI's preview OpenGL 4.0 drivers.
Viz_Fuerte
Posts: 91
Joined: Sun Oct 19, 2008 5:29 pm
Location: Valencia (Spain)
Contact:

Post by Viz_Fuerte »

I do not think you need to view an image that shows errors, i know that there are many :oops: , but thanks.

The important thing is to know where the error if the effect or how to obtain the shadow.

Here I show the code in GLSL, that I am using (only work in ARB):

Code: Select all

void main()
{
  vec3 lightDir = (gl_ModelViewMatrix * gl_Vertex 
                   - gl_LightSource[0].position).xyz;

	// if the vertex is lit
	float dt = dot(lightDir, gl_NormalMatrix * gl_Normal);
	if ( dt <0.01 )
	{
		// don't move it
    	gl_Position = ftransform();
	}
	else 
	{
		// move it far, is the light direction
		vec4 fin = gl_ProjectionMatrix * (
                 gl_ModelViewMatrix * gl_Vertex 
                 + vec4(normalize(lightDir) * 100000.0, 0.0)
               );

		// if fin is behind the far plane
		if ( fin.z > fin.w )
      		fin.z = fin.w; // move to the far plane (needed for z-fail algo.)

		gl_Position = fin;
	}
}
I hope someday to work properly :)
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Viz_Fuerte wrote:If this works, I would like to be integrated directly into the source code of the Irrlicht and not by any external system.

BlindSide@ I have nothing against your library, but is easier using the same command to generate the shadows as it is doing so far :wink:
I wasn't referring to my library XEffects, but the shadow system I am working on for Irrlicht.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
grumpymonkey
Posts: 222
Joined: Mon Jan 19, 2009 10:03 pm
Location: Miami, Florida
Contact:

Post by grumpymonkey »

wow this is really good, I got +1000 FPS with 15k triangles
Image

But it did seem a little buggy, idk but it seems like cylinder in the middle is cutting up the shadows, or, has an inverted shadow :\

btw, thats one creepy ass avatar xD
Image
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Post by devsh »

i think you're kinda missing the point with this shadowing, as I can see that the shadows are being drawn ON. A real shadow prevents a direct light ray from hitting a surface, therefore a real shadow would cause the phong or lambertian shading function to return 0 for both specular and diffuse. As I can see from the image both are present within the shadow but are dimmed down.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

He just optimized the standard shadow system in Irrlicht so it doesn't make sense that he should take all that into account.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Viz_Fuerte
Posts: 91
Joined: Sun Oct 19, 2008 5:29 pm
Location: Valencia (Spain)
Contact:

Post by Viz_Fuerte »

Hi :P

devsh@
As say BlindSide, I just want optimize the creation of shadows as does the Irrlicht. I know how to create shadows using the stencil buffer to make them look like Doom3, but that requires more complex and multipass, something that sounds not good.

For now I'm still "trying" to make this work but I am not very professional in this.
Erelas
Competition winner
Posts: 20
Joined: Mon Apr 18, 2011 8:40 am

Re: Shadow volume shader optimization

Post by Erelas »

This looks good! Any chance you could re-upload this?
I would like to see if I can integrate this into our game.
nespa
Posts: 167
Joined: Wed Feb 24, 2010 12:02 pm

Re: Shadow volume shader optimization

Post by nespa »

Hi,

has someone the source for the 1'st post ? ( ShadowVolumeExtrusion.zip )
zerosang
Posts: 2
Joined: Sat May 23, 2009 12:39 pm

Re: Shadow volume shader optimization

Post by zerosang »

nespa
Posts: 167
Joined: Wed Feb 24, 2010 12:02 pm

Re: Shadow volume shader optimization

Post by nespa »

many many thanks !!!!
Post Reply