Tile rework and shader fun
This commit is contained in:
43
src/hue_shift.fs
Normal file
43
src/hue_shift.fs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#version 330
|
||||||
|
|
||||||
|
// Input from vertex shader
|
||||||
|
in vec2 fragTexCoord;
|
||||||
|
in vec4 fragColor;
|
||||||
|
|
||||||
|
// Output to the screen
|
||||||
|
out vec4 finalColor;
|
||||||
|
|
||||||
|
uniform sampler2D texture0;
|
||||||
|
uniform float hueShift;
|
||||||
|
|
||||||
|
// RGB to HSV conversion
|
||||||
|
vec3 rgb2hsv(vec3 c) {
|
||||||
|
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||||
|
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||||
|
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||||
|
float d = q.x - min(q.w, q.y);
|
||||||
|
float e = 1.0e-10;
|
||||||
|
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||||
|
}
|
||||||
|
|
||||||
|
// HSV to RGB conversion
|
||||||
|
vec3 hsv2rgb(vec3 c) {
|
||||||
|
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||||
|
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||||
|
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
// Standard Raylib texture lookup
|
||||||
|
vec4 texelColor = texture(texture0, fragTexCoord) * fragColor;
|
||||||
|
|
||||||
|
// Convert to HSV
|
||||||
|
vec3 hsv = rgb2hsv(texelColor.rgb);
|
||||||
|
|
||||||
|
// Shift the Hue (hsv.x) and wrap it around 1.0 using fract()
|
||||||
|
hsv.x = fract(hsv.x + hueShift);
|
||||||
|
|
||||||
|
// Convert back to RGB and output
|
||||||
|
vec3 rgb = hsv2rgb(hsv);
|
||||||
|
finalColor = vec4(rgb, texelColor.a);
|
||||||
|
}
|
||||||
@@ -4,8 +4,10 @@ import "core:fmt"
|
|||||||
import "core:strings"
|
import "core:strings"
|
||||||
import "vendor:raylib"
|
import "vendor:raylib"
|
||||||
|
|
||||||
delta: f32
|
shader: raylib.Shader
|
||||||
|
hue_loc: i32
|
||||||
|
|
||||||
|
delta: f32
|
||||||
player: Player
|
player: Player
|
||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
@@ -25,6 +27,12 @@ main :: proc() {
|
|||||||
init_world()
|
init_world()
|
||||||
defer deinit_world()
|
defer deinit_world()
|
||||||
|
|
||||||
|
// Test shader stuff
|
||||||
|
shader = raylib.LoadShader(nil, "hue_shift.fs")
|
||||||
|
hue_loc = raylib.GetShaderLocation(shader, "hueShift")
|
||||||
|
shift_value: f32 = 0.4
|
||||||
|
raylib.SetShaderValue(shader, hue_loc, &shift_value, .FLOAT)
|
||||||
|
|
||||||
player = {
|
player = {
|
||||||
position = {300, 300},
|
position = {300, 300},
|
||||||
camera = {
|
camera = {
|
||||||
|
|||||||
@@ -34,55 +34,6 @@ InteractionType :: enum {
|
|||||||
EXAMINE,
|
EXAMINE,
|
||||||
}
|
}
|
||||||
|
|
||||||
nothing_tile := Tile {
|
|
||||||
type = .NOTHING,
|
|
||||||
frame_index = 0,
|
|
||||||
interaction = .NONE,
|
|
||||||
resource = .NONE,
|
|
||||||
animator = nil,
|
|
||||||
}
|
|
||||||
|
|
||||||
ground_tile := Tile {
|
|
||||||
type = .GROUND,
|
|
||||||
frame_index = 0,
|
|
||||||
interaction = .NONE,
|
|
||||||
resource = .NONE,
|
|
||||||
animator = nil,
|
|
||||||
}
|
|
||||||
|
|
||||||
test_wall_tile := Tile {
|
|
||||||
type = .WALL,
|
|
||||||
frame_index = 5,
|
|
||||||
interaction = .NONE,
|
|
||||||
resource = .NONE,
|
|
||||||
animator = nil,
|
|
||||||
}
|
|
||||||
|
|
||||||
plant_tile := Tile {
|
|
||||||
type = .FLORA,
|
|
||||||
frame_index = 0,
|
|
||||||
interaction = .HARVEST,
|
|
||||||
resource = .FLORA,
|
|
||||||
animator = nil,
|
|
||||||
}
|
|
||||||
|
|
||||||
plant_2_tile := Tile {
|
|
||||||
type = .FLORA,
|
|
||||||
frame_index = 1,
|
|
||||||
interaction = .HARVEST,
|
|
||||||
resource = .FLORA,
|
|
||||||
animator = nil,
|
|
||||||
}
|
|
||||||
|
|
||||||
plant_3_tile := Tile {
|
|
||||||
type = .FLORA,
|
|
||||||
frame_index = 2,
|
|
||||||
interaction = .HARVEST,
|
|
||||||
resource = .FLORA,
|
|
||||||
animator = nil,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
draw_tile :: proc(
|
draw_tile :: proc(
|
||||||
tilemap_sheet: ^TilemapSpritesheet,
|
tilemap_sheet: ^TilemapSpritesheet,
|
||||||
tile: ^Tile,
|
tile: ^Tile,
|
||||||
|
|||||||
129
src/tile_definitions.odin
Normal file
129
src/tile_definitions.odin
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
Ground_Tile_ID :: enum {
|
||||||
|
NOTHING,
|
||||||
|
GROUND,
|
||||||
|
WALL,
|
||||||
|
}
|
||||||
|
|
||||||
|
Interactive_Tile_ID :: enum {
|
||||||
|
PEPE_1,
|
||||||
|
PEPE_2,
|
||||||
|
PEPE_3,
|
||||||
|
FLOWER_1,
|
||||||
|
FLOWER_2,
|
||||||
|
FLOWER_3,
|
||||||
|
MINERAL_1,
|
||||||
|
MINERAL_2,
|
||||||
|
MINERAL_3,
|
||||||
|
MINERAL_4,
|
||||||
|
MINERAL_5,
|
||||||
|
MINERAL_6,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GROUND_TILES_MAP := [Ground_Tile_ID]Tile {
|
||||||
|
.NOTHING = {
|
||||||
|
type = .NOTHING,
|
||||||
|
frame_index = 0,
|
||||||
|
interaction = .NONE,
|
||||||
|
resource = .NONE,
|
||||||
|
animator = nil,
|
||||||
|
},
|
||||||
|
.GROUND = {
|
||||||
|
type = .GROUND,
|
||||||
|
frame_index = 0,
|
||||||
|
interaction = .NONE,
|
||||||
|
resource = .NONE,
|
||||||
|
animator = nil,
|
||||||
|
},
|
||||||
|
.WALL = {type = .WALL, frame_index = 5, interaction = .NONE, resource = .NONE, animator = nil},
|
||||||
|
}
|
||||||
|
|
||||||
|
INTERACTIVE_TILES_MAP := [Interactive_Tile_ID]Tile {
|
||||||
|
.PEPE_1 = {
|
||||||
|
type = .FLORA,
|
||||||
|
frame_index = 0,
|
||||||
|
interaction = .HARVEST,
|
||||||
|
resource = .FLORA,
|
||||||
|
animator = nil,
|
||||||
|
},
|
||||||
|
.PEPE_2 = {
|
||||||
|
type = .FLORA,
|
||||||
|
frame_index = 1,
|
||||||
|
interaction = .HARVEST,
|
||||||
|
resource = .FLORA,
|
||||||
|
animator = nil,
|
||||||
|
},
|
||||||
|
.PEPE_3 = {
|
||||||
|
type = .FLORA,
|
||||||
|
frame_index = 2,
|
||||||
|
interaction = .HARVEST,
|
||||||
|
resource = .FLORA,
|
||||||
|
animator = nil,
|
||||||
|
},
|
||||||
|
.FLOWER_1 = {
|
||||||
|
type = .FLORA,
|
||||||
|
frame_index = 3,
|
||||||
|
interaction = .HARVEST,
|
||||||
|
resource = .FLORA,
|
||||||
|
animator = nil,
|
||||||
|
},
|
||||||
|
.FLOWER_2 = {
|
||||||
|
type = .FLORA,
|
||||||
|
frame_index = 4,
|
||||||
|
interaction = .HARVEST,
|
||||||
|
resource = .FLORA,
|
||||||
|
animator = nil,
|
||||||
|
},
|
||||||
|
.FLOWER_3 = {
|
||||||
|
type = .FLORA,
|
||||||
|
frame_index = 5,
|
||||||
|
interaction = .HARVEST,
|
||||||
|
resource = .FLORA,
|
||||||
|
animator = nil,
|
||||||
|
},
|
||||||
|
.MINERAL_1 = {
|
||||||
|
type = .FLORA,
|
||||||
|
frame_index = 6,
|
||||||
|
interaction = .HARVEST,
|
||||||
|
resource = .FLORA,
|
||||||
|
animator = nil,
|
||||||
|
},
|
||||||
|
.MINERAL_2 = {
|
||||||
|
type = .FLORA,
|
||||||
|
frame_index = 7,
|
||||||
|
interaction = .HARVEST,
|
||||||
|
resource = .FLORA,
|
||||||
|
animator = nil,
|
||||||
|
},
|
||||||
|
.MINERAL_3 = {
|
||||||
|
type = .FLORA,
|
||||||
|
frame_index = 8,
|
||||||
|
interaction = .HARVEST,
|
||||||
|
resource = .FLORA,
|
||||||
|
animator = nil,
|
||||||
|
},
|
||||||
|
.MINERAL_4 = {
|
||||||
|
type = .FLORA,
|
||||||
|
frame_index = 9,
|
||||||
|
interaction = .HARVEST,
|
||||||
|
resource = .FLORA,
|
||||||
|
animator = nil,
|
||||||
|
},
|
||||||
|
.MINERAL_5 = {
|
||||||
|
type = .FLORA,
|
||||||
|
frame_index = 10,
|
||||||
|
interaction = .HARVEST,
|
||||||
|
resource = .FLORA,
|
||||||
|
animator = nil,
|
||||||
|
},
|
||||||
|
.MINERAL_6 = {
|
||||||
|
type = .FLORA,
|
||||||
|
frame_index = 11,
|
||||||
|
interaction = .HARVEST,
|
||||||
|
resource = .FLORA,
|
||||||
|
animator = nil,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user