Looking for decent directional light normal mapping+shadows

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!

Looking for decent directional light normal mapping+shadows

Postby noretsar » Fri May 11, 2018 2:21 am

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. :)
noretsar
 
Posts: 11
Joined: Fri May 11, 2018 2:04 am

Re: Looking for decent directional light normal mapping+shad

Postby devsh » Fri May 11, 2018 10:35 am

Don't use PSSM, use CSM with texel clipping.

But here's a tutorial/article on PSSM
https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_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/IrrlichtBAW/tree/master/examples_tests/15.LayeredCubeMapShadows
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.
User avatar
devsh
Competition winner
 
Posts: 1890
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK

Re: Looking for decent directional light normal mapping+shad

Postby noretsar » Mon May 14, 2018 1:20 am

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. :/
noretsar
 
Posts: 11
Joined: Fri May 11, 2018 2:04 am

Re: Looking for decent directional light normal mapping+shad

Postby devsh » Mon May 14, 2018 12:05 pm

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/

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.


Don't ask me, I have literally 0% influence over the direction of irrlicht.


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.
User avatar
devsh
Competition winner
 
Posts: 1890
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK

Re: Looking for decent directional light normal mapping+shad

Postby noretsar » Mon May 14, 2018 1:24 pm

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.
noretsar
 
Posts: 11
Joined: Fri May 11, 2018 2:04 am

Re: Looking for decent directional light normal mapping+shad

Postby CuteAlien » Mon May 14, 2018 7:42 pm

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).
IRC: #irrlicht on irc.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
CuteAlien
Admin
 
Posts: 8533
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: Looking for decent directional light normal mapping+shad

Postby noretsar » Thu May 17, 2018 1:35 am

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).


Hey CuteAlien, that would be awesome! :D 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.
noretsar
 
Posts: 11
Joined: Fri May 11, 2018 2:04 am

Re: Looking for decent directional light normal mapping+shad

Postby CuteAlien » Thu May 17, 2018 10:04 am

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.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
CuteAlien
Admin
 
Posts: 8533
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: Looking for decent directional light normal mapping+shad

Postby noretsar » Tue May 22, 2018 7:12 pm

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 :-)


Oh I see, but yes that would be great and very helpful. :)

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 :( )
noretsar
 
Posts: 11
Joined: Fri May 11, 2018 2:04 am

Re: Looking for decent directional light normal mapping+shad

Postby CuteAlien » Tue May 22, 2018 7:58 pm

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.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
CuteAlien
Admin
 
Posts: 8533
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany


Return to Advanced Help

Who is online

Users browsing this forum: No registered users and 0 guests