poprawka
This commit is contained in:
parent
cdce965233
commit
30d796fe05
@ -23,6 +23,8 @@ uniform float u_time;
|
|||||||
|
|
||||||
in vec3 vecNormal;
|
in vec3 vecNormal;
|
||||||
in vec3 worldPos;
|
in vec3 worldPos;
|
||||||
|
in vec3 vecNormalClouds;
|
||||||
|
in vec3 worldPosClouds;
|
||||||
in vec2 vtc;
|
in vec2 vtc;
|
||||||
in vec2 vtcNoise;
|
in vec2 vtcNoise;
|
||||||
|
|
||||||
@ -180,14 +182,17 @@ vec4 noiseColor(float time) {
|
|||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec3 normal = normalize(vecNormal);
|
vec3 normal = normalize(vecNormal);
|
||||||
|
vec3 normalClouds = normalize(vecNormalClouds);
|
||||||
|
|
||||||
vec3 viewDir = normalize(cameraPos - worldPos);
|
vec3 viewDir = normalize(cameraPos - worldPos);
|
||||||
|
|
||||||
vec3 lightDir = normalize(lightPos - worldPos);
|
vec3 lightDir = normalize(lightPos - worldPos);
|
||||||
|
vec3 lightDirClouds = normalize(lightPos - worldPosClouds);
|
||||||
|
|
||||||
vec4 textureColor = texture2D(colorTexture, vtc);
|
vec4 textureColor = texture2D(colorTexture, vtc);
|
||||||
|
|
||||||
float diffuse = max(0, dot(normal, lightDir));
|
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 distance = lightColor / pow(length(lightPos - worldPos), 2.0) * 300;
|
||||||
vec3 toneMappedColor = toneMapping(vec3(textureColor) * min(1, AMBIENT + diffuse) * distance);
|
vec3 toneMappedColor = toneMapping(vec3(textureColor) * min(1, AMBIENT + diffuse) * distance);
|
||||||
//gamma correction
|
//gamma correction
|
||||||
@ -203,11 +208,11 @@ void main() {
|
|||||||
|
|
||||||
textureColor = vec4(vec3(1.0) - exp(-illumination * exposition), 1);
|
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);
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,9 @@ uniform mat4 noiseMatrix;
|
|||||||
|
|
||||||
out vec3 vecNormal;
|
out vec3 vecNormal;
|
||||||
out vec3 worldPos;
|
out vec3 worldPos;
|
||||||
|
out vec3 vecNormalClouds;
|
||||||
|
out vec3 worldPosClouds;
|
||||||
|
|
||||||
out vec2 vtc;
|
out vec2 vtc;
|
||||||
out vec2 vtcNoise;
|
out vec2 vtcNoise;
|
||||||
|
|
||||||
@ -29,6 +32,10 @@ void main()
|
|||||||
{
|
{
|
||||||
worldPos = (modelMatrix * vec4(vertexPosition, 1)).xyz;
|
worldPos = (modelMatrix * vec4(vertexPosition, 1)).xyz;
|
||||||
vecNormal = (modelMatrix * vec4(vertexNormal, 0)).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);
|
gl_Position = transformation * vec4(vertexPosition, 1.0);
|
||||||
|
|
||||||
vtc = vec2(vertexTexCoord.x, 1.0 - vertexTexCoord.y);
|
vtc = vec2(vertexTexCoord.x, 1.0 - vertexTexCoord.y);
|
||||||
|
@ -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, "lightPos"), sunPos.x, sunPos.y, sunPos.z);
|
||||||
glUniform3f(glGetUniformLocation(programPbr, "lightColor"), lightColor.x, lightColor.y, lightColor.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);
|
Core::DrawContext(context);
|
||||||
glUseProgram(0);
|
glUseProgram(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user