+4 votes

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

in Engine by (474 points)

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.

1 Answer

+6 votes
Best answer

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.

by (27,601 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.