Jump to content
The Dark Mod Forums

How do I get a gradual fade at the edges in a decal?


Fidcal

Recommended Posts

I'm trying to make a spilt drink decal based on the splat02 decal but fading out to transparent at its edges like dripping_slime05. I can't figure out how dripping_slime05 gets to fade out. The defs seem similar. When i convert dripping_slime05.dds to tga and examine it in Paintshop Pro it does not have any alpha channel though I don't know if that was lost in the conversion.

Link to comment
Share on other sites

Are you referring to the textures/decals/splat2 shader? It doesn't need no alpha channel, it's the blend keyword which does the "fading". You'll need to make the transparent regions black, and the opaque regions brighter. A white pixel in the texture would result in a black pixel on the screen.

Link to comment
Share on other sites

Mmm... well both have blend already. But when I look closer, splat just has blend filter while slime has blend gl_zero,gl_one_minus_src_color and also colored so maybe that's what makes it fade whereas splat is also dark and white but is a crisp edge. In fact it's dark and the white is transparent. Maybe all I need to do is fade it gradually to white. I got the idea somewhere that in Doom there is no variation of transparency - just opaque, half transparent and completely transparent. So I only just noticed when placing slime that it fades. Or rather it only just registered in my brain as I've used it before but didn't realize. I'll fool around with a new def and see what I get.

Link to comment
Share on other sites

Mmm... well both have blend already. But when I look closer, splat just has blend filter while slime has blend gl_zero,gl_one_minus_src_color and also colored so maybe that's what makes it fade whereas splat is also dark and white but is a crisp edge. In fact it's dark and the white is transparent.
Both blend methods have the "transparency" controlled by color, though they look at color in opposite ways (because blend filter is equivalent to blend gl_zero, gl_src_color).

 

