Author Topic: Implementing shadows(self-shadowing first) in GLSL...  (Read 23904 times)

0 Members and 1 Guest are viewing this topic.

Offline pecenipicek

  • Roast Chicken
  • 211
  • Powered by copious amounts of coffee and nicotine
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • PeceniPicek's own deviantart page
Implementing shadows(self-shadowing first) in GLSL...
I've been toying with this for a long time now, and i'm wondering, which things does the underlying OGL code expose? I've noted that i've been unable to appropriately implement anything even reminiscent of self-shadowing -.-


In any case, my idea for the implementation of shadows is something similar to Carmack's Reverse, with the shadow volume being capped in the distance of say 500m ingame, depending on the size of the shadowed object....


Since i'm obviously too dumb for things like pure OGL code, i've been trudging through the GLSL trying to figure out something worthwile... Anyone care to help?
Skype: vrganjko
Ho, ho, ho, to the bottle I go
to heal my heart and drown my woe!
Rain may fall and wind may blow,
and many miles be still to go,
but under a tall tree I will lie!

The Apocalypse Project needs YOU! - recruiting info thread.

 
Re: Implementing shadows(self-shadowing first) in GLSL...
i can't help you anyway i don't know anything about coding, but i just post to support you !

I wish you success!
$Formula: ( every-time
   ( has-time-elapsed "0" )
   ( Do-Nothing
   )
   ( send-message
      "#Dalek"
      "High"
      "Pro-crasti-nate"
   )
   )
)
+Name: Procratination
+Repeat Count: 99999999999
+Interval: 1

 

Online taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Re: Implementing shadows(self-shadowing first) in GLSL...
You may be able to get something going with steep parallax mapping, however the performance hit might be pretty extreme.  I'm not sure how else to get a decent effect with the current code though.

The current code was always intended to primarily be a place-holder/research-aid in order to work out what would be needed to add proper shader support in the future.  So what's there now is really just a shader version of the fixed-function pipeline, with all of the same basic limitations.  Somebody else might have an idea that could get it to work in pure GLSL, but I can't think of anything that would be remotely acceptable without a lot of code changes to get it working.

 

Offline pecenipicek

  • Roast Chicken
  • 211
  • Powered by copious amounts of coffee and nicotine
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • PeceniPicek's own deviantart page
Re: Implementing shadows(self-shadowing first) in GLSL...
time to dig into the OGL then :p



can you atleast tell me exactly which shaders are used on following settings

ship lab:

no diffuse, no spec, no normal, no env, no glow


only diffuse enabled


I cant seem to really isolate a single shader file with which i might test properly. basically, i'd need some more detailed guidelines...
Skype: vrganjko
Ho, ho, ho, to the bottle I go
to heal my heart and drown my woe!
Rain may fall and wind may blow,
and many miles be still to go,
but under a tall tree I will lie!

The Apocalypse Project needs YOU! - recruiting info thread.

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: Implementing shadows(self-shadowing first) in GLSL...
Isn't there another thread and now a wiki page with all of this information?  I don't know the links though.
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 

Offline pecenipicek

  • Roast Chicken
  • 211
  • Powered by copious amounts of coffee and nicotine
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • PeceniPicek's own deviantart page
Re: Implementing shadows(self-shadowing first) in GLSL...
yeah, there is, and if you remember, i participated in that discussion, tho i still havent isolated the ones where i can actually see any change, so yeah, help from the man who made them would be appreciated.
Skype: vrganjko
Ho, ho, ho, to the bottle I go
to heal my heart and drown my woe!
Rain may fall and wind may blow,
and many miles be still to go,
but under a tall tree I will lie!

The Apocalypse Project needs YOU! - recruiting info thread.

 

Online taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Re: Implementing shadows(self-shadowing first) in GLSL...
no diffuse, no spec, no normal, no env, no glow
Should be l-v and null-f (no maps, only lighting).

Quote
only diffuse enabled
Would be l-v and lb-f (assuming lighting, otherwise null-v and b-f).

 

Offline pecenipicek

  • Roast Chicken
  • 211
  • Powered by copious amounts of coffee and nicotine
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • PeceniPicek's own deviantart page
Re: Implementing shadows(self-shadowing first) in GLSL...
tnx.


i thought i was doing something wrong... damn... hmmmm...


