Godot Version
4.4
Question
Recently in Blender I’ve created an approach to 2D eyes that suits my needs with the bare minimum of art assets required: simply the pupils, red channel for the eyes themselves, outline, and anything behind them are required in both an open and blinking state.
It would save a ton of time and effort for simple stylized game ideas if I could get this working in Godot, however, despite viewing many tutorials, none I’ve seen cover transferring a shader for this kind of subject to Godot, I don’t even know if it’s possible, I was hoping someone here knows how.
All value nodes you’ll be seeing are storing a 0 to 1 “empty” shapekey that I’ll be using to export a variable controlled by a driver to Godot, since bone transformation space seems to vary
To breakdown the Blender shader, the first major part is a vector math sequence of subtract, divide, and add, in that order to set the origin point of the given texture. Whenever you see that going forward, know that the bottom input for divide controls the scale. This allows me to scale the eye layer itself without the pupil or eyelids in a way that looks more natural instead of flattening itself into either the top or bottom edge of the plane
Next I setup something similar for the pupils with a different origin point, since those are mostly centered (specifically I set X 0.5, Y 0.5 Z 1) and with both the X and Y of my shapekey value controlling the scale
That leads into the vector input of my “X” and “Y” shapekey values for pupil movement (the X will be flipped on the other eye)
And finally, the color and overlays. I’m feeding the alpha channels into each other so that the eye pupil is multiplied in a mix color onto the eye texture, that way the black outline always displays on top of the pupil, and the eyelid just sits in the back of everything.
All assets are pure red and black since swapping colors for customization is a big deal for my projects. I already made a custom color change shader in Godot that allows me to recolor the RGB channels independently, it goes something like this:
shader_type spatial;
render_mode diffuse_toon,specular_toon;
uniform vec4 Color1 : source_color;
uniform vec4 Color2 : source_color;
uniform vec4 Color3 : source_color;
uniform float Alpha = 1;
uniform sampler2D texture_albedo : source_color, filter_linear_mipmap, repeat_disable;
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 Tex_Color = texture(texture_albedo, base_uv);
vec4 End_Color = (Tex_Color.r * Color1 + Tex_Color.g * Color2 + Tex_Color.b * Color3);
ALBEDO = End_Color.rgb;
}
If you have a better one, or if redoing the shader from the ground up is required to get the overlays working, please do tell.
As a TLDR: the shader in Godot needs to have 3 (or 2 if I put the eyelids on the face texture) layers, pupils above eyes above eyelids, the pupils need to be displayed bellow the black outlines of the eyes, the pupils need to be able to move and scale on their own, the eye needs to scalable on the Y axis, and both need to have custom origin points set.
if you need any more info or images, let me know and I’ll provide. I REALLY need to get this working, please share any info on the subject you can
P.S don’t worry about anything for transitioning to a blink texture, I’ve already accounted for that in the script outside of the shader





