Added flickering to lighting shader.
This commit is contained in:
parent
b68015a6c4
commit
93f87cc9c5
@ -37,6 +37,7 @@ uniform float directionalIntensity;
|
||||
uniform vec3 lightSources[32];
|
||||
uniform vec3 lightColors[32];
|
||||
uniform float lightIntensities[32];
|
||||
uniform bool isFlame[32];
|
||||
uniform float farPlane;
|
||||
uniform vec4 fogColor;
|
||||
uniform vec3 cameraCenter;
|
||||
@ -63,6 +64,10 @@ vec2 poissonDisk[16] = vec2[](
|
||||
vec2( 0.14383161, -0.14100790 )
|
||||
);
|
||||
|
||||
float flickerFunction() {
|
||||
return sin(time);
|
||||
}
|
||||
|
||||
float sampleDirectionalShadow(sampler2DShadow shadowMap, vec4 shadowCoord, float maxBias ) {
|
||||
float visibility = 1.0;
|
||||
const float stretching = 650.0;
|
||||
@ -178,7 +183,13 @@ void main()
|
||||
pointVisibility = samplePointShadow(shadowMap_cube9, lightDirection);
|
||||
}
|
||||
vec3 lightVector = normalize(lightSources[i]-vec3(fragPosition));
|
||||
float intensity = clamp(exp(-(1/lightIntensities[i])*distance), 0.0, 1.0);
|
||||
float intensity = 0.0f;
|
||||
if (isFlame[i] == true) {
|
||||
intensity = clamp(exp(-(1/(lightIntensities[i] + flickerFunction()))*distance), 0.0, 1.0);
|
||||
}
|
||||
else {
|
||||
intensity = clamp(exp(-(1/lightIntensities[i])*distance), 0.0, 1.0);
|
||||
}
|
||||
diffuseColor += clamp(dot(normalize(vNormal), lightVector)
|
||||
*diffuseFactor*intensity*lightColors[i], 0.0, 1.0)*pointVisibility;
|
||||
vec3 cameraVector = normalize(camera - vec3(fragPosition));
|
||||
|
@ -440,12 +440,18 @@ void Graphics::updateLights() {
|
||||
lightingShader->setUniform("directionalIntensity",
|
||||
level->getDirectionalLight()->getIntensity());
|
||||
}
|
||||
bool isFlame[closestLights.size()];
|
||||
closestFlames = std::vector<Flame*>();
|
||||
for (unsigned int i = 0; i<closestLights.size(); i++) {
|
||||
if (closestLights.at(i).isFlame()) {
|
||||
closestFlames.push_back(closestLights.at(i).getFlame());
|
||||
isFlame[i] = true;
|
||||
}
|
||||
else {
|
||||
isFlame[i] = false;
|
||||
}
|
||||
}
|
||||
glUniform1iv(lightingShader->getUniformLocation("isFlame"), sizeof(isFlame), (GLint*) isFlame);
|
||||
}
|
||||
|
||||
void Graphics::resize(glm::uvec2 windowSize) {
|
||||
|
Loading…
Reference in New Issue
Block a user