Jump to content


Photo

Problems with blending modes


17 replies to this topic

#1 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 36631 posts

Posted 09 August 2007 - 11:11 AM

Frustration number four while working on the purchase screen. <_<


I am trying to add a blend effect to the object images. For some reason, however, if I point to a material file, the image will not be transparent. Instead, there are black (or white, depending on the blend mode I use) boxes around the image. The .tga itself is has a transparent background.

If I use blend blend, then the transparency renders properly, but that mode just looks like the object is drawn on top of the parchment--it doesn't actually 'blend' with the parchment at all.

Here's the material I'm using:

guis/assets/purchase_menu/lantern
{

{
blend modulate
map guis/assets/hud/inventory_icons/healthpotion_icon.tga
alpha parm3
}
}


And this is what it looks like:

Posted Image

Oddly, the black doesn't fill the entire dimensions of the image.

I know it's a longshot, but any ideas about why the blend modes aren't rendering the transparency properly?

#2 greebo

greebo

    Heroic Coder

  • Root
  • 15987 posts

Posted 09 August 2007 - 11:45 AM

Assuming the image has an alpha channel, have you tried to add an "alphatest" expression to the shader?

edit: As for your screenshot: the black squares are in the actual RGB bitmap, it seems that the alpha channel (which is shaped correctly) is ignored.

#3 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 36631 posts

Posted 09 August 2007 - 11:51 AM

Assuming the image has an alpha channel, have you tried to add an "alphatest" expression to the shader?


I did try an alphaTest 0.5, but it didn't have any effect I could see. Adding "translucent" didn't seem to effect anything either.

the black squares are in the actual RGB bitmap


I'm not sure what you mean by this. I tried a few different images, and the black boxes seem to follow the shape of the object in the image for some reason.

#4 greebo

greebo

    Heroic Coder

  • Root
  • 15987 posts

Posted 09 August 2007 - 11:52 AM

I was referring to the pixel data in the healthpotion_icon.tga file (see below).

Have you tried to directly refer to the image file (instead of a shader)?

Attached Files



#5 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 36631 posts

Posted 09 August 2007 - 11:55 AM

Hmm? This is what it looks like for me.

Posted Image

Is this a PS 7 problem again?

Have you tried to directly refer to the image file (instead of a shader)?


Yep, and that works fine. But it doesn't blend into the parchment and therefore doesn't look very good.

#6 greebo

greebo

    Heroic Coder

  • Root
  • 15987 posts

Posted 09 August 2007 - 12:08 PM

Can you upload your current state to somewhere so that I can take a look at it? Perhaps I can think about something, or maybe angua (although she's not at home currently, but later this evening).

And yes, this is what the image looks like in my Photoshop CS. The black image is in the actual RGB bitmap, the alpha channel is correctly shaped.

#7 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 36631 posts

Posted 09 August 2007 - 12:16 PM

I just loaded it in my PS5.5 downstairs, and it looks like yours there. Clearly I need a new version of PS, because 7 does not render it like that all.

#8 OrbWeaver

OrbWeaver

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 7409 posts

Posted 09 August 2007 - 12:17 PM

AFAIK "blend modulate" makes no use of the alpha channel at all. If you want no effect, you have to use white pixels, since anything darker will darken the underlying image.

#9 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 36631 posts

Posted 09 August 2007 - 12:33 PM

Putting a white background instead of a transparency helped a lot. Here's what it looks like now, which is pretty close to what I wanted:

Posted Image

#10 greebo

greebo

    Heroic Coder

  • Root
  • 15987 posts

Posted 09 August 2007 - 12:40 PM

Ah, I see what you wanted to achieve. I like the look of it. Should we set the font color to darkgrey (0.9 0.9 0.9) (edit: actually 0.1 0.1 0.1 was meant, zomglol) instead of black?

#11 Springheel

Springheel

    Creative Director (retired)

  • Admin
  • 36631 posts

Posted 09 August 2007 - 12:59 PM

It's worth trying.

#12 New Horizon

New Horizon

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 13784 posts

Posted 09 August 2007 - 01:07 PM

That looks awesome Spring! :)

#13 OrbWeaver

OrbWeaver

    Mod hero

  • Active Developer
  • PipPipPipPipPip
  • 7409 posts

Posted 09 August 2007 - 01:17 PM

Yes, modulate is the best option for burned, stained or dirtied effects. It is the only blend effect which doesn't break the lighting (since both blend and add will make things appear to glow or be self-lit).

#14 sparhawk

sparhawk

    Repository Manager

  • Active Developer
  • PipPipPipPipPip
  • 21776 posts

Posted 09 August 2007 - 05:06 PM

That looks aweseome. :) As if it was painted that way. :)
Gerhard

#15 PinkDot

PinkDot

    Advanced Member

  • Member
  • PipPipPip
  • 1176 posts

Posted 09 August 2007 - 05:52 PM

What's the diffrence between blend filter and blend modulate? Anytime I used it in my material shader it gave the same results.

Hmm? This is what it looks like for me.

If I do some textures with alpha channels I never use that Photoshop transparency. I just have background in solid colour (black or whatever) and then I create a greyscale channel called Alpha1 (or something like this - the default name anyway) and I save it as TGA 32-bit. If you want the bottle to be semitransparent then Alpha channel should be grey there and black at the background.

#16 Crispy

Crispy

    Uber member

  • Member
  • PipPipPipPip
  • 4996 posts

Posted 10 August 2007 - 12:59 AM

Hmm? This is what it looks like for me.

The thing to remember in this situation is that two transparent pixels can actually have different RGBA values, and yet look exactly the same. For example, RGBA 0,0,0,255 is different from RGBA 255,255,255,255, even though they look exactly the same (i.e. they're completely transparent). That's what was happening with that health potion image; the alpha channel was being ignored entirely, so the RGBA 0,0,0,255 pixels were showing up black while the RGBA 255,255,255,255 pixels were showing up white. Greebo turned off the alpha channel in that image he posted in order to demonstrate this.

"Modulate" basically means "multiply" (using decimal values for the colours, i.e. 0.0 to 1.0 instead of 0 to 255), which is why white looks "transparent" with the modulate blend mode active. Since white is "RGB 1.0, 1.0, 1.0" (again using decimal notation), and 1.0 multiplied by any number is that number.

The end result looks cool, nice work. :)

@PinkDot: Modulate and filter are the same, according to this handy reference page.
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.

#17 nbohr1more

nbohr1more

    Darkmod PR, Wordsmith

  • Development Role
  • PipPipPipPipPip
  • 8176 posts

Posted 06 February 2017 - 01:03 PM

Hey Judith:

 

https://modwiki.xnet..._stage_keyword)

 

https://modwiki.xnet...ode_(Materials)

 

(The old Modwiki is gone.)


  • Judith 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...)

#18 Judith

Judith

    Advanced Member

  • Member
  • PipPipPip
  • 758 posts

Posted 06 February 2017 - 03:54 PM

Oh, this stuff is good, something I can work on, thanks!





Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users