This commit is contained in:
sasankasa 2024-02-03 19:44:26 +01:00
parent cdce965233
commit 30d796fe05
3 changed files with 17 additions and 5 deletions

View File

@ -23,6 +23,8 @@ uniform float u_time;
in vec3 vecNormal;
in vec3 worldPos;
in vec3 vecNormalClouds;
in vec3 worldPosClouds;
in vec2 vtc;
in vec2 vtcNoise;
@ -180,14 +182,17 @@ vec4 noiseColor(float time) {
void main() {
vec3 normal = normalize(vecNormal);
vec3 normalClouds = normalize(vecNormalClouds);
vec3 viewDir = normalize(cameraPos - worldPos);
vec3 lightDir = normalize(lightPos - worldPos);
vec3 lightDirClouds = normalize(lightPos - worldPosClouds);
vec4 textureColor = texture2D(colorTexture, vtc);
float diffuse = max(0, dot(normal, lightDir));
//float diffuseClouds = max(0, dot(normalClouds, lightDir));
vec3 distance = lightColor / pow(length(lightPos - worldPos), 2.0) * 300;
vec3 toneMappedColor = toneMapping(vec3(textureColor) * min(1, AMBIENT + diffuse) * distance);
//gamma correction
@ -203,11 +208,11 @@ void main() {
textureColor = vec4(vec3(1.0) - exp(-illumination * exposition), 1);
vec4 noiseColor = noiseColor(u_time);
vec4 noiseColor = noiseColor(u_time) * min(1, AMBIENT + diffuse);
vec3 mixedColor = mix(textureColor.rgb, noiseColor.rgb, u_time);
vec3 mixedColor = mix(textureColor.rgb, noiseColor.rgb, noiseColor.r);
outColor = vec4(mixedColor, 1.0);
//outColor = vec4(mixedColor, 1.0);
//outColor = vec4(mixedColor * min(1, AMBIENT + diffuse), 1.0);
outColor = vec4(mixedColor * min(1, AMBIENT + diffuse), 1.0);
}

View File

@ -14,6 +14,9 @@ uniform mat4 noiseMatrix;
out vec3 vecNormal;
out vec3 worldPos;
out vec3 vecNormalClouds;
out vec3 worldPosClouds;
out vec2 vtc;
out vec2 vtcNoise;
@ -29,6 +32,10 @@ void main()
{
worldPos = (modelMatrix * vec4(vertexPosition, 1)).xyz;
vecNormal = (modelMatrix * vec4(vertexNormal, 0)).xyz;
worldPosClouds = (noiseMatrix * vec4(vertexPosition, 1)).xyz;
vecNormalClouds = (noiseMatrix * vec4(vertexNormal, 0)).xyz;
gl_Position = transformation * vec4(vertexPosition, 1.0);
vtc = vec2(vertexTexCoord.x, 1.0 - vertexTexCoord.y);

View File

@ -212,7 +212,7 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::mat
glUniform3f(glGetUniformLocation(programPbr, "lightPos"), sunPos.x, sunPos.y, sunPos.z);
glUniform3f(glGetUniformLocation(programPbr, "lightColor"), lightColor.x, lightColor.y, lightColor.z);
glUniform1f(glGetUniformLocation(programNoise, "u_time"), time);
glUniform1f(glGetUniformLocation(programPbr, "u_time"), time);
Core::DrawContext(context);
glUseProgram(0);