Tree transparency fix

This commit is contained in:
2025-09-01 15:49:07 -05:00
parent 4a4d198617
commit 123c374ab4
2 changed files with 6 additions and 5 deletions

11
main.c
View File

@@ -118,6 +118,9 @@ int main(void)
//Define window size, create window, establish fps target, fullscreen.
const int screenWidth = 1440*2;
const int screenHeight = 960*2;
// BEFORE InitWindow (optional but nice): enable MSAA for smoother alpha edges
SetConfigFlags(FLAG_MSAA_4X_HINT);
InitWindow(screenWidth, screenHeight, "raylib");
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
@@ -177,7 +180,7 @@ int main(void)
SetTextureFilter(tree, TEXTURE_FILTER_BILINEAR); // optional but looks nicer
Vector3 treepos = (Vector3){ 0.0f, 0.0f, 0.0f }; // where in 3D world to place it
float treeSize = 15.0f; // billboard height in world units
float cutoffAlpha = 0.3f; // Threshold for transparency cut off.
float cutoffAlpha = 0.7f; //Needs to be aggressive to remove the alpha.
// Grass tile setup
Texture2D texGrass = LoadTexture("resources/textures/grass_textures/Grass_01.png");
@@ -197,7 +200,8 @@ int main(void)
Model skybox = LoadModelFromMesh(cube);
// Load skybox shader
Shader skyboxShader = LoadShader(
Shader skyboxShader = LoadShader
(
"shaders/skybox.vs",
"shaders/skybox.fs"
);
@@ -243,7 +247,6 @@ int main(void)
int locIntensity = GetShaderLocation(fog, "u_intensity");
int locBeamSpread = GetShaderLocation(fog, "u_beamSpread");
// Let raylib know which matrices the shader expects
fog.locs[SHADER_LOC_MATRIX_MODEL] = GetShaderLocation(fog, "matModel");
fog.locs[SHADER_LOC_MATRIX_VIEW] = GetShaderLocation(fog, "matView");
@@ -284,7 +287,6 @@ int main(void)
SetShaderValue(fog, locMinShadow, &minShadow, SHADER_UNIFORM_FLOAT);
SetShaderValue(fog, locFogColor, &fogColor, SHADER_UNIFORM_VEC4);
SetShaderValue(fog, locSharpness, &sharpness, SHADER_UNIFORM_FLOAT);
//--------------------------------------------------------------------------------------
// Main game loop
@@ -432,7 +434,6 @@ int main(void)
BeginShaderMode(fog);
RenderTrees(&g, tree, treepos, treeSize);
DrawBillboard(g.player.camera, sign, bbPos, bbSize, WHITE);
EndShaderMode();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB