52 lines
1.4 KiB
Plaintext
52 lines
1.4 KiB
Plaintext
|
[gd_resource type="ShaderMaterial" load_steps=2 format=2]
|
||
|
|
||
|
[sub_resource type="Shader" id=1]
|
||
|
code = "shader_type spatial;
|
||
|
render_mode blend_mix,depth_draw_opaque,cull_disabled,skip_vertex_transform;
|
||
|
|
||
|
|
||
|
uniform mat3 canvas_transform;
|
||
|
uniform sampler2D table : hint_albedo;
|
||
|
|
||
|
|
||
|
vec4 indx(int i) {
|
||
|
//return vec4(1.0, 1.0, 0.0, 1.0);
|
||
|
return textureLod(table, vec2(float(i) * 0.125 + 0.0625), 0);
|
||
|
}
|
||
|
|
||
|
void vertex() {
|
||
|
vec4 row0;
|
||
|
vec4 row1;
|
||
|
vec4 row2;
|
||
|
vec4 row3;
|
||
|
|
||
|
if (VERTEX.z >= 0.0) {
|
||
|
row0 = vec4(indx(0).x, indx(0).y, indx(0).z, indx(0).w);
|
||
|
row1 = vec4(indx(1).x, indx(1).y, indx(1).z, indx(1).w);
|
||
|
row2 = vec4(indx(2).x, indx(2).y, indx(2).z, indx(2).w);
|
||
|
row3 = vec4(indx(3).x, indx(3).y, indx(3).z, indx(3).w);
|
||
|
}
|
||
|
else {
|
||
|
row0 = vec4(indx(4).x, indx(4).y, indx(4).z, indx(4).w);
|
||
|
row1 = vec4(indx(5).x, indx(5).y, indx(5).z, indx(5).w);
|
||
|
row2 = vec4(indx(6).x, indx(6).y, indx(6).z, indx(6).w);
|
||
|
row3 = vec4(indx(7).x, indx(7).y, indx(7).z, indx(7).w);
|
||
|
}
|
||
|
mat4 crank_matrix = mat4(row0, row1, row2, row3);
|
||
|
|
||
|
|
||
|
vec4 pre = vec4(VERTEX, 1.0) * crank_matrix;
|
||
|
vec3 transformed_xy = vec3(pre.xy, 1.0) * transpose(canvas_transform);
|
||
|
vec4 post = vec4(transformed_xy.x, transformed_xy.y, pre.z, pre.w);
|
||
|
POSITION = post;
|
||
|
VERTEX = (post / post.w).xyz;
|
||
|
}
|
||
|
|
||
|
void fragment() {
|
||
|
ALBEDO = vec3(0.33, 0.81, 0.95);
|
||
|
}"
|
||
|
|
||
|
[resource]
|
||
|
shader = SubResource( 1 )
|
||
|
shader_param/canvas_transform = null
|