Page 1 of 1

3D model lighting via headlamp effect?

Posted: Sun Jun 24, 2018 8:10 am
by Diode
We all know that 3D models in typical doom environments without dynamic lights in them look ugly and flat due to being uniformly lit, so... why not light them with a headlamp that only illuminates models? Why not have their ambient light level be perhaps be slightly lower than the sector light level, and then apply the sector light level as a highlight shining from the camera (or even slightly above the camera)?

This would essentially be mimicking the way most sprites are shaded.

To get an idea of what this would looks like when strafing around a model, just open blender and rotate the camera around an unlit model. Blender applies the same headlamp effect.

Re: 3D model lighting via headlamp effect?

Posted: Sun Jun 24, 2018 8:23 am
by Cherno
What I would like to see instead is a global directional light, like sunlight, that shines from above at an angle, with a possible second, weaker directional light shining in the inverted direction (to light the areas of a model that the main light doesn't reach).

Re: 3D model lighting via headlamp effect?

Posted: Sun Jun 24, 2018 10:52 am
by Diode
Cherno wrote:What I would like to see instead is a global directional light, like sunlight, that shines from above at an angle, with a possible second, weaker directional light shining in the inverted direction (to light the areas of a model that the main light doesn't reach).
That would be nice for maps designed specifically for 3D models from the ground up, but that's a vanishingly small percentage of content. If you want models to look good across the board, you've got to work within the bounds of sector lighting.

Hence my call to apply the sector lighting as if it were shining from the camera.

Re: 3D model lighting via headlamp effect?

Posted: Wed Jun 27, 2018 9:43 am
by RockstarRaccoon
Keeping in mind I haven't really experimented with this yet, but doesn't attenuated lighting light them properly? I feel like it would be better to just get the normal lighting effects to work on them than to put in this Legacy work around...

Re: 3D model lighting via headlamp effect?

Posted: Wed Jun 27, 2018 12:19 pm
by Diode
RockstarRaccoon wrote:doesn't attenuated lighting light them properly? I feel like it would be better to just get the normal lighting effects to work on them than to put in this Legacy work around...
They do, but they do nothing to address the problem of sector lighting. Until you've got something applying sector light from an angle, sector lights are always going to result in flat looking models - which means models look flat on 99.9% of maps.

I know that shaders can be applied to models in GLDEFS, so if it's possible possible to tweak colors based on view angle, this is potentially a shader request rather than a feature request.

Re: 3D model lighting via headlamp effect?

Posted: Wed Jun 27, 2018 10:24 pm
by RockstarRaccoon
Could put an attenuated spotlight on the player's viewpoint that has relatively high intensity but #202020 as a color, and it would function like you're saying, I think...

Re: 3D model lighting via headlamp effect?

Posted: Thu Jun 28, 2018 8:41 am
by Diode
RockstarRaccoon wrote:Could put an attenuated spotlight on the player's viewpoint that has relatively high intensity but #202020 as a color, and it would function like you're saying, I think...
That would illuminate level geometry as well, and wouldn't match sector light.

The Hardware shaders (https://zdoom.org/wiki/GLDEFS#Hardware_shaders) section of the GLDEFS article says that lightlevel and camerpos are variables that can be used, so I'm inclined to think that this or something close to it can be done through shaders. ...Although the fact that nobody's done it yet also suggests that it can't be done with the current tools.

Hopefully someone who knows will weigh in on this.

Re: 3D model lighting via headlamp effect?

Posted: Sun Jul 01, 2018 6:11 am
by Diode
So, using my grotesquely limited coding abilities, I attempted to cobble a crude and not-quite-right matcap shader and and apply it to the model's brightmap to fake the effect I was asking for. It would mean no brightmaps, but it was worth a shot.

...Unfortunately it seems a shader can't be applied to a brightmap. Fuck.

Still, I'm sure there's a way to do this, and I'm sure someone who actually had a clue what they were doing would bust this out in no time.

All I was able to do was put my useless wonky matcap on a model. It's... misaligned, but it's there.

https://i.imgur.com/6wk85Vp.png

Re: 3D model lighting via headlamp effect?

Posted: Thu Jul 12, 2018 10:40 am
by Diode


I've done some more blind fumbling with shaders and this is the current result. On the left is a the default rendering of a model with no dynamic lights near it, on the right is the same spot with a shader applied. If I had a clue what I was doing, shader would be applying that shadow to the parts of the model that are closest to facing 90 degrees from the camera, but because I don't, the calculations are wrong. Still, the model no longer looks flat and dynamic shadows are imitated even if they're not in the desirable positions.

This isn't necessarily a feature suggestion at this point - so I'll probably post about this elsewhere.