How to debug a GLSL shader?

后端 未结 11 1353
青春惊慌失措
青春惊慌失措 2020-11-28 17:38

I need to debug a GLSL program but I don\'t know how to output intermediate result. Is it possible to make some debug traces (like with printf) with GLSL ?

11条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-28 18:39

    void main(){
      float bug=0.0;
      vec3 tile=texture2D(colMap, coords.st).xyz;
      vec4 col=vec4(tile, 1.0);
    
      if(something) bug=1.0;
    
      col.x+=bug;
    
      gl_FragColor=col;
    }
    

提交回复
热议问题