Directional contrast (models and optionally the world)

Like feature suggestions, but you've actually written code to make it happen. More likely to make it into the game than some random request in feature suggestions.

Moderator: GZDoom Developers

Forum rules
Please see Code submission guidelines

GZDoom Status:
Image

Legacy Status:
Image Image

QZDoom Status:
Image

Directional contrast (models and optionally the world)

Postby Nash » Fri Jul 10, 2020 6:59 am

https://github.com/coelckers/gzdoom/pull/1133

Continue dpJudas' work on directional contrast. For best results, EvenLighting is advised.

- New MAPINFO option: DirectionalContrastMode. 0 = default (no added contrast), 1 = affect models only, 2 = affect models and world textures (walls and flats).

- New MAPINFO option: DirectionalContrast = <X>, <Y>, <Z>, <Strength>. Sets the directional contrast vector, and strength. All defaults to 0.

- New ZScript functions: Level.SetDirectionalContrast(double x, double y, double z, double w), Level.GetDirectionalContrastVec() and Level.GetDirectionalContrastStr().

- New MODELDEF option: NoDirectionalContrast for disabling contrast effect on specific models.

The purpose of this feature is to improve lighting contrast on models, and optionally the world. Without this, models have flat lighting, and normal/specular maps are only visible when they are touching dynamic lights, which often forces map authors to spam their level with dynamic lights. This addresses that problem.

Example file coming later, I need time to make it.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: Directional contrast (models and optionally the world)

Postby Graf Zahl » Sun Jul 19, 2020 12:49 am

Like the other one - please provide a small demo so it can be reviewed.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Directional contrast (models and optionally the world)

Postby Nash » Sun Jul 19, 2020 2:14 am

Sorry I got a little busy with other work and didn't have time to prepare the demo file - will prepare it within the next few days (same goes for the other PR too).
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: Directional contrast (models and optionally the world)

Postby Nash » Thu Jul 23, 2020 5:58 am

Download demo file: https://www.dropbox.com/s/pn8r4b5qizdr0 ... o.pk3?dl=1

(too big to attach to forum)

You can select which map to start on to see the various directional contrast modes in action.

The fire button fires a fireball with a dynamic light (for material interaction purposes).

Disabled - as if the feature doesn't exist
Models only - the statues and your hand have directional contrast
Models + world - like above, but additionally the whole world gets affected too - including the wall and floor contrast direction (looks better than ZDoom's fake contrast IMO), and materials on all level textures also appear without needing a dynamic light source
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: Directional contrast (models and optionally the world)

Postby HAL9000 » Thu Jul 23, 2020 12:05 pm

Hi Nash. How can I test this,what GZDoom build is compatible with Directional contrast?
User avatar
HAL9000
I'm sorry Dave, I'm afraid I can't do that
 
Joined: 16 Mar 2018
Discord: HAL9000#9378

Re: Directional contrast (models and optionally the world)

Postby Major Cooke » Thu Jul 23, 2020 1:56 pm

You'll have to compile your own build if you want to test it.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: Directional contrast (models and optionally the world)

Postby Deybar_TECH » Wed Jul 29, 2020 12:49 am

Oh God.
:shock:

As I understand, this will solve the
need to use 8 small points of light
to simulate a sun lamp for my 3D
models.
which is greatly reducing performance.

I don't know anything about how to compile.
So I can only wait until all this is
included in the next version of
GZDoom to try it.
User avatar
Deybar_TECH
Siempre vuelo mas alla de los <∟imites>
 
Joined: 26 Dec 2018
Location: La Paz - BOLIVIA

Re: Directional contrast (models and optionally the world)

Postby drfrag » Wed Jul 29, 2020 4:03 am

What about merging this into QZDoom?
User avatar
drfrag
Os voy a romper a pedazos!
Vintage GZDoom Developer
 
Joined: 23 Apr 2004
Location: Spain
Discord: drfrag#3555
Github ID: drfrag666

Re: Directional contrast (models and optionally the world)

Postby Talon1024 » Sun Aug 02, 2020 6:40 pm

The models seem to be lit in one direction only, regardless of which direction they are facing. For example, if you walk around the "models+world" map in Nash's example PK3, and run "summon DemonStatue 0" in the console a few times, you'll notice that the model is always lit from the front, and never from the back.
Talon1024
 
 
 
Joined: 28 Jun 2016
Github ID: Talon1024
Operating System: Debian-like Linux (Debian, Ubuntu, Kali, Mint, etc) 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Directional contrast (models and optionally the world)

Postby dpJudas » Mon Aug 03, 2020 3:22 am

Hmm, I can't spot any errors in the shader code in the PR itself. The directional contrast light vector is in world coordinates, pixelpos.xyz is in world coordinates, so the object normal vector should also be expected to be in world coordinates. Could there be a more general bug right now where the normal vector is not rotated for models?
dpJudas
 
 
 
Joined: 28 May 2016

Re: Directional contrast (models and optionally the world)

Postby Nash » Mon Aug 03, 2020 4:12 am

Talon1024 wrote:The models seem to be lit in one direction only, regardless of which direction they are facing. For example, if you walk around the "models+world" map in Nash's example PK3, and run "summon DemonStatue 0" in the console a few times, you'll notice that the model is always lit from the front, and never from the back.


Could be bugged normals on the model. I'll try to re-export it later.

(it may be possible that it's a mistake on my part, it's happened before LOL)

In the mean time, you can debug normals in-game by typing gl_ssao_debug 4
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: Directional contrast (models and optionally the world)

Postby Talon1024 » Mon Aug 03, 2020 8:18 am

BTW, it seems like scaling models up by a large factor in the MODELDEF file (for example, 10 on each axis) causes normals to break.
Talon1024
 
 
 
Joined: 28 Jun 2016
Github ID: Talon1024
Operating System: Debian-like Linux (Debian, Ubuntu, Kali, Mint, etc) 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Directional contrast (models and optionally the world)

Postby Major Cooke » Mon Aug 03, 2020 9:02 am

I take back what I said. QZDoom will need a reset first I think. Since the last build is so old and there's been so many directory changes, merging it is going to be a complete clusterfuck, especially as it attempted to merge the squared PR.
User avatar
Major Cooke
QZDoom Maintenance Team
 
Joined: 28 Jan 2007

Re: Directional contrast (models and optionally the world)

Postby Nash » Mon Aug 03, 2020 11:13 am

Talon1024 wrote:BTW, it seems like scaling models up by a large factor in the MODELDEF file (for example, 10 on each axis) causes normals to break.


So is this an exporter problem? GZDoom problem? Something else? This warrants its own topic. :)
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: Directional contrast (models and optionally the world)

Postby dpJudas » Mon Aug 03, 2020 1:16 pm

I did some testing with this model and I'm now 100% sure it has broken normals. If I programmatically forces it to recalculate the normals when loading the MD3 the light reflects correctly from the right direction.
dpJudas
 
 
 
Joined: 28 May 2016

Next

Return to Code Submissions

Who is online

Users browsing this forum: No registered users and 0 guests