|
@@ -340,6 +340,27 @@ vec3 get_red_color_inverted()
|
|
}
|
|
}
|
|
```
|
|
```
|
|
|
|
|
|
|
|
+## Editor-specific shader code
|
|
|
|
+
|
|
|
|
+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.
|
|
|
|
+
|
|
|
|
+This is particularly useful for:
|
|
|
|
+ - Adding debug visualizations that should only appear in the editor.
|
|
|
|
+ - Implementing editor-specific features like wireframe modes or material previews.
|
|
|
|
+ - Providing fallback rendering for materials that might not work properly in the editor viewport.
|
|
|
|
+
|
|
|
|
+Use the `#ifdef EDITOR` preprocessor directive to conditionally compile code that should only run in the editor:
|
|
|
|
+
|
|
|
|
+```glsl
|
|
|
|
+#ifdef EDITOR
|
|
|
|
+ // This code will only execute when the shader is rendered in the Defold Editor
|
|
|
|
+ color_out = vec4(1.0, 0.0, 1.0, 1.0); // Magenta color for editor preview
|
|
|
|
+#else
|
|
|
|
+ // This code will execute when running in the game
|
|
|
|
+ color_out = texture(texture_sampler, var_texcoord0) * tint_pm;
|
|
|
|
+#endif
|
|
|
|
+```
|
|
|
|
+
|
|
## The rendering process
|
|
## The rendering process
|
|
|
|
|
|
Before ending up on the screen, the data that you create for your game goes through a series of steps:
|
|
Before ending up on the screen, the data that you create for your game goes through a series of steps:
|