How to reproduce the spatial material with the spatial shader

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By FuLeZi

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):

Material properties (export from Blender):

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?

:bust_in_silhouette: Reply From: Ninfur

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

Fantastic! Thanks.

FuLeZi | 2022-04-26 05:33