I'm having a few issues with lightmaps and alpha channels

Discussion for Level editing, modeling, programming, or any of the other technical aspects of Quake
Post Reply
KittenIgnition
Posts: 252
Joined: Sun Nov 06, 2011 11:11 pm

I'm having a few issues with lightmaps and alpha channels

Post by KittenIgnition »

I've been working on this map for probably over a year, constantly dissatisfied with how it looks and how it plays - recently I decided the gameplay is good enough, and I'm going to release it as it is with just some lighting. However, I'm running into some really annoying lighting bugs...

[youtube]zH9qTuIfivU[/youtube]
glass.png
There's this glass shader, which has a border and the center is blank. When I render lighting, it creates a lightmap that covers the entire surface, including the blank centers of the glass. No combination of alphaFunc or blendFunc create exactly the result I'm looking for, which is lightmaps only on the glass borders.

Code: Select all

textures/mc/49
{
	qer_editorimage textures/mc/49.tga
	qer_alphafunc greater 0.5
	qer_trans 0.75
	q3map_lightmapSize 512 512
	q3map_lightmapBrightness 2.0
	q3map_alphaShadow
	q3map_lightFilter
	q3map_nonplanar
	surfaceparm trans
	{
		tcgen lightmap
		map $lightmap
		rgbGen identity
		blendfunc filter
	}
	{
		map textures/mc/49.tga
		alphaFunc GE128
		rgbGen identity
	}
}
I'm not sure what else to put here, any help is appreciated, and anything you need to know I'll try and answer... this is really bothering me. I just want to release a damn map!
User avatar
Eraser
Posts: 19177
Joined: Fri Dec 01, 2000 8:00 am

Re: I'm having a few issues with lightmaps and alpha channels

Post by Eraser »

Wow, what is all that info on your screen?
KittenIgnition
Posts: 252
Joined: Sun Nov 06, 2011 11:11 pm

Re: I'm having a few issues with lightmaps and alpha channels

Post by KittenIgnition »

Eraser wrote:Wow, what is all that info on your screen?
That's the kind of stuff you can see in Defrag. On the bottom-left is movement info - jump distance, angles, jump acceleration, jump speed, jump height, overbounces, X/Y/Z velocity... On the middle-right is simply movement speed, overbounces, and distance from crosshair. There are some pretty cluttered HUDs in Defrag :olo:
User avatar
seremtan
Posts: 36013
Joined: Wed Nov 19, 2003 8:00 am

Re: I'm having a few issues with lightmaps and alpha channels

Post by seremtan »

that looks an awful lot like the glass texture from sphax's purebdcraft set

is this an MC-inspired map?
sst13
Posts: 298
Joined: Mon Feb 15, 2010 11:05 pm

Re: I'm having a few issues with lightmaps and alpha channels

Post by sst13 »

The important missing keys are:

depthWrite in the stage with the alpha-channel texture using one of the alphaFuncs.
depthFunc equal in the lightmap stage.

Code: Select all

textures/mc/49
{
	qer_editorimage textures/mc/49.tga
	qer_alphafunc greater 0.5
	qer_trans 0.75
	q3map_lightmapSize 512 512
	q3map_lightmapBrightness 2.0
	q3map_alphaShadow
	q3map_lightFilter
	q3map_nonplanar
	surfaceparm trans
	{
		map textures/effects/tinfx3.tga
		blendfunc add
		rgbGen identity
		tcGen environment
	}
	{
		map textures/mc/49.tga
		alphaFunc GE128
		rgbGen identity
		depthWrite
	}
	{
		map $lightmap
		blendfunc filter
		rgbGen identity
		tcGen lightmap
		depthFunc equal
}
The first stage in this example is optional. ;)
[url=https://sst13.de]Q3A Maps - by sst13[/url]
[url=https://steamcommunity.com/id/_sst13_/myworkshopfiles]Quake Live Workshop[/url]
KittenIgnition
Posts: 252
Joined: Sun Nov 06, 2011 11:11 pm

Re: I'm having a few issues with lightmaps and alpha channels

Post by KittenIgnition »

Thank you!! That appears to have worked, thank you very much for the help.

Yes, it's a Minecraft map, if you had even looked at the thumbnail of the video you would have noticed that :o
KittenIgnition
Posts: 252
Joined: Sun Nov 06, 2011 11:11 pm

Re: I'm having a few issues with lightmaps and alpha channels

Post by KittenIgnition »

Now, for a nice necro post:

Is it possible to put lightmaps on a "blendFunc blend" shader in the same fashion? ie. so that the lightmap is only on the visible portions.
User avatar
CZghost
Posts: 1943
Joined: Wed Jun 22, 2011 1:45 pm
Location: Czechia
Contact:

Re: I'm having a few issues with lightmaps and alpha channels

Post by CZghost »

There are still people who play DeFrag? I tried it once but didn't fit well in my preferences, so I leaved DeFrag for ever, playing only vanilla Q3 and TA...

EDIT: The same method for blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA (aka blendFunc blend) doesn't work well, since the shader interpreter has no information about depth equality, alpha channel doesn't contain any information about depth and lightmap doesn't have alpha channel to be applied, so it would create nasty dark area throughout the texture with alpha channel.
With only blendFunc blend it's impossible to create a depth with depthWrite (it would create entire rectangle area filled, so nothing changed) as depthWrite needs a binary alphaFunc to work properly. Binary as it accepts a boolean value opaque/transparent, which is constructed on simple condition accessed to alphaFunc (GT0 = greater than 0 is opaque - creates nasty jagged edges, LT128 = less than 128 is opaque - inverts transparency, smooths out edges, GE128 = greater than or equal 128 is opaque - creates nice smooth edges)

You can, of course, combine those alphaFunc and blendFunc together, it will work. For best result I'd recommend to use alphaFunc GE128 together with blendFunc blend.
[ Linktree | Twitch | YouTube | Instagram | Websites ]
When you feel the worst, turn to the sun and all the shadows will fall behind you.” - John Lennon
Post Reply