Jump to content


Photo

Negative Spectrum?

lights

17 replies to this topic

#1 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 9477 posts

Posted 11 January 2019 - 12:18 PM

While working on fog issues, I noted that the spectrum keyword (which allows you to pair lights to materials
based on spectrum number value) does not have an entity arg.

I was considering adding one to make the spectrum feature a little more useful but it struck
me that the main use case for spectrum outside of "hidden writing" is trying to keep lights
from illuminating unintended surfaces. In that context, we would not want to manually specify the matching
spectrum number for everything we want to be lit but rather we would want to have a flag that says
"light everything except this".

I am proposing that I can create a "noSpectrum" keyword that can achieve this opposite \ negative functionality.

It's an easy enough change.

Is it worth the addition?

Would any mappers use it?
  • Anderson likes this
Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

(Yeah, shameless promotion... but traffic is traffic folks...)

#2 Dragofer

Dragofer

    Modeler

  • Member
  • PipPipPip
  • 606 posts

Posted 11 January 2019 - 01:02 PM

While working on fog issues, I noted that the spectrum keyword (which allows you to pair lights to materials
based on spectrum number value) does not have an entity arg.

I was considering adding one to make the spectrum feature a little more useful but it struck
me that the main use case for spectrum outside of "hidden writing" is trying to keep lights
from illuminating unintended surfaces. In that context, we would not want to manually specify the matching
spectrum number for everything we want to be lit but rather we would want to have a flag that says
"light everything except this".

I am proposing that I can create a "noSpectrum" keyword that can achieve this opposite \ negative functionality.

It's an easy enough change.

Is it worth the addition?

Would any mappers use it?

 

Yes please, I missed spectrum lighting greatly in Down by the Riverside. I'm assuming you're thinking of just a small tweak, but I wasn't able to get spectrum to work at all.



#3 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 9477 posts

Posted 11 January 2019 - 01:10 PM

Hmm...

I'll double check the original spectrum setup too but I copied the core parts to make noFog work
and that works as expected. (I also used spectrum to help design lightgem culling in 2.05).

To be clear, the current inconvenient way to setup spectrum is:

Add spectrum <number> to the global area of your light shader material def

Add spectrum <same number> to the global area of your texture material def

(Managing this on a per texture basis sucks!)

https://modwiki.dhew...global_keyword)


Is that what you tried?
Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

(Yeah, shameless promotion... but traffic is traffic folks...)

#4 Dragofer

Dragofer

    Modeler

  • Member
  • PipPipPip
  • 606 posts

Posted 11 January 2019 - 01:28 PM

Yes, just tested it and found what my problem was again:

 

Adding non-zero spectrum to the material definition causes the texture to become pitch black ingame. The interaction between the spectrum light and object is correct, but in the absence of the correct spectrum light it's clearly visible where the spectrum object is because of its black silhouette.

 

I've attached my test map & materials, where I tested spectrum 0, 1 and 2.

Attached Files



#5 Dragofer

Dragofer

    Modeler

  • Member
  • PipPipPip
  • 606 posts

Posted 11 January 2019 - 01:33 PM

What would seem intuitive usage to me as a mapper would be if a "spectrum" "1" spawnarg could be added to an entity and a light (that order of priority), bringing spectrum into reach even for beginners. The nospectrum spawnarg would complement those spawnargs well I'd think.


  • nbohr1more likes this

#6 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 9477 posts

Posted 11 January 2019 - 01:38 PM

Yes, I recall this issue now.

In the original context, spectrum was performed against transparent decals
so they would disappear since you were multiplying the source alpha
by zero.

I'll try a few things tonight.

One thing you may try right now, is adding the translucent keyword to your material
and a small amount of alpha 0.0001 (etc).

Hmm...

I guess, another thing to do would be to exclude ambient lights from the spectrum check.
this would be more TDM specific but it would open up more uses too...
  • Dragofer likes this
Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

(Yeah, shameless promotion... but traffic is traffic folks...)

#7 Dragofer

Dragofer

    Modeler

  • Member
  • PipPipPip
  • 606 posts

Posted 11 January 2019 - 02:19 PM

