tutorials/shaders/shader_reference/shading_language #314
Replies: 10 comments 4 replies
-
| Note that the  ALBEDO = mix(pow((col.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), col.rgb * (1.0 / 12.92), lessThan(col.rgb, vec3(0.04045))); | 
Beta Was this translation helpful? Give feedback.
-
| It says "Per instance Uniforms are only available in Spatial (3D) shaders". I think that's no longer true as of 4.4? | 
Beta Was this translation helpful? Give feedback.
-
| Albedo means color for anyone else wandering. | 
Beta Was this translation helpful? Give feedback.
-
| For anyone looking for references to the  | 
Beta Was this translation helpful? Give feedback.
-
| In current godot (4.4.1) you set up shader globals under tab globals ->shader globals. The menu image here is no longer up to date. | 
Beta Was this translation helpful? Give feedback.
-
| Remember that changing uniform default of material already assigned to node wont change its current uniform value. | 
Beta Was this translation helpful? Give feedback.
-
| It doesn't say this in the documents, but all shader params and variables must be lower case. Godot will not warn you, the shader compiler will not warn you, things will just silently not work. | 
Beta Was this translation helpful? Give feedback.
-
| The "Uniform limits" section suggests to pack data into a texture. To elaborate on that, here are the high level steps: 
 The  If the data is  As a workaround, create an image with format  In C# it might look like this: int bytesPerPixel = 4;
byte[] data = new byte[width * height * bytesPerPixel];
int position = 0;
Span<byte> buffer = new(data);
// Looping over each pixel:
foreach (....) {
  System.Buffers.Binary.BinaryPrimitives.WriteInt32LittleEndian(buffer[position..], pixelData);
  position += bytesPerPixel;
}
Image.Format format = Image.Format.Rf;
Image image = Image.CreateFromData(width, height, false, format, data);In your shader, use an  int value = texelFetch(sampler, position, 0).r;This will read the correct value. Note that no conversion in the shader is needed, and as no real typecasting happens, there will be no precision loss. For more details, see the linked issue above. | 
Beta Was this translation helpful? Give feedback.
-
| It seems that a  | 
Beta Was this translation helpful? Give feedback.
-
| You can replace  float depth = texture(DEPTH_TEXTURE, SCREEN_UV).r;
vec4 upos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 – 1.0, depth, 1.0);
vec3 pixel_position = upos.xyz / upos.w;
vec3 normal = normalize(cross(dFdy(pixel_position),dFdx(pixel_position)));on  While  | 
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
tutorials/shaders/shader_reference/shading_language
Introduction: Godot uses a shading language similar to GLSL ES 3.0. Most datatypes and functions are supported, and the few remaining ones will likely be added over time. If you are already familia...
https://docs.godotengine.org/en/stable/tutorials/shaders/shader_reference/shading_language.html
Beta Was this translation helpful? Give feedback.
All reactions