Quake3World.com Forums
     Level Editing & Modeling
        Need help with shader


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC




Print view Previous topic | Next topic 
Topic Starter Topic: Need help with shader

Cool #9
Cool #9
Joined: 01 Dec 2000
Posts: 44131
PostPosted: 06-05-2018 12:01 PM           Profile   Send private message  E-mail  Edit post Reply with quote


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 06-06-2018 01:14 AM, edited 1 time in total.

Top
                 

Insane Quaker
Insane Quaker
Joined: 06 Nov 2011
Posts: 250
PostPosted: 06-05-2018 03:28 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

Cool #9
Cool #9
Joined: 01 Dec 2000
Posts: 44131
PostPosted: 06-06-2018 01:13 AM           Profile   Send private message  E-mail  Edit post Reply with quote


It's not doing what I wanted. There's no transparency at all.




Top
                 

Insane Quaker
Insane Quaker
Joined: 06 Nov 2011
Posts: 250
PostPosted: 06-06-2018 05:28 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.

Attachment:
eraser_lq.jpg
eraser_lq.jpg [ 160.71 KB | Viewed 277 times ]


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




Top
                 
Quake3World.com | Forum Index | Level Editing & Modeling


Post new topic Reply to topic


cron
Quake3World.com
© ZeniMax. Zenimax, QUAKE III ARENA, Id Software and associated trademarks are trademarks of the ZeniMax group of companies. All rights reserved.
This is an unofficial fan website without any affiliation with or endorsement by ZeniMax.
All views and opinions expressed are those of the author.