From 1c7dfd26cfe4aee4268ac50178bf53b8d30fab90 Mon Sep 17 00:00:00 2001 From: austin Date: Mon, 19 May 2025 14:56:25 -0400 Subject: [PATCH] foliage uses new lighting flow --- assets/Shaders/entities/foliage/foliage.fs | 48 +++++++++------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/assets/Shaders/entities/foliage/foliage.fs b/assets/Shaders/entities/foliage/foliage.fs index cda69f5a..da5cfcc0 100644 --- a/assets/Shaders/entities/foliage/foliage.fs +++ b/assets/Shaders/entities/foliage/foliage.fs @@ -5,6 +5,13 @@ //foliage.fs + +/** + * Transparency of the foliage + */ +#define FOLIAGE_TRANSPARENCY 1.0 + + in vec3 FragPos; in vec3 ViewFragPos; in vec3 Normal; @@ -58,38 +65,23 @@ void main(){ //grab light intensity vec3 lightIntensity = vec3(calcLightIntensityTotal(norm)); - //get color of base texture - // vec3 textureColor = vec3((norm.x + 1) / 2.0, norm.y, 1.0 - (norm.x + 1) / 2.0); - // vec3 textureColor = vec3(TexCoord,1.0); - // vec3 textureColor = vec3(0.17647,0.4,0.09411);//texture(material.diffuse, TexCoord).rgb; - - //shadow - float shadow = ShadowCalculation(FragPosLightSpace, normalize(-directLight.direction.xyz), norm); - - // - //point light calculations - uint clusterIndex = findCluster(ViewFragPos, zNear, zFar); - uint pointLightCount = clusters[clusterIndex].count; - for(int i = 0; i < pointLightCount; i++){ - uint pointLightIndex = clusters[clusterIndex].lightIndices[i]; - PointLight pointLight = pointLight[pointLightIndex]; - lightIntensity = lightIntensity + CalcPointLight(pointLight, norm, FragPos, viewDir); - } - //error checking on light clusters - if(pointLightCount > MAX_LIGHTS_PER_CLUSTER){ - FragColor = vec4(1.0f,0.0f,0.0f,1); - return; - } + // Calculate the light to apply + vec3 light = getTotalLight( + material, + textureColor, + vec3(viewPos.xyz), + FragPosLightSpace, + ViewFragPos, + FragPos, + norm, + viewDir + ); //calculate final color - vec3 finalColor = textureColor * lightIntensity;// * max(shadow,0.4); - // vec3 lightAmount = CalcDirLight(norm, viewDir); - // for(int i = 0; i < NR_POINT_LIGHTS; i++){ - // lightAmount += CalcPointLight(i, norm, FragPos, viewDir); - // } + vec3 finalColor = light; //this final calculation is for transparency - FragColor = vec4(finalColor, 1.0);//texture(ourTexture, TexCoord);//vec4(result, 1.0); + FragColor = vec4(finalColor, FOLIAGE_TRANSPARENCY); } float easeIn(float interpolator){