Tree transparency fix
This commit is contained in:
11
main.c
11
main.c
@@ -118,6 +118,9 @@ int main(void)
|
|||||||
//Define window size, create window, establish fps target, fullscreen.
|
//Define window size, create window, establish fps target, fullscreen.
|
||||||
const int screenWidth = 1440*2;
|
const int screenWidth = 1440*2;
|
||||||
const int screenHeight = 960*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");
|
InitWindow(screenWidth, screenHeight, "raylib");
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
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
|
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
|
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 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
|
// Grass tile setup
|
||||||
Texture2D texGrass = LoadTexture("resources/textures/grass_textures/Grass_01.png");
|
Texture2D texGrass = LoadTexture("resources/textures/grass_textures/Grass_01.png");
|
||||||
@@ -197,7 +200,8 @@ int main(void)
|
|||||||
Model skybox = LoadModelFromMesh(cube);
|
Model skybox = LoadModelFromMesh(cube);
|
||||||
|
|
||||||
// Load skybox shader
|
// Load skybox shader
|
||||||
Shader skyboxShader = LoadShader(
|
Shader skyboxShader = LoadShader
|
||||||
|
(
|
||||||
"shaders/skybox.vs",
|
"shaders/skybox.vs",
|
||||||
"shaders/skybox.fs"
|
"shaders/skybox.fs"
|
||||||
);
|
);
|
||||||
@@ -243,7 +247,6 @@ int main(void)
|
|||||||
int locIntensity = GetShaderLocation(fog, "u_intensity");
|
int locIntensity = GetShaderLocation(fog, "u_intensity");
|
||||||
int locBeamSpread = GetShaderLocation(fog, "u_beamSpread");
|
int locBeamSpread = GetShaderLocation(fog, "u_beamSpread");
|
||||||
|
|
||||||
|
|
||||||
// Let raylib know which matrices the shader expects
|
// Let raylib know which matrices the shader expects
|
||||||
fog.locs[SHADER_LOC_MATRIX_MODEL] = GetShaderLocation(fog, "matModel");
|
fog.locs[SHADER_LOC_MATRIX_MODEL] = GetShaderLocation(fog, "matModel");
|
||||||
fog.locs[SHADER_LOC_MATRIX_VIEW] = GetShaderLocation(fog, "matView");
|
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, locMinShadow, &minShadow, SHADER_UNIFORM_FLOAT);
|
||||||
SetShaderValue(fog, locFogColor, &fogColor, SHADER_UNIFORM_VEC4);
|
SetShaderValue(fog, locFogColor, &fogColor, SHADER_UNIFORM_VEC4);
|
||||||
SetShaderValue(fog, locSharpness, &sharpness, SHADER_UNIFORM_FLOAT);
|
SetShaderValue(fog, locSharpness, &sharpness, SHADER_UNIFORM_FLOAT);
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
@@ -432,7 +434,6 @@ int main(void)
|
|||||||
BeginShaderMode(fog);
|
BeginShaderMode(fog);
|
||||||
|
|
||||||
RenderTrees(&g, tree, treepos, treeSize);
|
RenderTrees(&g, tree, treepos, treeSize);
|
||||||
|
|
||||||
DrawBillboard(g.player.camera, sign, bbPos, bbSize, WHITE);
|
DrawBillboard(g.player.camera, sign, bbPos, bbSize, WHITE);
|
||||||
|
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
Reference in New Issue
Block a user