Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Axis & Allies 1942 Online is now available in Early Access! Buy it on Steam. The FAQ is available.
New Premium Module: Tyrants of the Moonsea! Read More
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

a second texture/ decal as an overlay

Hi all,

i tried everything to get a second texture "texture1" in my material mtr shader working. Nope, nothing happens at all. So if anyone of you had a sucess already please post an example shader or tell me what i have to do. Here is what my own material shader looks like. Everything named correctly of course :

//customshaderVS vstomlB
//customshaderFS fstomlB

// Specifies a custom vertex shader: vsSkinned.shdcustomshaderFS fsFancyNew
// Specifies a custom fragment shader: fsFancyNew.shd

texture0 !cH_head001
// Specifies a texture that will be bound to texUnit0 in the fragment shader. Will override bitmap/tetxure0 in the model

texture1 !tmb_water01
// Binds to texUnit1 in the fragment shader. We support up to fifteen of these textures: texture0 - texture14.

texture2 tmb_water01
//test to see if this might work!

parameter float vDiffuse 0.8 1.0 0.65 1.0
// Creates a 4-float parameter that will be bound to a shader uniform of the same name (if it exists)

parameter float fModulator 0.5
// Creates a float parameter that will be bound to a shader uniform of the same name (if it exists)

parameter int iCount 2
// Creates an int parameter that will be bound to a shader uniform of the same name (if it exists)

//mipmap 0
//filter 0
//downsamplemax 0

Comments

  • NWN_TömlNWN_Töml Member Posts: 90
    edited February 2018
    Ok you happy modders...i got it working :smiley: Thanks to Sherincal once again ;)

    Here is the FS code as an example for you :

    uniform sampler2D texUnit0;
    uniform sampler2D texUnit1; //important second decal
    //uniform sampler2D texUnit2;
    uniform mediump float fogEnd;
    uniform mediump float fogStart;
    uniform lowp vec4 fogColor;
    uniform int fogMode;
    uniform int fogEnabled;
    uniform int texture0Bound;
    uniform int texture1Bound; //add this line for texunit1

    varying lowp vec4 vColorOut;
    varying mediump vec2 vTc;
    varying mediump float fFogFragCoord;

    void main (void)
    {
    lowp vec4 color;
    lowp vec4 env;

    color = vColorOut;
    if (texture0Bound != 0)
    {
    color = texture2D(texUnit0, vTc.xy);


    }

    if (texture1Bound != 0)
    {
    vec4 decal = texture2D(texUnit1, vTc.xy);
    color = mix(color, decal, decal.a); //here is the magic happening!!!
    }
    if (fogEnabled!=0)
    {
    if ( fogMode == 0 )
    {
    float fog;

    fog = (fogEnd - fFogFragCoord) / (fogEnd - fogStart);
    fog = clamp(fog, 0.0, 1.0);
    color = vec4(mix( vec3(fogColor), vec3(color), fog), color.a);
    }
    else if ( fogMode == 1 )
    {
    // Not implemented
    }
    else if ( fogMode == 2 )
    {
    // Not implemented
    }
    }

    gl_FragColor = color;
    }

Sign In or Register to comment.