foliage uses new lighting flow
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
0c15941efa
commit
1c7dfd26cf
@ -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){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user