# What's the difference between two code in shader?

I'm doing a project with assimp.

I got confused with the weird situation for me. I think the both code are exactly same, but the result is different.

Why the codes act differently?

#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec3 aNormal;
layout (location = 2) in vec2 aTexCoords;

// declare an interface block; see 'Advanced GLSL' for what these are.
out VS_OUT {
vec2 TexCoords;
} vs_out;

out vec2 TexCoords;

uniform mat4 model;
uniform mat4 projection;
uniform mat4 view;

void main()
{
TexCoords = aTexCoords; ----(1)
//vs_out.TexCoords = aTexCoords; ----(2)
gl_Position = projection * view * model * vec4(aPos, 1.0);
}


#version 330 core
out vec4 FragColor;

in VS_OUT {
vec2 TexCoords;
} fs_in;

in vec2 TexCoords;

uniform sampler2D texture_diffuse1;
uniform vec3 lightPos;
uniform vec3 viewPos;

void main()
{
FragColor = vec4(texture(texture_diffuse1, TexCoords).rgb, 1.0); ----(1)
//FragColor = vec4(texture(texture_diffuse1, fs_in.TexCoords).rgb, 1.0); ----(2)
}


If I use the code above, the result is as follows

but, instead of (1) pair, if I use the pair (2), then the result is strange.

Why it happened?

• if you use (2), do you comment out the first line of your vertex shader (in the main function, the TexCoords assignement)? because if you do, i'm not sure this is legal - you'd have an out variable that never had a value assignment. – Tare Dec 15 '17 at 12:23
• I tried both of them. And all result were same. – shashack Dec 15 '17 at 12:30
• I added comment the below answer. I'm really sorry about that – shashack Dec 15 '17 at 20:58