Commit 11f1c739 authored by Jan Scheffczyk's avatar Jan Scheffczyk
Browse files

HDR working. Also added another segment

parent 3e2ec09f
#pragma once
// Std. Includes
#include <vector>
// GL Includes
#include <GL/glew.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
// Defines several possible options for camera movement. Used as abstraction to stay away from window-system specific input methods
enum Camera_Movement {
FORWARD,
BACKWARD,
LEFT,
RIGHT
};
// Default camera values
const GLfloat YAW = -90.0f;
const GLfloat PITCH = 0.0f;
const GLfloat SPEED = 3.0f;
const GLfloat SENSITIVTY = 0.25f;
const GLfloat ZOOM = 45.0f;
// An abstract camera class that processes input and calculates the corresponding Eular Angles, Vectors and Matrices for use in OpenGL
class Camera
{
public:
// Camera Attributes
glm::vec3 Position;
glm::vec3 Front;
glm::vec3 Up;
glm::vec3 Right;
glm::vec3 WorldUp;
// Eular Angles
GLfloat Yaw;
GLfloat Pitch;
// Camera options
GLfloat MovementSpeed;
GLfloat MouseSensitivity;
GLfloat Zoom;
// Constructor with vectors
Camera(glm::vec3 position = glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3 up = glm::vec3(0.0f, 1.0f, 0.0f), GLfloat yaw = YAW, GLfloat pitch = PITCH) : Front(glm::vec3(0.0f, 0.0f, -1.0f)), MovementSpeed(SPEED), MouseSensitivity(SENSITIVTY), Zoom(ZOOM)
{
this->Position = position;
this->WorldUp = up;
this->Yaw = yaw;
this->Pitch = pitch;
this->updateCameraVectors();
}
// Constructor with scalar values
Camera(GLfloat posX, GLfloat posY, GLfloat posZ, GLfloat upX, GLfloat upY, GLfloat upZ, GLfloat yaw, GLfloat pitch) : Front(glm::vec3(0.0f, 0.0f, -1.0f)), MovementSpeed(SPEED), MouseSensitivity(SENSITIVTY), Zoom(ZOOM)
{
this->Position = glm::vec3(posX, posY, posZ);
this->WorldUp = glm::vec3(upX, upY, upZ);
this->Yaw = yaw;
this->Pitch = pitch;
this->updateCameraVectors();
}
// Returns the view matrix calculated using Eular Angles and the LookAt Matrix
glm::mat4 GetViewMatrix()
{
return glm::lookAt(this->Position, this->Position + this->Front, this->Up);
}
// Processes input received from any keyboard-like input system. Accepts input parameter in the form of camera defined ENUM (to abstract it from windowing systems)
void ProcessKeyboard(Camera_Movement direction, GLfloat deltaTime)
{
GLfloat velocity = this->MovementSpeed * deltaTime;
if (direction == FORWARD)
this->Position += this->Front * velocity;
if (direction == BACKWARD)
this->Position -= this->Front * velocity;
if (direction == LEFT)
this->Position -= this->Right * velocity;
if (direction == RIGHT)
this->Position += this->Right * velocity;
}
// Processes input received from a mouse input system. Expects the offset value in both the x and y direction.
void ProcessMouseMovement(GLfloat xoffset, GLfloat yoffset, GLboolean constrainPitch = true)
{
xoffset *= this->MouseSensitivity;
yoffset *= this->MouseSensitivity;
this->Yaw += xoffset;
this->Pitch += yoffset;
// Make sure that when pitch is out of bounds, screen doesn't get flipped
if (constrainPitch)
{
if (this->Pitch > 89.0f)
this->Pitch = 89.0f;
if (this->Pitch < -89.0f)
this->Pitch = -89.0f;
}
// Update Front, Right and Up Vectors using the updated Eular angles
this->updateCameraVectors();
}
// Processes input received from a mouse scroll-wheel event. Only requires input on the vertical wheel-axis
void ProcessMouseScroll(GLfloat yoffset)
{
if (this->Zoom >= 1.0f && this->Zoom <= 45.0f)
this->Zoom -= yoffset;
if (this->Zoom <= 1.0f)
this->Zoom = 1.0f;
if (this->Zoom >= 45.0f)
this->Zoom = 45.0f;
}
private:
// Calculates the front vector from the Camera's (updated) Eular Angles
void updateCameraVectors()
{
// Calculate the new Front vector
glm::vec3 front;
front.x = cos(glm::radians(this->Yaw)) * cos(glm::radians(this->Pitch));
front.y = sin(glm::radians(this->Pitch));
front.z = sin(glm::radians(this->Yaw)) * cos(glm::radians(this->Pitch));
this->Front = glm::normalize(front);
// Also re-calculate the Right and Up vector
this->Right = glm::normalize(glm::cross(this->Front, this->WorldUp)); // Normalize the vectors, because their length gets closer to 0 the more you look up or down which results in slower movement.
this->Up = glm::normalize(glm::cross(this->Right, this->Front));
}
};
#ifndef SHADER_H
#define SHADER_H
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
#include <GL/glew.h>
class Shader
{
public:
GLuint Program;
// Constructor generates the shader on the fly
Shader(const GLchar* vertexPath, const GLchar* fragmentPath)
{
// 1. Retrieve the vertex/fragment source code from filePath
std::string vertexCode;
std::string fragmentCode;
std::ifstream vShaderFile;
std::ifstream fShaderFile;
// ensures ifstream objects can throw exceptions:
vShaderFile.exceptions (std::ifstream::badbit);
fShaderFile.exceptions (std::ifstream::badbit);
try
{
// Open files
vShaderFile.open(vertexPath);
fShaderFile.open(fragmentPath);
std::stringstream vShaderStream, fShaderStream;
// Read file's buffer contents into streams
vShaderStream << vShaderFile.rdbuf();
fShaderStream << fShaderFile.rdbuf();
// close file handlers
vShaderFile.close();
fShaderFile.close();
// Convert stream into string
vertexCode = vShaderStream.str();
fragmentCode = fShaderStream.str();
}
catch (std::ifstream::failure e)
{
std::cout << "ERROR::SHADER::FILE_NOT_SUCCESFULLY_READ" << std::endl;
}
const GLchar* vShaderCode = vertexCode.c_str();
const GLchar * fShaderCode = fragmentCode.c_str();
// 2. Compile shaders
GLuint vertex, fragment;
GLint success;
GLchar infoLog[512];
// Vertex Shader
vertex = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertex, 1, &vShaderCode, NULL);
glCompileShader(vertex);
// Print compile errors if any
glGetShaderiv(vertex, GL_COMPILE_STATUS, &success);
if (!success)
{
glGetShaderInfoLog(vertex, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::VERTEX::COMPILATION_FAILED\n" << infoLog << std::endl;
}
// Fragment Shader
fragment = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragment, 1, &fShaderCode, NULL);
glCompileShader(fragment);
// Print compile errors if any
glGetShaderiv(fragment, GL_COMPILE_STATUS, &success);
if (!success)
{
glGetShaderInfoLog(fragment, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::FRAGMENT::COMPILATION_FAILED\n" << infoLog << std::endl;
}
// Shader Program
this->Program = glCreateProgram();
glAttachShader(this->Program, vertex);
glAttachShader(this->Program, fragment);
glLinkProgram(this->Program);
// Print linking errors if any
glGetProgramiv(this->Program, GL_LINK_STATUS, &success);
if (!success)
{
glGetProgramInfoLog(this->Program, 512, NULL, infoLog);
std::cout << "ERROR::SHADER::PROGRAM::LINKING_FAILED\n" << infoLog << std::endl;
}
// Delete the shaders as they're linked into our program now and no longer necessery
glDeleteShader(vertex);
glDeleteShader(fragment);
}
// Uses the current shader
void Use()
{
glUseProgram(this->Program);
}
};
#endif
To install (play the game)
choose either Linux_64bit or Windows_64bir
Linux -
extract all Files
make sure both the CP16.sh and CP16 exceutable have exceute rights
excetue CP16.sh
Windows
extract all Files
start CP16.exe
To compile:
......@@ -41,6 +41,6 @@ add_dependencies(CP16 SHADER MODEL)
if (UNIX)
target_link_libraries(CP16 glfw ${GLFW_LIBRARIES} freetypeGL GLU c m GLEW )
else()
target_link_libraries(CP16 glfw3 ${GLFW_LIBRARIES} glew32 gdi32 assimp freetype opengl32)
target_link_libraries(CP16 glfw3 ${GLFW_LIBRARIES} glew32 gdi32 freetype opengl32)
endif(UNIX)
......@@ -91,7 +91,7 @@
</plane>
<mesh name="Plane.001">
<indices amount="2">0, 1, 2, 0, 2, 3, </indices>
<diffuse>D:/C_Programme/ComputerGraphicProject/Programm/model/textures/textures/Ground2.png</diffuse>
<diffuse>//../../textures/textures/Ground2.png</diffuse>
<mat4>
<vec4>2.085202f, 0.000000f, 0.000000f, 0.000000f </vec4>
<vec4>0.000000f, 6.000000f, 0.000000f, 0.000000f </vec4>
......@@ -117,7 +117,7 @@
</plane>
<mesh name="Plane.002">
<indices amount="2">0, 1, 2, 0, 2, 3, </indices>
<diffuse>D:/C_Programme/ComputerGraphicProject/Programm/model/textures/textures/Ground2.png</diffuse>
<diffuse>//../../textures/textures/Ground2.png</diffuse>
<mat4>
<vec4>2.085202f, 0.000000f, 0.000000f, 0.000000f </vec4>
<vec4>0.000000f, 5.157487f, 3.065995f, 0.000000f </vec4>
......@@ -143,7 +143,7 @@
</plane>
<mesh name="Plane.003">
<indices amount="2">0, 1, 2, 0, 2, 3, </indices>
<diffuse>D:/C_Programme/ComputerGraphicProject/Programm/model/textures/textures/Ground2.png</diffuse>
<diffuse>//../../textures/textures/Ground2.png</diffuse>
<mat4>
<vec4>2.085202f, 0.000000f, 0.000000f, 0.000000f </vec4>
<vec4>0.000000f, 5.996758f, 0.197215f, 0.000000f </vec4>
......@@ -189,4 +189,38 @@
<vertex>-1.000000f, 1.000000f, 1.000000f, -0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f</vertex>
<vertex>-1.000000f, -1.000000f, 1.000000f, -0.000000f, 0.000000f, 1.000000f, 0.000000f, 1.000000f</vertex>
</mesh>
<mesh name="light.003">
<indices amount="12">0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23, </indices>
<diffuse>//../../textures/textures/light.png</diffuse>
<mat4>
<vec4>1.000000f, 0.000000f, 0.000000f, 0.000000f </vec4>
<vec4>0.000000f, 1.000000f, 0.000000f, 0.000000f </vec4>
<vec4>0.000000f, 0.000000f, 1.000000f, 0.000000f </vec4>
<vec4>3.671408f, 47.334187f, 7.913214f, 1.000000f </vec4>
</mat4>
<vertex>-1.000000f, 1.000000f, -1.000000f, -1.000000f, 0.000000f, -0.000000f, 1.000000f, 1.000000f</vertex>
<vertex>-1.000000f, -1.000000f, -1.000000f, -1.000000f, 0.000000f, -0.000000f, 0.000000f, 1.000000f</vertex>
<vertex>-1.000000f, -1.000000f, 1.000000f, -1.000000f, 0.000000f, -0.000000f, 0.000000f, 0.000000f</vertex>
<vertex>-1.000000f, 1.000000f, 1.000000f, -1.000000f, 0.000000f, -0.000000f, 1.000000f, 0.000000f</vertex>
<vertex>-1.000000f, 1.000000f, 1.000000f, 0.000000f, 1.000000f, -0.000000f, 0.000000f, 0.000000f</vertex>
<vertex>1.000000f, 1.000000f, 1.000000f, 0.000000f, 1.000000f, -0.000000f, 1.000000f, 0.000000f</vertex>
<vertex>1.000000f, 1.000000f, -1.000000f, 0.000000f, 1.000000f, -0.000000f, 1.000000f, 1.000000f</vertex>
<vertex>-1.000000f, 1.000000f, -1.000000f, 0.000000f, 1.000000f, -0.000000f, 0.000000f, 1.000000f</vertex>
<vertex>1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, -0.000000f, 0.000000f, 0.000000f</vertex>
<vertex>1.000000f, -1.000000f, 1.000000f, 1.000000f, 0.000000f, -0.000000f, 1.000000f, 0.000000f</vertex>
<vertex>1.000000f, -1.000000f, -1.000000f, 1.000000f, 0.000000f, -0.000000f, 1.000000f, 1.000000f</vertex>
<vertex>1.000000f, 1.000000f, -1.000000f, 1.000000f, 0.000000f, -0.000000f, 0.000000f, 1.000000f</vertex>
<vertex>-1.000000f, -1.000000f, -1.000000f, 0.000000f, -1.000000f, -0.000000f, 1.000000f, 1.000000f</vertex>
<vertex>1.000000f, -1.000000f, -1.000000f, 0.000000f, -1.000000f, -0.000000f, 0.000000f, 1.000000f</vertex>
<vertex>1.000000f, -1.000000f, 1.000000f, 0.000000f, -1.000000f, -0.000000f, 0.000000f, 0.000000f</vertex>
<vertex>-1.000000f, -1.000000f, 1.000000f, 0.000000f, -1.000000f, -0.000000f, 1.000000f, 0.000000f</vertex>
<vertex>-1.000000f, -1.000000f, -1.000000f, -0.000000f, 0.000000f, -1.000000f, 0.000000f, 0.000000f</vertex>
<vertex>-1.000000f, 1.000000f, -1.000000f, -0.000000f, 0.000000f, -1.000000f, 1.000000f, 0.000000f</vertex>
<vertex>1.000000f, 1.000000f, -1.000000f, -0.000000f, 0.000000f, -1.000000f, 1.000000f, 1.000000f</vertex>
<vertex>1.000000f, -1.000000f, -1.000000f, -0.000000f, 0.000000f, -1.000000f, 0.000000f, 1.000000f</vertex>
<vertex>1.000000f, -1.000000f, 1.000000f, -0.000000f, 0.000000f, 1.000000f, 0.000000f, 0.000000f</vertex>
<vertex>1.000000f, 1.000000f, 1.000000f, -0.000000f, 0.000000f, 1.000000f, 1.000000f, 0.000000f</vertex>
<vertex>-1.000000f, 1.000000f, 1.000000f, -0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f</vertex>
<vertex>-1.000000f, -1.000000f, 1.000000f, -0.000000f, 0.000000f, 1.000000f, 0.000000f, 1.000000f</vertex>
</mesh>
</TunnelSegment>
\ No newline at end of file
<?xml version = "1.0" encoding = "UTF-8"?>
<TunnelSegment>
<meta>
<difficulty>4</difficulty>
<difficulty>5</difficulty>
<type>0</type>
<rot>0.0</rot>
<mat4 type="start">
......@@ -57,7 +57,7 @@
</plane>
<mesh name="Plane.001">
<indices amount="2">0, 1, 2, 0, 2, 3, </indices>
<diffuse>D:/C_Programme/ComputerGraphicProject/Programm/model/textures/textures/Ground2.png</diffuse>
<diffuse>//../../textures/textures/Ground2.png</diffuse>
<mat4>
<vec4>2.085202f, 0.000000f, 0.000000f, 0.000000f </vec4>
<vec4>0.000000f, 6.000000f, 0.000000f, 0.000000f </vec4>
......@@ -83,7 +83,7 @@
</plane>
<mesh name="Plane.002">
<indices amount="2">0, 1, 2, 0, 2, 3, </indices>
<diffuse>D:/C_Programme/ComputerGraphicProject/Programm/model/textures/textures/Ground2.png</diffuse>
<diffuse>//../../textures/textures/Ground2.png</diffuse>
<mat4>
<vec4>2.085202f, 0.000000f, 0.000000f, 0.000000f </vec4>
<vec4>0.000000f, 5.157487f, 3.065995f, 0.000000f </vec4>
......@@ -109,7 +109,7 @@
</plane>
<mesh name="Plane.003">
<indices amount="2">0, 1, 2, 0, 2, 3, </indices>
<diffuse>D:/C_Programme/ComputerGraphicProject/Programm/model/textures/textures/Ground2.png</diffuse>
<diffuse>//../../textures/textures/Ground2.png</diffuse>
<mat4>
<vec4>2.085202f, 0.000000f, 0.000000f, 0.000000f </vec4>
<vec4>0.000000f, 5.996758f, 0.197215f, 0.000000f </vec4>
......@@ -121,10 +121,44 @@
<vertex>1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 0.999900f, 0.999900f</vertex>
<vertex>-1.000000f, 1.000000f, 0.000000f, 0.000000f, 0.000000f, 1.000000f, 0.000100f, 0.999900f</vertex>
</mesh>
<mesh name="light.003">
<indices amount="12">0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23, </indices>
<diffuse>//../../textures/textures/light.png</diffuse>
<mat4>
<vec4>1.000000f, 0.000000f, 0.000000f, 0.000000f </vec4>
<vec4>0.000000f, 1.000000f, 0.000000f, 0.000000f </vec4>
<vec4>0.000000f, 0.000000f, 1.000000f, 0.000000f </vec4>
<vec4>3.671408f, 47.334187f, 7.913214f, 1.000000f </vec4>
</mat4>
<vertex>-1.000000f, 1.000000f, -1.000000f, -1.000000f, 0.000000f, -0.000000f, 1.000000f, 1.000000f</vertex>
<vertex>-1.000000f, -1.000000f, -1.000000f, -1.000000f, 0.000000f, -0.000000f, 0.000000f, 1.000000f</vertex>
<vertex>-1.000000f, -1.000000f, 1.000000f, -1.000000f, 0.000000f, -0.000000f, 0.000000f, 0.000000f</vertex>
<vertex>-1.000000f, 1.000000f, 1.000000f, -1.000000f, 0.000000f, -0.000000f, 1.000000f, 0.000000f</vertex>
<vertex>-1.000000f, 1.000000f, 1.000000f, 0.000000f, 1.000000f, -0.000000f, 0.000000f, 0.000000f</vertex>
<vertex>1.000000f, 1.000000f, 1.000000f, 0.000000f, 1.000000f, -0.000000f, 1.000000f, 0.000000f</vertex>
<vertex>1.000000f, 1.000000f, -1.000000f, 0.000000f, 1.000000f, -0.000000f, 1.000000f, 1.000000f</vertex>
<vertex>-1.000000f, 1.000000f, -1.000000f, 0.000000f, 1.000000f, -0.000000f, 0.000000f, 1.000000f</vertex>
<vertex>1.000000f, 1.000000f, 1.000000f, 1.000000f, 0.000000f, -0.000000f, 0.000000f, 0.000000f</vertex>
<vertex>1.000000f, -1.000000f, 1.000000f, 1.000000f, 0.000000f, -0.000000f, 1.000000f, 0.000000f</vertex>
<vertex>1.000000f, -1.000000f, -1.000000f, 1.000000f, 0.000000f, -0.000000f, 1.000000f, 1.000000f</vertex>
<vertex>1.000000f, 1.000000f, -1.000000f, 1.000000f, 0.000000f, -0.000000f, 0.000000f, 1.000000f</vertex>
<vertex>-1.000000f, -1.000000f, -1.000000f, 0.000000f, -1.000000f, -0.000000f, 1.000000f, 1.000000f</vertex>
<vertex>1.000000f, -1.000000f, -1.000000f, 0.000000f, -1.000000f, -0.000000f, 0.000000f, 1.000000f</vertex>
<vertex>1.000000f, -1.000000f, 1.000000f, 0.000000f, -1.000000f, -0.000000f, 0.000000f, 0.000000f</vertex>
<vertex>-1.000000f, -1.000000f, 1.000000f, 0.000000f, -1.000000f, -0.000000f, 1.000000f, 0.000000f</vertex>
<vertex>-1.000000f, -1.000000f, -1.000000f, -0.000000f, 0.000000f, -1.000000f, 0.000000f, 0.000000f</vertex>
<vertex>-1.000000f, 1.000000f, -1.000000f, -0.000000f, 0.000000f, -1.000000f, 1.000000f, 0.000000f</vertex>
<vertex>1.000000f, 1.000000f, -1.000000f, -0.000000f, 0.000000f, -1.000000f, 1.000000f, 1.000000f</vertex>
<vertex>1.000000f, -1.000000f, -1.000000f, -0.000000f, 0.000000f, -1.000000f, 0.000000f, 1.000000f</vertex>
<vertex>1.000000f, -1.000000f, 1.000000f, -0.000000f, 0.000000f, 1.000000f, 0.000000f, 0.000000f</vertex>
<vertex>1.000000f, 1.000000f, 1.000000f, -0.000000f, 0.000000f, 1.000000f, 1.000000f, 0.000000f</vertex>
<vertex>-1.000000f, 1.000000f, 1.000000f, -0.000000f, 0.000000f, 1.000000f, 1.000000f, 1.000000f</vertex>
<vertex>-1.000000f, -1.000000f, 1.000000f, -0.000000f, 0.000000f, 1.000000f, 0.000000f, 1.000000f</vertex>
</mesh>
<mat4 type="Pendulum">
<vec4>1.000000f, 0.000000f, 0.000000f, 0.000000f </vec4>
<vec4>0.000000f, 1.000000f, 0.000000f, 0.000000f </vec4>
<vec4>0.000000f, 0.000000f, 1.000000f, 0.000000f </vec4>
<vec4>0.108476f, 34.953339f, 7.810189f, 1.000000f </vec4>
<vec4>-0.267040f, 33.274639f, 6.283897f, 1.000000f </vec4>
</mat4>
</TunnelSegment>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
<?xml version = "1.0" encoding = "UTF-8"?>
<TunnelSegment>
<meta>
<difficulty>0</difficulty>
<difficulty>5</difficulty>
<type>0</type>
<rot>0.0</rot>
<mat4 type="start">
......@@ -542,8 +542,8 @@
<vertex>-1.000000f, -1.000000f, 1.000000f, -0.000000f, 0.000000f, 1.000000f, 0.000000f, 1.000000f</vertex>
</mesh>
<mat4 type="Pendulum">
<vec4>-0.000000f, 1.000000f, 0.000000f, 0.000000f </vec4>
<vec4>-1.000000f, -0.000000f, 0.000000f, 0.000000f </vec4>
<vec4>1.000000f, 0.000000f, 0.000000f, 0.000000f </vec4>
<vec4>0.000000f, 1.000000f, 0.000000f, 0.000000f </vec4>
<vec4>0.000000f, 0.000000f, 1.000000f, 0.000000f </vec4>
<vec4>-18.346243f, 25.661060f, 0.257104f, 1.000000f </vec4>
</mat4>
......@@ -554,8 +554,8 @@
<vec4>-24.566843f, 63.419106f, -3.587038f, 1.000000f </vec4>
</mat4>
<mat4 type="Pendulum.002">
<vec4>-0.000000f, 1.000000f, 0.000000f, 0.000000f </vec4>
<vec4>-1.000000f, -0.000000f, 0.000000f, 0.000000f </vec4>
<vec4>1.000000f, 0.000000f, 0.000000f, 0.000000f </vec4>
<vec4>0.000000f, 1.000000f, 0.000000f, 0.000000f </vec4>
<vec4>0.000000f, 0.000000f, 1.000000f, 0.000000f </vec4>
<vec4>-18.346243f, 32.549492f, 0.257104f, 1.000000f </vec4>
</mat4>
......
#version 330 core
out vec4 color;
in vec2 TexCoords;
uniform sampler2D hdrBuffer;
uniform float exposure;
uniform float gamma;
uniform bool hdr;
void main()
{
vec3 hdrColor = texture(hdrBuffer, TexCoords).rgb;
// Exposure tone mapping
// vec3 mapped = hdrColor / (hdrColor + vec3(1.0));
vec3 mapped = vec3(1.0) - exp(-hdrColor * exposure);
// Gamma correction
mapped = pow(mapped, vec3(1.0 / gamma));
color = vec4(mapped, 1.0);
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment