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

I'm having a few issues with lightmaps and alpha channels
https://www.quake3world.com/forum/viewtopic.php?f=10&t=51949
Page 1 of 1

Author:  KittenIgnition [ 04-11-2016 06:34 AM ]
Post subject:  I'm having a few issues with lightmaps and alpha channels

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



Attachment:
glass.png
glass.png [ 2.84 KB | Viewed 1931 times ]


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:
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!

Author:  Eraser [ 04-11-2016 06:51 AM ]
Post subject:  Re: I'm having a few issues with lightmaps and alpha channels

Wow, what is all that info on your screen?

Author:  KittenIgnition [ 04-11-2016 07:16 AM ]
Post subject:  Re: I'm having a few issues with lightmaps and alpha channels

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:

Author:  seremtan [ 04-11-2016 01:05 PM ]
Post subject:  Re: I'm having a few issues with lightmaps and alpha channels

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

is this an MC-inspired map?

Author:  sst13 [ 04-11-2016 01:56 PM ]
Post subject:  Re: I'm having a few issues with lightmaps and alpha channels

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:
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. ;)

Author:  KittenIgnition [ 04-12-2016 01:32 PM ]
Post subject:  Re: I'm having a few issues with lightmaps and alpha channels

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

Author:  KittenIgnition [ 05-03-2017 04:54 PM ]
Post subject:  Re: I'm having a few issues with lightmaps and alpha channels

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.

Author:  CZghost [ 05-04-2017 11:44 PM ]
Post subject:  Re: I'm having a few issues with lightmaps and alpha channels

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.

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