Sunday, January 28, 2024

2024 New Year Update!

Inventory Updates

There has been a whole lot of development accomplished since my last post.  The inventory system has been updated to provide a customized window for the player inventory.  Up to this point, the player inventory was using the standard container window scene which looks like this.

Now, there is a custom scene that will be used for the player's inventory.  I am calling it the Accoutrements scene.  It comes with a paper doll and slots for various clothing, tools, and weapons, hence the name Accoutrements.  The current version looks like this.

With this new scene I am able to apply some custom drag and drop rules.  For example, when the player adds a belt in the belt slot, five more slots become usable.  The three slots along the belt and the two middle slots on the right side can hold four small and one medium attachment.  I have thought long and hard about inventory management since I have been working on this new version of the inventory engine.  Being this is a survival game set in 1820 and the player is a mountain man, it would not make sense that a player could trek around the forest carrying 15,000 items.  Rather, I think it is fitting and more immersive to consider player inventory within the bounds of what a mountain man might carry around.  A pack on the back can add additional storage slots when traveling.  If the player has a mule or a horse, they will also have storage slots.  I know there is a fine balance between immersion and frustration.  I aim to find that sweet spot with this design.  We shall see how it goes.

Water Tiles with Depth

I am excited to share that I have completed a first pass at coding water depth using materials and shaders.  This was a huge improvement over my old Unity solution.  I have a video on my YouTube Channel that demonstrates how to create a procedurally generated world.

What you see above are water tiles, with lighter colored tiles representing shallow water and darker tiles representing deeper and deeper water.  This was achieved using the following water shader and individual Materials placed on each of five atlas tiles.  Here is the code for the shader.  Here is also a link to the video where I found this shader implemented.  Note, I am not endorsing any person or project, just providing you with my source.

======================

shader_type canvas_item;
//https://www.youtube.com/watch?v=eU-F-xuEo7s&t=14s

uniform sampler2D waterSource : repeat_enable;
uniform sampler2D noise1 : repeat_enable;
uniform sampler2D noise2 : repeat_enable;
uniform vec2 scroll1 = vec2(0.05, 0.05);
uniform vec2 scroll2 = vec2(-0.05, -0.05);
uniform float distortion : hint_range(-1, 1) = 0.1;
uniform vec4 tone_color : source_color;
uniform vec4 top_color : source_color;
uniform float light_start : hint_range(0.0, 1.0) = 0.275;
uniform float light_end : hint_range(0.0, 1.0) = 0.4;

void fragment() {
    float depth = texture(noise1, UV + scroll1 * TIME).r * texture(noise2, UV + scroll2 * TIME).r;
    vec4 water = texture(waterSource, UV + distortion * vec2(depth));
    vec4 top_light = smoothstep(light_start, light_end, depth) * top_color;
    //COLOR = water;
    COLOR = water * tone_color + top_light;   
    COLOR.a = 1.0;
}

=====================

Moving into February, I am focused on my ItemAction engine which will be coupled with my Inventory engine to handle most game actions and will provide the ability to build out my crafting system.  I am very happy to get started on that.

In closing, my YouTube channel has been steadily growing.  I welcome you to join and follow along if you are so inclined.

Until next time,

I'm Bound2bCoding.