Page 1 of 1
I'm having a few issues with lightmaps and alpha channels
Posted: Mon Apr 11, 2016 2:34 pm
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!
Re: I'm having a few issues with lightmaps and alpha channels
Posted: Mon Apr 11, 2016 2:51 pm
by Eraser
Wow, what is all that info on your screen?
Re: I'm having a few issues with lightmaps and alpha channels
Posted: Mon Apr 11, 2016 3:16 pm
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

Re: I'm having a few issues with lightmaps and alpha channels
Posted: Mon Apr 11, 2016 9:05 pm
by seremtan
that looks an awful lot like the glass texture from sphax's purebdcraft set
is this an MC-inspired map?
Re: I'm having a few issues with lightmaps and alpha channels
Posted: Mon Apr 11, 2016 9:56 pm
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.

Re: I'm having a few issues with lightmaps and alpha channels
Posted: Tue Apr 12, 2016 9:32 pm
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

Re: I'm having a few issues with lightmaps and alpha channels
Posted: Thu May 04, 2017 12:54 am
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.
Re: I'm having a few issues with lightmaps and alpha channels
Posted: Fri May 05, 2017 7:44 am
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.