the fun part? for example, in the shader designer i can see the rough effect of my code. in the ship lab, i fail to see any change at all. Does the usual folder hierarchy (ie. fs2/data/ dirs trounce mod folders and built in vp's?) apply to sdr files too or?
Skype: vrganjko
Ho, ho, ho, to the bottle I go
to heal my heart and drown my woe!
Rain may fall and wind may blow,
and many miles be still to go,
but under a tall tree I will lie!

The Apocalypse Project needs YOU! - recruiting info thread.

 

Online taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Re: Implementing shadows(self-shadowing first) in GLSL...
When I was working on that stuff originally I just made mod folders for testing different shaders.  So if I was you I would create a "shadows" mod and put the shader files that you are working on under data/effects/ in that new mod directory.  Then just put "shadows" first in your -mod cmdline and that way you will always know that you are working with the files that you want to use.

 

Offline pecenipicek

  • Roast Chicken
  • 211
  • Powered by copious amounts of coffee and nicotine
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • PeceniPicek's own deviantart page
Re: Implementing shadows(self-shadowing first) in GLSL...
tnx :)
Skype: vrganjko
Ho, ho, ho, to the bottle I go
to heal my heart and drown my woe!
Rain may fall and wind may blow,
and many miles be still to go,
but under a tall tree I will lie!

The Apocalypse Project needs YOU! - recruiting info thread.

 

Offline pecenipicek

  • Roast Chicken
  • 211
  • Powered by copious amounts of coffee and nicotine
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • PeceniPicek's own deviantart page
Re: Implementing shadows(self-shadowing first) in GLSL...
where in the code can i find the data that reveals what does OGL code expose to the shaders? I've been rummaging about now, and its kind of hard to find...
Skype: vrganjko
Ho, ho, ho, to the bottle I go
to heal my heart and drown my woe!
Rain may fall and wind may blow,
and many miles be still to go,
but under a tall tree I will lie!

The Apocalypse Project needs YOU! - recruiting info thread.

 

Online taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Re: Implementing shadows(self-shadowing first) in GLSL...
The uniforms that it uses are in gropenglshader.cpp (big array near the top of the file).  Beyond that and a few of the built-ins needed to render, nothing else gets exposed.  It really only offers the basic settings/functionality that the fixed-function pipeline uses too.

Is there something specific that you were looking for?

 

Offline pecenipicek

  • Roast Chicken
  • 211
  • Powered by copious amounts of coffee and nicotine
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • PeceniPicek's own deviantart page
Re: Implementing shadows(self-shadowing first) in GLSL...
i've been looking to analyze the code exposing to see what i can actually use to get the needed data for the bloody thing...


after further research, i need to either get the stencil buffer out to the shaders, or something like that... after 3-4 hours of researching through ****, i'm at a loss... i'll work out something, could you just direct me to the part of the code that deals with depth buffers and in general framebuffers?



