mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-02 04:37:54 +08:00
Final updates on PBR tutorials w/ updated code.
This commit is contained in:
@@ -1,61 +0,0 @@
|
||||
#
|
||||
# Try to find GLEW library and include path.
|
||||
# Once done this will define
|
||||
#
|
||||
# GLEW_FOUND
|
||||
# GLEW_INCLUDE_PATH
|
||||
# GLEW_LIBRARY
|
||||
#
|
||||
IF (WIN32)
|
||||
FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
|
||||
${CMAKE_SOURCE_DIR}/includes
|
||||
$ENV{PROGRAMFILES}/GLEW/include
|
||||
${GLEW_ROOT_DIR}/include
|
||||
DOC "The directory where GL/glew.h resides")
|
||||
IF (NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
|
||||
FIND_LIBRARY( GLEW_LIBRARY
|
||||
NAMES glew64 glew64s
|
||||
PATHS
|
||||
$ENV{PROGRAMFILES}/GLEW/lib
|
||||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
|
||||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
|
||||
DOC "The GLEW library (64-bit)"
|
||||
)
|
||||
ELSE(NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
|
||||
FIND_LIBRARY( GLEW_LIBRARY
|
||||
NAMES glew GLEW glew32 glew32s
|
||||
PATHS
|
||||
${CMAKE_SOURCE_DIR}/lib
|
||||
$ENV{PROGRAMFILES}/GLEW/lib
|
||||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
|
||||
${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
|
||||
DOC "The GLEW library"
|
||||
)
|
||||
ENDIF(NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
|
||||
ELSE (WIN32)
|
||||
FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/sw/include
|
||||
/opt/local/include
|
||||
${GLEW_ROOT_DIR}/include
|
||||
DOC "The directory where GL/glew.h resides")
|
||||
FIND_LIBRARY( GLEW_LIBRARY
|
||||
NAMES GLEW glew
|
||||
PATHS
|
||||
/usr/lib64
|
||||
/usr/lib
|
||||
/usr/local/lib64
|
||||
/usr/local/lib
|
||||
/sw/lib
|
||||
/opt/local/lib
|
||||
${GLEW_ROOT_DIR}/lib
|
||||
DOC "The GLEW library")
|
||||
ENDIF (WIN32)
|
||||
SET(GLEW_FOUND "NO")
|
||||
IF (GLEW_INCLUDE_PATH AND GLEW_LIBRARY)
|
||||
SET(GLEW_LIBRARIES ${GLEW_LIBRARY})
|
||||
SET(GLEW_FOUND "YES")
|
||||
ENDIF (GLEW_INCLUDE_PATH AND GLEW_LIBRARY)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_LIBRARY GLEW_INCLUDE_PATH)
|
||||
@@ -1,42 +0,0 @@
|
||||
# - Locate SOIL library
|
||||
# This module defines
|
||||
# SOIL_LIBRARY, the name of the library to link against
|
||||
# SOIL_FOUND
|
||||
# SOIL_INCLUDE_DIR, where to find SOIL.h
|
||||
# To Adding search path, set SOIL_ROOT_DIR as follows
|
||||
# set(SOIL_ROOT_DIR "path/to/soil")
|
||||
# or launch cmake with -DSOIL_ROOT_DIR="/path/to/SOIL_ROOT_DIR".
|
||||
#
|
||||
# author: Kazunori Kimura
|
||||
# email : kazunori.abu@gmail.com
|
||||
#
|
||||
# revisions: github.com/zwookie
|
||||
|
||||
find_path(SOIL_INCLUDE_DIR SOIL.h
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/opt/local/include
|
||||
${CMAKE_SOURCE_DIR}/includes
|
||||
)
|
||||
|
||||
find_library(SOIL_LIBRARY SOIL
|
||||
/usr/lib64
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
/opt/local/lib
|
||||
${CMAKE_SOURCE_DIR}/lib
|
||||
)
|
||||
|
||||
IF(SOIL_INCLUDE_DIR AND SOIL_LIBRARY)
|
||||
SET( SOIL_FOUND TRUE )
|
||||
SET( SOIL_LIBRARIES ${SOIL_LIBRARY} )
|
||||
ENDIF(SOIL_INCLUDE_DIR AND SOIL_LIBRARY)
|
||||
IF(SOIL_FOUND)
|
||||
IF(NOT SOIL_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found SOIL: ${SOIL_LIBRARY}")
|
||||
ENDIF(NOT SOIL_FIND_QUIETLY)
|
||||
ELSE(SOIL_FOUND)
|
||||
IF(SOIL_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "Could not find libSOIL")
|
||||
ENDIF(SOIL_FIND_REQUIRED)
|
||||
ENDIF(SOIL_FOUND)
|
||||
@@ -15,7 +15,6 @@ uniform vec3 lightPositions[4];
|
||||
uniform vec3 lightColors[4];
|
||||
|
||||
uniform vec3 camPos;
|
||||
uniform float exposure;
|
||||
|
||||
const float PI = 3.14159265359;
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include <learnopengl/filesystem.h>
|
||||
#include <learnopengl/shader_m.h>
|
||||
#include <learnopengl/shader.h>
|
||||
#include <learnopengl/camera.h>
|
||||
#include <learnopengl/model.h>
|
||||
|
||||
@@ -127,7 +127,6 @@ int main()
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
shader.setMat4("view", view);
|
||||
shader.setVec3("camPos", camera.Position);
|
||||
shader.setFloat("exposure", 1.0f);
|
||||
|
||||
// render rows*column number of spheres with varying metallic/roughness values scaled by rows and columns respectively
|
||||
glm::mat4 model;
|
||||
|
||||
@@ -16,7 +16,6 @@ uniform vec3 lightPositions[4];
|
||||
uniform vec3 lightColors[4];
|
||||
|
||||
uniform vec3 camPos;
|
||||
uniform float exposure;
|
||||
|
||||
const float PI = 3.14159265359;
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include <learnopengl/filesystem.h>
|
||||
#include <learnopengl/shader_m.h>
|
||||
#include <learnopengl/shader.h>
|
||||
#include <learnopengl/camera.h>
|
||||
#include <learnopengl/model.h>
|
||||
|
||||
@@ -132,7 +132,6 @@ int main()
|
||||
glm::mat4 view = camera.GetViewMatrix();
|
||||
shader.setMat4("view", view);
|
||||
shader.setVec3("camPos", camera.Position);
|
||||
shader.setFloat("exposure", 1.0f);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, albedo);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include <learnopengl/filesystem.h>
|
||||
#include <learnopengl/shader_m.h>
|
||||
#include <learnopengl/shader.h>
|
||||
#include <learnopengl/camera.h>
|
||||
#include <learnopengl/model.h>
|
||||
|
||||
@@ -162,21 +162,21 @@ int main()
|
||||
glm::mat4 captureProjection = glm::perspective(glm::radians(90.0f), 1.0f, 0.1f, 10.0f);
|
||||
glm::mat4 captureViews[] =
|
||||
{
|
||||
glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.0f, -1.0f, 0.0f)),
|
||||
glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3( 1.0f, 0.0f, 0.0f), glm::vec3(0.0f, -1.0f, 0.0f)),
|
||||
glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(-1.0f, 0.0f, 0.0f), glm::vec3(0.0f, -1.0f, 0.0f)),
|
||||
glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f)),
|
||||
glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, -1.0f, 0.0f), glm::vec3(0.0f, 0.0f, -1.0f)),
|
||||
glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.0f, -1.0f, 0.0f)),
|
||||
glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, -1.0f), glm::vec3(0.0f, -1.0f, 0.0f))
|
||||
glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3( 0.0f, 1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f)),
|
||||
glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3( 0.0f, -1.0f, 0.0f), glm::vec3(0.0f, 0.0f, -1.0f)),
|
||||
glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3( 0.0f, 0.0f, 1.0f), glm::vec3(0.0f, -1.0f, 0.0f)),
|
||||
glm::lookAt(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3( 0.0f, 0.0f, -1.0f), glm::vec3(0.0f, -1.0f, 0.0f))
|
||||
};
|
||||
|
||||
// pbr: convert HDR equirectangular environment map to cubemap equivalent
|
||||
// ----------------------------------------------------------------------
|
||||
equirectangularToCubemapShader.use();
|
||||
equirectangularToCubemapShader.setInt("equirectangularMap", 0);
|
||||
equirectangularToCubemapShader.setMat4("projection", captureProjection);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, hdrTexture);
|
||||
equirectangularToCubemapShader.setMat4("projection", captureProjection);
|
||||
|
||||
glViewport(0, 0, 512, 512); // don't forget to configure the viewport to the capture dimensions.
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, captureFBO);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include <learnopengl/filesystem.h>
|
||||
#include <learnopengl/shader_m.h>
|
||||
#include <learnopengl/shader.h>
|
||||
#include <learnopengl/camera.h>
|
||||
#include <learnopengl/model.h>
|
||||
|
||||
@@ -176,9 +176,9 @@ int main()
|
||||
// ----------------------------------------------------------------------
|
||||
equirectangularToCubemapShader.use();
|
||||
equirectangularToCubemapShader.setInt("equirectangularMap", 0);
|
||||
equirectangularToCubemapShader.setMat4("projection", captureProjection);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, hdrTexture);
|
||||
equirectangularToCubemapShader.setMat4("projection", captureProjection);
|
||||
|
||||
glViewport(0, 0, 512, 512); // don't forget to configure the viewport to the capture dimensions.
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, captureFBO);
|
||||
@@ -199,7 +199,7 @@ int main()
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, irradianceMap);
|
||||
for (unsigned int i = 0; i < 6; ++i)
|
||||
{
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB32F, 32, 32, 0, GL_RGB, GL_FLOAT, nullptr);
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB16F, 32, 32, 0, GL_RGB, GL_FLOAT, nullptr);
|
||||
}
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
@@ -215,9 +215,9 @@ int main()
|
||||
// -----------------------------------------------------------------------------
|
||||
irradianceShader.use();
|
||||
irradianceShader.setInt("environmentMap", 0);
|
||||
irradianceShader.setMat4("projection", captureProjection);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, envCubemap);
|
||||
irradianceShader.setMat4("projection", captureProjection);
|
||||
|
||||
glViewport(0, 0, 32, 32); // don't forget to configure the viewport to the capture dimensions.
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, captureFBO);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include <learnopengl/filesystem.h>
|
||||
#include <learnopengl/shader_m.h>
|
||||
#include <learnopengl/shader.h>
|
||||
#include <learnopengl/camera.h>
|
||||
#include <learnopengl/model.h>
|
||||
|
||||
@@ -183,9 +183,9 @@ int main()
|
||||
// ----------------------------------------------------------------------
|
||||
equirectangularToCubemapShader.use();
|
||||
equirectangularToCubemapShader.setInt("equirectangularMap", 0);
|
||||
equirectangularToCubemapShader.setMat4("projection", captureProjection);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, hdrTexture);
|
||||
equirectangularToCubemapShader.setMat4("projection", captureProjection);
|
||||
|
||||
glViewport(0, 0, 512, 512); // don't forget to configure the viewport to the capture dimensions.
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, captureFBO);
|
||||
@@ -210,7 +210,7 @@ int main()
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, irradianceMap);
|
||||
for (unsigned int i = 0; i < 6; ++i)
|
||||
{
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB32F, 32, 32, 0, GL_RGB, GL_FLOAT, nullptr);
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB16F, 32, 32, 0, GL_RGB, GL_FLOAT, nullptr);
|
||||
}
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
@@ -226,9 +226,9 @@ int main()
|
||||
// -----------------------------------------------------------------------------
|
||||
irradianceShader.use();
|
||||
irradianceShader.setInt("environmentMap", 0);
|
||||
irradianceShader.setMat4("projection", captureProjection);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, envCubemap);
|
||||
irradianceShader.setMat4("projection", captureProjection);
|
||||
|
||||
glViewport(0, 0, 32, 32); // don't forget to configure the viewport to the capture dimensions.
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, captureFBO);
|
||||
@@ -263,16 +263,16 @@ int main()
|
||||
// ----------------------------------------------------------------------------------------------------
|
||||
prefilterShader.use();
|
||||
prefilterShader.setInt("environmentMap", 0);
|
||||
prefilterShader.setMat4("projection", captureProjection);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, envCubemap);
|
||||
prefilterShader.setMat4("projection", captureProjection);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, captureFBO);
|
||||
unsigned int maxMipLevels = 5;
|
||||
for (unsigned int mip = 0; mip < maxMipLevels; ++mip)
|
||||
{
|
||||
// reisze framebuffer according to mip-level size.
|
||||
unsigned int mipWidth = 128 * std::pow(0.5, mip);
|
||||
unsigned int mipWidth = 128 * std::pow(0.5, mip);
|
||||
unsigned int mipHeight = 128 * std::pow(0.5, mip);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, captureRBO);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, mipWidth, mipHeight);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
#include <learnopengl/filesystem.h>
|
||||
#include <learnopengl/shader_m.h>
|
||||
#include <learnopengl/shader.h>
|
||||
#include <learnopengl/camera.h>
|
||||
#include <learnopengl/model.h>
|
||||
|
||||
@@ -223,9 +223,9 @@ int main()
|
||||
// ----------------------------------------------------------------------
|
||||
equirectangularToCubemapShader.use();
|
||||
equirectangularToCubemapShader.setInt("equirectangularMap", 0);
|
||||
equirectangularToCubemapShader.setMat4("projection", captureProjection);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, hdrTexture);
|
||||
equirectangularToCubemapShader.setMat4("projection", captureProjection);
|
||||
|
||||
glViewport(0, 0, 512, 512); // don't forget to configure the viewport to the capture dimensions.
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, captureFBO);
|
||||
@@ -250,7 +250,7 @@ int main()
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, irradianceMap);
|
||||
for (unsigned int i = 0; i < 6; ++i)
|
||||
{
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB32F, 32, 32, 0, GL_RGB, GL_FLOAT, nullptr);
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB16F, 32, 32, 0, GL_RGB, GL_FLOAT, nullptr);
|
||||
}
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
@@ -266,9 +266,9 @@ int main()
|
||||
// -----------------------------------------------------------------------------
|
||||
irradianceShader.use();
|
||||
irradianceShader.setInt("environmentMap", 0);
|
||||
irradianceShader.setMat4("projection", captureProjection);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, envCubemap);
|
||||
irradianceShader.setMat4("projection", captureProjection);
|
||||
|
||||
glViewport(0, 0, 32, 32); // don't forget to configure the viewport to the capture dimensions.
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, captureFBO);
|
||||
@@ -303,9 +303,9 @@ int main()
|
||||
// ----------------------------------------------------------------------------------------------------
|
||||
prefilterShader.use();
|
||||
prefilterShader.setInt("environmentMap", 0);
|
||||
prefilterShader.setMat4("projection", captureProjection);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, envCubemap);
|
||||
prefilterShader.setMat4("projection", captureProjection);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, captureFBO);
|
||||
unsigned int maxMipLevels = 5;
|
||||
|
||||
Reference in New Issue
Block a user