OpenB3D Disable Stencil Self Shadowing?

BlitzMax Forums/MiniB3D Module/OpenB3D Disable Stencil Self Shadowing?

RustyKristi(Posted 2016) [#1]
I wonder if this is possible or is there any way to manage it. The self shadows looks kind of blocky even though if you apply smooth normals.


Kryzon(Posted 2016) [#2]
I'm not sure if the stencil shadowing technique in OpenB3D does this, but stencil shadowing usually reveals an ambient-lit-only vision of the scene.

You can tone down the hard edge effect of the shadowed faces of the mesh by changing the intensity of the light sources in your scene -- I don't remember if it's by making the light sources stronger or weaker.
Ideally, you want to have a shading that goes from lit mesh to ambient-lit mesh, so that the ambient-lit-mesh part blends (and hides) with the hard edges.

Other than that, you can also change the OpenB3D shadow-volume generation code (this file from the OpenB3D module) to implement something like "reverse extruded shadow volumes", which avoids the shadowed face artifacts:
http://aras-p.info/texts/revext.html


RustyKristi(Posted 2016) [#3]
Wow thanks Kryzon :D this looks like even a better solution. I never knew that this kind of approach existed. Great find!

I'm not that familiar (yet) with openb3d to start messing around with it, so I would like to hear angros47 and munch's take on this. But this is really as good as it gets.

Maybe something along the lines like:

Function CreateShadow:TShadowObject( parent:TMesh,Static:Int=False, Mode:Int=0 )

Where:
0 = Default
1 = Reverse Extruded

Or if it can't be a per instance thing, maybe an extra command to toggle it SetShadowMode

Tried the demo, it looks really good and I see it's DirectX, shader based. though I'm still wondering if this will solve the flickering problem.

thanks again.


angros47(Posted 2016) [#4]
In OpenB3D, stencil shadows just makes the area darker, without re-computing lighting. It's less accurate, but avoids rendering the scene twice (and this is good in terms of speed), and it allows to cast two shadows if there are two lights, making the area where two shadows intersect even darker. Of course, the drawback is that if ambient light is bright shadows would look unrealistic.

But all shadow solutions have advantages, and disadvantages


RustyKristi(Posted 2016) [#5]
Thanks angros47. Looking at my work again, I think I can manage for now with my current setup. It is really faster having those stencil shadows but I would agree with the pros and cons.

BTW, will it be simple to turn off self shadowing in the source or there's a lot of code changes?


angros47(Posted 2016) [#6]
You would have to replace the z - fail algorithm with z - pass algorithm. It's not obvious, and might introduce other bugs


RustyKristi(Posted 2016) [#7]
Ok got it thanks.