SimSun Shader - Simulated directional light for models

Re: SimSun Shader - Simulated directional light for models

Postby Graf Zahl » Wed Mar 18, 2020 12:50 am

dpJudas wrote:2) The physical correct falloff is actually not to convert it to an angle. Light level should be "float lightLevel = clamp(dot(l,n), 0.0, 1.0);".


For a case like this, where it's only supposed to improve contrast, wouldn't it make sense to keep a certain amount of ambient light?, e.g.

float lightLevel = 0.4 + 0.6 * clamp(dot(l,n), 0.0, 1.0);

?
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: SimSun Shader - Simulated directional light for models

Postby Cherno » Wed Mar 18, 2020 5:37 am

Thanks for the suggestions and help. If the shader is improved in any way by it, I am more than willing to change the code :)
User avatar
Cherno
 
Joined: 06 Dec 2016

Re: SimSun Shader - Simulated directional light for models

Postby dpJudas » Wed Mar 18, 2020 7:33 am

Graf Zahl wrote:For a case like this, where it's only supposed to improve contrast, wouldn't it make sense to keep a certain amount of ambient light?, e.g.

float lightLevel = 0.4 + 0.6 * clamp(dot(l,n), 0.0, 1.0);

?

Yes, it would.

Overall doing this in the material shader is problematic anyway as it changes the base color that then in turn is used by dynamic lights. I created a lightlevelcontrast branch that does it at right point in the fragment shader. Currently it is applying it to everything (so walls and flats, too), but both contrast strength and which object types we want to apply it to could be configurable by changing the strength variable to an uniform. Or the uniform could be controlled by the texture, like the SimSun Shader is doing.
dpJudas
 
 
 
Joined: 28 May 2016

Re: SimSun Shader - Simulated directional light for models

Postby Cherno » Sat Mar 28, 2020 4:22 pm

Update:
SimSun 1.1
Corrected the lightdir shader variable so it now doesn't need an inverted z value.
Shifted the light level by 0.25 to lessen the amount of extremely dark areas.
Added a cube model to the TESTMAP.

See first post for the latest version.
User avatar
Cherno
 
Joined: 06 Dec 2016

Re: SimSun Shader - Simulated directional light for models

Postby 3336655445 » Mon Mar 30, 2020 9:26 pm

stupid question: is this mod (?) working fine with LZDoom?
edit answer: yes it works with LZDoom
3336655445
 
Joined: 24 Jul 2019
Location: Odessa
Discord: Счастливая трубка
Operating System: Other OS Not Listed Here
Graphics Processor: Not Listed

Re: SimSun Shader - Simulated directional light for models

Postby Kizoky » Sat Aug 14, 2021 3:08 am

I finally got tired of .bat files, so I wrote a program in C# for use with this shader:
https://github.com/Kizoky/simsun_output_gen
User avatar
Kizoky
I smell like gravity
 
Joined: 14 Nov 2011
Location: Around weirdos, I'm the biggest weirdo among them
Discord: Kizoky#0375
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia with Vulkan support

Re: SimSun Shader - Simulated directional light for models

Postby Enjay » Sat Aug 14, 2021 5:27 am

I tried this by the drag-drop method and there was no output (in fact, Windows Explorer hung the first time that I tried and I had to reboot). After restarting, several tries with several different files didn't seem to be generating anything.

So I went to the command prompt and typed simsungen and got:

Code: Select allExpand view
A fatal error occurred. The required library hostfxr.dll could not be found.
If this is a self-contained application, that library should exist in [C:\Users\[username]\AppData\Local\Temp\.net\SimSunGen\c23qeulz.eur\].
If this is a framework-dependent application, install the runtime in the global location [C:\Program Files (x86)\dotnet] or use the DOTNET_ROOT(x86) environment variable to specify the runtime location or register the runtime location in [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation].

The .NET Core runtime can be found at:
  - https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x86&rid=win10-x86
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: SimSun Shader - Simulated directional light for models

Postby Kizoky » Sat Aug 14, 2021 6:25 am

Enjay wrote:I tried this by the drag-drop method and there was no output (in fact, Windows Explorer hung the first time that I tried and I had to reboot). After restarting, several tries with several different files didn't seem to be generating anything.

So I went to the command prompt and typed simsungen and got:

Code: Select allExpand view
A fatal error occurred. The required library hostfxr.dll could not be found.
If this is a self-contained application, that library should exist in [C:\Users\[username]\AppData\Local\Temp\.net\SimSunGen\c23qeulz.eur\].
If this is a framework-dependent application, install the runtime in the global location [C:\Program Files (x86)\dotnet] or use the DOTNET_ROOT(x86) environment variable to specify the runtime location or register the runtime location in [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation].

The .NET Core runtime can be found at:
  - https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x86&rid=win10-x86


