How to use two texture (one is model texture one is contour texture) have the same weight line output by shader?

Viewed 14

The first is model texture

enter image description here

The code in fs :

void main(void){

if (drawWireframe)
{
    float ef = edgeFactor();
    color = mix(wireColor, newFaceColor, ef);
}

float depth = logisticDepth(gl_FragCoord.z);

fragColor = vec4(vec3(depth), 1.0f);}

This is contour shader picture:

enter image description here

The code is

float linearizeDepth(float depth)
{
    return (2.0 * near * far) / (far + near - (depth * 2.0 - 1.0) * (far - near));
}

float logisticDepth(float depth, float steepness = 0.1f, float offset = 5.0f)
{
    float zVal = linearizeDepth(depth);
    return (1 / (1 + exp(-steepness * (zVal - offset))));
}

void main(void)
{
    float depth = logisticDepth(gl_FragCoord.z);
     fragColor = vec4(vec3(depth,depth,depth), 1.0f);//-vec4(0,0,0.1,0);        
}

Now the output like this:

enter image description here

And the code is like this

#version 410
out vec4 FragColor;
in vec3 ourColor;
in vec2 TexCoord;
uniform sampler2D texture1;
uniform sampler2D texture2;
uniform int width;
uniform int height;
int half_size=3;
void main()
{
    vec4 color1 = texture(texture1, TexCoord);
    vec4 color2 = texture(texture2, TexCoord);
    vec4 color3;

    if(color2.g<=color1.g &&color2.g!=1)
        color3.rgb=vec3(1,0,0);
    else //if(color2.r==1)
        color3.rgb=vec3(1,1,1);

    FragColor = color2;
}

But I need the output lines are same weight

0 Answers
Related