In this exercise, you'll start with a different procedural texture. It works
fine, but I want you to know about an important debugging technique. Since you
can't put break points inside a shader, it's hard to know what's going on. The
answer is to send various shader computations to the screen itself. In other
words, instead of putting your final result into GL_FRAGColor, put these other
intermediate values. In fact, you have three whole color channels to use and
view on the screen. Your task is to send the following program values, diffuse,
ugain alpha, and attenuation to each of these channels. All three of these
values is in the proper range of zero to one, so need no adjustment. Here's
what things will look like when you're done. Under material control in the user
interface is a slider called gain alpha. So, I think it will change the green
channel to match the value selected. One bit to notice in the code is that
there's a sub routine called compute bias. It's fine to use sub routines inside
shaders, and they have a C language type of interface.
次は異なるプロシージャルテクスチャを例に
デバッグのやり方について説明しましょう
シェーダ内にブレークポイントを設定できないため
スクリーン自体にシェーダの計算結果を送ります
つまりgl_FragColorには最終的な値でなく
中間値を入れるわけです
ここに単一色のチャンネルが3つあります これにdiffuse、uGainAlpha、Attenuationの
3つのプログラム値を各チャンネルへ送ります
これらの値は0～1の範囲内にあるので 調整する必要はありません
結果 このような画像が現れます
操作画面上のgain alphaスライダで緑のチャンネルから
自分が選択する値へ変えられます
またシェーダ内の コンピュート･バイアスと呼ばれるC言語タイプの
サブルーチンを使用することもできます