Passing data through tessellation shaders to the fragment shader

一曲冷凌霜 提交于 2019-12-03 07:30:46

This is not surprising, TCS inputs/outputs must be in the form:

in  vec4 vs_color  [];
out vec4 tcs_color [];

or in input/output blocks that also take the form of unbounded arrays:

in CustomVertex {
  vec4 color;
} custom_vs [];

out CustomVertex {
  vec4 color;
} custom_tcs [];

For a little bit of context, this is what a TCS / geometry shader sees as the output from vertex shaders:

in gl_PerVertex
{
  vec4  gl_Position;
  float gl_PointSize;
  float gl_ClipDistance [];
} gl_in [];

To keep things as simple as possible, I will avoid using interface blocks.

Instead, I will introduce the concept of per-patch inputs and outputs, because they will further simplify your shaders considering the color is constant across the entire tessellated surface...

Modified Tessellation Control Shader:

      in  vec4 vs_color [];
patch out vec4 patch_color;

...

  patch_color = vs_color [gl_InvocationID];

Modified Tessellation Evaluation Shader:

patch in  vec4 patch_color;
      out vec4 tes_color;

...

  tes_color = patch_color;

With these changes, you should have a working pass-through and a slightly better understanding of how the TCS and TES stages work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!