Shader troubles


(DarthStevenus) #1

Alright, I have this waterfall shader I’m trying to get to work in a map. All goes well so far except that the sides of the waterfall are all black like this:

When they should be fully transparent. These are the three images I am using, all of them are .tga’s and I did color to alpha with a color value of 000000 (black) so anything black should be transparent.

And here is the shader I’m using.

textures/batcave/waterfall
{
    qer_editorimage textures/batcave/wf1
    qer_trans 0.65
    sort banner
    surfaceparm nonsolid
    surfaceparm nonopaque
    surfaceparm trans
    surfaceparm nomarks
    surfaceparm water
    q3map_material water
    deformvertexes normal 0.1 0.1
    deformvertexes wave 64 sin 0 0.75 0.2 1
    cull none
    {
        map textures/batcave/wf3
        blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
        tcMod scroll 0 -0.35
    }
    {
        map textures/batcave/wf2
        blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
        tcMod scroll 0 -0.75
    }
    {
        map textures/batcave/wf1
        blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
        tcMod scroll 0 -1
    }
    {
        map $lightmap
        blendFunc GL_DST_COLOR GL_ZERO
    }
}

I found that when I removed the lightmap the textures were fullbright and didn’t have any color but the black edges were gone. So this leads me to believe the problem is with the lightmap or it’s blend function. I opened the shader in shaderEd and looked through all the different blend functions but its hard to tell what it will look like in-game. Just taking the lightmap out is obviously not an option because a super bright glowing waterfall would just look weird.


(obsidian) #2

The texture stages are blended so that the alpha channel displays transparency (that’s what you want). The lightmap is filtered, which is a subtractive function that darkens the texture (not what you want). It has no alpha transparency. So the black edges are just the dark pixels generated by the lightmap.

Stuff like this really shouldn’t be lightmapped. Remove the lightmap, add surfaceparm nolightmap. If it is too bright, either darken the textures or remove one of the stages (you essentially have lots of white pixels layered on top of more white pixels). You can also try adjusting the transparency with alphaGen const or edit the alpha channel.


(DarthStevenus) #3

Hmm…so there’s absolutely no way what so ever for it to be lightmapped without having the black edges? Because in my map the waterfall stretches down to a bottomless pit with negative lights and I wanted it to be darkened by those lights so that it just faded out naturally.


(obsidian) #4

Instead of negative lights, why don’t you use a black fog. It’ll fade nicely into black and it will work with the waterfall.

Or you could try using q3map_alphaMod volume brushes with alphaGen vertex on each stage of the waterfall shader. That will fade it out.


(DarthStevenus) #5

Hadn’t thought of that but I’ll try it out, thanks.


(luciana07) #6

Hi Darth, how’s it now?


(DarthStevenus) #7

Unfortunately I haven’t had time to tinker with it lately…I’ve been spending all my time studying and trying desperately to pass calc 2 :confused: But I’ll get to it some time this week probably.