You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When shaders are rendered in the Defold Editor viewport, a preprocessor definition `EDITOR` is available. This allows you to write shader code that behaves differently when running in the editor versus when running in the actual game engine.
346
+
347
+
This is particularly useful for:
348
+
- Adding debug visualizations that should only appear in the editor.
349
+
- Implementing editor-specific features like wireframe modes or material previews.
350
+
- Providing fallback rendering for materials that might not work properly in the editor viewport.
351
+
352
+
Use the `#ifdef EDITOR` preprocessor directive to conditionally compile code that should only run in the editor:
353
+
354
+
```glsl
355
+
#ifdef EDITOR
356
+
// This code will only execute when the shader is rendered in the Defold Editor
357
+
color_out = vec4(1.0, 0.0, 1.0, 1.0); // Magenta color for editor preview
358
+
#else
359
+
// This code will execute when running in the game
0 commit comments