Skip to reading
Shaders, Effects & Layered Scenery

22. Import a shader without guessing its type

Edition 0.86.4.0

Revised 0.86.4.0 edition with new supplements; earlier 0.86.3.4 lessons and screenshot labels are retained within the supplied PDF.

Download PDFView PDF page

Use a built-in preset when it does the job. Import a shader when you have a specific effect and understand its inputs. A shader written for another engine or a shader website is not automatically ready to run.

1. Create or select an asset in Asset Designer and set its kind to Shader.

2. Browse to a .gdshader, .glsl, .frag or .fs file. Read the import result before applying.

3. For Godot source, the file must begin with shader_type spatial; or shader_type canvas_item;.

4. Choose a spatial asset for a 3D surface. Choose a canvas asset for a room screen shader, GUI or overlay.

5. Apply the asset and assign it through the destination’s Imported Shader selector.

6. Save and test in the intended renderer. Keep the source license and attribution with your project.

Source table from 22. Import a shader without guessing its type, page 26
Importer boundaryWhat to do
Simple GLSL fragment with void main()The limited converter can translate a predictable fragment subset.
Canvas GLSL fragmentThe converter recognizes the pca3d:canvas marker. Otherwise GLSL imports as spatial.
Vertex program, includes or Shadertoy mainImageConvert it manually to a compatible Godot shader first.
Custom uniform controlsDo not assume the built-in preset sliders populate arbitrary uniforms. Use suitable defaults or a deliberate custom setup.
A shader selected on a surfaceIt replaces that surface’s built-in effect layers while selected.

A shader can compile and still be wrong for its destination. A room screen shader needs to read the rendered screen; an object shader needs the surface’s texture or material inputs. A plain ColorRect does not supply a model’s texture automatically.

Page 26 of 93Permalink
Go to page