Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vec3 PointLightFunc(PointLight pointLight, vec3 norm, vec3 viewDir){
- //ambient part
- vec3 ambient = 0.1 * vec3(pointLight.color) * vec3(texture(texture_diffuse1, texCoords).rgb);
- vec3 lightDir = normalize(vec3(pointLight.position) - FragPoshttps://pastebin.com/);
- if(normalMapON == true){
- lightDir = normalize(TangentLightPos - TangentFragPos);
- }
- vec2 texCoords = TexCoords;
- if(parallaxmappingEnabled == true){
- texCoords = ParallaxMapping(TexCoords, viewDir);
- }
- if(texCoords.x > 1.0 || texCoords.y > 1.0 || texCoords.x < 0.0 || texCoords.y < 0.0){
- discard;
- }
- //diffuse part
- float diff = max(dot(norm, lightDir), 0.0);
- vec3 diffuse = vec3(pointLight.color) * diff * vec3(texture(texture_diffuse1, texCoords).rgb);
- //specular part
- vec3 reflectDir = reflect(-lightDir, norm);
- float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess);
- vec3 specular = vec3(pointLight.color) * spec * vec3(texture(texture_specular1, texCoords).rgb);
- // attenuation
- float distance = length(vec3(pointLight.position) - FragPos);
- if(normalMapON == true){
- distance = length(TangentLightPos - TangentFragPos);;
- }
- float attenuation = 1.0 / (pointLight.constant + (pointLight.linear * distance) + (pointLight.quadratic * (distance * distance)));
- ambient *= attenuation;
- diffuse *= attenuation;
- specular *= attenuation;
- float shadow = ShadowCalculation(FragPos);
- vec3 lighting = ((ambient + (1.0 - shadow)) * (diffuse + specular));
- return lighting;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement