Updated hologram shader to use instanced albedo
This commit is contained in:
parent
a23db504ca
commit
8a0e163e64
|
@ -161,10 +161,17 @@ func set_visual_build_progress(ratio: float) -> void:
|
|||
var geometries: Array[Node] = find_children("", "GeometryInstance3D", true)
|
||||
for node in geometries:
|
||||
var geometry: GeometryInstance3D = node as GeometryInstance3D
|
||||
var mesh_instance: MeshInstance3D = node as MeshInstance3D
|
||||
if geometry != null:
|
||||
if ratio >= 1.0:
|
||||
geometry.material_override = null
|
||||
else:
|
||||
if mesh_instance:
|
||||
var mesh_material: StandardMaterial3D = mesh_instance.mesh.surface_get_material(0)
|
||||
if mesh_material != null:
|
||||
var mesh_colour: Color = mesh_material.albedo_color
|
||||
geometry.set_instance_shader_parameter("albedo_color", mesh_colour)
|
||||
|
||||
geometry.material_override = hologram_material
|
||||
var built_amount: float = remap(ratio, 0, 1, hologram_build_min, hologram_build_max)
|
||||
geometry.set_instance_shader_parameter("built_amount", built_amount)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
shader_type spatial;
|
||||
render_mode blend_mix, depth_prepass_alpha, cull_disabled; // blend_add
|
||||
render_mode blend_add, depth_prepass_alpha, cull_disabled; // blend_add
|
||||
|
||||
uniform vec4 albedo_color : source_color;
|
||||
uniform float base_opacity: hint_range(0.0, 1.0) = 0.2;
|
||||
|
||||
group_uniforms warp;
|
||||
uniform bool enable_warp = false;
|
||||
|
@ -9,30 +9,45 @@ uniform vec3 warp_vector = vec3(1.0, 1.0, 1.0);
|
|||
uniform float warp_strength : hint_range(0.0, 1.0) = 0.5;
|
||||
uniform float warp_rate : hint_range(0.0, 200.0) = 0.5;
|
||||
|
||||
group_uniforms glow;
|
||||
uniform bool glow_enabled;
|
||||
uniform float glow_amount = 4.0;
|
||||
uniform float glow_intensity = 4.5;
|
||||
uniform vec3 glow_colour: source_color;
|
||||
|
||||
instance uniform float built_amount = 2.0;
|
||||
instance uniform vec4 albedo_color : source_color = vec4(1, 1, 1, 1);
|
||||
instance uniform vec4 hologram_colour : source_color = vec4(1.0, 0.54, 0.0, 1.0);
|
||||
|
||||
varying float model_y;
|
||||
|
||||
vec3 fresnel_glow(float amount, float intensity, vec3 color, vec3 normal, vec3 view) {
|
||||
return pow((1.0 - dot(normalize(normal), normalize(view))), amount) * color * intensity;
|
||||
}
|
||||
|
||||
// Called for every vertex the material is visible on.
|
||||
void vertex() {
|
||||
model_y = VERTEX.y;
|
||||
if (enable_warp && VERTEX.y > built_amount) {
|
||||
float offset = sin(pow(VERTEX.y, 2) * warp_rate * TIME) * pow(warp_strength, 2);
|
||||
float offset = sin(warp_rate * TIME) * pow(warp_strength, 2);
|
||||
VERTEX += offset * warp_vector;
|
||||
}
|
||||
}
|
||||
|
||||
// Called for every pixel the material is visible on.
|
||||
void fragment() {
|
||||
float base_opacity = 0.2;
|
||||
|
||||
if (model_y > built_amount) {
|
||||
vec3 fresnel = vec3(0, 0, 0);
|
||||
if (glow_enabled) {
|
||||
fresnel = fresnel_glow(glow_amount, glow_intensity, glow_colour, NORMAL, VIEW);
|
||||
}
|
||||
ALBEDO.rgb = (hologram_colour
|
||||
).rgb + fresnel;
|
||||
ALPHA = base_opacity;
|
||||
} else {
|
||||
ALPHA = 1.0;
|
||||
ALBEDO.rgb = albedo_color.rgb;
|
||||
}
|
||||
|
||||
ALBEDO.rgb = albedo_color.rgb;
|
||||
}
|
||||
|
||||
// Called for every pixel for every light affecting the material.
|
||||
|
|
|
@ -5,8 +5,12 @@
|
|||
[resource]
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_p0wwg")
|
||||
shader_parameter/albedo_color = Color(1, 1, 1, 1)
|
||||
shader_parameter/base_opacity = 0.2
|
||||
shader_parameter/enable_warp = true
|
||||
shader_parameter/warp_vector = Vector3(0.1, 0, 0.1)
|
||||
shader_parameter/warp_strength = 0.576
|
||||
shader_parameter/warp_rate = 29.667
|
||||
shader_parameter/glow_enabled = true
|
||||
shader_parameter/glow_amount = 4.0
|
||||
shader_parameter/glow_intensity = 4.5
|
||||
shader_parameter/glow_colour = Color(1, 0.470588, 1, 1)
|
||||
|
|
Loading…
Reference in New Issue