#version 430 core float AMBIENT = 0.1; uniform vec3 color; uniform vec3 lightPos; uniform sampler2D colorTexture; in vec3 fragNormal; in vec3 fragPosition; in vec2 texCoords; out vec4 outColor; uniform float shininess; uniform vec3 ambientColor; uniform vec3 specularColor; uniform vec3 emissiveColor; uniform float opticalDensity; uniform float dissolve; uniform int illuminationModel; void main() { vec3 lightDir = normalize(lightPos - fragPosition); vec3 normal = normalize(fragNormal); float diffuse = max(0.0, dot(normal, lightDir)); vec3 lambertian = texture(colorTexture, texCoords).rgb * diffuse; vec3 viewDir = normalize(-fragPosition); vec3 halfwayDir = normalize(lightDir + viewDir); float specular = pow(max(0.0, dot(normal, halfwayDir)), shininess); vec3 blinnPhong = specularColor * specular; vec3 emissive = emissiveColor; vec3 ambient = ambientColor * AMBIENT; vec3 finalColor = lambertian + blinnPhong + emissive + ambient; finalColor *= (1.0 - dissolve); outColor = vec4(finalColor, 1.0); }