http://arcsynthesis.org/gltut/Positioning/Tut03%20More%20Power%20To%20The%20Shaders.htmlのチュートリアルを進めています。
私は現在、三角形を作成し、それを円方向に動かし、徐々に白から緑に色を変えるレッスンを行っています。完全なサイクルの後、色は白に戻ります。白から緑へと徐々に色を変えようとしています。色の変化の方向を設定する条件ステートメントが true に評価されないように見えるため、変更が有効になりません。
これが私のフラグメントシェーダーです。
#version 330
out vec4 outputColor;
uniform float fragLoopDuration; //5.0f
uniform float time;
const vec4 firstColor = vec4(1.0f, 1.0f, 1.0f, 1.0f);
const vec4 secondColor = vec4(0.0f, 1.0f, 0.0f, 1.0f);
void main()
{
bool myFlag = false; //flag will indicate which direction color change will take.
float currTime = mod(time, fragLoopDuration);
float currLerp = currTime / fragLoopDuration; //currLerp range = (0.0f-1.0f)
if (currLerp == 0.9f) myFlag = !myFlag; //this flag is not geting triggered.
if (myFlag) outputColor = mix(secondColor, firstColor, currLerp * -1.0f + 1.0f); //green to white
if (!myFlag) outputColor = mix(firstColor, secondColor, currLerp); //white to green
}