Shadows

Everything about development and the OpenMW source code.
User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: Shadows

Post by scrawl »

Every shadow technique except ShadowTexture replaces the fixed-function rendering of receivers
There's a hint you can set:

Code: Select all

settings->setShaderHint(osgShadow::ShadowSettings::PROVIDE_VERTEX_AND_FRAGMENT_SHADER);
At least the VDSM technique did respect it, IIRC.
with a (supposedly) equivalent shader with shadow support, except that it might not be equivalent if, for example, fog is on,
... or if multitexturing is used, or <insert 100 other reasons here>
as the shader used can't access fixed-function state
You can access a lot of fixed function state, but not all of it. Generally the GL_ENABLE states aren't available. We've mostly worked around this by setting values that are no-ops instead (e.g. setting a really large fog start distance, or a light with color (0,0,0) ).
I also found an issue with Git for Windows' bash shell - the cp command replaces existing files normally but doesn't do so when copying the entire contents of a folder. This means actually testing my shaders is a pain as the prebuild script can't put the new versions in the right place without tweaking.
I'm not sure what you mean by prebuild script. Running cmake should copy the new files. Does it not do that?
User avatar
AnyOldName3
Posts: 2668
Joined: 26 Nov 2015, 03:25

Re: Shadows

Post by AnyOldName3 »

I'm a little confused now as to what's going on. My settings.cfg in my documents folder contains the following lines, but even when I put something intentionally stupid in the shaders (such as making every channel except red go to zero), they don't seem to show up and I'm stuck in fixed-function mode. If I had to guess, I'd say my new shaders don't actually compile or link, but I can't see any error information.

The reason why the CMake setup isn't enough and the prebuild script is needed is that in Visual Studio, the binaries end up in a subfolder of the solution directory, and that's set as their working directory (otherwise you can't launch one binary from another). The resources are copied directly to the solution directory instead of that subfolder, and then the prebuild script copies them. Our CMake scripts can probably be tweaked to do things properly in the first place, but the current setup works perfectly save for a bug that was because of a Git Bash function doing dumb things which was easily fixed once I knew of its existence.
User avatar
AnyOldName3
Posts: 2668
Joined: 26 Nov 2015, 03:25

Re: Shadows

Post by AnyOldName3 »

Apparently, when I mentioned my settings.cfg containing the following lines I didn't actually include them, and they're different now to when I uncommented them, so maybe that's related to the issue.

Code: Select all

auto use object normal maps = true
auto use object specular maps = true
clamp lighting = false
force per pixel lighting = true
force shaders = true
[Shaders]
# invalid setting: auto use object normal maps = true
# invalid setting: auto use object specular maps = true
# invalid setting: force shaders = true
# invalid setting: force per pixel lighting = true
# invalid setting: clamp lighting = false
User avatar
AnyOldName3
Posts: 2668
Joined: 26 Nov 2015, 03:25

Re: Shadows

Post by AnyOldName3 »

Somehow that resolved itself... shaders are working now, but some errors are being produced.
User avatar
AnyOldName3
Posts: 2668
Joined: 26 Nov 2015, 03:25

Re: Shadows

Post by AnyOldName3 »

The shader-based version has fixed the weird colours on Indrele Rathryon's Shack door in the evening, which is nice.
User avatar
AnyOldName3
Posts: 2668
Joined: 26 Nov 2015, 03:25

Re: Shadows

Post by AnyOldName3 »

The current weirdness is that I keep getting

Code: Select all

Warning: detected OpenGL error 'invalid operation' at after RenderBin::draw(..)
spammed to the console, but I'm going to call it a day and push the version with updated shaders to GitHub.
drshfyersrg
Posts: 8
Joined: 17 Sep 2017, 23:52

Re: Shadows

Post by drshfyersrg »

Any chance this could get merged with the OSG post processing branch or vice versa? Sorta just make this a multi-purpose graphical branch.
User avatar
AnyOldName3
Posts: 2668
Joined: 26 Nov 2015, 03:25

Re: Shadows

Post by AnyOldName3 »

I'm making all kinds of wacky and disgusting changes to things, so you don't really want this interacting with another person's wacky and disgusting changes. That said, there's not an unreasonable chance that they'll merge fairly easily if you want to try it on your own fork.

In other news, I've made shadows play nicely without per-pixel lighting. With or without it, they should now definitely only block the diffuse and specular components of light from the one light that's casting them. Under any circumstances, the shader-based version should now look better than the fixed-function-but-not-actually-because-it-uses-OSG's-shaders version.

One thing that I have noticed is that we only apply specular lighting for light zero. While this made shadowing specular highlights from just light zero really easy, it doesn't seem like the kind of thing we necessarily want to be doing.
drshfyersrg
Posts: 8
Joined: 17 Sep 2017, 23:52

Re: Shadows

Post by drshfyersrg »

I know this is super far off from being a thing. But, soft shadows (PCF, or even PCSS) are super amazing!

An example of PCF: https://github.com/BennyQBD/3DEngineCpp ... 595302a809
An example of PCSS: https://github.com/TheMasonX/UnityPCSS

Good work Any, and Scrawl! Can't wait to see where this goes! As for the post processing doohicky, I think I might finally start sifting through the endless depths of the code, maybe learn a thing or two before I go breaking things :D
drshfyersrg
Posts: 8
Joined: 17 Sep 2017, 23:52

Re: Shadows

Post by drshfyersrg »

Also, can we get some screenshots of the latest work with non-modded content? :)
Post Reply