Hello!
I have two issues with the 3D project I cannot find a solution to. Godot version is 3.5.2-custim build on Windows 10.
1) Shadows stop rendering at some (not very far) distance. And I can see a very distinct and obvious line where there are no more shadows. Is there a control for it? Please see the first image attached.
2) I have a shader material which is essentially a scaled noise for the color and for the transparency. What I notice is it works as intended only when the background is not too far. And there seems to be some threshold distance beyond which semitransparent parts become 100% transparent. Please see the second and 3-rd images attached. If it matters, I've pasted the shader code below.
I'd appreciate any advice! Thank you!
shader_type spatial;
render_mode unshaded, cull_disabled;
uniform float size_y = 15.0;
// Color related.
uniform float decay = 0.05;
uniform float power = 0.0;
uniform float exhaust_speed = 150.0;
uniform vec2 texture_scale = vec2( 2.0, 0.2 );
// Geometry related.
uniform float displacement_gain = 5.0;
uniform sampler2D noise;
uniform sampler2D displacement_x;
uniform sampler2D displacement_z;
uniform vec4 color_bright: hint_color = vec4( 0.6471, 0.8039, 1.0, 1.0 );
uniform vec4 color_dark: hint_color = vec4( 0.3529, 0.3529, 0.3529, 1.0 );
varying float time;
varying vec3 point3d;
varying vec3 normal3d;
varying vec2 tex_coords;
vec4 compute_color( sampler2D tex, float t, vec3 r )
{
float v = exhaust_speed / size_y;
vec2 uv = tex_coords * texture_scale;
uv.y -= v*t;
uv.y = mod( uv.y, 1.0 );
vec4 c = texture( tex, uv );
float coef = c.x;
vec3 color = color_bright.rgb * coef + color_dark.rgb * (1.0-coef);
float sz = size_y * (1.0 + power);
float a = 1.0 - pow( abs(r.y/sz), decay );
if (a < 0.0)
a = 0.0;
return vec4(color.rgb, a);
}
vec2 compute_displacement( float t, float v, vec3 r, vec3 n )
{
v /= size_y;
vec2 uv = tex_coords;
uv.y -= v*t;
uv.y = mod( uv.y, 1.0 );
float gain = abs(r.y/size_y) * displacement_gain;
float dx = texture( displacement_x, uv ).r - 0.5;
float dz = texture( displacement_z, uv ).r - 0.5;
dx *= gain;
dz *= gain;
return vec2( dx, dz );
}
void vertex()
{
time = TIME;
point3d = VERTEX;
normal3d = NORMAL;
tex_coords = UV;
vec2 d = compute_displacement( time, exhaust_speed, point3d, normal3d );
float x = VERTEX.x + d.x;
float z = VERTEX.z + d.y;
VERTEX.x = x;
VERTEX.z = z;
}
void fragment() {
vec4 c = compute_color( noise, time, point3d );
ALBEDO = c.rgb;
ALPHA = c.a;
}