Skip to content

Instantly share code, notes, and snippets.

@jotson
Last active June 17, 2026 20:12
Show Gist options
  • Select an option

  • Save jotson/c9e93d06da5d6dfa48ede8bd1e880630 to your computer and use it in GitHub Desktop.

Select an option

Save jotson/c9e93d06da5d6dfa48ede8bd1e880630 to your computer and use it in GitHub Desktop.
// For use in the next pass of a stencil outline shader in godot 4.6
// NOTE: Shader automatically converted from Godot Engine 4.6.2.stable's StandardMaterial3D.
shader_type spatial;
render_mode blend_mix, depth_draw_opaque, cull_back, diffuse_burley, specular_schlick_ggx, unshaded;
stencil_mode read, compare_not_equal, 1;
uniform vec4 albedo : source_color;
uniform sampler2D texture_albedo : source_color, filter_linear_mipmap, repeat_enable;
uniform float grow : hint_range(-16.0, 16.0, 0.001);
uniform ivec2 albedo_texture_size;
uniform float point_size : hint_range(0.1, 128.0, 0.1);
uniform float roughness : hint_range(0.0, 1.0);
uniform sampler2D texture_metallic : hint_default_white, filter_linear_mipmap, repeat_enable;
uniform vec4 metallic_texture_channel;
uniform sampler2D texture_roughness : hint_roughness_r, filter_linear_mipmap, repeat_enable;
uniform float specular : hint_range(0.0, 1.0, 0.01);
uniform float metallic : hint_range(0.0, 1.0, 0.01);
uniform vec3 uv1_scale;
uniform vec3 uv1_offset;
uniform vec3 uv2_scale;
uniform vec3 uv2_offset;
uniform float size = 1.0;
uniform float speed = 1.0;
uniform sampler2D noise: repeat_enable;
void vertex() {
UV = UV * uv1_scale.xy + uv1_offset.xy;
// Grow: Enabled
VERTEX += NORMAL * grow;
// MAGIC ***
vec4 clip_pos = PROJECTION_MATRIX * (MODELVIEW_MATRIX * vec4(VERTEX, 1.0));
vec2 uv = UV + VERTEX.xz;
uv += floor(TIME * 0.1 * speed) * 0.087;
vec4 n1 = texture(noise, uv) - 0.5;
vec4 n2 = texture(noise, uv + 0.3) - 0.5;
float x = n1.r * size * 0.01;
float y = n2.r * size * 0.01;
clip_pos += vec4(x, y, 0.0, 0.0) * clip_pos.w;
POSITION = clip_pos;
}
void fragment() {
vec2 base_uv = UV;
vec4 albedo_tex = texture(texture_albedo, base_uv);
ALBEDO = albedo.rgb * albedo_tex.rgb;
float metallic_tex = dot(texture(texture_metallic, base_uv), metallic_texture_channel);
METALLIC = metallic_tex * metallic;
SPECULAR = specular;
vec4 roughness_texture_channel = vec4(1.0, 0.0, 0.0, 0.0);
float roughness_tex = dot(texture(texture_roughness, base_uv), roughness_texture_channel);
ROUGHNESS = roughness_tex * roughness;
ALPHA *= albedo.a * albedo_tex.a;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment