@Dschoonmaker said:
It's not possible with spatial material. You could convert the spatial material to a shader material and do it in a shader.
I've converted it and it gives me this with ObjectDither on:
shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_disabled,diffuse_burley,specular_schlick_ggx;
uniform vec4 albedo : hint_color;
uniform sampler2D texture_albedo : hint_albedo;
uniform float specular;
uniform float metallic;
uniform float distance_fade_min;
uniform float distance_fade_max;
uniform float roughness : hint_range(0,1);
uniform float point_size : hint_range(0,128);
uniform float rim : hint_range(0,1);
uniform float rim_tint : hint_range(0,1);
uniform sampler2D texture_rim : hint_white;
uniform vec3 uv1_scale;
uniform vec3 uv1_offset;
uniform vec3 uv2_scale;
uniform vec3 uv2_offset;
void vertex() {
UV=UV*uv1_scale.xy+uv1_offset.xy;
}
void fragment() {
vec2 base_uv = UV;
vec4 albedo_tex = texture(texture_albedo,base_uv);
ALBEDO = albedo.rgb * albedo_tex.rgb;
METALLIC = metallic;
ROUGHNESS = roughness;
SPECULAR = specular;
{
float fade_distance = abs((INV_CAMERA_MATRIX * WORLD_MATRIX[3]).z);
float fade=clamp(smoothstep(distance_fade_min,distance_fade_max,fade_distance),0.0,1.0);
int x = int(FRAGCOORD.x) % 4;
int y = int(FRAGCOORD.y) % 4;
int index = x + y * 4;
float limit = 0.0;
if (x < 8) {
if (index == 0) limit = 0.0625;
if (index == 1) limit = 0.5625;
if (index == 2) limit = 0.1875;
if (index == 3) limit = 0.6875;
if (index == 4) limit = 0.8125;
if (index == 5) limit = 0.3125;
if (index == 6) limit = 0.9375;
if (index == 7) limit = 0.4375;
if (index == 8) limit = 0.25;
if (index == 9) limit = 0.75;
if (index == 10) limit = 0.125;
if (index == 11) limit = 0.625;
if (index == 12) limit = 1.0;
if (index == 13) limit = 0.5;
if (index == 14) limit = 0.875;
if (index == 15) limit = 0.375;
}
if (fade < limit)
discard;
}
vec2 rim_tex = texture(texture_rim,base_uv).xy;
RIM = rim*rim_tex.x; RIM_TINT = rim_tint*rim_tex.y;
}
What am I supposed to edit here to lock it to how it looks when I'm at this distance?
https://imgur.com/PyTnpGx.jpg
I know I have to get rid of or modify these:
float fade_distance = abs((INV_CAMERA_MATRIX * WORLD_MATRIX[3]).z);
float fade=clamp(smoothstep(distance_fade_min,distance_fade_max,fade_distance),0.0,1.0);
Probably need to trick it into thinking I'm always at the same distance but not sure what controls it.
I tried to replace fade_distance, and while it does control the transparency, it also makes the object truly transparent, and I'm trying to avoid true transparency because then the objects do not see each other anymore.
EDIT: I think I got it.
float fade=clamp(smoothstep(-15,40,fade_distance),0.0,0.3);
-15 so player never reaches full 0 alpha for the 2nd object while looking through the first. It's the difference between distances and the last 2 values in those brackets (0.0, 0.3) that allows visibility through refractive objects. 0.3 ensures the object never reaches full opacity even in distance.