Uh oh
Do you use Windows 10 or some earlier OS?

edit: nevermind, I know what's the issue here :(
Last edited by Kizoky on Sat Aug 14, 2021 6:34 am, edited 1 time in total.
User avatar
Kizoky
I smell like gravity
 
Joined: 14 Nov 2011
Location: Around weirdos, I'm the biggest weirdo among them
Discord: Kizoky#0375
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia with Vulkan support

Re: SimSun Shader - Simulated directional light for models

Postby Enjay » Sat Aug 14, 2021 6:31 am

Windows 10 Pro 64-bit - fully updated.
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: SimSun Shader - Simulated directional light for models

Postby Kizoky » Sat Aug 14, 2021 7:00 am

Enjay wrote:Windows 10 Pro 64-bit - fully updated.


Could you please go here (https://github.com/Kizoky/simsun_output ... es/tag/1.1) and download SimSunGen_L.exe ?
It seems I totally forgot how .NET apps work, with that app it should now work fine, ofc with the downside that it's file size is now much bigger :shock:

edit:
Above link is dead, use this: https://github.com/Kizoky/GLDEFGenerato ... s/tag/v1.0
Last edited by Kizoky on Sun Aug 15, 2021 2:40 pm, edited 1 time in total.
User avatar
Kizoky
I smell like gravity
 
Joined: 14 Nov 2011
Location: Around weirdos, I'm the biggest weirdo among them
Discord: Kizoky#0375
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia with Vulkan support

Re: SimSun Shader - Simulated directional light for models

Postby Enjay » Sat Aug 14, 2021 11:44 am

That works, thank you kindly. :)
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: SimSun Shader - Simulated directional light for models

Postby Kazudra » Thu Nov 04, 2021 9:31 pm

MFG38 wrote:I'm curious, though: how good would this look on a 2D sprite?


If you prep the sprites in a way that all shading is handled by the normalmap it'll basically look like a 3d Model.
This is how Mario Maker Handles New Super Mario Assets (aside from Mario, the only 3D asset).

It only leaves the vital question; How big does the sprites NEED to be to be handled this way proper?
Kazudra
 
Joined: 25 May 2015

Re: SimSun Shader - Simulated directional light for models

Postby ramon.dexter » Wed Dec 08, 2021 11:34 am

Wait, there is automatic GLDEFS generator? :shock: Great to know that after spending two days writing defs for my models to use the simsum shader :)
User avatar
ramon.dexter
rudebwoy
 
Joined: 20 Oct 2015
Location: Kozolupy, Bohemia
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: SimSun Shader - Simulated directional light for models

Postby Enjay » Sat Feb 19, 2022 9:03 pm

I finally got around to trying this properly with a lot of models from model resource folder I have.

Firstly, Kizoky's GLDEF generator was a godsend. I just dropped the models folder onto the exe and it spat out a flawless GLDEFS for every graphic in the folder - including sub folders - with correct paths and everything. Almost 800 models skins allocated to the SimSun shader in less than a second.

Then "all" I had to do was browse through my models folder to try and identify the skins that I didn't think would work too well with this. This turned out mostly to be skins for models that are meant to be light sources. The shader darkens them and the problem is particularly obvious for ceiling lights where the underside gets darkened the most.

Fortunately, it was an easy job to go through the folder to identify these and a few others. The skins that I deemed unsuitable for shading were very much in the minority and visually pretty obvious when scanning through the thumbnails by eye.

There were, also, one or two model skins where I was already using another shader on them and these can't co exist so I had to decide wither to keep the original shader or go with SimSun. Again, this selection process was pretty easy because there were only a handful of these and, of course, they are all already listed in a GLDEFS file so it was easy to find them in that file, search for the same graphics in the SimSun generated file then decide which one to comment out.

I guess the whole process took about 20 minutes - so no big deal really for so many models.

And the end result is very nice. As others have said, it's subtle (which is good) but definitely there and when switching back and forth between using the shader and not, the unshaded models very quickly started to look quite flat in comparison.

I'll still have to go through the models and evaluate them more thoroughly in game where they are most likely to be used but as a big, brutal, bulk test of both the GLDEFS generator and the SimSun shader, everything worked very well and the whole thing was surprisingly painless and error free to set up.
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: SimSun Shader - Simulated directional light for models

Postby Cherno » Sun Feb 20, 2022 1:05 am

SimSun can be combined with brightmaps, which I suggest for any light source models.

A SimSun-like feature will be integrated into one of the future GZDoom releases and automaticaly work without the need for GLDEFS entries, so this whole thing can be made obsolete, which I am looking forward to.
User avatar
Cherno
 
Joined: 06 Dec 2016

PreviousNext

Return to Shaders

Who is online

Users browsing this forum: No registered users and 0 guests