improve game icon
This commit is contained in:
parent
f4fa4159c9
commit
fe54b39afd
4 changed files with 10 additions and 10 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,6 +9,7 @@ zig-out/
|
|||
/docgen_tmp/
|
||||
|
||||
# Temporary project-specific things
|
||||
qgl/
|
||||
vsh/
|
||||
dumped/
|
||||
menu/
|
||||
|
|
BIN
icon-normal-3.png
Normal file
BIN
icon-normal-3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
13
src/main.zig
13
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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue