holland01 / YAQ3R

view a (I)BSP map!
Other
6 stars 1 forks source link

bug in shader_gen.cpp for fragment shaders with alpha gen #17

Open holland01 opened 8 years ago

holland01 commented 8 years ago

In the WriteTexture(...) function there's this block:

sampleTextureExpr = SampleTexture2D( "sampler0", "st" );

    std::stringstream colorAssign;

    colorAssign << "\tvec4 color = ";

    // Some shader entries will incorporate specific alpha values
    if ( stage.alphaGen != 0.0f )
    {
        fragmentSrc.push_back( "\tconst float alphaGen = "
            + std::to_string( stage.alphaGen ) + std::to_string( ';' ) );

        colorAssign << sampleTextureExpr << ".rgb, alphaGen )";

        if ( UsesColor( stage ) )
        {
             colorAssign << " * vec4( frag_Color.rgb, alphaGen )";
        }
    }

If an alphaGen does exist, then colorAssign will end up looking like:

vec4 color = texture2D(sampler0, st).rgb, alphaGen );

So, there won't be an actual vec4 prefix in the constructor. What's weird that I haven't seen any explicit errors for this; it could be that a shader with an explicit alpha gen just hasn't been used yet.