adding a small amount of alpha 0.0001 (etc).

 
As I'm not so well-versed in material definitions I tried to implement this by adding a shaderParm5 Parameter & translucent to the material and setting shaderParm5 to 0.001 on the entity, but it seemed to have no effect. Might be my method was wrong.
 
In any case I've tried out a couple other transparent textures and added a moveable red spectrum light (on a pot lid). On the image from left:

- the original rough_wood_darkbrown cube, without my attempt to add alpha. Turns black in the absence of spectrum light.
Spoiler

- stainwall doesn't react at all to the spectrum keyword.
Spoiler

- web4_id will disappear correctly in the absence of spectrum light, but only a portion of the cube is lit up at any moment depending on light angle.
Spoiler


AWzG9hf.jpg

Attached Files


Edited by Dragofer, 11 January 2019 - 02:28 PM.

  • Anderson likes this

#8 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 9477 posts

Posted 11 January 2019 - 02:32 PM

Thanks again.

Lot's to chew on there.

Alpha <float value>

is a stage keyword.

Some examples here:

http://wiki.thedarkm...parent_textures

but the basic one I'd have you try is


{

  blend diffusemap
  map /path/to/texture
  alpha 0.01

}

I'll have lots to study tonight.
Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

(Yeah, shameless promotion... but traffic is traffic folks...)

#9 NeonsStyle

NeonsStyle

    Advanced Member

  • Member
  • PipPipPip
  • 1478 posts

Posted 12 January 2019 - 12:32 AM

Pardon my technical noobish ignorance. How would that be useful to a mapper? I may have a nice aesthetic sense, but I am severely lacking in the 

more technical aspects of TDM, something i hope to improve over time.


I have an eclectic YouTube channel making videos on a variety of games. Come and have look here:
 
https://www.youtube.com/c/NeonsStyleHD

 

Dark Mod Missions: Briarwood Manor - available here or in game

http://forums.thedar...2017-update-16/

 

 

 


#10 Dragofer

Dragofer

    Modeler

  • Member
  • PipPipPip
  • 606 posts

Posted 12 January 2019 - 06:54 AM

Pardon my technical noobish ignorance. How would that be useful to a mapper? I may have a nice aesthetic sense, but I am severely lacking in the 

more technical aspects of TDM, something i hope to improve over time.

 

My original idea for Down by the Riverside was to give the player a unique moveable light source that would reveal hidden scenes & objects within the mansion, including the ghostly path, requiring special care around the AI as it'd slightly illuminate the player as well. Even a more worldly map could use spectrum i.e. for revealing the hidden writing on a seemingly blank document (could be done by having a spectrum sheet 0.1 units above the blank sheet). Another idea that comes to mind now is having 2 sets of illumination in your map, where switching from one to the other changes how the same area appears to you. So there's quite some potential for creative use out of this I'd say.

 

nbohr1more furthermore mentions the possibility to avoid illuminating certain surfaces, which sounds like it can come in useful but for which I couldn't think of a usage case yet.

 

In the end I reverted to just binding a proximity trigger to the player that fades in the ghostly path when he comes close enough. Doesn't seem like I filed a bugtracker entry back then unfortunately.

 

 

Speaking of which, would it be possible to have spectrum light that's visible to the player? In the screenshot above you can't see the spectrum light unless you clone in an identical, but non-spectrum light.



#11 VanishedOne

VanishedOne

    Advanced Member

  • Member
  • PipPipPip
  • 982 posts

Posted 12 January 2019 - 03:05 PM

Pardon my technical noobish ignorance. How would that be useful to a mapper? I may have a nice aesthetic sense, but I am severely lacking in the 

more technical aspects of TDM, something i hope to improve over time.

The upper library in In The Black has eight overlapping lights projecting a shadow display onto the ceiling. Behind the scenes, the lights and the ceiling are on their own spectrum, so only the ceiling is lit by those lights, and the rest of the room is lit by a single light volume, to avoid performance costs.


Some things I'm repeatedly thinking about...

- louder scream when you're dying


#12 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 9477 posts

Posted 13 January 2019 - 01:00 AM

Yes, just tested it and found what my problem was again:
 
Adding non-zero spectrum to the material definition causes the texture to become pitch black ingame. The interaction between the spectrum light and object is correct, but in the absence of the correct spectrum light it's clearly visible where the spectrum object is because of its black silhouette.
 