blend filter multiplies what's on screen by your image; as a result, darker sections of your image change what's on screen more than lighter sections (white doesn't change anything at all). Colors are valid too.

 

blend gl_zero, gl_one_minus_src_color multiplies what's on screen by the inverse of your image; as a result, lighter sections of your image change what's on the screen more and darker sections change it less (black doesn't change it at all). Colors are valid too, but result in the opposite color being seen. Think of your image like a mask. The advantage of this blend technique is that

red 1 - parm0
green 1 - parm1
blue 1 - parm2

can be used, allowing the mapper to control the color/intensity of the image via an entity's color.

 

I got the idea somewhere that in Doom there is no variation of transparency - just opaque, half transparent and completely transparent.
In general that's not true, but for surfaces to interact with lighting and shadows, they must be fully opaque (though it is ok for them to have "holes" where they're not drawn at all). Transparent surfaces may interact with lighting but cannot receive shadows. Lighting is additively blended, so its transparency would be controlled by the color.
Link to comment
Share on other sites

snip

 

Thanx for the excellent explanations!

 

@Fidcal: Here is a link I am refering often to:

 

http://www.iddevnet.com/doom3/materials.php

 

@Gildoran:

 

Your remarks about shadows got me thinking that my blue tiles (the version with the red base + blue overlay) looked mighty odd in the shadows. Maybe this is an issue.

 

Can you please have a look at this material and tell me if what I want to achive is actually possible with doom shaders or if it would be better to "paint" complete diffuse maps for each tile color (aka "only blue, red, green and maybe yellow")?

 

Please see here:

 

http://forums.thedarkmod.com/index.php?showt...st&p=147621

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

(because blend filter is equivalent to blend gl_zero, gl_src_color).

 

Does that mean blend gl_zero, gl_one_minus_src_color is the equivelant of blend add?

 

red 1 - parm0

green 1 - parm1

blue 1 - parm2

can be used, allowing the mapper to control the color/intensity of the image via an entity's color.

 

Is this functionally different than using rgb *?

Link to comment
Share on other sites

Your remarks about shadows got me thinking that my blue tiles (the version with the red base + blue overlay) looked mighty odd in the shadows. Maybe this is an issue.
How are you doing the blue overlay? If it's multiplication, it should work fine. If you're doing something like blend blend, it'll be too bright.

 

Can you please have a look at this material and tell me if what I want to achive is actually possible with doom shaders or if it would be better to "paint" complete diffuse maps for each tile color (aka "only blue, red, green and maybe yellow")?
This is entirely possible. For a while I was trying to encourage people to avoid making multiple diffusemaps. In fact, textures/darkmod/stone/brick/red_sloppymortar_dark does exactly what you're looking for, except you'd change the rgb keyword into separate red, green and blue keywords. The one tricky bit would be getting the additive part part of the frob highlight to match the color (it may be easier to just not worry about it for now).

 

Does that mean blend gl_zero, gl_one_minus_src_color is the equivelant of blend add?
No, blend add is blend gl_one, gl_one.

 

blend gl_zero, gl_one_minus_src_color means to use the following formula:

screen = (0) * image + (1-image) * screen

which simplifies to

screen = (1-image) * screen

blend gl_one, gl_one (eg, blend add) means to use the following formula:

screen = (1) * image + (1) * screen

which simplifies to

screen = image + screen

Is this functionally different than using rgb *?
It's very similar; rgb x is shorthand for

red x
green x
blue x

Likewise, colored is shorthand for

red parm0
green parm1
blue parm2

Link to comment
Share on other sites

Does that mean blend gl_zero, gl_one_minus_src_color is the equivelant of blend add?

 

No, blend add is "gl_one, gl_one". Please see

 

http://www.iddevnet.com/doom3/materials.php

 

for reference. (need to scroll down a bit)

 

Is this functionally different than using rgb *?

 

Yes. rgb is basically "red parm0" "green parm1" and "blue parm2" and "red 1 - parm0" is just the inverse.

 

(I didn't know you could do "1 - parm0", which is kinda silly, because it follows you should be able to do this. Sometimes I feel really stupid)

 

The trick is that if you add "colored" as keyword to a material, the values of "parm0" etc are taken from spawnargs of the entity (actually from the three parts of the "_color" spawnarg), and if these are not set, they are 0. Which means if you create an entity in the editor, add a material with "colored" to it, the material is by default black.

 

If you don't use "colored", but add manually "red 1 - parm0" etc, then the inverse is true, meaning it is by default white and the _color spawnarg subtracts.

 

The wiki article http://wiki.thedarkmod.com/index.php/ShaderParm needs some more explanations, I guess. :blush:

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

How are you doing the blue overlay? If it's multiplication, it should work fine. If you're doing something like blend blend, it'll be too bright.

 

I used "blend blend" because it was the first that "worked". How do I use "multiplication"? The "overlay" is basically 0 alpha on the transparent parts, and 100% alpha on the blue parts.

 

This is entirely possible. For a while I was trying to encourage people to avoid making multiple diffusemaps. In fact, textures/darkmod/stone/brick/red_sloppymortar_dark does exactly what you're looking for, except you'd change the rgb keyword into separate red, green and blue keywords. The one tricky bit would be getting the additive part part of the frob highlight to match the color (it may be easier to just not worry about it for now).

 

Edit: Yes, I was worrying about the frob, too.

 

I *think* with the trick of "red parm0", it should be possible to make a material that is by default red and turns into whatever color is set in the editor. The only real problem is that DR doesn't show you this color - you'd need to start D3.

 

I have another go tomorrow creating overlays and a myriad of mosaics :D

 

Thanx again!

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

I used "blend blend" because it was the first that "worked". How do I use "multiplication"?
blend filter and blend modulate both mean multiplicative blending.

 

Edit: Yes, I was worrying about the frob, too.
If you only have one settable color, you might do something like this for the frob part:

{ // this can stay the same since it just scales the brightness of what's on screen
if ( parm11 > 0 )
blend	   gl_dst_color, gl_one
map		 _white
rgb		 0.40 * parm11
}
{
// implicit: blend gl_one, gl_zero
map alphaMapRepresentingColoredAreas
maskColor
}
{ // Where the alpha is high, additively blend, tinting with your color
if ( parm11 > 0 )
blend	   gl_dst_alpha, gl_one
map		 yourDiffuseMap
maskAlpha // just to make sure we don't screw up the alpha
red		 0.15 * parm11 * yourColor'sRed
green	   0.15 * parm11 * yourColor'sGreen
blue		0.15 * parm11 * yourColor'sBlue
}
{ // Where the alpha is low, additively blend normally
if ( parm11 > 0 )
blend	   gl_one_minus_dst_alpha, gl_one
map		 yourDiffuseMap
rgb		 0.15 * parm11
}

 

The only real problem is that DR doesn't show you this color - you'd need to start D3.
Any custom material stages will only show up in-game or in D3ed's preview... I wouldn't worry about it too much, since the editor image is only there to give an idea of what texture is being used when you don't have the lighting preview on.
Link to comment
Share on other sites

Well, can't say as I understand all this techy stuff so I just copied the slime one and inverted my image. It's come out the right way and fades how I want...

post-400-1205496699_thumb.jpg

Since which I see there are more splats in the Doom decals that I might have adapted.

Link to comment
Share on other sites

Thanx for the help again!

 

Any custom material stages will only show up in-game or in D3ed's preview... I wouldn't worry about it too much, since the editor image is only there to give an idea of what texture is being used when you don't have the lighting preview on.

 

well, the "problem" here is the editor won't show you whether you got red, blue, green or whatever tiles. Especially under Linux this is awkward, you always need to close DR, start D3, check out the color, then quit D3, then restart DR. Which is a major hassle :(

"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." -- George Bernard Shaw (1856 - 1950)

 

"Remember: If the game lets you do it, it's not cheating." -- Xarax

Link to comment
Share on other sites

This might be relevent or redundant depending on what;

 

I remember learning that decals in Doom 3 just use multiplication blending, and no alpha channel - this means that you can just use a texture of bright red blood on a white background, and anything white won't show up, but the red will look very dark depending on the surface. This looks fine for blood, but not much else.

Link to comment
Share on other sites

From what I remember, it depends on the decal's material settings. Multiplicative is one option. The big problem is that decals don't receive lighting themselves; they can only get colour from their backgrounds or from the image. So you can't simply overlay a decal on a surface unless you're OK with having it fullbright. That's one reason why we couldn't do vines with decals (the other reason being that they picked up the normal map from the surface behind them, which looked really bad).

My games | Public Service Announcement: TDM is not set in the Thief universe. The city in which it takes place is not the City from Thief. The player character is not called Garrett. Any person who contradicts these facts will be subjected to disapproving stares.
Link to comment
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.

  • Recent Status Updates

    • Petike the Taffer

      I've finally managed to log in to The Dark Mod Wiki. I'm back in the saddle and before the holidays start in full, I'll be adding a few new FM articles and doing other updates. Written in Stone is already done.
      · 4 replies
    • nbohr1more

      TDM 15th Anniversary Contest is now active! Please declare your participation: https://forums.thedarkmod.com/index.php?/topic/22413-the-dark-mod-15th-anniversary-contest-entry-thread/
       
      · 0 replies
    • JackFarmer

      @TheUnbeholden
      You cannot receive PMs. Could you please be so kind and check your mailbox if it is full (or maybe you switched off the function)?
      · 1 reply
    • OrbWeaver

      I like the new frob highlight but it would nice if it was less "flickery" while moving over objects (especially barred metal doors).
      · 4 replies
    • nbohr1more

      Please vote in the 15th Anniversary Contest Theme Poll
       
      · 0 replies
×
×
  • Create New...