Refactoring crap
This commit is contained in:
@@ -1,50 +0,0 @@
|
||||
shader_type spatial;
|
||||
render_mode cull_disabled;
|
||||
|
||||
uniform sampler2D npcTexture : filter_nearest;
|
||||
uniform vec4 color : source_color;
|
||||
uniform int frame;
|
||||
uniform int direction;
|
||||
|
||||
const int FRAMES = 1;
|
||||
const int DIRECTIONS = 4;
|
||||
const float PIXEL_UNIT = 1.0 / 32.0; // Define pixel-perfect unit
|
||||
|
||||
void vertex() {
|
||||
vec2 tileSize = vec2(1.0 / float(DIRECTIONS), 1.0 / float(FRAMES));
|
||||
vec2 topLeft = tileSize * vec2(
|
||||
float(direction % DIRECTIONS),
|
||||
float(frame % FRAMES)
|
||||
);
|
||||
vec2 bottomRight = topLeft + tileSize;
|
||||
|
||||
if(VERTEX_ID == 3) {
|
||||
UV = topLeft;
|
||||
} else if(VERTEX_ID == 2) {
|
||||
UV = vec2(bottomRight.x, topLeft.y);
|
||||
} else if(VERTEX_ID == 1) {
|
||||
UV = vec2(topLeft.x, bottomRight.y);
|
||||
} else if(VERTEX_ID == 0) {
|
||||
UV = bottomRight;
|
||||
}
|
||||
|
||||
// Round UV to the nearest pixel-perfect unit
|
||||
UV = floor(UV / PIXEL_UNIT + 0.5) * PIXEL_UNIT;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec4 npcColor = texture(npcTexture, UV);
|
||||
|
||||
if(npcColor.a == 0.0)
|
||||
discard;
|
||||
|
||||
// Remove PINK background
|
||||
if(npcColor.r == 1.0 && npcColor.g == 0.0 && npcColor.b == 1.0)
|
||||
discard;
|
||||
|
||||
// Remove GREEN borders
|
||||
if(npcColor.r == 0.00392156862745 && npcColor.g == 1.0 && npcColor.b == 0.0)
|
||||
discard;
|
||||
|
||||
ALBEDO.rgb = npcColor.rgb * color.rgb;
|
||||
}
|
||||
|
Reference in New Issue
Block a user