Initial commit
This commit is contained in:
36
game-of-life-test/dot_matrix.gdshader
Normal file
36
game-of-life-test/dot_matrix.gdshader
Normal file
@@ -0,0 +1,36 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
uniform sampler2D unlitTex;
|
||||
uniform sampler2D litTex;
|
||||
uniform sampler2D binDataTex;
|
||||
uniform int n;
|
||||
|
||||
const int cellSize = 8;
|
||||
|
||||
void vertex() {
|
||||
// Called for every vertex the material is visible on.
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
// Called for every pixel the material is visible on.
|
||||
vec2 totalGridSize = vec2(float(n) * float(cellSize));
|
||||
|
||||
vec2 scaledUV = UV * float(n);
|
||||
ivec2 cellIdx = ivec2(floor(scaledUV));
|
||||
vec2 cellUV = fract(scaledUV);
|
||||
|
||||
float binVal = texelFetch(binDataTex, cellIdx, 0).r;
|
||||
bool isWhite = binVal > 0.5;
|
||||
|
||||
vec4 color = texture(unlitTex, cellUV);
|
||||
if (isWhite) {
|
||||
color = texture(litTex, cellUV);
|
||||
}
|
||||
|
||||
COLOR = color;
|
||||
}
|
||||
|
||||
//void light() {
|
||||
// // Called for every pixel for every light affecting the material.
|
||||
// // Uncomment to replace the default light processing function with this one.
|
||||
//}
|
||||
Reference in New Issue
Block a user