Page 1 of 1

Need help with shader

Posted: Tue Jun 05, 2018 8:01 pm
by Eraser
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?

Re: Need help with shader

Posted: Tue Jun 05, 2018 11:28 pm
by KittenIgnition
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.

Re: Need help with shader

Posted: Wed Jun 06, 2018 9:13 am
by Eraser
It's not doing what I wanted. There's no transparency at all.

Re: Need help with shader

Posted: Thu Jun 07, 2018 1:28 am
by KittenIgnition
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.
eraser_lq.jpg

Code: Select all

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: Select all

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.