id Tech Forums

id Tech 4 (Doom3/Prey/Q4) => id Tech 4 Textures => Topic started by: spamclark15 on July 25, 2017, 12:26:05 AM

Title: Light material question
Post by: spamclark15 on July 25, 2017, 12:26:05 AM
I've changed the color of the lights on doors for locked/unlocked but I'm noticing that, while the red image appears correctly, the green image seems to be a combination of both the "locked" and "unlocked" images. Looking through the material files, I found

Code: [Select]
textures/base_door/doorlight
{
//noShadows
qer_editorimage textures/base_door/doorlight_red.tga
bumpmap textures/base_door/doorlight_local.tga
        diffusemap textures/base_door/doorlight_red.tga
{
if ( parm7 == 0 )
blend add
map textures/base_door/doorlight_red.tga
colored
}
{
if ( parm7 == 1 )
blend add
map textures/base_door/doorlight_grn.tga
colored
}
}

textures/base_door/doorlight_red_to_green
{
qer_editorimage textures/base_door/doorlight_red.tga
bumpmap textures/base_door/doorlight_local.tga
        diffusemap textures/base_door/doorlight_red.tga
{
if ( parm7 == 1 )
blend add
map textures/base_door/doorlight_red.tga
rgb 5
}
{
if ( parm7 == 0 )
blend add
map textures/base_door/doorlight_grn.tga
rgb 5
}
}

textures/base_door/doorlight_grn
{
//noShadows
qer_editorimage textures/base_door/doorlight_grn.tga
bumpmap textures/base_door/doorlight_local.tga
        diffusemap textures/base_door/doorlight_grn.tga
{
blend add
map textures/base_door/doorlight_grn.tga
colored
}
}

Does anyone know enough about the material files who knows what needs changed to get green to appear fully opaque rather than a mixture?
Title: Re: Light material question
Post by: Snehk on July 25, 2017, 08:54:13 AM
I don't see anything wrong with those materials, but I'm not a materials expert, or even Doom3 modding expert. Maybe check which material doors scripts call?
Title: Re: Light material question
Post by: spamclark15 on July 25, 2017, 12:50:35 PM
It's not something wrong, it's just not looking quite like I would like. It's not an issue with scripts but rather the way the material is displaying the green light texture on top of the red but not displaying it opaquely.
Title: Re: Light material question
Post by: argoon on July 25, 2017, 01:48:50 PM
Instead of blend add

try all the other blend types and see what they do:

blend blend

blend filter

blend none

See here https://www.iddevnet.com/doom3/materials.php (https://www.iddevnet.com/doom3/materials.php)  for more information on materials.

You could also try removing the blend keyword and see what it does. 
Title: Re: Light material question
Post by: Phrozo on July 25, 2017, 01:58:44 PM
Yes try blend blend instead of blend add if you want opacity. Also do you have your switch values in reserve? Maybe I'm mistaken but
in textures/base_door/doorlight you have '0' as a switch for red and '1' as a switch for green but in textures/base_door/doorlight_red_to_green you have '1' as a switch for red and '0' as a switch for green.
Title: Re: Light material question
Post by: spamclark15 on July 25, 2017, 02:23:53 PM
Those switches are actually untouched from the original material file base_light.mtr. For all I know the originals _could_ be messed up. Here's what I got:

Replacing blend adds with blend none = green doesn't appear at all, red always shown and unlit
Replacing blend adds with blend blend or blend filter = both red and green appear but are unlit

So it's possible to get them opaque doing this but they no longer appear lit?
Title: Re: Light material question
Post by: Phrozo on July 25, 2017, 03:03:45 PM
If these are materials from the game then they should be fine. How many lights are there?
Title: Re: Light material question
Post by: argoon on July 25, 2017, 03:21:10 PM
Those switches are actually untouched from the original material file base_light.mtr. For all I know the originals _could_ be messed up. Here's what I got:

Replacing blend adds with blend none = green doesn't appear at all, red always shown and unlit
Replacing blend adds with blend blend or blend filter = both red and green appear but are unlit

So it's possible to get them opaque doing this but they no longer appear lit?

Blend add works like photoshop Overlay blend, there's no light coming of those textures is just a trick, so if you want a color to appear "lit" you need to "blend add" a white image to it.

