Shadows with reversed triangle facing

Shadows with reversed triangle facing

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Shadows with reversed triangle facing

Post by Beherith »

I wish to thank the developers, specifically jK who revamped the shadow code and made its transformation matrix linear, for their valuable time and effort invested into improving engine features.

I would like to ask if the possibility of reversing the triangle facing on the shadow map would be possible?

Because currently many of Mr Bobs wonderful remakes have non closed volumes, and the shadows look buggy on those because of the shadowmap triangle direction inversion.

I feel that making the tri's on these models double sided would be very wasteful wrt. to tri count.

I know this next question will sound dumb, but is it possible to have the vertex shader animations done in lua unit rendering to pass along to the shadows and have the shadows be animated corresponding to the units? It may just have been me who screwed up this part, but I couldnt get this to work.

See the following screenshot for details.
shadowflip.jpg
shadowflip.jpg (11.9 KiB) Viewed 2031 times
cranphin
Posts: 136
Joined: 13 Jun 2005, 16:37

Re: Shadows with reversed triangle facing

Post by cranphin »

Where does this model come from and how do I put it in a game? :)
I'm curious to see what it looks like in master :)
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Shadows with reversed triangle facing

Post by Beherith »

The model is Mr Bobs core air repair pad. Checkout the mod from google code here: http://code.google.com/p/baremake/
cranphin
Posts: 136
Joined: 13 Jun 2005, 16:37

Re: Shadows with reversed triangle facing

Post by cranphin »

Tried it on master (b182bcbd686aef8e5913), sadly pretty much the same result:
shadows.jpg
(122.76 KiB) Downloaded 2 times
Was hoping it might be fixed with new shadow code, but alas :)
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Shadows with reversed triangle facing

Post by Beherith »

Tried it it master too, though the shadows are much nicer now (linear :D) they still are back faced.

Is there a technical reason for the back faced shadowing? Like if front faces were used then everything would shadow itself?
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Shadows with reversed triangle facing

Post by Beherith »

Wierd, its set the right way with features...

Image
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Shadows with reversed triangle facing

Post by Kloot »

That's not so strange, face-culling is disabled for features of any type during the shadow pass (because features are often modelled trees with non-manifold surfaces, and their shadows would otherwise look like those in your screenshots). Also, 3DO models of old tended to have gaps in them that became exposed with culling enabled.

For units the back-faces are always culled in both normal and shadow rendering (http://imageshack.us/f/546/screen00001.png), there is no "triangle direction inversion" (anymore). You only notice this in the shadow projection if a model is not a closed volume.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Shadows with reversed triangle facing

Post by jK »

Kloot wrote:there is no "triangle direction inversion" (anymore)
Shouldn't the shadowmap then contain exactly the same triangles as the onscreen buffer?
In BD's examples the sun is above the units and so the sun looks on the _front_ faces. But they obviously aren't rendered instead the back faces are -> means culling is inverted in shadowpass.
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Shadows with reversed triangle facing

Post by Kloot »

Relevant OpenGL state (glFrontFace(GL_CCW), glCullFace(GL_BACK)) is the same in each pass, so it would have to be the shadow-matrix projection flipping an axis.

edit, after looking at it more closely: https://github.com/spring/spring/commit ... 74eef0b2be (-> http://imageshack.us/f/233/screen00000a.png)
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Shadows with reversed triangle facing

Post by Beherith »

Oh my god I LOVE YOU!

This was one of the major obstacles in the path of the BA remake, as many buildings had holes in them. It also enables me to keep working on bump mapped ba :D
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: Shadows with reversed triangle facing

Post by FLOZi »

0.83 is going to be awesome. :-)
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Shadows with reversed triangle facing

Post by smoth »

<3 klooty

Behe, roamz, nao!
Post Reply

Return to “Engine”