I've attached my test map & materials, where I tested spectrum 0, 1 and 2.


Is this a little closer to what you wanted?

spectrum_2019-01-13_00.57.00.jpg

Spoiler

Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

(Yeah, shameless promotion... but traffic is traffic folks...)

#13 Dragofer

Dragofer

    Modeler

  • Member
  • PipPipPip
  • 606 posts

Posted 13 January 2019 - 04:52 AM

Is this a little closer to what you wanted?


Now this is quite ethereal, I can see plenty of potential already in that kind of effect. There is still a faint transparent silhouette in the absence of a spectrum light(my 2nd test map has a moveable light source), but this could be resolved without apparent downsides by taking out the block with blend_gl_one_minus. I've experimented a little more by blending the texture's own diffusemap instead of _white and turned rgb up to 2, which I think brought out some more definition in the texture.

It's a very likeable effect. Just tried it out on some other textures: how about finding a faintly green tinged, formerly invisible painting of an old man who's been dead for centuries when you relight his ancient candles?


Spoiler



Procedure for creating spectrum materials (correct if necessary):
Spoiler




Would you say that in order for spectrum to work correctly for hiding objects it requires the material to be translucent?

Edited by Dragofer, 13 January 2019 - 04:54 AM.


#14 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 9477 posts

Posted 13 January 2019 - 10:49 AM

Would you say that in order for spectrum to work correctly for hiding objects it requires the material to be translucent?


Yes.

Currently, translucent is a misleading keyword. It means "draw with an alpha blend".
Since spectrum just toggles the light interaction on a surface, the unlit material
must completely stop rendering when unlit. The only material that can do that
is some sort of GL blend and those require alpha manipulation.

I tried to find a gl blend mode that would saturate the alpha on the light texture
so that it would look like alpha-test on the material but I wasn't having much luck last night.

To make unlit surfaces disappear without translucent, we'd probably have to create a "view"
(like mirrors, portalsky, etc) to render those tris to. The caveat there is that it would
be all or nothing. If light hits part of a tri, then it's entire surface renders solid.
In that case, we'd still be at the point where we need to decide:

Ambient light on the unlit portion? vs Transparent on the unlit portion?

With the latter being a GL blend either built into the renderer or added to the material def.
  • Dragofer likes this
Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

(Yeah, shameless promotion... but traffic is traffic folks...)

#15 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 9477 posts

Posted 14 January 2019 - 09:24 PM

Some progress on the code side:

Rev 7913

Added Spectrum as an entity arg.

Currently this is purely Light Entity to Entity compared.

If either the entity defs mismatch OR the material defs mismatch
then the light won't render.


Rev 7914

New entity args.

lightspectrum keyword: just like spectrum but allows ambient light regardless of spectrum

nospectrum keyword: allow all lights except those that have a spectrum matching the nospectrum value


It seems that none of the newer saturate blend modes exist in the sources so
using blend modes to achieve the "fully visible if lit vs fully invisible if unlit"
function would require a custom light shader.

A use case that this tracker was created for:

http://bugs.thedarkm...iew.php?id=4361
Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

(Yeah, shameless promotion... but traffic is traffic folks...)

#16 New Horizon

New Horizon

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 13891 posts

Posted 15 January 2019 - 07:41 AM

Nice to see this finally happening.  I had requested a feature like this years ago.  It could have so many uses.



#17 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 9477 posts

Posted 15 January 2019 - 01:19 PM

Yes, Doom3world regularly had topics about the potential of this keyword and why it
was so frustrating in it's current form.

Note for later:

ignoreAlphaTest...
Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

(Yeah, shameless promotion... but traffic is traffic folks...)

#18 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 9477 posts

Posted 15 January 2019 - 01:29 PM

Looking into also adding a "stagespectrum" keyword. It seems that drawStatebits is the per-stage toggle.

Example (draw_common.cpp):


// skip the entire stage if a blend would be completely transparent
	if ( ( pStage->drawStateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) ) == ( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ) && color[3] <= 0 ) {
		return;
}

I might be able to do something further on the invisible if unlit front yet.
Please visit TDM's IndieDB site and help promote the mod:

http://www.indiedb.c...ds/the-dark-mod

(Yeah, shameless promotion... but traffic is traffic folks...)



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users