Skip to content

Commit

Permalink
Added a bunch of files that i forgot before... oops
Browse files Browse the repository at this point in the history
  • Loading branch information
nitronoid committed Mar 31, 2018
1 parent 8ec089f commit ec2a43d
Show file tree
Hide file tree
Showing 16 changed files with 38,435 additions and 211 deletions.
6 changes: 2 additions & 4 deletions Criminowl.pro
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ HEADERS += \
include/MaterialWireframe.h \
include/MaterialFractal.h \
include/MaterialEnvMap.h \
include/MaterialBump.h \
include/HDR_cube.h
include/MaterialBump.h


SOURCES += \
Expand All @@ -65,8 +64,7 @@ SOURCES += \
src/MaterialWireframe.cpp \
src/MaterialFractal.cpp \
src/MaterialEnvMap.cpp \
src/MaterialBump.cpp \
src/HDR_cube.cpp
src/MaterialBump.cpp

OTHER_FILES += \
$$files(shaders/*, true) \
Expand Down
21,067 changes: 21,067 additions & 0 deletions images/Alexs_Apt_2k.hdr

Large diffs are not rendered by default.

330 changes: 330 additions & 0 deletions images/Alexs_Apt_Env.hdr

Large diffs are not rendered by default.

16,864 changes: 16,864 additions & 0 deletions images/LA_Downtown_Afternoon_Fishing_3k.hdr

Large diffs are not rendered by default.

Binary file added images/woodShop.exr
Binary file not shown.
28 changes: 0 additions & 28 deletions include/HDR_cube.h

This file was deleted.

2 changes: 2 additions & 0 deletions include/MaterialPBR.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ class MaterialPBR : public Material
void initSphereMap();
void initCubeMap(const Mesh &_cube, const MeshVBO &_vbo);
void initIrradianceMap(const Mesh &_cube, const MeshVBO &_vbo);
void initPrefilteredMap(const Mesh &_cube, const MeshVBO &_vbo);
std::array<QMatrix4x4, 6> m_captureViews;
QMatrix4x4 m_captureProjection;

std::unique_ptr<QOpenGLTexture> m_sphereMap;
std::unique_ptr<QOpenGLTexture> m_cubeMap;
std::unique_ptr<QOpenGLTexture> m_irradianceMap;
std::unique_ptr<QOpenGLTexture> m_prefilteredMap;

glm::vec3 m_albedo;
QOpenGLContext* m_context;
Expand Down
59 changes: 59 additions & 0 deletions models/unitCube.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This file uses centimeters as units for non-parametric coordinates.

mtllib unitCube.mtl
g default
v -0.500000 -0.500000 0.500000
v 0.500000 -0.500000 0.500000
v -0.500000 0.500000 0.500000
v 0.500000 0.500000 0.500000
v -0.500000 0.500000 -0.500000
v 0.500000 0.500000 -0.500000
v -0.500000 -0.500000 -0.500000
v 0.500000 -0.500000 -0.500000
vt 0.375000 0.000000
vt 0.625000 0.000000
vt 0.375000 0.250000
vt 0.625000 0.250000
vt 0.375000 0.500000
vt 0.625000 0.500000
vt 0.375000 0.750000
vt 0.625000 0.750000
vt 0.375000 1.000000
vt 0.625000 1.000000
vt 0.875000 0.000000
vt 0.875000 0.250000
vt 0.125000 0.000000
vt 0.125000 0.250000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
s off
g pCube1
usemtl initialShadingGroup
f 1/1/1 2/2/2 4/4/3 3/3/4
f 3/3/5 4/4/6 6/6/7 5/5/8
f 5/5/9 6/6/10 8/8/11 7/7/12
f 7/7/13 8/8/14 2/10/15 1/9/16
f 2/2/17 8/11/18 6/12/19 4/4/20
f 7/13/21 1/1/22 3/3/23 5/14/24
5 changes: 5 additions & 0 deletions shaderPrograms/hdr_cubemap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"Name" : "HDR_cubemap",
"Vertex" : "shaders/hdr_cubemap_vert.glsl",
"Fragment" : "shaders/hdr_cubemap_frag.glsl"
}
5 changes: 5 additions & 0 deletions shaderPrograms/hdr_cubemap_irradiance.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"Name" : "HDR_cubemap_irradiance",
"Vertex" : "shaders/hdr_cubemap_vert.glsl",
"Fragment" : "shaders/hdr_cubemap_irradiance_frag.glsl"
}
23 changes: 23 additions & 0 deletions shaders/hdr_cubemap_frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#version 410 core

layout(location=0) out vec4 FragColor;
in vec3 localPos;

uniform sampler2D sphereMap;

const vec2 invAtan = vec2(0.1591, 0.3183);
vec2 SampleSphericalMap(vec3 v)
{
vec2 uv = vec2(atan(v.z, v.x), asin(v.y));
uv *= invAtan;
uv += 0.5;
return uv;
}

void main()
{
vec2 uv = SampleSphericalMap(normalize(localPos)); // make sure to normalize localPos
vec3 color = texture(sphereMap, uv).rgb;

FragColor = vec4(color, 1.0);
}
44 changes: 44 additions & 0 deletions shaders/hdr_cubemap_irradiance_frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#version 410 core

layout(location=0) out vec4 FragColor;
in vec3 localPos;

uniform samplerCube envMap;

const float PI = 3.14159265359;

void main()
{
// The world vector acts as the normal of a tangent surface
// from the origin, aligned to WorldPos. Given this normal, calculate all
// incoming radiance of the environment. The result of this radiance
// is the radiance of light coming from -Normal direction, which is what
// we use in the PBR shader to sample irradiance.
vec3 N = normalize(localPos);

vec3 irradiance = vec3(0.0);

// tangent space calculation from origin point
vec3 up = vec3(0.0, 1.0, 0.0);
vec3 right = cross(up, N);
up = cross(N, right);

float sampleDelta = 0.025;
float nrSamples = 0.0;
for(float phi = 0.0; phi < 2.0 * PI; phi += sampleDelta)
{
for(float theta = 0.0; theta < 0.5 * PI; theta += sampleDelta)
{
// spherical to cartesian (in tangent space)
vec3 tangentSample = vec3(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta));
// tangent space to world
vec3 sampleVec = tangentSample.x * right + tangentSample.y * up + tangentSample.z * N;

irradiance += texture(envMap, sampleVec).rgb * cos(theta) * sin(theta);
nrSamples++;
}
}
irradiance = PI * irradiance * (1.0 / float(nrSamples));

FragColor = vec4(irradiance, 1.0);
}
14 changes: 14 additions & 0 deletions shaders/hdr_cubemap_vert.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#version 410 core

layout (location = 0) in vec3 inVert;

out vec3 localPos;

uniform mat4 view;
uniform mat4 projection;

void main()
{
localPos = inVert;
gl_Position = projection * view * vec4(localPos, 1.0);
}
4 changes: 1 addition & 3 deletions src/DemoScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <QOpenGLContext>
#include <QOpenGLFunctions_4_1_Core>
#include <QOpenGLFramebufferObject>
#include "HDR_cube.h"

//-----------------------------------------------------------------------------------------------------
void DemoScene::writeMeshAttributes()
Expand Down Expand Up @@ -39,11 +38,10 @@ void DemoScene::init()
{
Scene::init();

glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);

// HDR_cube map;
// map.init(m_shaderLib, context());
initMaterials();

initGeo();
Expand Down
Loading

0 comments on commit ec2a43d

Please sign in to comment.