[edit] after some thinking, i believe that doing it via shadow volumes would probably be the best option... ( http://en.wikipedia.org/wiki/Shadow_volume )


My proposal?

Get the engine to actually do the damn thing :p

(no, its not a feature request, its more of a "point me to the relevant blocks of code and i might do something proper for a change" :p )




It might be worth to explore this problematic further....
« Last Edit: May 05, 2009, 06:09:21 pm by pecenipicek »
Skype: vrganjko
Ho, ho, ho, to the bottle I go
to heal my heart and drown my woe!
Rain may fall and wind may blow,
and many miles be still to go,
but under a tall tree I will lie!

The Apocalypse Project needs YOU! - recruiting info thread.

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: Implementing shadows(self-shadowing first) in GLSL...
Careful, apparently some of those techniques are patented.
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 

Offline pecenipicek

  • Roast Chicken
  • 211
  • Powered by copious amounts of coffee and nicotine
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • PeceniPicek's own deviantart page
Re: Implementing shadows(self-shadowing first) in GLSL...
i'm quite aware.

we'll find a way around. probably something unrelated to the shadow volumes. we'll see how the engine reacts once i actually get to working code.
Skype: vrganjko
Ho, ho, ho, to the bottle I go
to heal my heart and drown my woe!
Rain may fall and wind may blow,
and many miles be still to go,
but under a tall tree I will lie!

The Apocalypse Project needs YOU! - recruiting info thread.

 

Offline karx11erx

  • 27
  • D2X-XL and DLE-XP coder
    • Descent 2 & D2X-XL
Re: Implementing shadows(self-shadowing first) in GLSL...
You don't need shaders for Carmack's reverse. Actually that way of producing shadows is rather simple (as long as you stick with a single light source, like a nearby sun), and I guess that in space you wouldn't even need to have soft shadows.

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: Implementing shadows(self-shadowing first) in GLSL...
Yeah I pondered the need for soft shadows for all of .03 seconds before realizing it would be a seriously wasted effort.
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 

Offline Herra Tohtori

  • The Academic
  • 211
  • Bad command or file name
Re: Implementing shadows(self-shadowing first) in GLSL...
It wouldn't be wasted effort because sun is not a point source of light (although they behave as such in FreeSpace) but a disk. Softness in shadows isn't caused by the atmosphere; ambient light from scattering is a different matter altogether. All shadows have umbra, penumbra and antumbra, and that includes the shadows cast by objects in space. The "blurry edge" of the shadow would be defined by the angular diameter of the light source and the distance of the shadowed object and shading object.

Of course, for general purposes simple stencil shadows would be well sufficient and much better than no shadows at all. But in capital ship scale, shadows would definitely have a degree of blur on their edges. But I would not call soft shadows a wasted effort by any means - if someone can implement a solution that doesn't tax the computer impossibly much.
There are three things that last forever: Abort, Retry, Fail - and the greatest of these is Fail.

 

Offline karx11erx

  • 27
  • D2X-XL and DLE-XP coder
    • Descent 2 & D2X-XL
Re: Implementing shadows(self-shadowing first) in GLSL...
You are wrong. The blurred borders of shadows are caused by scattered light, and so are penumbras - these appear when shadows from several light sources (or a big one) that are lit by ambient light overlap. In space you have no scattered light and only a single light source, and if the sun is sufficiently far away, it is close to an ideal point. Just google for some photographs of space stations orbiting the earth, or the Lunar lander: http://scienceblogs.com/gregladen/images/Surveyor_NASA_lunar_lander.jpg , http://www.lpi.usra.edu/expmoon/Apollo11/A11_LanderFS.gif

If you wanted a perfect solution, you'd take light reflected by ship hulls into account ... but then we're talking raytracing already.
« Last Edit: May 06, 2009, 12:53:55 pm by karx11erx »

 

Offline Herra Tohtori

  • The Academic
  • 211
  • Bad command or file name
Re: Implementing shadows(self-shadowing first) in GLSL...
No, I am in fact not wrong.

The half shadow phenomenon is caused by the fact that sun is not a point source of light. The light passing through the atmosphere of Earth has a different effect, as the red light passing through and refracting and dispersing causes it to light objects in the shadow of Earth and this effect colours the Moon copper-shaded. But the geometry of shadows in space (or anywhere) is not in any way dependant on atmosphere. The shadow cast by the Moon has the exact same geometry that accounts for different kinds of solar eclipses.

The bigger the apparent diameter of the light source, the faster the shadow edges grow blurry. This image should clear it up nicely:



Or in scale:



You can see the shadow's edge getting much less defined as the distance increases, and it has fundamentally nothing to do with the atmospheric scattering.

The reason for shadows appearing so sharp and defined in space photography is because they are precisely that - at the scale that they are photographed. The length of the shadow is simply short enough that the shadow's geometry doesn't play an important role in it. Which is why I said that for general purposes, a stencil shadow system would be largely sufficient. Especially for self-shadowing of ships that are sized similar to, say, the Space Shuttle Orbiter and smaller.

But things like the Colossus are several kilometres long. At this kind of distance, some softening on the edges of the shadows would definitely happen already (depending on the apparent diameter of the light source of course). Not to mention stuff like casting shadows on other models, in which case the distances can be even larger and soft shadows (if accurately depicting the umbra/penumbra phenomenon) would definitely be beneficial to realistic lighting.

But like I said, stencil shadows would be "close enough" for most cases and definitely better than the complete lack of shadows that we have right now. :)

EDIT: And while it is true that far enough from the star it would appear close enough to point source of light, who says you'll always be that far from it?

You could have a situation where a red dwarf or red giant has a lot bigger diameter than our Sun at one AU distance (about half a degree). Or you could have a situation where the apparent diameter of the star is so close to point that it doesn't matter in the distances involved in FS2.

However, a stencil shadow can only deal accurately with the latter optimal scenery, while if the shadows were more accurately modeled, same system could obviously deal with both cases. It would "just" require a definition of the apparent diameter of the star's disk in mission background information. And of course a working system that correctly implements umbras, penumbras and all that jazz...
« Last Edit: May 06, 2009, 01:14:33 pm by Herra Tohtori »
There are three things that last forever: Abort, Retry, Fail - and the greatest of these is Fail.