Renderer/assets/Shaders/entities/skysphere/skysphere.fs
austin f02d9979e3
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
leverage standard uniforms buffer
2025-05-25 00:34:46 -04:00

92 lines
1.8 KiB
GLSL

#version 450 core
#extension GL_ARB_shading_language_include : require
#include "../../lib/standarduniform.fs"
/**
Bind points for different SSBOs
*/
#define DIRECT_LIGHT_SSBO_BIND_POINT 3
/**
transparency
*/
#define SMALL_EPSILON 0.001
/**
The direct global light
*/
struct DirectLight {
vec3 direction;
vec3 color;
vec3 ambientColor;
};
out vec4 FragColor;
layout(std430, binding = DIRECT_LIGHT_SSBO_BIND_POINT) restrict buffer dirLightSSBO {
DirectLight directLight;
};
struct Material {
sampler2D diffuse;
sampler2D specular;
float shininess;
};
in vec3 FragPos;
in vec3 Normal;
in vec2 TexCoord;
in vec4 FragPosLightSpace;
uniform vec3 viewPos;
uniform Material material;
//texture stuff
// uniform sampler2D ourTexture;
uniform int hasTransparency;
// uniform sampler2D specularTexture;
//light depth map
uniform sampler2D shadowMap;
// function prototypes
float calcLightIntensityTotal(vec3 normal);
void main(){
if(hasTransparency == 1){
if(texture(material.diffuse, TexCoord).a < 0.1){
discard;
}
}
vec4 textureColor = texture(material.diffuse, TexCoord);
//grab light intensity
vec3 norm = normalize(Normal);
vec3 lightIntensity = vec3(calcLightIntensityTotal(norm));
//calculate final color
vec3 finalColor = textureColor.rgb * lightIntensity;
FragColor = vec4(finalColor, textureColor.a);
}
float calcLightIntensityAmbient(){
//calculate average of ambient light
float avg = (directLight.color.x + directLight.color.y + directLight.color.z)/3.0;
return avg;
}
//
float calcLightIntensityTotal(vec3 normal){
//ambient intensity
float ambientLightIntensity = calcLightIntensityAmbient();
//sum
float total = ambientLightIntensity;
return total;
}