Renderer/assets/Shaders/entities/fluid2/fluid2.fs
austin dfc59e0ea6
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit
fluid work
2024-11-29 21:19:59 -05:00

61 lines
1.5 KiB
GLSL

#version 450 core
#extension GL_ARB_shading_language_include : require
#include "../../lib/lights.fs"
struct Material {
sampler2D diffuse;
sampler2D specular;
float shininess;
};
in vec3 FragPos;
in vec3 Normal;
in vec2 texPlane1;
in vec2 texPlane2;
in vec2 texPlane3;
in vec4 FragPosLightSpace;
uniform vec3 viewPos;
uniform Material material;
out vec4 FragColor;
// function prototypes
vec3 getColor(vec2 texPlane1, vec2 texPlane2, vec2 texPlane3, vec3 normal, Material material);
void main(){
vec3 norm = normalize(Normal);
vec3 viewDir = normalize(viewPos - FragPos);
//grab light intensity
float lightIntensity = calcLightIntensityTotal(norm);
//get color of base texture
vec3 textureColor = vec3(0.6, 0.92, 0.92);//getColor(texPlane1, texPlane2, texPlane3, norm, material);
//shadow
float shadow = ShadowCalculation(FragPosLightSpace, normalize(-directLight.direction), norm);
//calculate final color
vec3 finalColor = textureColor * lightIntensity * max(shadow,0.4);
//this final calculation is for transparency
FragColor = vec4(finalColor, 0.2);
}
vec3 getColor(vec2 texPlane1, vec2 texPlane2, vec2 texPlane3, vec3 normal, Material material){
vec3 weights = abs(normal);
vec3 albedoX = texture(material.diffuse, texPlane1).rgb;
vec3 albedoY = texture(material.diffuse, texPlane2).rgb;
vec3 albedoZ = texture(material.diffuse, texPlane3).rgb;
return (albedoX * weights.x + albedoY * weights.y + albedoZ * weights.z);
}