diff --git a/.gitignore b/.gitignore index 8454e44..f2b3048 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ zig-out/ /docgen_tmp/ # Temporary project-specific things +qgl/ vsh/ dumped/ menu/ diff --git a/icon-normal-3.png b/icon-normal-3.png new file mode 100644 index 0000000..70b8579 Binary files /dev/null and b/icon-normal-3.png differ diff --git a/src/main.zig b/src/main.zig index e32b3e9..e6ac84a 100644 --- a/src/main.zig +++ b/src/main.zig @@ -21,8 +21,7 @@ pub fn main() !void { defer crossmenu.deinit(); const game_column = try crossmenu.appendColumn(.{ - .icon = raylib.LoadTexture("icon-mask.png"), - .normal = raylib.LoadTexture("icon-normal-2.png"), + .icon = raylib.LoadTexture("icon-normal-3.png"), .title = "Game", }); @@ -273,18 +272,18 @@ pub const Column = struct { pub const Options = struct { icon: raylib.Texture2D, - normal: ?raylib.Texture2D = null, title: []const u8, }; pub fn init(allocator: Allocator, options: Options) Column { raylib.SetTextureFilter(options.icon, raylib.TEXTURE_FILTER_BILINEAR); + raylib.SetTextureWrap(options.icon, raylib.TEXTURE_WRAP_CLAMP); return .{ .items = .init(allocator), .icon = .{ .texture = options.icon, - .normal = options.normal, + .is_normal_map = true, }, .title = .{ .string = options.title, @@ -627,7 +626,8 @@ pub const BoundingBox = struct { pub const Image = struct { box: BoundingBox = undefined, texture: raylib.Texture2D, - normal: ?raylib.Texture2D = null, + // normal: ?raylib.Texture2D = null, + is_normal_map: bool = false, mode: Mode = .fit, align_h: Align = .center, @@ -664,8 +664,7 @@ pub const Image = struct { raylib.MAROON, ); } else { - if (self.normal) |n| { - raylib.SetShaderValueTexture(icon_shader, raylib.GetShaderLocation(icon_shader, "textureNormal"), n); + if (self.is_normal_map) { raylib.BeginShaderMode(icon_shader); defer raylib.EndShaderMode(); raylib.DrawTextureEx(self.texture, position, 0, scale, raylib.WHITE); diff --git a/src/shaders/icon.fs b/src/shaders/icon.fs index a83e8fd..693a8dd 100644 --- a/src/shaders/icon.fs +++ b/src/shaders/icon.fs @@ -4,7 +4,7 @@ in vec2 fragTexCoord; in vec4 fragColor; uniform sampler2D texture0; -uniform sampler2D textureNormal; +// uniform sampler2D textureNormal; uniform vec3 lightDir; uniform vec4 lightColor; @@ -15,7 +15,7 @@ out vec4 finalColor; void main() { float d = length(lightDir); - vec3 n = normalize(texture(textureNormal, fragTexCoord).xyz); + vec3 n = normalize(texture(texture0, fragTexCoord).xyz); vec3 l = normalize(lightDir); vec3 diffuse = lightColor.rgb * lightColor.a * max(dot(n, l), 0.0); @@ -25,5 +25,5 @@ void main() { vec3 final = diffuse.rgb * intensity; - finalColor = vec4(final, texture(texture0, fragTexCoord).a * 0.93); + finalColor = vec4(final, texture(texture0, fragTexCoord).a); }