xray-16 icon indicating copy to clipboard operation
xray-16 copied to clipboard

Sun mask in DX10 & 11

Open ghost opened this issue 10 years ago • 12 comments

Apparently USE_SUNMASK in config.h or config_defines.h does not work in DX10&11 (after deleting the shaders_cache of course). I'm pretty sure it works fine in DX9 though.

Anyway, it would be nice if we could get it working properly for 10&11. The error it spits out is the typical "your video card doesn't support this, blah blah blah" shader error.

Cromm Cruac, of Atmosfear 3 fame, also suggested not just to universally get this working without having to modify the shaders each time we want to use it. That last part I know how to do, I just don't know what causes the issue with 10&11.

ghost avatar Oct 17 '14 19:10 ghost

The error it spits out is the typical "your video card doesn't support this, blah blah blah" shader error.

As I mentioned in task list, that means shader compilation error occurred. You could look at fxc output and see what causes that error.

nitrocaster avatar Oct 17 '14 19:10 nitrocaster

But which shader would I check with fxc? I also got the error wrong. It's not the usual pixel shader 1.1 error, it says my system doesn't meet the requirements (it clearly can; quad-core, 8gb ram, gtx 970).

I asked Cromm Cruac about the problem and he says CS had the same issue. I also noticed that R2 has some shaders related to sun cascades, which contain some sun mask code, which 10/11 don't have.

I'm also not the least bit good with HLSL, as I brought this up hoping you or someone else working on this could try to figure it out.

ghost avatar Oct 19 '14 22:10 ghost

Actually, you'll need to rewrite some core responsible for shader compilation in order to get compiler output when there's a compilation error, so you could analyze the cause of error and fix it.

nitrocaster avatar Oct 20 '14 07:10 nitrocaster

Okay, I'm going to admit it: I don't know ANY C++. Anything I've coded has been done through trial and error process.

I was really hoping someone as talented as yourself would be willing to figure out sun_mask for DX10&11 as it's a cool feature.

In return I'm willing to email you a present: all the shaders from the newest Unreal Engine 4 release (they're all in hlsl, so they can be converted for use in Stalker).

Would you be willing to help me?

ghost avatar Oct 21 '14 18:10 ghost

the shaders from the newest Unreal Engine 4 release (they're all in hlsl, so they can be converted for use in Stalker).

Shaders usually are engine specific, but it might be useful to take a look at them anyway.

nitrocaster avatar Oct 21 '14 19:10 nitrocaster

Is that a yes on taking a look at the sun mask issue (and yes they're engine specific, but oddly it looks like many of them wouldn't take much to convert over)?

ghost avatar Oct 21 '14 21:10 ghost

An update on this: I successfully added DX10 & 11 sunmask effect some time ago. It was a shader-based solution that turned out to be quite easy.

I'd be happy to provide the shaders for your project if you want them.

Also: I programmed it so that the sunmask effect can be turned on/off via console command (requires a restart though) so if you want that as well let me know.

ghost avatar Nov 03 '15 16:11 ghost

Could you post some screenshots (before/after)?

nitrocaster avatar Nov 03 '15 17:11 nitrocaster

No SUNMASK: http://i.imgur.com/29ktLua.jpg

SUNMASK enabled: http://i.imgur.com/bNWKFZd.jpg http://i.imgur.com/QobMQ52.jpg

The only issue I can think of is that you have to disable r3\objects and r4\objects in order for the new shader to be recognized and loaded. I was lazy so I've just done this in my code by setting it to r3\disabled and r4\disabled in r3.cpp and r4.cpp.

Then the user has to delete their current shaders_cache. The shaders_cache still get's used, but in order for the user to load any shader changes when a shader is changed or a new one is added the shaders_cache has to be deleted each time there's a big shader change. Obviously there is a better/correct way of doing it, I just haven't bothered.

I can also provide screenshots of: grass shadows, actor shadow, and both of those on DX9 when I have a modified shadow.h shader based on Lost Alpha's shadow.h that creates a very nice soft shadows effect.

I should also note that I have not experienced any performance changes at all not using the precompiled shaders that GSC made for the R3 and R4 renderers (the objects folders). The Lost Alpha team had come to the same conclusion when I asked them a long while back.

ghost avatar Nov 03 '15 21:11 ghost

Cloud shadows, am I right? That may require additional tweaks to look more realistic, however. I think we could upload some screenshots to wiki.

nitrocaster avatar Nov 03 '15 21:11 nitrocaster

Yep, cloud shadows. What I was thinking is that once cloud lerping is fixed, instead of just using a texture named "sunmask" for the effect, instead the sunmask texture would use whatever current texture is used by "clouds_texture" in the weather config files.

This would look a lot better, however it depends entirely on what clouds texture is used (white areas of the alpha channel in the texture produce no shadow, grayscale/black areas do).

ghost avatar Nov 03 '15 21:11 ghost

The OP is no longer on GitHub. Has anyone else figured out how to fix the shaders? Edit: Got them back in vanilla Clear Sky: moved USE_SUNMASK define outside of commented section of common.h and removed duplicate m_sunmask definitions from some shaders.

vlad54rus avatar Dec 24 '23 14:12 vlad54rus