Code: [Select]
        {
if ( parm7 == 0 )
blend filter
map textures/base_door/doorlight_red.tga
colored
}
        {
if ( parm7 == 0 )
blend add
map _white
}

 
Title: Re: Light material question
Post by: spamclark15 on July 25, 2017, 03:42:11 PM
Is there a certain order these need to be in? I added the additional stuff and now they appear just solid white. Is filter required as the blend type?
Title: Re: Light material question
Post by: argoon on July 25, 2017, 04:09:15 PM
Is there a certain order these need to be in? I added the additional stuff and now they appear just solid white. Is filter required as the blend type?

Perhaps, i'm using this from memory, i don't mess with idtech4 materials for a long time and i didn't tested the code above. But perhaps is full white because the blend add stage could be over-saturating the underlying color, you could try removing the blend filter and use other blend's, blend blend or blend diffusemap perhaps, you could also control the blend add strength with" rgb 1, 1, 1, alpha_number_here".

Is just a matter of trying until it works that was i found this stuff.

For example here is a material where i blend a color over a texture to make texture highlight system.

Code: [Select]
textures/door/door_wooden_door
{

wood

qer_editorimage textures/door/door_wooden_door.tga

diffusemap textures/door/door_wooden_door.tga

{
        if  ( parm7 > 0 )
        blend      blend
        map         _white
        color       0.99, 0.95, 0.62, 0.03
    }
}

The color keyword is so i can change the color of the highlight.
Title: Re: Light material question
Post by: spamclark15 on July 25, 2017, 07:24:17 PM
Code: [Select]

        {
blend blend
map textures/base_door/doorlight_grn.tga
colored
}
{
                blend   add
                map             _white
}

This was basically what I tried. I'm wondering if having multiple sections with a map causes the latter to replace the former?
Title: Re: Light material question
Post by: spamclark15 on July 26, 2017, 02:17:04 AM
Alright figured it out. Who keeps downvoting me for asking questions? Here comes another one, so get your downvote ready.

I'm wondering about the statues and the large beams that act as teleporters on the hell map. Since there don't seem to be any graphics files that are that green color or look the way they do, I assume they're defined as materials. Looking through the material file for hell doesn't have any obvious contenders. Is there a way I could determine the color and then search for that in all of the material files?
Title: Re: Light material question
Post by: Phrozo on July 26, 2017, 08:37:56 AM
Mind sharing what the solution was?
Title: Re: Light material question
Post by: spamclark15 on July 26, 2017, 03:29:31 PM
I ended up not using the extra white blend and have "blend blend" set as the blend type for the 2 lights. After testing it over a wider range of maps it does seem to work properly. The behavior that id gave the lights is unusual, particularly as use of the flashlight makes the default behavior worse, where light colors become a 50/50 mix of both images leaving you with yellow when really even under the flashlight, they should appear red or green and not any other color. I'm guessing it was done in a hurry.
Title: Re: Light material question
Post by: Phrozo on July 27, 2017, 12:14:19 AM
Hmm, still a bit perplexing. I wish I had Doom 3 installed to see so for myself.

Anyways the beams for the hell portals are made with particles. If you look at those particles in edit mode with the particle editor you should be able to select them and look at each stage to get the materials being used and also the vertex coloring used for that exact green it uses.
Title: Re: Light material question
Post by: spamclark15 on July 27, 2017, 01:51:29 AM
Found it in the particle editor. Why do some particle effects display properly while others create tons of black boxes rather than what I'm assuming is the correct artwork for them?

EDIT: Extracted everything out of the pak files. Apparently the game's editing tools don't like them so I have another copy of the game at C:\doom with everything extracted. Some effects still produce black squares but it's fewer in number.
Title: Re: Light material question
Post by: Phrozo on July 27, 2017, 10:34:18 AM
Particles will render solid black if the material being referenced can't be found or if the material is faulty. Some of the stock particles are broken but aren't used in game.
Title: Re: Light material question
Post by: spamclark15 on July 29, 2017, 01:06:28 AM
How about the blueish glow on the viewmesh for the soul cube? Is that a material as well or is the light defined somewhere else?

Any ideas?
Title: Re: Light material question
Post by: Phrozo on July 31, 2017, 03:54:55 PM
If I recall correctly the soulcubes specular map image is blueish so when light shines on it, it reflects 'blue'. So check in the soulcube material to see which image it is using for the specular blend stage.
Title: Re: Light material question
Post by: spamclark15 on August 01, 2017, 08:05:46 PM
Tried desaturating the textures for the soulcube but even with it in monochrome there is still a greenish blue light projected on the front. There's nothing that appears in the game's code that would be for this behavior and it doesn't seem to be treated as an actual light in the game as it doesn't show up as an entity when all entities are labeled.