Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create cubemap from file #93

Merged
merged 56 commits into from
May 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
c0c07af
partial implementation of cubemap support
stf976 Oct 26, 2020
a819e2f
finish first working draft of cubemap texture support,
stf976 Oct 29, 2020
6cbbb05
in texture_cubemap example, transform left-handed cubemap coordinates…
stf976 Nov 24, 2020
b451822
first (incomplete) draft for loading cubemap from six individual files
stf976 Nov 24, 2020
6fe145f
adapt texture_cubemap example and load_cubemap_from_file after rebasi…
stf976 Nov 25, 2020
82101f3
add image_resource_t helper class for image loading library abstraction;
stf976 Nov 27, 2020
726afae
partial implementation of cubemap support
stf976 Oct 26, 2020
e5ae27f
finish first working draft of cubemap texture support,
stf976 Oct 29, 2020
e22b572
in texture_cubemap example, transform left-handed cubemap coordinates…
stf976 Nov 24, 2020
35c2520
first (incomplete) draft for loading cubemap from six individual files
stf976 Nov 24, 2020
7cdcfe7
adapt texture_cubemap example and load_cubemap_from_file after rebasi…
stf976 Nov 25, 2020
f0d3dd6
add image_resource_t helper class for image loading library abstraction;
stf976 Nov 27, 2020
4bdd96f
add cubemap sample texture in ktx and dds format
stf976 Feb 27, 2021
8ab4b4b
implement image_resource as bridge pattern to facilitate caching
stf976 Feb 27, 2021
17491e3
update revision of auto_vk
stf976 Feb 27, 2021
b3be9df
Merge branch 'create_cubemap_from_file' of https://github.com/cg-tuwi…
stf976 Feb 27, 2021
b08d507
add license information about yokohama_at_night textures
stf976 Mar 20, 2021
5e05a02
remove commented-out code
stf976 Mar 20, 2021
4b8155b
follow naming conventions
stf976 Mar 20, 2021
cd86eb4
rename sRGB, HDR parameters
stf976 Mar 20, 2021
1c6d867
add virtual constructor to image_resource_t
stf976 Mar 21, 2021
43607a5
Merge branch 'create_cubemap_from_file' of https://github.com/cg-tuwi…
stf976 Mar 21, 2021
278fd60
delete special functions for image_resource_base_t
stf976 Mar 21, 2021
8f0d4ca
follow naming conventions
stf976 Mar 21, 2021
2d601bf
Apply suggestions from code review
stf976 Mar 21, 2021
41cebe9
use avk::resource_reference for type of image_resource instead of std…
stf976 Mar 25, 2021
8a4cf47
use avk::owning_resource for type of image_resource instead of std::u…
stf976 Mar 25, 2021
d0e8fb1
Merge branch 'create_cubemap_from_file' of https://github.com/cg-tuwi…
stf976 Mar 25, 2021
cff294d
add explanation of memory, resource leaks for [[nodiscard]] to guidel…
stf976 Mar 28, 2021
6e95f0f
add image_resource.hpp to gvk.hpp
stf976 Mar 28, 2021
4a298f6
don't create image_resource explicitly in cubemap example, use create…
stf976 Mar 28, 2021
54ac8ef
rename image_resource* types and files to image_data*
stf976 Mar 28, 2021
3a4a68a
Revert "add explanation of memory, resource leaks for [[nodiscard]] t…
stf976 Mar 28, 2021
92a20e9
rename image_resource* types to image_data*
stf976 Mar 28, 2021
9a5b1b4
code cleanup in cubemap_texture example
stf976 Apr 25, 2021
edad486
remove initialization of removed mInitTime variable
stf976 Apr 25, 2021
357b886
use consistent parameter names, camel case
stf976 Apr 25, 2021
9efcfc1
use consistent variable names
stf976 Apr 25, 2021
7cead62
use create_vertex_and_index_buffers, create_normals_buffer for model …
stf976 Apr 25, 2021
2655919
remove owning_resource wrapper from image_data
stf976 Apr 25, 2021
c20685b
remove owning_resource from image_data
stf976 Apr 25, 2021
373e123
use only a single descriptor cache for both pipelines
stf976 Apr 25, 2021
54cd2c9
add mirror_matrix and cancel_translation_from_matrix helper functions
stf976 Apr 25, 2021
321d016
use enum to define axis in mirror_matrix
stf976 May 10, 2021
14bc637
update auto_vk ref
stf976 May 10, 2021
131a95d
Merge branch 'master' of https://github.com/cg-tuwien/Gears-Vk into c…
stf976 May 10, 2021
d40fdfd
update description of texture_cubemap shaders, add newline
stf976 May 10, 2021
ab98735
don't explicitly specify image format for image view
stf976 May 10, 2021
c527559
Merge branch 'create_cubemap_from_file' of https://github.com/cg-tuwi…
stf976 May 10, 2021
0301fb0
use enum struct instead of old style enum
stf976 May 11, 2021
4f03ea2
- Restructured texture_cubemap example a bit by introducing `enum str…
johannesugb May 12, 2021
593337e
Linked to latest Auto-Vk master which includes necessary changes for …
johannesugb May 17, 2021
4546deb
don't try to flip gli texture if it wasn't loaded successfully
stf976 May 17, 2021
51aa1c1
Merge branch 'create_cubemap_from_file' of https://github.com/cg-tuwi…
stf976 May 17, 2021
16cd3d2
Merge branch 'master' into create_cubemap_from_file
johannesugb May 18, 2021
76c7d0e
Fixed RELEASE-mode project config in texture_cubemap.vcxproj.user
johannesugb May 18, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ The following files are licensed under the Attribution 3.0 Unported (CC BY 3.0)
* all files under [`assets/3rd_party/models/cornell_box`](assets/3rd_party/models/cornell_box)
* all files under [`assets/3rd_party/models/fireplace_room`](assets/3rd_party/models/fireplace_room)
* all files under [`assets/3rd_party/models/sponza`](assets/3rd_party/models/sponza)
* all files under [`assets/3rd_party/textures/yokohama_at_night`](assets/3rd_party/textures/yokohama_at_night)

See https://creativecommons.org/licenses/by/3.0/ for full license details.

Expand Down
Binary file not shown.
13 changes: 13 additions & 0 deletions assets/3rd_party/textures/yokohama_at_night/license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Author
======

This is the work of Emil Persson, aka Humus.
http://www.humus.name



License
=======

This work is licensed under a Creative Commons Attribution 3.0 Unported License.
stf976 marked this conversation as resolved.
Show resolved Hide resolved
http://creativecommons.org/licenses/by/3.0/
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions assets/3rd_party/textures/yokohama_at_night/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The JPG files were downloaded from:

https://www.humus.name/Textures/Yokohama3.zip

The KTX and DDS files were created for gears-vk from the JPG files using ImageViewer available at:

https://github.com/kopaka1822/ImageViewer

For copyright and license information see license.txt.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion auto_vk
40 changes: 40 additions & 0 deletions examples/texture_cubemap/shaders/reflect.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// adapted from https://github.com/SaschaWillems/Vulkan/blob/master/data/shaders/glsl/texturecubemap/reflect.frag
#version 450

layout (binding = 1) uniform samplerCube samplerColor;

layout (binding = 0) uniform UBO
{
mat4 projection;
mat4 model;
mat4 invModel;
float lodBias;
} ubo;

layout (location = 0) in vec3 inPos;
layout (location = 1) in vec3 inNormal;
layout (location = 2) in vec3 inViewVec;
layout (location = 3) in vec3 inLightVec;

layout (location = 0) out vec4 outFragColor;

void main()
{
vec3 cI = normalize (inPos);
vec3 cR = reflect (cI, normalize(inNormal));

// Convert world coordinates to cubemap coordinate space
// the inverse model-view matrix already deals with the transformation from right-handed to left-handed coordinates
cR = vec3(ubo.invModel * vec4(cR, 0.0));

vec4 color = texture(samplerColor, cR, ubo.lodBias);

vec3 N = normalize(inNormal);
vec3 L = normalize(inLightVec);
vec3 V = normalize(inViewVec);
vec3 R = reflect(-L, N);
vec3 ambient = vec3(0.5) * color.rgb;
vec3 diffuse = max(dot(N, L), 0.0) * vec3(1.0);
vec3 specular = pow(max(dot(R, V), 0.0), 16.0) * vec3(0.5);
outFragColor = vec4(ambient + diffuse * color.rgb + specular, 1.0);
}
30 changes: 30 additions & 0 deletions examples/texture_cubemap/shaders/reflect.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// copied from https://github.com/SaschaWillems/Vulkan/blob/master/data/shaders/glsl/texturecubemap/reflect.vert
#version 450

layout (location = 0) in vec3 inPos;
layout (location = 1) in vec3 inNormal;

layout (binding = 0) uniform UBO
{
mat4 projection;
mat4 model;
mat4 invModel;
float lodBias;
} ubo;

layout (location = 0) out vec3 outPos;
layout (location = 1) out vec3 outNormal;
layout (location = 2) out vec3 outViewVec;
layout (location = 3) out vec3 outLightVec;

void main()
{
gl_Position = ubo.projection * ubo.model * vec4(inPos.xyz, 1.0);

outPos = vec3(ubo.model * vec4(inPos, 1.0));
outNormal = mat3(ubo.model) * inNormal;

vec3 lightPos = vec3(0.0f, -5.0f, 5.0f);
outLightVec = lightPos.xyz - outPos.xyz;
outViewVec = -outPos.xyz;
}
stf976 marked this conversation as resolved.
Show resolved Hide resolved
13 changes: 13 additions & 0 deletions examples/texture_cubemap/shaders/skybox.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// copied from https://github.com/SaschaWillems/Vulkan/blob/master/data/shaders/glsl/texturecubemap/skybox.frag
#version 450

layout (binding = 1) uniform samplerCube samplerCubeMap;

layout (location = 0) in vec3 inUVW;

layout (location = 0) out vec4 outFragColor;

void main()
{
outFragColor = texture(samplerCubeMap, inUVW);
}
22 changes: 22 additions & 0 deletions examples/texture_cubemap/shaders/skybox.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// adapted from https://github.com/SaschaWillems/Vulkan/blob/master/data/shaders/glsl/texturecubemap/skybox.vert
#version 450

layout (location = 0) in vec3 inPos;

layout (binding = 0) uniform UBO
{
mat4 projection;
mat4 model;
} ubo;

layout (location = 0) out vec3 outUVW;

void main()
{
// the skybox vertices are already in a left-handed coordinate system,
// so we can pass them to the fragment shader as-is for texture coordinate lookup
outUVW = inPos;

// the model matrix of the skybox takes care of transforming its vertices to right-handed world coordinates
gl_Position = ubo.projection * ubo.model * vec4(inPos.xyz, 1.0);
}
stf976 marked this conversation as resolved.
Show resolved Hide resolved
Loading