Summit
Summit

Reputation: 2258

How will the value be passed to the fragment shader

This is a extract from a Geometry shader.

#version 460 core

layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;

noperspective out vec3 g_edge_distance;

in vec3 world_pos[];
in vec3 normal[];

void main()
{
  
    // Calc triangle altitudes
    float ha = abs( c * sin( beta ) );
    float hb = abs( c * sin( alpha ) );
    float hc = abs( b * sin( alpha ) );

     g_edge_distance = vec3( ha, 0, 0 );
      gl_Position     = gl_in[0].gl_Position;
    EmitVertex();

     g_edge_distance = vec3( 0, hb, 0 );
      gl_Position     = gl_in[1].gl_Position;
    EmitVertex();

      g_edge_distance = vec3( 0, 0, hc );
       gl_Position     = gl_in[2].gl_Position;
    EmitVertex();

    EndPrimitive();
}

What i want to understand is how will the value of g_edge_distance be passed to the fragment shader.

Upvotes: 0

Views: 31

Answers (1)

Sergei Solokhin
Sergei Solokhin

Reputation: 366

You will have a value that is linear interpolated in a screen (window) space. You can read more about type qualifiers on the official khronos page

I think to quickly see and understand the difference, have a look at the Geeks3d tutorial

Upvotes: 1

Related Questions