Is there a way to debug shaders or print out a value?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Tybobobo
:warning: Old Version Published before Godot 3 was released.

Is there a way to print out a value from within Fragment, Vertex and Lighting shaders?

What i undertand is that all you can get from shaders is what you see, your only way to “debug” is on the print fashion trying to set specific areas to a different fixed color to try to understand where happens what.

eons | 2016-10-24 17:34

:bust_in_silhouette: Reply From: Zylann

In general, you cannot print from shaders, because they are executed on the graphic card, and even if you could, the output would be so flooded that you would be unable to see anything relevant (that thing gets run for every vertice and every pixel, you know^^).

The most common way of debugging a shader is to output different colors for testing, maybe moving the vertices, see the result, and going step by step.

Doing a quick research yields some results about shader debuggers that are specific to some graphic cards or shader languages (so it’s a thing, there is gDebugger for OpenGL), but I have no idea to what extent Godot could support something like that on any platform.