Need help with shader

Discussion for Level editing, modeling, programming, or any of the other technical aspects of Quake
Post Reply
User avatar
Eraser
Posts: 19168
Joined: Fri Dec 01, 2000 8:00 am

Need help with shader

Post 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?
Last edited by Eraser on Wed Jun 06, 2018 9:14 am, edited 1 time in total.
KittenIgnition
Posts: 252
Joined: Sun Nov 06, 2011 11:11 pm

Re: Need help with shader

Post 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.
User avatar
Eraser
Posts: 19168
Joined: Fri Dec 01, 2000 8:00 am

Re: Need help with shader

Post by Eraser »

It's not doing what I wanted. There's no transparency at all.
KittenIgnition
Posts: 252
Joined: Sun Nov 06, 2011 11:11 pm

Re: Need help with shader

Post 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.
Post Reply