Jump to content
The Dark Mod Forums

Negative Spectrum?


Recommended Posts

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?

  • Like 1

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

 

http://www.indiedb.com/mods/the-dark-mod

 

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

Link to post
Share on other sites

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.

Link to post
Share on other sites

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.dhewm3.org/Spectrum_(Material_global_keyword)

 

 

Is that what you tried?

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

 

http://www.indiedb.com/mods/the-dark-mod

 

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

Link to post
Share on other sites

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.

spectrum.pk4.txt

Link to post
Share on other sites

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.

  • Like 1
Link to post
Share on other sites

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...

  • Like 1

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

 

http://www.indiedb.com/mods/the-dark-mod

 

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

Link to post
Share on other sites

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.

 

textures/darkmod/wood/boards/rough_wood_darkbrown_dull_spectrum

{

 

wood

spectrum 1

qer_editorimage textures/darkmod/wood/boards/rough_wood_darkbrown_dull_ed

 

bumpmap textures/darkmod/wood/boards/rough_wood_fungi_local

diffusemap textures/darkmod/wood/boards/rough_wood_darkbrown_dull

 

{

if ( parm11 > 0 )

blend gl_dst_color, gl_one

map _white

rgb 0.40 * parm11

}

{

if ( parm11 > 0 )

blend add

map textures/darkmod/wood/boards/rough_wood_darkbrown_dull

rgb 0.15 * parm11

}

 

// TDM Ambient Method Related

{

if (global5 == 1)

blend add

map textures/darkmod/wood/boards/rough_wood_darkbrown_dull

scale 1, 1

red global2

green global3

blue global4

}

 

 

 

}

 

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

 

 

textures/darkmod/decals/dirt/stainwall_spectrum

{

polygonOffset 0.75 // this is 1 in DECAL_MACRO

discrete

sort decal

noShadows

spectrum 1

qer_editorimage textures/decals/stainwall.tga

{

blend gl_dst_color,gl_zero

map textures/decals/stainwall.tga

}

 

}

 

- 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.

 

 

textures/darkmod/decals/webs/web4_id_spectrum

{

 

qer_editorimage textures/darkmod/decals/webs/web4_ed

translucent

noshadows

twosided

nonsolid

spectrum 1

sort 5

bumpmap heightmap (textures/darkmod/decals/webs/web4, 2)

diffusemap textures/darkmod/decals/webs/web4

{

blend specularmap

map textures/darkmod/decals/webs/web4

red .25

green .25

blue .2

}

// TDM Ambient Method Related

{

if (global5 == 1)

blend add

map textures/darkmod/decals/webs/web4

scale 1, 1

red global2

green global3

blue global4

}

 

}

 

 

AWzG9hf.jpg

spectrum_v2.pk4.txt

Edited by Dragofer
  • Like 1
Link to post
Share on other sites

Thanks again.

 

Lot's to chew on there.

 

Alpha <float value>

 

is a stage keyword.

 

Some examples here:

 

http://wiki.thedarkmod.com/index.php?title=Making_Semi-transparent_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.com/mods/the-dark-mod

 

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

Link to post
Share on other sites

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.thedarkmod.com/topic/18980-fan-mission-briarwood-manor-by-neonsstyle-first-mission-6082017-update-16/

 

 

Link to post
Share on other sites

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.

Link to post
Share on other sites

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

Link to post
Share on other sites

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?

 

post-3763-0-91650700-1547359091_thumb.jpg

 

 

 

 


textures/darkmod/wood/boards/rough_wood_darkbrown_dull_spectrum1
{

    spectrum 2
	wood
	translucent
	
    qer_editorimage textures/darkmod/wood/boards/rough_wood_darkbrown_dull_ed

	bumpmap         textures/darkmod/wood/boards/rough_wood_fungi_local
	
	{
	blend diffusemap
	map   	_white
	rgb 0.3
	}
	
	{
	blend gl_one_minus_src_alpha, gl_one
	map textures/darkmod/wood/boards/rough_wood_darkbrown_dull
	rgb 0.5
	alpha 0.8
	}
	
    {
        if ( parm11 > 0 )
        blend       gl_dst_color, gl_one
        map         _white
        rgb         0.40 * parm11
    }
    {
        if ( parm11 > 0 )
        blend       add
        map         textures/darkmod/wood/boards/rough_wood_darkbrown_dull
        rgb         0.15 * parm11
    }
				

}

 

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

 

http://www.indiedb.com/mods/the-dark-mod

 

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

Link to post
Share on other sites

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?

 

 

 

 

textures/darkmod/wood/boards/rough_wood_darkbrown_dull_spectrum1
{

    spectrum 2
	wood
	translucent
	
    qer_editorimage textures/darkmod/wood/boards/rough_wood_darkbrown_dull_ed

	bumpmap         textures/darkmod/wood/boards/rough_wood_fungi_local
	
	{
	blend diffusemap
	map   	textures/darkmod/wood/boards/rough_wood_darkbrown_dull
	rgb 2
	}
	

    {
        if ( parm11 > 0 )
        blend       gl_dst_color, gl_one
        map         _white
        rgb         0.40 * parm11
    }
    {
        if ( parm11 > 0 )
        blend       add
        map         textures/darkmod/wood/boards/rough_wood_darkbrown_dull
        rgb         0.15 * parm11
    }
				

}

 

 

 

Procedure for creating spectrum materials (correct if necessary):

 

1. Add translucent and spectrum 1 near the top of the material.

2. Copy paste into the material file:

{

blend diffusemap

map (texture path)

rgb 2

}

3. Go to the material's diffusemap line, delete diffusemap, cut & paste the path so that it replaces (texture path) in the block from step 2.

 

 

To get a spectrum light all that's needed is to add spectrum 1 to the light's material.

 

 

 

 

 

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

Edited by Dragofer
Link to post
Share on other sites

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.

  • Like 1

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

 

http://www.indiedb.com/mods/the-dark-mod

 

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

Link to post
Share on other sites

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.thedarkmod.com/view.php?id=4361

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

 

http://www.indiedb.com/mods/the-dark-mod

 

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

Link to post
Share on other sites

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.com/mods/the-dark-mod

 

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

Link to post
Share on other sites

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.com/mods/the-dark-mod

 

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

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...