简体   繁体   English

该值将如何传递给片段着色器

[英]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.我想了解的是如何将 g_edge_distance 的值传递给片段着色器。

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您可以在官方khronos 页面上阅读有关类型限定符的更多信息

I think to quickly see and understand the difference, have a look at the Geeks3d tutorial我想快速查看和理解差异,看看Geeks3d 教程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM