34 lines
1 KiB
Text
34 lines
1 KiB
Text
shader_type canvas_item;
|
|
|
|
uniform ivec2 location;
|
|
uniform ivec2 dimension = ivec2(1,1);
|
|
|
|
uniform float ground_height = 3000.;
|
|
uniform float cell_height = 300.;
|
|
uniform int num_cells = 60;
|
|
|
|
varying vec2 world_position;
|
|
|
|
void vertex()
|
|
{
|
|
world_position = (MODEL_MATRIX * vec4(VERTEX, 0.0, 1.0)).xy;
|
|
}
|
|
|
|
void fragment() {
|
|
float radius = sqrt(world_position.x * world_position.x + world_position.y * world_position.y);
|
|
float angle = atan(world_position.y, world_position.x);
|
|
|
|
float sample_y = 1. - ((radius - ground_height) / cell_height - float( location.y)) / float(dimension.y);
|
|
float sample_x = mod(fract(angle / TAU + 1.) * float(num_cells) - float(location.x) + float(num_cells), float(num_cells)) / float(dimension.x);
|
|
|
|
if(sample_y > 1. || sample_y < 0. || sample_x > 1. || sample_x < 0.) {
|
|
discard;
|
|
}
|
|
COLOR = texture(TEXTURE, vec2(sample_x, sample_y));
|
|
|
|
}
|
|
|
|
//void light() {
|
|
// // Called for every pixel for every light affecting the CanvasItem.
|
|
// // Uncomment to replace the default light processing function with this one.
|
|
//}
|