Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CPP
LearnOpenGL
提交
ae3d985d
L
LearnOpenGL
项目概览
CPP
/
LearnOpenGL
8 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
LearnOpenGL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
ae3d985d
编写于
5月 18, 2023
作者:
J
Joey de Vries
提交者:
GitHub
5月 18, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #358 from agnat/fix/8.2.csm
2.3.csm: fix mac os issues
上级
7291ee8c
a43c5045
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
37 addition
and
28 deletion
+37
-28
src/8.guest/2021/2.csm/10.debug_cascade.fs
src/8.guest/2021/2.csm/10.debug_cascade.fs
+2
-2
src/8.guest/2021/2.csm/10.debug_cascade.vs
src/8.guest/2021/2.csm/10.debug_cascade.vs
+2
-2
src/8.guest/2021/2.csm/10.debug_quad.vs
src/8.guest/2021/2.csm/10.debug_quad.vs
+2
-2
src/8.guest/2021/2.csm/10.debug_quad_depth.fs
src/8.guest/2021/2.csm/10.debug_quad_depth.fs
+2
-2
src/8.guest/2021/2.csm/10.shadow_mapping.fs
src/8.guest/2021/2.csm/10.shadow_mapping.fs
+3
-3
src/8.guest/2021/2.csm/10.shadow_mapping.vs
src/8.guest/2021/2.csm/10.shadow_mapping.vs
+2
-2
src/8.guest/2021/2.csm/10.shadow_mapping_depth.fs
src/8.guest/2021/2.csm/10.shadow_mapping_depth.fs
+2
-2
src/8.guest/2021/2.csm/10.shadow_mapping_depth.gs
src/8.guest/2021/2.csm/10.shadow_mapping_depth.gs
+6
-3
src/8.guest/2021/2.csm/10.shadow_mapping_depth.vs
src/8.guest/2021/2.csm/10.shadow_mapping_depth.vs
+2
-2
src/8.guest/2021/2.csm/shadow_mapping.cpp
src/8.guest/2021/2.csm/shadow_mapping.cpp
+14
-8
未找到文件。
src/8.guest/2021/2.csm/10.debug_cascade.fs
浏览文件 @
ae3d985d
#
version
4
6
0
core
#
version
4
1
0
core
out
vec4
FragColor
;
uniform
vec4
color
;
...
...
@@ -6,4 +6,4 @@ uniform vec4 color;
void
main
()
{
FragColor
=
color
;
}
\ No newline at end of file
}
src/8.guest/2021/2.csm/10.debug_cascade.vs
浏览文件 @
ae3d985d
#version 4
6
0 core
#version 4
1
0 core
layout
(
location
=
0
)
in
vec3
aPos
;
uniform
mat4
view
;
...
...
@@ -7,4 +7,4 @@ uniform mat4 projection;
void
main
()
{
gl_Position
=
projection
*
view
*
vec4
(
aPos
,
1
.
0
);
}
\ No newline at end of file
}
src/8.guest/2021/2.csm/10.debug_quad.vs
浏览文件 @
ae3d985d
#version 4
6
0 core
#version 4
1
0 core
layout
(
location
=
0
)
in
vec3
aPos
;
layout
(
location
=
1
)
in
vec2
aTexCoords
;
...
...
@@ -8,4 +8,4 @@ void main()
{
TexCoords
=
aTexCoords
;
gl_Position
=
vec4
(
aPos
,
1
.
0
);
}
\ No newline at end of file
}
src/8.guest/2021/2.csm/10.debug_quad_depth.fs
浏览文件 @
ae3d985d
#
version
4
6
0
core
#
version
4
1
0
core
out
vec4
FragColor
;
in
vec2
TexCoords
;
...
...
@@ -20,4 +20,4 @@ void main()
float
depthValue
=
texture
(
depthMap
,
vec3
(
TexCoords
,
layer
)).
r
;
// FragColor = vec4(vec3(LinearizeDepth(depthValue) / far_plane), 1.0); // perspective
FragColor
=
vec4
(
vec3
(
depthValue
),
1
.
0
);
// orthographic
}
\ No newline at end of file
}
src/8.guest/2021/2.csm/10.shadow_mapping.fs
浏览文件 @
ae3d985d
#
version
4
6
0
core
#
version
4
1
0
core
out
vec4
FragColor
;
in
VS_OUT
{
...
...
@@ -16,7 +16,7 @@ uniform float farPlane;
uniform
mat4
view
;
layout
(
std140
,
binding
=
0
)
uniform
LightSpaceMatrices
layout
(
std140
)
uniform
LightSpaceMatrices
{
mat4
lightSpaceMatrices
[
16
];
};
...
...
@@ -108,4 +108,4 @@ void main()
vec3
lighting
=
(
ambient
+
(
1
.
0
-
shadow
)
*
(
diffuse
+
specular
))
*
color
;
FragColor
=
vec4
(
lighting
,
1
.
0
);
}
\ No newline at end of file
}
src/8.guest/2021/2.csm/10.shadow_mapping.vs
浏览文件 @
ae3d985d
#version 4
6
0 core
#version 4
1
0 core
layout
(
location
=
0
)
in
vec3
aPos
;
layout
(
location
=
1
)
in
vec3
aNormal
;
layout
(
location
=
2
)
in
vec2
aTexCoords
;
...
...
@@ -21,4 +21,4 @@ void main()
vs_out
.
Normal
=
transpose
(
inverse
(
mat3
(
model
)))
*
aNormal
;
vs_out
.
TexCoords
=
aTexCoords
;
gl_Position
=
projection
*
view
*
model
*
vec4
(
aPos
,
1
.
0
);
}
\ No newline at end of file
}
src/8.guest/2021/2.csm/10.shadow_mapping_depth.fs
浏览文件 @
ae3d985d
#
version
4
6
0
core
#
version
4
1
0
core
void
main
()
{
}
\ No newline at end of file
}
src/8.guest/2021/2.csm/10.shadow_mapping_depth.gs
浏览文件 @
ae3d985d
#version 4
6
0 core
#version 4
1
0 core
layout
(
triangles
,
invocations
=
5
)
in
;
layout
(
triangle_strip
,
max_vertices
=
3
)
out
;
layout
(
std140
,
binding
=
0
)
uniform
LightSpaceMatrices
layout
(
std140
)
uniform
LightSpaceMatrices
{
mat4
lightSpaceMatrices
[
16
];
};
/*
uniform mat4 lightSpaceMatrices[16];
*/
void
main
()
{
...
...
@@ -17,4 +20,4 @@ void main()
EmitVertex
();
}
EndPrimitive
();
}
\ No newline at end of file
}
src/8.guest/2021/2.csm/10.shadow_mapping_depth.vs
浏览文件 @
ae3d985d
#version 4
6
0 core
#version 4
1
0 core
layout
(
location
=
0
)
in
vec3
aPos
;
uniform
mat4
model
;
...
...
@@ -6,4 +6,4 @@ uniform mat4 model;
void
main
()
{
gl_Position
=
model
*
vec4
(
aPos
,
1
.
0
);
}
\ No newline at end of file
}
src/8.guest/2021/2.csm/shadow_mapping.cpp
浏览文件 @
ae3d985d
...
...
@@ -30,6 +30,10 @@ void drawCascadeVolumeVisualizers(const std::vector<glm::mat4>& lightMatrices, S
const
unsigned
int
SCR_WIDTH
=
2560
;
const
unsigned
int
SCR_HEIGHT
=
1440
;
// framebuffer size
int
fb_width
;
int
fb_height
;
// camera
Camera
camera
(
glm
::
vec3
(
0.0
f
,
0.0
f
,
3.0
f
));
float
lastX
=
(
float
)
SCR_WIDTH
/
2.0
;
...
...
@@ -69,7 +73,7 @@ int main()
// ------------------------------
glfwInit
();
glfwWindowHint
(
GLFW_CONTEXT_VERSION_MAJOR
,
4
);
glfwWindowHint
(
GLFW_CONTEXT_VERSION_MINOR
,
6
);
glfwWindowHint
(
GLFW_CONTEXT_VERSION_MINOR
,
1
);
glfwWindowHint
(
GLFW_OPENGL_PROFILE
,
GLFW_OPENGL_CORE_PROFILE
);
#ifdef __APPLE__
...
...
@@ -89,6 +93,7 @@ int main()
glfwSetFramebufferSizeCallback
(
window
,
framebuffer_size_callback
);
glfwSetCursorPosCallback
(
window
,
mouse_callback
);
glfwSetScrollCallback
(
window
,
scroll_callback
);
glfwGetFramebufferSize
(
window
,
&
fb_width
,
&
fb_height
);
// tell GLFW to capture our mouse
glfwSetInputMode
(
window
,
GLFW_CURSOR
,
GLFW_CURSOR_DISABLED
);
...
...
@@ -239,15 +244,15 @@ int main()
glBindFramebuffer
(
GL_FRAMEBUFFER
,
0
);
// reset viewport
glViewport
(
0
,
0
,
SCR_WIDTH
,
SCR_HEIGHT
);
glViewport
(
0
,
0
,
fb_width
,
fb_height
);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
// 2. render scene as normal using the generated depth/shadow map
// --------------------------------------------------------------
glViewport
(
0
,
0
,
SCR_WIDTH
,
SCR_HEIGHT
);
glViewport
(
0
,
0
,
fb_width
,
fb_height
);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
shader
.
use
();
const
glm
::
mat4
projection
=
glm
::
perspective
(
glm
::
radians
(
camera
.
Zoom
),
(
float
)
SCR_WIDTH
/
(
float
)
SCR_HEIGHT
,
cameraNearPlane
,
cameraFarPlane
);
const
glm
::
mat4
projection
=
glm
::
perspective
(
glm
::
radians
(
camera
.
Zoom
),
(
float
)
fb_width
/
(
float
)
fb_height
,
cameraNearPlane
,
cameraFarPlane
);
const
glm
::
mat4
view
=
camera
.
GetViewMatrix
();
shader
.
setMat4
(
"projection"
,
projection
);
shader
.
setMat4
(
"view"
,
view
);
...
...
@@ -540,7 +545,7 @@ void processInput(GLFWwindow *window)
fPress
=
glfwGetKey
(
window
,
GLFW_KEY_F
);
static
int
plusPress
=
GLFW_RELEASE
;
if
(
glfwGetKey
(
window
,
GLFW_KEY_
KP_ADD
)
==
GLFW_RELEASE
&&
plusPress
==
GLFW_PRESS
)
if
(
glfwGetKey
(
window
,
GLFW_KEY_
N
)
==
GLFW_RELEASE
&&
plusPress
==
GLFW_PRESS
)
{
debugLayer
++
;
if
(
debugLayer
>
shadowCascadeLevels
.
size
())
...
...
@@ -548,7 +553,7 @@ void processInput(GLFWwindow *window)
debugLayer
=
0
;
}
}
plusPress
=
glfwGetKey
(
window
,
GLFW_KEY_
KP_ADD
);
plusPress
=
glfwGetKey
(
window
,
GLFW_KEY_
N
);
static
int
cPress
=
GLFW_RELEASE
;
if
(
glfwGetKey
(
window
,
GLFW_KEY_C
)
==
GLFW_RELEASE
&&
cPress
==
GLFW_PRESS
)
...
...
@@ -564,6 +569,8 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
// make sure the viewport matches the new window dimensions; note that width and
// height will be significantly larger than specified on retina displays.
fb_width
=
width
;
fb_height
=
height
;
glViewport
(
0
,
0
,
width
,
height
);
}
...
...
@@ -662,7 +669,7 @@ std::vector<glm::vec4> getFrustumCornersWorldSpace(const glm::mat4& proj, const
glm
::
mat4
getLightSpaceMatrix
(
const
float
nearPlane
,
const
float
farPlane
)
{
const
auto
proj
=
glm
::
perspective
(
glm
::
radians
(
camera
.
Zoom
),
(
float
)
SCR_WIDTH
/
(
float
)
SCR_HEIGHT
,
nearPlane
,
glm
::
radians
(
camera
.
Zoom
),
(
float
)
fb_width
/
(
float
)
fb_height
,
nearPlane
,
farPlane
);
const
auto
corners
=
getFrustumCornersWorldSpace
(
proj
,
camera
.
GetViewMatrix
());
...
...
@@ -712,7 +719,6 @@ glm::mat4 getLightSpaceMatrix(const float nearPlane, const float farPlane)
}
const
glm
::
mat4
lightProjection
=
glm
::
ortho
(
minX
,
maxX
,
minY
,
maxY
,
minZ
,
maxZ
);
return
lightProjection
*
lightView
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录