Quake3World.com
https://www.quake3world.com/forum/

Need help with shader
https://www.quake3world.com/forum/viewtopic.php?f=10&t=53913
Page 1 of 1

Author:  Eraser [ 06-05-2018 12:01 PM ]
Post subject:  Need help with shader

I've got a greyscale JPG texture (black background with white lines drawn on top) that I wish to be:
1 - lit with a lightmap (otherwise it ends up fullbright and that's ugly)
2 - I want the black to be 100% transparent and white to be 0% transparent (fully opaque) and everything in-between scaled

What should my shader look like?

Author:  KittenIgnition [ 06-05-2018 03:28 PM ]
Post subject:  Re: Need help with shader

Easy with alphaFunc, not so easy with blendFunc, for reasons unknown to me. I've done it plenty of times with alphaFunc, like so:


textures/whatever
{
{
map textures/whatever.tga
alphaFunc GE128
depthWrite
}
{
map $lightmap
blendfunc filter
rgbGen identity
tcGen lightmap
depthFunc equal
}
}

Pretty sure that works, I don't really feel like testing and etc. right now. I used to have one that actually used blendFunc, but I deleted that shader when I cleaned out my q3 a few months back ;_;

Maybe someone else can help further.

Author:  Eraser [ 06-06-2018 01:13 AM ]
Post subject:  Re: Need help with shader

It's not doing what I wanted. There's no transparency at all.

Author:  KittenIgnition [ 06-06-2018 05:28 PM ]
Post subject:  Re: Need help with shader

It requires an alpha channel. It creates solid borders around objects though - everything below 50% opacity is removed, and everything above is treated as 100%.

If that isn't good enough for you, I think what you want can't be done, unless you're okay with the lightmap being completely visible over the entire surface.

You can't have the lightmap fade the same as the texture underneath it, unless you cut out that part of the lightmap page and photoshop it - not very practical.

Attachment:
eraser_lq.jpg
eraser_lq.jpg [ 160.71 KB | Viewed 281 times ]


Code:
textures/eraser/blendFunc
{
   surfaceparm trans
   {
      map textures/eraser/eraser.tga
      blendFunc GL_DST_COLOR GL_ONE
      rgbGen identity
   }
   {
      map $lightmap
      rgbGen identity
      blendFunc filter
      tcGen lightmap
   }
}


Code:
textures/eraser/alphaFunc
{
   surfaceparm trans
   {
      map textures/eraser/eraser2.tga
      alphaFunc GE128
      rgbGen identity
      depthWrite
   }
   {
      map $lightmap
      rgbGen identity
      blendFunc filter
      depthFunc equal
      tcGen lightmap
   }
}


The blendFunc image is a jpg with some white lines and a gaussian blur applied, to ensure there's a gradient. I then warped it, duplicated one of the channels for alpha, and saved it as targa.

As far as I know, there's no way to inherit depth from blendFuncs because they don't have depth or they're weird somehow (?). AlphaFunc is great for this, because it lets you use the depth buffer info for other stages (?). I understand the concept but I don't know the words to apply to it lol.

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/