forked from FWGS/xash3d-fwgs
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Merge pull request #736 from w23/E373-tradsky
E373: Draw skybox in traditional renderer Fixes #732
Showing
18 changed files
with
501 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#version 450 | ||
|
||
layout(set = 0, binding = 0) uniform UBO { | ||
mat4 mvp; | ||
mat4 inv_proj; | ||
mat4 inv_view; | ||
vec2 resolution; | ||
} ubo; | ||
|
||
layout(set = 0, binding = 1) uniform samplerCube skybox; | ||
|
||
layout(location = 0) out vec4 out_color; | ||
|
||
vec3 clipToWorldSpace(vec3 clip) { | ||
const vec4 eye_space = ubo.inv_proj * vec4(clip, 1.); | ||
return (ubo.inv_view * vec4(eye_space.xyz / eye_space.w, 1.)).xyz; | ||
} | ||
|
||
vec3 getDirection(in vec2 uv) { | ||
uv = uv * 2. - 1.; | ||
const vec3 world_near = clipToWorldSpace(vec3(uv, 0.)); | ||
const vec3 world_far = clipToWorldSpace(vec3(uv, 1.)); | ||
return normalize(world_far - world_near); | ||
} | ||
|
||
void main() { | ||
const vec2 uv = gl_FragCoord.xy / ubo.resolution; | ||
const vec3 direction = getDirection(uv); | ||
out_color = texture(skybox, direction); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#version 450 | ||
|
||
layout(set=0,binding=0) uniform UBO { | ||
mat4 mvp; | ||
mat4 inv_proj; | ||
mat4 inv_view; | ||
vec2 resolution; | ||
} ubo; | ||
|
||
layout(location=0) in vec3 a_pos; | ||
|
||
void main() { | ||
gl_Position = ubo.mvp * vec4(a_pos.xyz, 1.); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.