Vulkan port

This commit is contained in:
2025-11-16 21:53:29 +01:00
parent 258dfe8ef5
commit 444d20243c
14 changed files with 32918 additions and 237 deletions

View File

@@ -1,4 +1,4 @@
@vs vertex
@vs vs_main
layout(location = 0) in vec3 positionOS;
layout(location = 1) in vec2 texCoord;
@@ -43,7 +43,7 @@ void main() {
}
@end
@fs fragment
@fs fs_main
struct Point_Light {
vec3 positionWS;
@@ -217,4 +217,60 @@ void main() {
@end
@program main vertex fragment
@cs cs_equirectangular_to_cubemap
layout(binding = 0) uniform Layer_Index {
int _LayerIndex;
};
layout(binding = 0) uniform texture2D _EquirectangularTexture;
layout(binding = 1, rgba16f) uniform writeonly image2DArray _CubemapImage;
layout(binding = 0) uniform sampler _EquirectangularSampler;
const float INV_PI = 0.31830987;
const float HALF_INV_PI = 0.15915494;
layout(local_size_x = 8, local_size_y = 8) in;
void main() {
vec2 size = vec2(imageSize(_CubemapImage).xy);
vec2 texCoord = (vec2(gl_GlobalInvocationID.xy) + vec2(0.5)) / size;
texCoord = texCoord * vec2(2.0) - vec2(1.0); // Map to range [-1, 1]
vec3 cubeCoord;
if (_LayerIndex == 0) {
// Positive X
cubeCoord = vec3(1, -texCoord.y, -texCoord.x);
} else if (_LayerIndex == 1) {
// Negative X
cubeCoord = vec3(-1, -texCoord.y, texCoord.x);
} else if (_LayerIndex == 2) {
// Positive Y
cubeCoord = vec3(texCoord.x, 1, texCoord.y);
} else if (_LayerIndex == 3) {
// Negative Y
cubeCoord = vec3(texCoord.x, -1, -texCoord.y);
} else if (_LayerIndex == 4) {
// Positive Z
cubeCoord = vec3(texCoord.x, -texCoord.y, 1);
} else if (_LayerIndex == 5) {
// Negative Z
cubeCoord = vec3(-texCoord.x, -texCoord.y, -1);
}
vec3 cubeDir = normalize(cubeCoord);
float theta = atan(cubeDir.y, cubeDir.x);
float phi = asin(cubeDir.z);
vec2 equirectCoord = vec2(theta * HALF_INV_PI, phi * INV_PI) + vec2(0.5);
vec4 irradiance = texture(sampler2D(_EquirectangularTexture, _EquirectangularSampler), equirectCoord);
imageStore(_CubemapImage, ivec3(ivec2(gl_GlobalInvocationID.xy), _LayerIndex), irradiance);
}
@end
@program main vs_main fs_main
@program equirectangular_to_cubemap cs_equirectangular_to_cubemap

BIN
assets/skybox.hdr (Stored with Git LFS) Normal file

Binary file not shown.