This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I would like to write a spatial shader and end up with the same result as with a spatial material.
As a first step I tried to mimic the spatial material but without success. My material (terrain) appears too bright.

Expected result (export from Blender):
Expected result

Material properties (export from Blender):
Material properties (export from Blender)

My spatial shader (too bright):
My spatial shader (too bright)

And here is the shader I've tried:

shader_type spatial;
render_mode diffuse_burley, specular_schlick_ggx, ensure_correct_normals, depth_draw_opaque;

uniform sampler2D sand_tex;
uniform sampler2D sand_normal;
uniform float sandres = 1;

void fragment() {
  vec3 sandcolor;

  sandcolor = texture(sand_tex, UV * sandres).rgb;
  ALBEDO = sandcolor;
  NORMAL_MAP = texture(sand_normal, UV * sandres).rgb;
  SPECULAR = 0.5;
  ROUGHNESS = 0.5;
  METALLIC = 0.0;

Do you see what I've missed?

Godot version 4.0 Alpha 6
in Engine by (38 points)

1 Answer

+1 vote
Best answer

You can convert a SpatialMaterial into a ShaderMaterial from the material drop down. The generated shader code will exactly replicate the SpatialMaterial that it was generated from.

enter image description here

by (1,122 points)
selected by

Fantastic! Thanks.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.