是否禁止在片段着色器中更改不变量的值?当我尝试将新值设置为 "doseValue" 时,以下代码会崩溃:
const GLchar *point_fragment_shader =
"#version 420\n"
""
"/* Per Fragment Input Attributes */"
"in float doseValue;"
"in float alphaValue;"
"in vec2 displayUncertaintyByChangedColor;"
""
"/* Uniform Attributes */"
"uniform float minDisplayDoseValue;"
"uniform int pointVisualizationMode;"
""
"/* Per Fragment Output Values */"
"out vec4 out_color;"
""
"void main()"
"{"
" "
" /* Discard all Points whose dose value is below the minimum */"
" if(doseValue < minDisplayDoseValue)"
" {"
" discard;"
" }"
" else"
" {"
" if(displayUncertaintyByChangedColor.x == 1.0)"
" {"
" doseValue = 500.0;"
" }"
" ..."
在 vec2 内部,第一个分量是 0.0 或 1.0,第二个分量是一些浮点数。如果我设置一个新变量并在第二个 if 语句中使用任意值对其进行初始化,则不会出现错误。