diff --git a/assets/4x4checker.png b/assets/4x4checker.png new file mode 100644 index 0000000..fd93130 Binary files /dev/null and b/assets/4x4checker.png differ diff --git a/assets/4x4checker.png.import b/assets/4x4checker.png.import new file mode 100644 index 0000000..6e9265a --- /dev/null +++ b/assets/4x4checker.png.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="StreamTexture" +path.s3tc="res://.import/4x4checker.png-2d12b07d9dea94e0b7f78a32f72bdad7.s3tc.stex" +path.etc2="res://.import/4x4checker.png-2d12b07d9dea94e0b7f78a32f72bdad7.etc2.stex" +metadata={ +"imported_formats": [ "s3tc", "etc2" ], +"vram_texture": true +} + +[deps] + +source_file="res://assets/4x4checker.png" +dest_files=[ "res://.import/4x4checker.png-2d12b07d9dea94e0b7f78a32f72bdad7.s3tc.stex", "res://.import/4x4checker.png-2d12b07d9dea94e0b7f78a32f72bdad7.etc2.stex" ] + +[params] + +compress/mode=2 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=true +flags/filter=true +flags/mipmaps=true +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/assets/4x4checkerColor.png b/assets/4x4checkerColor.png new file mode 100644 index 0000000..c67d5ab Binary files /dev/null and b/assets/4x4checkerColor.png differ diff --git a/assets/4x4checkerColor.png.import b/assets/4x4checkerColor.png.import new file mode 100644 index 0000000..66d87ff --- /dev/null +++ b/assets/4x4checkerColor.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/4x4checkerColor.png-aa2feda4a05a30bbb021b287c7398aac.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/4x4checkerColor.png" +dest_files=[ "res://.import/4x4checkerColor.png-aa2feda4a05a30bbb021b287c7398aac.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=2 +flags/repeat=true +flags/filter=false +flags/mipmaps=true +flags/anisotropic=false +flags/srgb=1 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=0.001 diff --git a/materials/HexTileCoordinateToTextureColor.gdshader b/materials/HexTileCoordinateToTextureColor.gdshader new file mode 100644 index 0000000..eed801b --- /dev/null +++ b/materials/HexTileCoordinateToTextureColor.gdshader @@ -0,0 +1,62 @@ +shader_type spatial; +render_mode specular_schlick_ggx, async_visible; + +uniform sampler2D MapAlbedoTexture : hint_black_albedo; +uniform mat4 HexAffineInverse; +varying vec2 map_coord; + +const mat2 _HexAffineInverse = mat2(vec2(1.333333, -0.6666667), vec2(0, -1.154701)); + +vec2 axial_to_offset(vec2 axial) { + ivec2 axial_i = ivec2(axial); + int x = axial_i.x; + int y = axial_i.y; + int off_y = y + (x - (x % 1)) / 2; + return vec2(float(x), float(off_y)); +} + +void vertex() { +// Input:2 + mat4 model_matrix = WORLD_MATRIX; + + vec3 origin = vec4(WORLD_MATRIX * vec4(0, 0, 0, 1)).xyz; + + vec3 axial_coords = vec3(_HexAffineInverse * origin.xz, 0); + +// Output:0 + map_coord = origin.xz * 0.25; + map_coord = axial_to_offset(axial_coords.xy) * 0.25; +} + +void fragment() { +// Input:3 + mat4 n_out3p0 = WORLD_MATRIX; + +// TransformDecompose:5 + vec3 n_out5p0 = n_out3p0[0].xyz; + vec3 n_out5p1 = n_out3p0[1].xyz; + vec3 n_out5p2 = n_out3p0[2].xyz; + vec3 n_out5p3 = n_out3p0[3].xyz; + +// VectorOp:9 + vec3 n_in9p1 = vec3(1.00000, 1.00000, 1.00000); + vec3 n_out9p0 = n_out5p3 * n_in9p1; + +// TextureUniform:4 + vec3 n_out4p0; + float n_out4p1; + { + vec4 n_tex_read = texture(MapAlbedoTexture, map_coord); + n_out4p0 = n_tex_read.rgb; + n_out4p1 = n_tex_read.a; + } + +// Output:0 + ALBEDO = n_out4p0; + +} + +void light() { +// Output:0 + +} diff --git a/scenes/Game.cs b/scenes/Game.cs index 9e6597e..45014ac 100644 --- a/scenes/Game.cs +++ b/scenes/Game.cs @@ -15,6 +15,7 @@ public class Game : Spatial private Label _numCoordsAddedLabel; private Label _numCoordsRemovedLabel; private TextureRect _worldTextureRect; + private Button _generateWorldButton; // scene nodes private Spatial _tileHighlight; @@ -49,7 +50,8 @@ public class Game : Spatial _mouseTileLabel = GetNode