- Home /
How to debug a shader?
Is there a way to debug a CGPROGRAM shader by setting breakpoints and seeing variables in a watch window? I couldn't get it to work (the red breakpoint symbol turns to a hollow ring - I'm assuming that means it's disabled).
There doesn't seem to be any info in the docs regarding the debugging of shader code.
Any help would be appreciated. I'm using Unity Pro if that makes any difference.
Answer by Elecman · Apr 29, 2015 at 08:20 AM
You can now debug shaders in Visual Studio. See this guide: http://forum.unity3d.com/threads/debugging-shaders-in-visual-studio.322186/
Answer by ScroodgeM · Aug 15, 2012 at 06:02 PM
there's no way to debug shader using unity3d
shader is a special program that executes by GPU and can't be interacted.
you shoud use some third-party solution that emulates shader and try to run compiled shader there.
in unity the one easy way to debug what happened is to output values you want to check as color for geometry.
for example, simple row
return frac(IN.texcoord);
instead of return color can return a UV mapping info in color placed on geometry.
Your answer
Follow this Question
Related Questions
Are conditional breakpoints when debugging in VS2017 working for you? 2 Answers
callstacks and coroutines 0 Answers
Why does the frame debugger say node uses different shader when it isn't? 0 Answers
How to force the compilation of a shader in Unity? 5 Answers
UnityVS not breaking on exception and missing debug info 1 Answer