diff options
| author | nathan <nathansmith@disroot.org> | 2025-10-18 23:09:54 +0000 |
|---|---|---|
| committer | nathan <nathansmith@disroot.org> | 2025-10-18 23:09:54 +0000 |
| commit | e3f220ee2003e93b2a1ebc335630fac8444a412e (patch) | |
| tree | 748a84ea22be2a39f104b18940b9f77b80556b6b | |
| parent | adf84529a0f59bccea0e111b0f76d2eef3968971 (diff) | |
| download | FindThings-e3f220ee2003e93b2a1ebc335630fac8444a412e.tar.gz FindThings-e3f220ee2003e93b2a1ebc335630fac8444a412e.tar.bz2 FindThings-e3f220ee2003e93b2a1ebc335630fac8444a412e.zip | |
Color thingy
| -rw-r--r-- | assets/shaders/glsl330/color-depth.fs | 24 | ||||
| -rw-r--r-- | src/assets.c | 3 | ||||
| -rw-r--r-- | src/assets.h | 6 | ||||
| -rw-r--r-- | src/game.c | 10 |
4 files changed, 35 insertions, 8 deletions
diff --git a/assets/shaders/glsl330/color-depth.fs b/assets/shaders/glsl330/color-depth.fs new file mode 100644 index 0000000..c011df5 --- /dev/null +++ b/assets/shaders/glsl330/color-depth.fs @@ -0,0 +1,24 @@ +#version 330 + +in vec2 fragTexCoord; +in vec4 fragColor; + +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +out vec4 finalColor; + +const int factor = 30; // x/255 + +void main() +{ + // Texel color fetching from texture sampler + vec4 texelColor = texture(texture0, fragTexCoord)*colDiffuse*fragColor; + + ivec4 color = ivec4(texelColor / factor * 255); + color *= factor; + + // Calculate final fragment color + finalColor = vec4(float(color.r) / 255, float(color.g) / 255, + float(color.b) / 255, texelColor.a); +}
\ No newline at end of file diff --git a/src/assets.c b/src/assets.c index db87d54..0180d03 100644 --- a/src/assets.c +++ b/src/assets.c @@ -24,7 +24,8 @@ const char imageAssetPaths[IMAGE_ASSET_COUNT][FT_NAMEMAX] = { const char shaderAssetNames[SHADER_ASSET_COUNT][FT_NAMEMAX] = { "skybox", - "instancing" + "instancing", + "color-depth" }; const char modelAssetPaths[MODEL_ASSET_COUNT][FT_NAMEMAX] = { diff --git a/src/assets.h b/src/assets.h index 2cd5765..9b93e0e 100644 --- a/src/assets.h +++ b/src/assets.h @@ -1,11 +1,12 @@ #include "utils.h" +#include "settings.h" #ifndef ASSETS_H #define ASSETS_H #define TEXTURE_ASSET_COUNT 15 #define IMAGE_ASSET_COUNT 1 -#define SHADER_ASSET_COUNT 2 +#define SHADER_ASSET_COUNT 3 #define MODEL_ASSET_COUNT 4 extern const char textureAssetPaths[TEXTURE_ASSET_COUNT][FT_NAMEMAX]; @@ -42,7 +43,8 @@ enum { // Shader asset ids. enum { SKYBOX_SHADER, - INSTANCING_SHADER + INSTANCING_SHADER, + COLOR_DEPTH_SHADER }; // Model asset ids. @@ -39,7 +39,6 @@ void initGame(Game* game) // Settings. game->settings = defaultSettings(); - // Window. InitWindow(game->settings.windowWidth, game->settings.windowHeight, "Find Things"); @@ -67,7 +66,7 @@ void initGame(Game* game) game->player = createPlayer(); game->player.position = Vector3Scale(game->world.size, 0.5); - // DisableCursor(); + DisableCursor(); } void updateMainMenuScene(Game* game) @@ -90,8 +89,6 @@ void drawGameScreen(Game* game) void updateGameScene(Game* game) { - ClearBackground(BLACK); - BeginTextureMode(game->screen.render); ClearBackground(BLACK); BeginMode3D(game->player.camera); @@ -104,13 +101,16 @@ void updateGameScene(Game* game) rlEnableDepthMask(); updatePlayer(&game->player, game); - updateWorld(&game->world, game); EndMode3D(); EndTextureMode(); + ClearBackground(BLACK); + + BeginShaderMode(game->assets.shaders[COLOR_DEPTH_SHADER]); drawGameScreen(game); + EndShaderMode(); } void handleGameResize(Game* game) |
