Jump to content

Partially Alpha Shader


Recommended Posts

Still nothing but here's what I have.

 

models/players/clonetrainees/comhelm

{
    {
        map models/players/clonetrainees/comhelm
        rgbGen lightingDiffuseEntity
    }
    {
        map models/players/clonetrainees/comhelm
        blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
        detail
        rgbGen lightingDiffuse
    }
}

Link to comment

The shader stages are rendered in the order of definition: First the one without a blendFunc (which defaults to standard opaque rendering), then the one with GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA (which does alpha blending according to the texture's alpha channel).

 

You'll want to drop the first one.

 

Now with alpha blending you run into sorting issues; because Quake 3 does not properly sort transparent surfaces before rendering stuff they may actually look like their order is reversed (the further one is displayed in front of the closer one). That's why you so often see additive blending - GL_ONE GL_ONE - because addition is commutative, so order doesn't matter. But I think additive blending is what you described as "ugly painted sheet of orange".

 

To work around this you can manually specify the sort order; Opaque stuff gets "sort opaque", which is equivalent to "sort 3", while transparent stuff defaults to "sort additive", which equals "sort 9". Surfaces are drawn low number to high number. Now you can give it "sort banner", which is "sort 6", to make it always draw between opaque and default transparent things. Assuming you can only see the model's face through the visor and not transparent level geometry behind the model, this will always look right.

 

So that's something like this:

 

models/players/clonetrainees/comhelm

{
    sort banner
    {
        map models/players/clonetrainees/comhelm
        blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
        rgbGen lightingDiffuse
    }
}
I also dropped the "detail", which would make it not show up when r_detailTextures is disabled.

 

This is purely theoretical and untested, mind. And your texture needs to have a proper alpha channel, so you'll have to edit it to add that. Unless you want uniform transparency, in which case you can add an "alphaGen const 0.3" to the stage to make it 30% opaque. (Tweak number as necessary, obviously.)

Kualan likes this
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...