diff --git a/Possiblev7.zip b/Resources/182.png similarity index 66% rename from Possiblev7.zip rename to Resources/182.png index e8aa478..a76802f 100644 Binary files a/Possiblev7.zip and b/Resources/182.png differ diff --git a/Resources/BasicFS.glsl b/Resources/BasicFS.glsl new file mode 100644 index 0000000..d2378f9 --- /dev/null +++ b/Resources/BasicFS.glsl @@ -0,0 +1,157 @@ +#version 330 core + +struct Material { + vec3 ambient; + vec3 diffuse; + vec3 specular; + float shininess; +}; + +struct PointLight { + vec3 position; + + float constant; + float linear; + float quadratic; + + vec3 ambient; + vec3 diffuse; + vec3 specular; +}; + +struct DirLight { + vec3 direction; + + vec3 ambient; + vec3 diffuse; + vec3 specular; +}; + +struct SpotLight { + vec3 position; + vec3 direction; + float cutOff; + float outerCutOff; + + float constant; + float linear; + float quadratic; + + vec3 ambient; + vec3 diffuse; + vec3 specular; +}; + +in vec3 FragPos; +in vec3 Normal; +in vec3 ourColor; +in vec2 TexCoords; + +out vec4 color; + +uniform vec3 viewPos; +uniform Material material; +uniform DirLight dirLight; +uniform SpotLight spotLight; +uniform float time; +uniform float crazyStrength; + +// Texture samplers +uniform sampler2D myTexture; + +// Function prototypes +vec3 CalcDirLight(DirLight light, vec3 normal, vec3 viewDir); +vec3 CalcPointLight(PointLight light, vec3 normal, vec3 fragPos, vec3 viewDir); +vec3 CalcSpotLight(SpotLight light, vec3 norm, vec3 fragPos, vec3 viewDir); + +void main() +{ + // Properties + vec3 norm = normalize(Normal); + vec3 viewDir = normalize(viewPos - FragPos); + + // Directional lighting (sun) + vec3 result = vec3(texture(myTexture, TexCoords)); + result *= 0.35; + result += 0.85f; + result *= ourColor; + result *= CalcDirLight(dirLight, norm, viewDir); + // Flash light + result += CalcSpotLight(spotLight, norm, FragPos, viewDir); + result *= (1 - crazyStrength); + vec3 timeColor = vec3(abs(sin(FragPos.y + (time))*sin(FragPos.x + cos(time))), abs(cos(FragPos.z + time)*cos(FragPos.x + sin(time))),abs(sin(FragPos.z + time)*cos(FragPos.x + time))); + timeColor *= crazyStrength; + result += timeColor; + + color = vec4(result, 1.0); +} + +// Calculates the color when using a directional light. +vec3 CalcDirLight(DirLight light, vec3 normal, vec3 viewDir) +{ + vec3 lightDir = normalize(-light.direction); + // Diffuse shading + float diff = max(dot(normal, lightDir), 0.0); + // Specular shading + vec3 reflectDir = reflect(-lightDir, normal); + float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess); + // Combine results + vec3 ambient = light.ambient; + vec3 diffuse = light.diffuse * diff; + vec3 specular = light.specular * spec; + return (ambient + diffuse + specular); +} + +// Calculates the color when using a point light. +vec3 CalcPointLight(PointLight light, vec3 normal, vec3 fragPos, vec3 viewDir) +{ + vec3 lightDir = normalize(light.position - fragPos); + // Diffuse shading + float diff = max(dot(normal, lightDir), 0.0); + // Specular shading + vec3 reflectDir = reflect(-lightDir, normal); + float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess); + // Attenuation + float distance = length(light.position - fragPos); + float attenuation = 1.0f / (light.constant + light.linear * distance + light.quadratic * (distance * distance)); + // Combine results + vec3 ambient = light.ambient; + vec3 diffuse = light.diffuse * diff; + vec3 specular = light.specular * spec; + ambient *= attenuation; + diffuse *= attenuation; + specular *= attenuation; + return (ambient + diffuse + specular); +} + +vec3 CalcSpotLight(SpotLight light, vec3 norm, vec3 fragPos, vec3 viewDir){ +// Spotlight (soft edges) + // Ambient + vec3 ambient = light.ambient; + + // Diffuse + vec3 lightDir = normalize(light.position - FragPos); + float diff = max(dot(norm, lightDir), 0.0); + vec3 diffuse = light.diffuse * diff; + + // Specular + vec3 reflectDir = reflect(-lightDir, norm); + float spec = pow(max(dot(viewDir, reflectDir), 0.0), material.shininess); + vec3 specular = light.specular * spec; + + // Spotlight (soft edges) + float theta = dot(lightDir, normalize(-light.direction)); + float epsilon = (light.cutOff - light.outerCutOff); + float intensity = clamp((theta - light.outerCutOff) / epsilon, 0.0, 1.0); + diffuse *= intensity; + specular *= intensity; + + // Attenuation + float distance = length(light.position - FragPos); + float attenuation = 1.0f / (light.constant + light.linear * distance + light.quadratic * (distance * distance)); + ambient *= attenuation; + diffuse *= attenuation; + specular *= attenuation; + + return (ambient + diffuse + specular); +} diff --git a/Resources/BasicVS.glsl b/Resources/BasicVS.glsl new file mode 100644 index 0000000..6dc89a2 --- /dev/null +++ b/Resources/BasicVS.glsl @@ -0,0 +1,23 @@ +#version 330 core +layout (location = 0) in vec3 position; +layout (location = 1) in vec3 color; +layout (location = 2) in vec3 normal; +layout (location = 3) in vec2 texCoord; + +out vec3 ourColor; +out vec3 Normal; +out vec3 FragPos; +out vec2 TexCoords; + +uniform mat4 model; +uniform mat4 view; +uniform mat4 projection; + +void main() +{ + gl_Position = projection * view * model * vec4(position, 1.0f); + ourColor = color; + FragPos = vec3(model * vec4(position, 1.0f)); + Normal = mat3(transpose(inverse(model))) * normal; + TexCoords = texCoord; +} \ No newline at end of file diff --git a/Resources/Cinematic.PNG b/Resources/Cinematic.PNG new file mode 100644 index 0000000..8785e9f Binary files /dev/null and b/Resources/Cinematic.PNG differ diff --git a/Resources/LightFS.glsl b/Resources/LightFS.glsl new file mode 100644 index 0000000..8bdf136 --- /dev/null +++ b/Resources/LightFS.glsl @@ -0,0 +1,7 @@ +#version 330 core +out vec4 color; + +void main() +{ + color = vec4(0.6f); // Set alle 4 vector values to 1.0f +} \ No newline at end of file diff --git a/Resources/LightVS.glsl b/Resources/LightVS.glsl new file mode 100644 index 0000000..5cf5123 --- /dev/null +++ b/Resources/LightVS.glsl @@ -0,0 +1,11 @@ +#version 330 core +layout (location = 0) in vec3 position; + +uniform mat4 model; +uniform mat4 view; +uniform mat4 projection; + +void main() +{ + gl_Position = projection * view * model * vec4(position, 1.0f); +} \ No newline at end of file diff --git a/Resources/Specular.PNG b/Resources/Specular.PNG new file mode 100644 index 0000000..7bb1554 Binary files /dev/null and b/Resources/Specular.PNG differ diff --git a/Resources/Textures!.PNG b/Resources/Textures!.PNG new file mode 100644 index 0000000..e6f246f Binary files /dev/null and b/Resources/Textures!.PNG differ diff --git a/Resources/ned_86879038.flt b/Resources/ned_86879038.flt new file mode 100644 index 0000000..b5c6005 Binary files /dev/null and b/Resources/ned_86879038.flt differ diff --git a/Resources/ned_86879038.hdr b/Resources/ned_86879038.hdr new file mode 100644 index 0000000..c50fe11 --- /dev/null +++ b/Resources/ned_86879038.hdr @@ -0,0 +1,7 @@ +ncols 320 +nrows 283 +xllcorner -122.23111111089 +yllcorner 46.157777777631 +cellsize 0.00027777777779994 +NODATA_value -9999 +byteorder LSBFIRST diff --git a/Resources/ned_86879038.prj b/Resources/ned_86879038.prj new file mode 100644 index 0000000..ca52197 Binary files /dev/null and b/Resources/ned_86879038.prj differ