我是OpenGL ES編程的新手,我試圖調試我的着色器編程,我想知道是否有任何方法記錄特定變量的值。例如,在下面的頂點着色器程序,我想測試正常返回的值,基本上,我一直在尋找類似的NSLog東西......頂點着色器內部變量的日誌值
attribute vec4 position;
attribute vec3 normal;
attribute vec2 texture;
varying vec2 v_texCoord;
varying float LightIntensity;
uniform mat4 modelViewProjectionMatrix;
uniform mat3 normalMatrix;
void main()
{
vec3 eyeNormal = normalize(normalMatrix * normal);
vec3 lightPosition = vec3(-1.0, 0.0, 3.0);
float nDotVP = max(0.0, dot(eyeNormal, normalize(lightPosition)));
LightIntensity = nDotVP;
v_texCoord = texture;
gl_Position = modelViewProjectionMatrix * position;
}
看到這個問題的類似的討論:http://stackoverflow.com/questions/2508818/how-to-debug-a-glsl-shader –
感謝您的答案,我學到了新的東西:) – Pupillam