Looking for decent directional light normal mapping+shadows
Looking for decent directional light normal mapping+shadows
Hi, I would like to apply a decent normal mapping and textured shadows (possibly pssm?) that supports directional lights on my scene. Can anyone point to the right direction or provide previous examples that offer these features/shaders? would also be nice if it is in GLSL, thanks.
Re: Looking for decent directional light normal mapping+shad
Don't use PSSM, use CSM with texel clipping.
But here's a tutorial/article on PSSM
https://developer.nvidia.com/gpugems/GP ... _ch08.html
There are better ones for CSM.
Here's my example on cubemap shadows (draw in one pass with geometry shader) and PCF1 with simple lambertian point lighting, you can see how depth linearization works there.
https://github.com/buildaworldnet/Irrli ... MapShadows
Likewise for CSM you could use a texture array + layered FBO to achieve this "draw in one pass with gl_Layer" thing.
You could bind a depth-only MSAA texture array to a layered FBO and do a custom resolve shader (like in example 14.MSAA) to get a small blur radius Variance Shadow Map or Exponential Shadow Map for free! (You'd just have to linearizeZ in the resolve and calculate the second color channel G containing linearZ^2)
If you were feeling adventurous, you could get your feet wet in compute shaders to do Adaptive Shadow Maps (CSM but you calculate splits and projection matrices with compute shader).
Normal mapping is piss easy you just need the tangent space to from yet another rotation matrix (view*world*tangent*normal) for your normal map, Vectrotek from the forums has really colorful and bright pdfs and docs explaining that in the dumbest of terms.
You may want to skip calculating the tangent space and just use per-pixel deriviatives (dPdx and DPdy) like Naughty Dog does with derivative maps (works better with skinning too).
If you want parallax mapping, then its a little bit more hard-core, the best method I know is Cone-step mapping, which requires some displacement texture-preprocessing.
But here's a tutorial/article on PSSM
https://developer.nvidia.com/gpugems/GP ... _ch08.html
There are better ones for CSM.
Here's my example on cubemap shadows (draw in one pass with geometry shader) and PCF1 with simple lambertian point lighting, you can see how depth linearization works there.
https://github.com/buildaworldnet/Irrli ... MapShadows
Likewise for CSM you could use a texture array + layered FBO to achieve this "draw in one pass with gl_Layer" thing.
You could bind a depth-only MSAA texture array to a layered FBO and do a custom resolve shader (like in example 14.MSAA) to get a small blur radius Variance Shadow Map or Exponential Shadow Map for free! (You'd just have to linearizeZ in the resolve and calculate the second color channel G containing linearZ^2)
If you were feeling adventurous, you could get your feet wet in compute shaders to do Adaptive Shadow Maps (CSM but you calculate splits and projection matrices with compute shader).
Normal mapping is piss easy you just need the tangent space to from yet another rotation matrix (view*world*tangent*normal) for your normal map, Vectrotek from the forums has really colorful and bright pdfs and docs explaining that in the dumbest of terms.
You may want to skip calculating the tangent space and just use per-pixel deriviatives (dPdx and DPdy) like Naughty Dog does with derivative maps (works better with skinning too).
If you want parallax mapping, then its a little bit more hard-core, the best method I know is Cone-step mapping, which requires some displacement texture-preprocessing.
Re: Looking for decent directional light normal mapping+shad
Thanks for this in-depth info devsh! That build also looks great and a handful, but apparently I would like to just get a basic shadow mapping (pssm/csm) and plain old normal mapping+specular that supports direct lighting which you would expect from a renderer nowadays. I'm still a novice when it comes to shaders and eventually would like to port some stuff over as soon as I can grasp how Irrlicht shader works.
Yes, I was also wondering if this was that easy then why is this feature still not included in Irrlicht's latest version or at least as an Irrlicht extension. I understand that Irrlicht somehow has this keep it simple design/idealogy which got me back here in the first place, but this should be added as most engine or renderer already got this on their default shaders. It's also a shame there is a ton of related shared techniques posted all over the forums, but mostly are just broken links. :/
Yes, I was also wondering if this was that easy then why is this feature still not included in Irrlicht's latest version or at least as an Irrlicht extension. I understand that Irrlicht somehow has this keep it simple design/idealogy which got me back here in the first place, but this should be added as most engine or renderer already got this on their default shaders. It's also a shame there is a ton of related shared techniques posted all over the forums, but mostly are just broken links. :/
Re: Looking for decent directional light normal mapping+shad
Well irrlicht is not unity, so to get features from "renderers nowadays" you need to roll your own.
There's really no excuse not to learn GLSL shaders + there's no such thing as "Irrlicht shaders" (you can learn HLSL but that's for DirectX).
https://learnopengl.com/
One thing is that its difficult to maintain 100s of default shaders, as they stop working as soon as you change the input/output parameters a bit such as the input Vertex Type (struct layout) or the pixel shader ouputs.
Not to mention that normal mapping, specular, shadow mapping (each technique counts separately) generate hundreds of combinations which either would have to be put in one shader (so called uber-shader) with if-statements and surplus inputs, interpolants and texture fetches to support all codepaths which would degrade performance or all combinations would have to have their own specialized and optimized shader which would add lots and lots of work for the only 2 maintainers which are already struggling to get version 1.9 out the door or would give you very very bad irrlicht start-up time (loading lag to compile all the shader combos).
And irrlicht extensions are what they are called "extensions" hence not maintained by the core-irrlicht team so naturally how-up-to-date with the latest version and where they are hosted is not under irrlicht team's control.
Mind that most of the stuff on the forum was (irrRenderer, etc.) was made before github was popular and code disappeared on hosting sites which are now defunct (half of my stuff is dead because it was sucked up in the demise of googlecode).
There is an argument that if irrlicht moved its code hosting to github, forks would be easier to find and extensions would most probably be safer (and dependencies on particular irrlicht revisions could be tracked better) - but thats a whole different heated discussion that I would not like to reignite in this thread.
There's really no excuse not to learn GLSL shaders + there's no such thing as "Irrlicht shaders" (you can learn HLSL but that's for DirectX).
https://learnopengl.com/
Don't ask me, I have literally 0% influence over the direction of irrlicht.Yes, I was also wondering if this was that easy then why is this feature still not included in Irrlicht's latest version or at least as an Irrlicht extension.
One thing is that its difficult to maintain 100s of default shaders, as they stop working as soon as you change the input/output parameters a bit such as the input Vertex Type (struct layout) or the pixel shader ouputs.
Not to mention that normal mapping, specular, shadow mapping (each technique counts separately) generate hundreds of combinations which either would have to be put in one shader (so called uber-shader) with if-statements and surplus inputs, interpolants and texture fetches to support all codepaths which would degrade performance or all combinations would have to have their own specialized and optimized shader which would add lots and lots of work for the only 2 maintainers which are already struggling to get version 1.9 out the door or would give you very very bad irrlicht start-up time (loading lag to compile all the shader combos).
And irrlicht extensions are what they are called "extensions" hence not maintained by the core-irrlicht team so naturally how-up-to-date with the latest version and where they are hosted is not under irrlicht team's control.
Mind that most of the stuff on the forum was (irrRenderer, etc.) was made before github was popular and code disappeared on hosting sites which are now defunct (half of my stuff is dead because it was sucked up in the demise of googlecode).
There is an argument that if irrlicht moved its code hosting to github, forks would be easier to find and extensions would most probably be safer (and dependencies on particular irrlicht revisions could be tracked better) - but thats a whole different heated discussion that I would not like to reignite in this thread.
Re: Looking for decent directional light normal mapping+shad
I see ok, with that short history and status I kinda get what you mean. I guess I just need to find some good tutorials on Irrlicht + shaders.
Re: Looking for decent directional light normal mapping+shad
We could deliver such shaders as examples. Thought I should add first some screen-quad node to Irrlicht.
Shaders got a little disregarded, partly probably because I never really had to work on them much before (did some minor stuff, but mainly copy-pasting or porting shaders or modifying tiny bits).
But right (as in this week) now I also write some more, maybe I can put some stuff back in Irrlicht in the end (then again it's probably not going to make the best examples as I'm still a newbie in that regard).
Shaders got a little disregarded, partly probably because I never really had to work on them much before (did some minor stuff, but mainly copy-pasting or porting shaders or modifying tiny bits).
But right (as in this week) now I also write some more, maybe I can put some stuff back in Irrlicht in the end (then again it's probably not going to make the best examples as I'm still a newbie in that regard).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Looking for decent directional light normal mapping+shad
Hey CuteAlien, that would be awesome! also perhaps there could be a short guide on how to port some HLSL/GLSL shaders over, at least with the built-in and other Irrlicht specific shader variables. looking forward to these examples, thanks.CuteAlien wrote:We could deliver such shaders as examples. Thought I should add first some screen-quad node to Irrlicht.
Shaders got a little disregarded, partly probably because I never really had to work on them much before (did some minor stuff, but mainly copy-pasting or porting shaders or modifying tiny bits).
But right (as in this week) now I also write some more, maybe I can put some stuff back in Irrlicht in the end (then again it's probably not going to make the best examples as I'm still a newbie in that regard).
Re: Looking for decent directional light normal mapping+shad
Yeah, like I spend 2-3 hours yesterday until I figured out Irrlicht sends Tangent/Binormal as TEXCOORD1/2 instead of TANGENT/BINORMAL. Having example would have helped :-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Looking for decent directional light normal mapping+shad
Oh I see, but yes that would be great and very helpful.CuteAlien wrote:Yeah, like I spend 2-3 hours yesterday until I figured out Irrlicht sends Tangent/Binormal as TEXCOORD1/2 instead of TANGENT/BINORMAL. Having example would have helped
Another question, is Cg already part of Irrlicht? Are there any existing examples using Cg? (not IrrCg as it seems this is another outdated extension )
Re: Looking for decent directional light normal mapping+shad
We had Cg support in Irrlicht 1.8, but removed it by now in svn trunk. It's no longer supported by NVIDIA, so we also dropped support (we also had no maintainer still interested in it). Usually you can chose one - GLSL or HLSL. And if you really need to port between them ... shaders tend to be just a few lines of code and both systems work very similar. Both have same functions and types, just with slightly different names. Not saying there will be no problems, you always run into some stuff in programming, but it's similar enough that if you learned one system then understanding the other is pretty trivial.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm