remove other sample and change apk to inewme

This commit is contained in:
xsl
2025-09-21 17:18:31 +08:00
parent a43bd12970
commit 8c39579e1c
1321 changed files with 6 additions and 122951 deletions
@@ -1,101 +0,0 @@
#version 450
/* Copyright (c) 2020-2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#extension GL_EXT_shader_16bit_storage : require
layout(local_size_x = 8, local_size_y = 8) in;
layout(constant_id = 0) const uint WIDTH = 1;
layout(constant_id = 1) const uint HEIGHT = 1;
layout(set = 0, binding = 0) readonly buffer SSBO
{
// It is possible to use native 16-bit types in SSBOs and UBOs. We could use uvec2 here and unpack manually.
// The key feature of 16-bit storage is to allow scalar access to 16-bit values however.
// Avoiding extra unpacking and packing can also be useful.
f16vec4 blob_data[];
};
layout(rgba16f, set = 0, binding = 1) writeonly uniform mediump image2D o_results;
layout(push_constant) uniform Registers
{
uint num_blobs;
float seed;
ivec2 range;
} registers;
// This is very arbitrary. Expends a ton of arithmetic to compute
// something that looks similar to a lens flare.
vec4 compute_blob(vec2 pos, vec4 blob, float seed)
{
vec2 offset = pos - blob.xy;
vec2 s_offset = offset * (1.1 + seed);
vec2 r_offset = offset * 0.95;
vec2 g_offset = offset * 1.0;
vec2 b_offset = offset * 1.05;
float r_dot = dot(r_offset, r_offset);
float g_dot = dot(g_offset, g_offset);
float b_dot = dot(b_offset, b_offset);
float s_dot = dot(s_offset, s_offset);
vec4 dots = vec4(r_dot, g_dot, b_dot, s_dot) * blob.w;
// Now we have square distances to blob center.
// Gotta have some FMAs, right? :D
dots = dots * dots + dots;
dots = dots * dots + dots;
dots = dots * dots + dots;
dots = dots * dots + dots;
dots = dots * dots + dots;
dots = dots * dots + dots;
vec4 parabolas = max(vec4(1.0, 1.0, 1.0, 0.9) - dots, vec4(0.0));
parabolas -= parabolas.w;
parabolas = max(parabolas, vec4(0.0));
return parabolas;
}
void main()
{
uint num_blobs = uint(registers.num_blobs);
float x = float(gl_GlobalInvocationID.x) / float(WIDTH) - 0.5;
float y = float(gl_GlobalInvocationID.y) / float(HEIGHT) - 0.5;
vec2 pos = vec2(x, y);
vec4 result = vec4(0.0);
float seed = float(registers.seed);
ivec2 range = ivec2(registers.range);
const float EXPAND_FACTOR = 0.3;
float stride = seed * EXPAND_FACTOR;
for (uint i = 0; i < num_blobs; i++)
{
vec4 blob = vec4(blob_data[i]);
// Get as much mileage out of the buffer load as possible.
for (int y = -range.y; y <= range.y; y++)
for (int x = -range.x; x <= range.x; x++)
result += compute_blob(pos + stride * vec2(x, y), blob, seed);
}
imageStore(o_results, ivec2(gl_GlobalInvocationID.xy), result);
}
Binary file not shown.
@@ -1,105 +0,0 @@
#version 450
/* Copyright (c) 2020-2024, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Allows us to use float16_t for arithmetic purposes.
#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require
// Allows us to use int16_t, uint16_t and float16_t for buffers.
#extension GL_EXT_shader_16bit_storage : require
layout(local_size_x = 8, local_size_y = 8) in;
layout(constant_id = 0) const uint WIDTH = 1;
layout(constant_id = 1) const uint HEIGHT = 1;
layout(set = 0, binding = 0) readonly buffer SSBO
{
// It is possible to use native 16-bit types in SSBOs and UBOs. We could use uvec2 here and unpack manually.
// The key feature of 16-bit storage is to allow scalar access to 16-bit values however.
// Avoiding extra unpacking and packing can also be useful.
f16vec4 blob_data[];
};
layout(rgba16f, set = 0, binding = 1) writeonly uniform mediump image2D o_results;
layout(push_constant) uniform Registers
{
uint16_t num_blobs;
float16_t seed;
i16vec2 range;
}
registers;
// This is very arbitrary. Expends a ton of arithmetic to compute
// something that looks similar to a lens flare.
f16vec4 compute_blob(f16vec2 pos, f16vec4 blob, float16_t seed)
{
f16vec2 offset = pos - blob.xy;
f16vec4 rg_offset = offset.xxyy * f16vec4(0.95hf, 1.0hf, 0.95hf, 1.0hf);
f16vec4 bs_offset = offset.xxyy * f16vec4(1.05hf, 1.1hf + seed, 1.05hf, 1.1hf + seed);
f16vec4 rg_dot = rg_offset * rg_offset;
f16vec4 bs_dot = bs_offset * bs_offset;
// Dot products can be somewhat awkward in FP16, since the result is a scalar 16-bit value, and we don't want that.
// To that end, we compute at least two dot products side by side, and rg_offset and bs_offset are swizzled
// such that we avoid swizzling across a 32-bit boundary.
f16vec4 dots = f16vec4(rg_dot.xy + rg_dot.zw, bs_dot.xy + bs_dot.zw) * blob.w;
// Now we have square distances to blob center.
// Gotta have some FMAs, right? :D
dots = dots * dots + dots;
dots = dots * dots + dots;
dots = dots * dots + dots;
dots = dots * dots + dots;
dots = dots * dots + dots;
dots = dots * dots + dots;
f16vec4 parabolas = max(f16vec4(1.0hf, 1.0hf, 1.0hf, 0.9hf) - dots, f16vec4(0.0hf));
parabolas -= parabolas.w;
parabolas = max(parabolas, f16vec4(0.0hf));
return parabolas;
}
void main()
{
uint num_blobs = uint(registers.num_blobs);
float x = float(gl_GlobalInvocationID.x) / float(WIDTH) - 0.5;
float y = float(gl_GlobalInvocationID.y) / float(HEIGHT) - 0.5;
f16vec2 pos = f16vec2(x, y);
f16vec4 result = f16vec4(0.0hf);
float16_t seed = float16_t(registers.seed);
ivec2 range = ivec2(registers.range);
const float16_t EXPAND_FACTOR = 0.3hf;
float16_t stride = seed * EXPAND_FACTOR;
for (uint i = 0; i < num_blobs; i++)
{
f16vec4 blob = blob_data[i];
// Get as much mileage out of the buffer load as possible.
for (int y = -range.y; y <= range.y; y++)
for (int x = -range.x; x <= range.x; x++)
result += compute_blob(pos + stride * f16vec2(x, y), blob, seed);
}
imageStore(o_results, ivec2(gl_GlobalInvocationID.xy), result);
}
@@ -1,106 +0,0 @@
#version 450
/* Copyright (c) 2020-2024, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Allows us to use float16_t for arithmetic purposes.
#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require
// Allows us to use int16_t, uint16_t and float16_t for buffers.
#extension GL_EXT_shader_16bit_storage : require
layout(local_size_x = 8, local_size_y = 8) in;
layout(constant_id = 0) const uint WIDTH = 1;
layout(constant_id = 1) const uint HEIGHT = 1;
layout(set = 0, binding = 0) readonly buffer SSBO
{
// It is possible to use native 16-bit types in SSBOs and UBOs. We could use uvec2 here and unpack manually.
// The key feature of 16-bit storage is to allow scalar access to 16-bit values however.
// Avoiding extra unpacking and packing can also be useful.
f16vec4 blob_data[];
};
layout(rgba16f, set = 0, binding = 1) writeonly uniform mediump image2D o_results;
layout(push_constant) uniform Registers
{
// Fallback for implementations which do not support PushConstant16.
uint num_blobs;
float seed;
ivec2 range;
}
registers;
// This is very arbitrary. Expends a ton of arithmetic to compute
// something that looks similar to a lens flare.
f16vec4 compute_blob(f16vec2 pos, f16vec4 blob, float16_t seed)
{
f16vec2 offset = pos - blob.xy;
f16vec4 rg_offset = offset.xxyy * f16vec4(0.95hf, 1.0hf, 0.95hf, 1.0hf);
f16vec4 bs_offset = offset.xxyy * f16vec4(1.05hf, 1.1hf + seed, 1.05hf, 1.1hf + seed);
f16vec4 rg_dot = rg_offset * rg_offset;
f16vec4 bs_dot = bs_offset * bs_offset;
// Dot products can be somewhat awkward in FP16, since the result is a scalar 16-bit value, and we don't want that.
// To that end, we compute at least two dot products side by side, and rg_offset and bs_offset are swizzled
// such that we avoid swizzling across a 32-bit boundary.
f16vec4 dots = f16vec4(rg_dot.xy + rg_dot.zw, bs_dot.xy + bs_dot.zw) * blob.w;
// Now we have square distances to blob center.
// Gotta have some FMAs, right? :D
dots = dots * dots + dots;
dots = dots * dots + dots;
dots = dots * dots + dots;
dots = dots * dots + dots;
dots = dots * dots + dots;
dots = dots * dots + dots;
f16vec4 parabolas = max(f16vec4(1.0hf, 1.0hf, 1.0hf, 0.9hf) - dots, f16vec4(0.0hf));
parabolas -= parabolas.w;
parabolas = max(parabolas, f16vec4(0.0hf));
return parabolas;
}
void main()
{
uint num_blobs = uint(registers.num_blobs);
float x = float(gl_GlobalInvocationID.x) / float(WIDTH) - 0.5;
float y = float(gl_GlobalInvocationID.y) / float(HEIGHT) - 0.5;
f16vec2 pos = f16vec2(x, y);
f16vec4 result = f16vec4(0.0hf);
float16_t seed = float16_t(registers.seed);
ivec2 range = ivec2(registers.range);
const float16_t EXPAND_FACTOR = 0.3hf;
float16_t stride = seed * EXPAND_FACTOR;
for (uint i = 0; i < num_blobs; i++)
{
f16vec4 blob = blob_data[i];
// Get as much mileage out of the buffer load as possible.
for (int y = -range.y; y <= range.y; y++)
for (int x = -range.x; x <= range.x; x++)
result += compute_blob(pos + stride * f16vec2(x, y), blob, seed);
}
imageStore(o_results, ivec2(gl_GlobalInvocationID.xy), result);
}
-28
View File
@@ -1,28 +0,0 @@
#version 450
/* Copyright (c) 2020-2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Trivial shader that blits compute result to screen.
layout(location = 0) out vec4 o_color;
layout(location = 0) in vec2 in_uv;
layout(set = 0, binding = 0) uniform sampler2D tex;
void main()
{
o_color = vec4(textureLod(tex, in_uv, 0.0).rgb, 1.0);
}
Binary file not shown.
-33
View File
@@ -1,33 +0,0 @@
#version 450
/* Copyright (c) 2020-2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Trivial shader that blits compute result to screen.
layout(location = 0) out vec2 o_uv;
void main()
{
if (gl_VertexIndex == 0)
gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);
else if (gl_VertexIndex == 1)
gl_Position = vec4(-1.0, 3.0, 0.0, 1.0);
else
gl_Position = vec4(3.0, -1.0, 0.0, 1.0);
o_uv = gl_Position.xy * 0.5 + 0.5;
}
Binary file not shown.
@@ -1,29 +0,0 @@
#version 450
/* Copyright (c) 2020-2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout(location = 0) out vec4 o_color;
layout(location = 0) in vec3 in_color;
layout(location = 1) in vec3 in_normal;
layout(location = 2) in vec3 in_delta_pos;
void main()
{
vec3 normal_color = in_normal * 0.5 + 0.5;
o_color = vec4(mix(in_color, normal_color, 0.3), 1.0);
o_color.rgb -= 0.2 * fract(2.0 * in_delta_pos);
}
@@ -1,75 +0,0 @@
#version 450
/* Copyright (c) 2020-2025, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define MAX_LIGHT_COUNT 48
layout(location = 0) in vec3 position;
layout(location = 1) in vec3 normal;
layout(set = 0, binding = 1) uniform GlobalUniform {
mat4 model;
mat4 view_proj;
vec3 camera_position;
} global_uniform;
layout (location = 0) out vec3 o_vertex_color;
layout (location = 1) out vec3 o_normal;
layout (location = 2) out vec3 o_delta_pos;
// Push constants come with a limitation in the size of data.
// The standard requires at least 128 bytes
layout(push_constant, std430) uniform PBRMaterialUniform
{
vec4 base_color_factor;
float metallic_factor;
float roughness_factor;
}
pbr_material_uniform;
#include "lighting.h"
layout(set = 0, binding = 4) uniform LightsInfo
{
Light directional_lights[MAX_LIGHT_COUNT];
Light point_lights[MAX_LIGHT_COUNT];
Light spot_lights[MAX_LIGHT_COUNT];
}
lights_info;
layout(constant_id = 0) const uint DIRECTIONAL_LIGHT_COUNT = 0U;
layout(constant_id = 1) const uint POINT_LIGHT_COUNT = 0U;
layout(constant_id = 2) const uint SPOT_LIGHT_COUNT = 0U;
void main(void)
{
vec4 pos = global_uniform.model * vec4(position, 1.0);
vec3 normal = mat3(global_uniform.model) * normal;
gl_Position = global_uniform.view_proj * pos;
vec3 light_contribution = vec3(0.0);
for (uint i = 0U; i < DIRECTIONAL_LIGHT_COUNT; ++i)
{
light_contribution += apply_directional_light(lights_info.directional_lights[i], normal);
}
light_contribution += vec3(0.2);
light_contribution *= pbr_material_uniform.base_color_factor.rgb;
o_vertex_color = light_contribution;
o_normal = normal;
o_delta_pos = pos.xyz - global_uniform.camera_position;
}
@@ -1,31 +0,0 @@
#version 450
/* Copyright (c) 2020-2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#extension GL_EXT_shader_explicit_arithmetic_types_float16: require
layout(location = 0) out f16vec4 o_color;
layout(location = 0) in f16vec3 in_color;
layout(location = 1) in f16vec3 in_normal;
layout(location = 2) in f16vec3 in_delta_pos;
void main()
{
vec3 normal_color = vec3(in_normal) * 0.5 + 0.5;
vec4 color = vec4(mix(vec3(in_color), normal_color, 0.3), 1.0);
color.rgb -= 0.2 * fract(2.0 * vec3(in_delta_pos));
o_color = f16vec4(color);
}
@@ -1,76 +0,0 @@
#version 450
/* Copyright (c) 2020-2025, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require
#define MAX_LIGHT_COUNT 48
layout(location = 0) in vec3 position;
layout(location = 1) in vec3 normal;
layout(set = 0, binding = 1) uniform GlobalUniform {
mat4 model;
mat4 view_proj;
vec3 camera_position;
} global_uniform;
layout (location = 0) out f16vec3 o_vertex_color;
layout (location = 1) out f16vec3 o_normal;
layout (location = 2) out f16vec3 o_delta_pos;
// Push constants come with a limitation in the size of data.
// The standard requires at least 128 bytes
layout(push_constant, std430) uniform PBRMaterialUniform
{
vec4 base_color_factor;
float metallic_factor;
float roughness_factor;
}
pbr_material_uniform;
#include "lighting.h"
layout(set = 0, binding = 4) uniform LightsInfo
{
Light directional_lights[MAX_LIGHT_COUNT];
Light point_lights[MAX_LIGHT_COUNT];
Light spot_lights[MAX_LIGHT_COUNT];
}
lights_info;
layout(constant_id = 0) const uint DIRECTIONAL_LIGHT_COUNT = 0U;
layout(constant_id = 1) const uint POINT_LIGHT_COUNT = 0U;
layout(constant_id = 2) const uint SPOT_LIGHT_COUNT = 0U;
void main(void)
{
vec4 pos = global_uniform.model * vec4(position, 1.0);
vec3 normal = mat3(global_uniform.model) * normal;
gl_Position = global_uniform.view_proj * pos;
vec3 light_contribution = vec3(0.0);
for (uint i = 0U; i < DIRECTIONAL_LIGHT_COUNT; ++i)
{
light_contribution += apply_directional_light(lights_info.directional_lights[i], normal);
}
light_contribution += vec3(0.2);
light_contribution *= pbr_material_uniform.base_color_factor.rgb;
o_vertex_color = f16vec3(light_contribution);
o_normal = f16vec3(normal);
o_delta_pos = f16vec3(pos.xyz - global_uniform.camera_position);
}
-55
View File
@@ -1,55 +0,0 @@
/* Copyright (c) 2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef BLUR_COMMON_H_
#define BLUR_COMMON_H_
layout(set = 0, binding = 0) uniform sampler2D in_tex;
layout(rgba16f, set = 0, binding = 1) writeonly uniform image2D out_tex;
layout(push_constant) uniform Registers
{
uvec2 resolution;
vec2 inv_resolution;
vec2 inv_input_resolution;
}
registers;
vec2 get_uv(vec2 uv, float x, float y, float scale)
{
return uv + registers.inv_input_resolution * (vec2(x, y) * scale);
}
vec3 bloom_blur(vec2 uv, float uv_scale)
{
vec3 rgb = vec3(0.0);
const float N = -1.0;
const float Z = 0.0;
const float P = 1.0;
rgb += 0.25 * textureLod(in_tex, get_uv(uv, Z, Z, uv_scale), 0.0).rgb;
rgb += 0.0625 * textureLod(in_tex, get_uv(uv, N, P, uv_scale), 0.0).rgb;
rgb += 0.0625 * textureLod(in_tex, get_uv(uv, P, P, uv_scale), 0.0).rgb;
rgb += 0.0625 * textureLod(in_tex, get_uv(uv, N, N, uv_scale), 0.0).rgb;
rgb += 0.0625 * textureLod(in_tex, get_uv(uv, P, N, uv_scale), 0.0).rgb;
rgb += 0.125 * textureLod(in_tex, get_uv(uv, N, Z, uv_scale), 0.0).rgb;
rgb += 0.125 * textureLod(in_tex, get_uv(uv, P, Z, uv_scale), 0.0).rgb;
rgb += 0.125 * textureLod(in_tex, get_uv(uv, Z, N, uv_scale), 0.0).rgb;
rgb += 0.125 * textureLod(in_tex, get_uv(uv, Z, P, uv_scale), 0.0).rgb;
return rgb;
}
#endif
-36
View File
@@ -1,36 +0,0 @@
#version 450
/* Copyright (c) 2021-2025, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Downscale pass. Simple and naive :)
layout(local_size_x = 8, local_size_y = 8) in;
#include "blur_common.h"
const float SCALE = 1.75;
void main()
{
if (all(lessThan(gl_GlobalInvocationID.xy, registers.resolution)))
{
vec2 uv = (vec2(gl_GlobalInvocationID.xy) + 0.5) * registers.inv_resolution;
vec3 rgb = bloom_blur(uv, SCALE);
imageStore(out_tex, ivec2(gl_GlobalInvocationID.xy), vec4(rgb, 1.0));
}
}
Binary file not shown.
-36
View File
@@ -1,36 +0,0 @@
#version 450
/* Copyright (c) 2021-2025, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Upscale pass. Simple and naive :)
layout(local_size_x = 8, local_size_y = 8) in;
#include "blur_common.h"
const float SCALE = 0.875;
void main()
{
if (all(lessThan(gl_GlobalInvocationID.xy, registers.resolution)))
{
vec2 uv = (vec2(gl_GlobalInvocationID.xy) + 0.5) * registers.inv_resolution;
vec3 rgb = bloom_blur(uv, SCALE);
imageStore(out_tex, ivec2(gl_GlobalInvocationID.xy), vec4(rgb, 1.0));
}
}
Binary file not shown.
-30
View File
@@ -1,30 +0,0 @@
#version 450
/* Copyright (c) 2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout(location = 0) out vec4 o_color;
layout(location = 0) in vec2 in_uv;
layout(set = 0, binding = 0) uniform sampler2D hdr_tex;
layout(set = 0, binding = 1) uniform sampler2D bloom_tex;
void main()
{
// The most basic tonemap possible.
vec3 col = textureLod(hdr_tex, in_uv, 0.0).rgb + textureLod(bloom_tex, in_uv, 0.0).rgb;
col = col / (1.0 + col);
o_color = vec4(col, 1.0);
}
Binary file not shown.
-33
View File
@@ -1,33 +0,0 @@
#version 450
/* Copyright (c) 2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Trivial shader that blits compute result to screen.
layout(location = 0) out vec2 o_uv;
void main()
{
if (gl_VertexIndex == 0)
gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);
else if (gl_VertexIndex == 1)
gl_Position = vec4(-1.0, 3.0, 0.0, 1.0);
else
gl_Position = vec4(3.0, -1.0, 0.0, 1.0);
o_uv = gl_Position.xy * 0.5 + 0.5;
}
Binary file not shown.
-82
View File
@@ -1,82 +0,0 @@
#version 320 es
/* Copyright (c) 2019-2025, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
precision highp float;
layout(set = 0, binding = 0) uniform sampler2D base_color_texture;
layout(location = 0) in vec4 in_pos;
layout(location = 1) in vec2 in_uv;
layout(location = 2) in vec3 in_normal;
layout(location = 3) in vec4 in_shadow_clip;
layout(location = 0) out vec4 o_color;
layout(set = 0, binding = 1) uniform GlobalUniform
{
mat4 model;
mat4 view_proj;
vec3 camera_position;
}
global_uniform;
// Push constants come with a limitation in the size of data.
// The standard requires at least 128 bytes
layout(push_constant, std430) uniform PBRMaterialUniform
{
vec4 base_color_factor;
float metallic_factor;
float roughness_factor;
}
pbr_material_uniform;
#include "lighting.h"
layout(set = 0, binding = 4) uniform LightsInfo
{
Light directional_light;
} lights_info;
layout(set = 0, binding = 6) uniform highp sampler2DShadow tex_shadow;
void main(void)
{
vec3 normal = normalize(in_normal);
vec3 light_contribution = apply_directional_light(lights_info.directional_light, normal);
float shadow = 0.0;
shadow += textureProjLod(tex_shadow, in_shadow_clip, 0.0) / 4.0;
shadow += textureProjLodOffset(tex_shadow, in_shadow_clip, 0.0, ivec2(-1, 0)) / 8.0;
shadow += textureProjLodOffset(tex_shadow, in_shadow_clip, 0.0, ivec2(1, 0)) / 8.0;
shadow += textureProjLodOffset(tex_shadow, in_shadow_clip, 0.0, ivec2(0, -1)) / 8.0;
shadow += textureProjLodOffset(tex_shadow, in_shadow_clip, 0.0, ivec2(0, 1)) / 8.0;
shadow += textureProjLodOffset(tex_shadow, in_shadow_clip, 0.0, ivec2(-1, -1)) / 16.0;
shadow += textureProjLodOffset(tex_shadow, in_shadow_clip, 0.0, ivec2(1, 1)) / 16.0;
shadow += textureProjLodOffset(tex_shadow, in_shadow_clip, 0.0, ivec2(-1, 1)) / 16.0;
shadow += textureProjLodOffset(tex_shadow, in_shadow_clip, 0.0, ivec2(1, -1)) / 16.0;
light_contribution *= shadow;
vec4 base_color = vec4(1.0, 0.0, 0.0, 1.0);
base_color = texture(base_color_texture, in_uv);
vec3 ambient_color = vec3(0.25) * base_color.xyz;
o_color = vec4(ambient_color + light_contribution * base_color.xyz, base_color.w);
}
Binary file not shown.
-49
View File
@@ -1,49 +0,0 @@
#version 320 es
/* Copyright (c) 2019-2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout(location = 0) in vec3 position;
layout(location = 1) in vec2 texcoord_0;
layout(location = 2) in vec3 normal;
layout(set = 0, binding = 1) uniform GlobalUniform {
mat4 model;
mat4 view_proj;
vec3 camera_position;
} global_uniform;
layout(set = 0, binding = 5) uniform ShadowUniform {
mat4 matrix;
} shadow_uniform;
layout (location = 0) out vec4 o_pos;
layout (location = 1) out vec2 o_uv;
layout (location = 2) out vec3 o_normal;
layout (location = 3) out vec4 o_shadow_clip;
void main(void)
{
o_pos = global_uniform.model * vec4(position, 1.0);
o_uv = texcoord_0;
o_normal = mat3(global_uniform.model) * normal;
o_shadow_clip = shadow_uniform.matrix * o_pos;
gl_Position = global_uniform.view_proj * o_pos;
}
Binary file not shown.
-21
View File
@@ -1,21 +0,0 @@
#version 320 es
/* Copyright (c) 2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
void main()
{
}
Binary file not shown.
-30
View File
@@ -1,30 +0,0 @@
#version 320 es
/* Copyright (c) 2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout(location = 0) in vec3 position;
layout(set = 0, binding = 1) uniform GlobalUniform {
mat4 model;
mat4 view_proj;
} global_uniform;
void main(void)
{
vec4 o_pos = global_uniform.model * vec4(position, 1.0);
gl_Position = global_uniform.view_proj * o_pos;
}
Binary file not shown.
-40
View File
@@ -1,40 +0,0 @@
#version 450
/* Copyright (c) 2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout(local_size_x = 8, local_size_y = 8) in;
layout(set = 0, binding = 0) uniform sampler2D in_tex;
layout(rgba16f, set = 0, binding = 1) writeonly uniform image2D out_tex;
layout(push_constant) uniform Registers
{
uvec2 resolution;
vec2 inv_resolution;
vec2 inv_input_resolution;
} registers;
void main()
{
if (all(lessThan(gl_GlobalInvocationID.xy, registers.resolution)))
{
vec2 uv = (vec2(gl_GlobalInvocationID.xy) + 0.5) * registers.inv_resolution;
vec3 rgb = textureLod(in_tex, uv, 0.0).rgb;
rgb = 0.2 * max(rgb - 1.0, vec3(0.0));
imageStore(out_tex, ivec2(gl_GlobalInvocationID.xy), vec4(rgb, 1.0));
}
}
Binary file not shown.
-26
View File
@@ -1,26 +0,0 @@
/* Copyright (c) 2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#version 450
// Nothing interesting, just interpolate color from vertex.
layout(location = 0) flat in vec4 in_color;
layout(location = 0) out vec4 out_color;
void main()
{
out_color = in_color;
}
Binary file not shown.
-83
View File
@@ -1,83 +0,0 @@
/* Copyright (c) 2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#version 450
// Allows buffer_reference.
#extension GL_EXT_buffer_reference : require
// Since we did not enable vertexPipelineStoresAndAtomics, we must mark everything readonly.
layout(std430, buffer_reference, buffer_reference_align = 8) readonly buffer Position
{
vec2 positions[];
};
layout(std430, buffer_reference, buffer_reference_align = 8) readonly buffer PositionReferences
{
// Represents an array of pointers, where each pointer points to its own VBO (Position).
// The size of a pointer (VkDeviceAddress) is always 8 in Vulkan.
Position buffers[];
};
layout(push_constant) uniform Registers
{
mat4 view_projection;
// This is a pointer to an array of pointers, essentially:
// const VBO * const *vbos
PositionReferences references;
} registers;
// Flat shading looks a little cooler here :)
layout(location = 0) flat out vec4 out_color;
void main()
{
int slice = gl_InstanceIndex;
// One VBO per instance, load the VBO pointer.
// The cool thing here is that a compute shader could hypothetically
// write the pointer list where vertices are stored.
// With vertex attributes we do not have the luxury to modify VBO bindings on the GPU.
// The best we can do is to just modify the vertexOffset in an indirect draw call,
// but that's not always flexible enough, and enforces a very specific engine design to work.
// We can even modify the attribute layout per slice here, since we can just cast the pointer
// to something else if we want.
restrict Position positions = registers.references.buffers[slice];
// Load the vertex based on VertexIndex instead of an attribute. Fully flexible.
// Only downside is that we do not get format conversion for free like we do with normal vertex attributes.
vec2 pos = positions.positions[gl_VertexIndex] * 2.5;
// Place the quad meshes on screen and center it.
pos += 3.0 * (vec2(slice % 8, slice / 8) - 3.5);
// Normal projection.
gl_Position = registers.view_projection * vec4(pos, 0.0, 1.0);
// Color the vertex. Use a combination of a wave and checkerboard, completely arbitrary.
int index_x = gl_VertexIndex % 16;
int index_y = gl_VertexIndex / 16;
float r = 0.5 + 0.3 * sin(float(index_x));
float g = 0.5 + 0.3 * sin(float(index_y));
int checkerboard = (index_x ^ index_y) & 1;
r *= float(checkerboard) * 0.8 + 0.2;
g *= float(checkerboard) * 0.8 + 0.2;
out_color = vec4(r, g, 0.15, 1.0);
}
Binary file not shown.
@@ -1,86 +0,0 @@
/* Copyright (c) 2021, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#version 450
// Allows buffer_reference.
#extension GL_EXT_buffer_reference : require
layout(local_size_x = 8, local_size_y = 8) in;
// If we mark a buffer as buffer_reference, this is treated as a pointer type.
// A variable with the type Position is a 64-bit pointer to the data within.
// We can freely cast between pointer types if we wish, but that is not necessary in this sample.
// buffer_reference_align is used to let the underlying implementation know which alignment to expect.
// The pointer can have scalar alignment, which is something the compiler cannot know unless you tell it.
// It is best to use vector alignment when you can for optimal performance, but scalar alignment is sometimes useful.
// With SSBOs, the API has a minimum offset alignment which guarantees a minimum level of alignment from API side.
// It is possible to forward reference a pointer, so you can contain a pointer to yourself inside a struct.
// Useful if you need something like a linked list on the GPU.
// Here it's not particularly useful, but something to know about.
layout(buffer_reference) buffer Position;
layout(std430, buffer_reference, buffer_reference_align = 8) writeonly buffer Position
{
vec2 positions[];
};
layout(std430, buffer_reference, buffer_reference_align = 8) readonly buffer PositionReferences
{
// This buffer contains an array of pointers to other buffers.
Position buffers[];
};
// In push constant we place a pointer to VBO pointers, spicy!
// This way we don't need any descriptor sets, but there's nothing wrong with combining use of descriptor sets and buffer device addresses.
// It is mostly done for convenience here.
layout(push_constant) uniform Registers
{
PositionReferences references;
// A buffer reference is 64-bit, so offset of fract_time is 8 bytes.
float fract_time;
} registers;
void main()
{
// Every slice is a 8x8 grid of vertices which we update here in compute.
uvec2 local_offset = gl_GlobalInvocationID.xy;
uint local_index = local_offset.y * gl_WorkGroupSize.x * gl_NumWorkGroups.x + local_offset.x;
uint slice = gl_WorkGroupID.z;
restrict Position positions = registers.references.buffers[slice];
// This is a trivial wave-like function. Arbitrary for demonstration purposes.
const float TWO_PI = 3.1415628 * 2.0;
float offset = TWO_PI * fract(registers.fract_time + float(slice) * 0.1);
// Simple grid.
vec2 pos = vec2(local_offset);
// Wobble, wobble.
pos.x += 0.2 * sin(2.2 * pos.x + offset);
pos.y += 0.2 * sin(2.25 * pos.y + 2.0 * offset);
pos.x += 0.2 * cos(1.8 * pos.y + 3.0 * offset);
pos.y += 0.2 * cos(2.85 * pos.x + 4.0 * offset);
pos.x += 0.5 * sin(offset);
pos.y += 0.5 * sin(offset + 0.3);
// Center the mesh in [-0.5, 0.5] range.
// Here we write to a raw pointer.
// Be aware, there is no robustness support for buffer_device_address since we don't have a complete descriptor!
positions.positions[local_index] = pos / (vec2(gl_WorkGroupSize.xy) * vec2(gl_NumWorkGroups.xy) - 1.0) - 0.5;
}
Binary file not shown.
@@ -1,32 +0,0 @@
#version 450
/* Copyright (c) 2023-2024, Mobica Limited
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout (input_attachment_index = 0, binding = 0) uniform subpassInput in_color_r;
layout (input_attachment_index = 1, binding = 1) uniform subpassInput in_color_g;
layout (input_attachment_index = 2, binding = 2) uniform subpassInput in_color_b;
layout (location = 0) out vec4 outColor;
void main()
{
vec4 color_r = subpassLoad(in_color_r);
vec4 color_g = subpassLoad(in_color_g);
vec4 color_b = subpassLoad(in_color_b);
outColor = color_r + color_g + color_b;
}
Binary file not shown.
@@ -1,28 +0,0 @@
#version 320 es
/* Copyright (c) 2023-2024, Mobica Limited
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
out gl_PerVertex
{
vec4 gl_Position;
};
void main()
{
vec2 uv = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2);
gl_Position = vec4(uv * 2.0f - 1.0f, 0.0f, 1.0f);
}
Binary file not shown.
@@ -1,33 +0,0 @@
#version 450
/* Copyright (c) 2023-2024, Mobica Limited
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout(location = 0) in vec3 in_color;
layout(location = 0) out vec4 out_color_r;
layout(location = 1) out vec4 out_color_g;
layout(location = 2) out vec4 out_color_b;
// The full color is copied to individual attachments.
// Each attachment has a single component bit (R, G, B) enabled
// via the blend_attachment in ColorWriteEnable::prepare_pipelines.
void main()
{
out_color_r = vec4(in_color, 1.0f);
out_color_g = vec4(in_color, 1.0f);
out_color_b = vec4(in_color, 1.0f);
}
@@ -1,37 +0,0 @@
#version 450
/* Copyright (c) 2023-2024, Mobica Limited
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout(location = 0) out vec3 out_color;
vec2 triangle_positions[3] = vec2[](
vec2(0.0, -0.5),
vec2(0.5, 0.5),
vec2(-0.5, 0.5)
);
vec3 triangle_colors[3] = vec3[](
vec3(1.0, 0.0, 0.0),
vec3(0.0, 1.0, 0.0),
vec3(0.0, 0.0, 1.0)
);
void main()
{
gl_Position = vec4(triangle_positions[gl_VertexIndex], 0.0, 1.0);
out_color = triangle_colors[gl_VertexIndex];
}
@@ -1,29 +0,0 @@
/* Copyright (c) 2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
[[vk::input_attachment_index(0)]][[vk::binding(0)]] SubpassInput in_color_r;
[[vk::input_attachment_index(1)]][[vk::binding(1)]] SubpassInput in_color_g;
[[vk::input_attachment_index(2)]][[vk::binding(2)]] SubpassInput in_color_b;
float4 main() : SV_TARGET0
{
float4 color_r = in_color_r.SubpassLoad();
float4 color_g = in_color_g.SubpassLoad();
float4 color_b = in_color_b.SubpassLoad();
return color_r + color_g + color_b;
}
Binary file not shown.
@@ -1,29 +0,0 @@
/* Copyright (c) 2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
struct VSOutput
{
float4 Pos : SV_POSITION;
};
VSOutput main(uint VertexIndex : SV_VertexID)
{
VSOutput output = (VSOutput) 0;
float2 uv = float2((VertexIndex << 1) & 2, VertexIndex & 2);
output.Pos = float4(uv * 2.0f - 1.0f, 0.0f, 1.0f);
return output;
}
Binary file not shown.
@@ -1,41 +0,0 @@
/* Copyright (c) 2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
struct VSOutput
{
float4 Pos : SV_POSITION;
[[vk::location(0)]] float3 Color : COLOR0;
};
struct FSOutput
{
float4 ColorR : SV_TARGET0;
float4 ColorG : SV_TARGET1;
float4 ColorB : SV_TARGET2;
};
// The full color is copied to individual attachments.
// Each attachment has a single component bit (R, G, B) enabled
// via the blend_attachment in ColorWriteEnable::prepare_pipelines.
FSOutput main(VSOutput Input)
{
FSOutput output = (FSOutput)0;
output.ColorR = float4(Input.Color, 1.0f);
output.ColorG = float4(Input.Color, 1.0f);
output.ColorB = float4(Input.Color, 1.0f);
return output;
}
@@ -1,43 +0,0 @@
/* Copyright (c) 2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
struct VSOutput
{
float4 Pos : SV_POSITION;
[[vk::location(0)]] float3 Color : COLOR0;
};
static float2 triangle_positions[3] = {
float2(0.0, -0.5),
float2(0.5, 0.5),
float2(-0.5, 0.5)
};
static float3 triangle_colors[3] = {
float3(1.0, 0.0, 0.0),
float3(0.0, 1.0, 0.0),
float3(0.0, 0.0, 1.0)
};
VSOutput main(uint VertexIndex : SV_VertexID)
{
VSOutput output = (VSOutput) 0;
output.Pos = float4(triangle_positions[VertexIndex], 0.0, 1.0);
output.Color = triangle_colors[VertexIndex];
return output;
}
-30
View File
@@ -1,30 +0,0 @@
#version 450
/* Copyright (c) 2019-2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout (binding = 0) uniform sampler2D samplerColorMap;
layout (binding = 1) uniform sampler2D samplerGradientRamp;
layout (location = 0) in float inGradientPos;
layout (location = 0) out vec4 outFragColor;
void main ()
{
vec3 color = texture(samplerGradientRamp, vec2(inGradientPos, 0.0)).rgb;
outFragColor.rgb = texture(samplerColorMap, gl_PointCoord).rgb * color;
}
Binary file not shown.
-48
View File
@@ -1,48 +0,0 @@
#version 450
/* Copyright (c) 2019-2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout (location = 0) in vec4 inPos;
layout (location = 1) in vec4 inVel;
layout (location = 0) out float outGradientPos;
layout (binding = 2) uniform UBO
{
mat4 projection;
mat4 modelview;
vec2 screendim;
} ubo;
out gl_PerVertex
{
vec4 gl_Position;
float gl_PointSize;
};
void main ()
{
const float spriteSize = 0.005 * inPos.w; // Point size influenced by mass (stored in inPos.w);
vec4 eyePos = ubo.modelview * vec4(inPos.x, inPos.y, inPos.z, 1.0);
vec4 projectedCorner = ubo.projection * vec4(0.5 * spriteSize, 0.5 * spriteSize, eyePos.z, eyePos.w);
gl_PointSize = clamp(ubo.screendim.x * projectedCorner.x / projectedCorner.w, 1.0, 128.0);
gl_Position = ubo.projection * eyePos;
outGradientPos = inVel.w;
}
Binary file not shown.
@@ -1,89 +0,0 @@
#version 450
/* Copyright (c) 2019-2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
struct Particle
{
vec4 pos;
vec4 vel;
};
// Binding 0 : Position storage buffer
layout(std140, binding = 0) buffer Pos
{
Particle particles[ ];
};
layout (binding = 1) uniform UBO
{
float deltaT;
int particleCount;
} ubo;
layout (constant_id = 1) const int SHARED_DATA_SIZE = 1024;
layout (constant_id = 2) const float GRAVITY = 0.002;
layout (constant_id = 3) const float POWER = 0.75;
layout (constant_id = 4) const float SOFTEN = 0.05;
layout (local_size_x_id = 0) in;
// Share data between computer shader invocations to speed up caluclations
shared vec4 sharedData[SHARED_DATA_SIZE];
#define TIME_FACTOR 0.05
void main()
{
// Current SSBO index
uint index = gl_GlobalInvocationID.x;
if (index >= ubo.particleCount)
return;
vec4 position = particles[index].pos;
vec4 velocity = particles[index].vel;
vec4 acceleration = vec4(0.0);
for (int i = 0; i < ubo.particleCount; i += SHARED_DATA_SIZE)
{
if (i + gl_LocalInvocationID.x < ubo.particleCount)
{
sharedData[gl_LocalInvocationID.x] = particles[i + gl_LocalInvocationID.x].pos;
}
else
{
sharedData[gl_LocalInvocationID.x] = vec4(0.0);
}
barrier();
for (int j = 0; j < gl_WorkGroupSize.x; j++)
{
vec4 other = sharedData[j];
vec3 len = other.xyz - position.xyz;
acceleration.xyz += GRAVITY * len * other.w / pow(dot(len, len) + SOFTEN, POWER);
}
barrier();
}
particles[index].vel.xyz += ubo.deltaT * TIME_FACTOR * acceleration.xyz;
// Gradient texture position
particles[index].vel.w += 0.1 * TIME_FACTOR * ubo.deltaT;
if (particles[index].vel.w > 1.0)
particles[index].vel.w -= 1.0;
}
@@ -1,48 +0,0 @@
#version 450
/* Copyright (c) 2019-2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
struct Particle
{
vec4 pos;
vec4 vel;
};
// Binding 0 : Position storage buffer
layout(std140, binding = 0) buffer Pos
{
Particle particles[ ];
};
layout (local_size_x_id = 0) in;
layout (binding = 1) uniform UBO
{
float deltaT;
int particleCount;
} ubo;
#define TIME_FACTOR 0.05
void main()
{
int index = int(gl_GlobalInvocationID);
vec4 position = particles[index].pos;
vec4 velocity = particles[index].vel;
position += ubo.deltaT * TIME_FACTOR * velocity;
particles[index].pos = position;
}
@@ -1,37 +0,0 @@
/* Copyright (c) 2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Texture2D textureColorMap : register(t0);
SamplerState samplerColorMap : register(s0);
Texture2D textureGradientRamp : register(t1);
SamplerState samplerGradientRamp : register(s1);
struct VSOutput
{
float4 Pos : SV_POSITION;
[[vk::location(0)]] float GradientPos : POSITION0;
[[vk::location(1)]] float2 CenterPos : POSITION1;
[[vk::builtin("PointSize")]] float PSize : PSIZE;
[[vk::location(2)]] float PointSize : TEXCOORD0;
};
float4 main(VSOutput input) : SV_TARGET
{
float3 color = textureGradientRamp.Sample(samplerGradientRamp, float2(input.GradientPos, 0.0)).rgb;
float2 PointCoord = (input.Pos.xy - input.CenterPos.xy) / input.PointSize + 0.5;
return float4(textureColorMap.Sample(samplerColorMap, PointCoord).rgb * color, 1);
}
Binary file not shown.
@@ -1,56 +0,0 @@
/* Copyright (c) 2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
struct VSInput
{
[[vk::location(0)]] float4 Pos : POSITION0;
[[vk::location(1)]] float4 Vel : TEXCOORD0;
};
struct VSOutput
{
float4 Pos : SV_POSITION;
[[vk::location(0)]] float GradientPos : POSITION3;
[[vk::location(1)]] float2 CenterPos : POSITION1;
[[vk::builtin("PointSize")]] float PSize : PSIZE;
[[vk::location(2)]] float PointSize : TEXCOORD0;
};
struct UBO
{
float4x4 projection;
float4x4 modelview;
float2 screendim;
};
[[vk::binding(2, 0)]]
ConstantBuffer<UBO> ubo : register(b2);
VSOutput main(VSInput input)
{
VSOutput output = (VSOutput) 0;
const float spriteSize = 0.005 * input.Pos.w; // Point size influenced by mass (stored in input.Pos.w);
float4 eyePos = mul(ubo.modelview, float4(input.Pos.x, input.Pos.y, input.Pos.z, 1.0));
float4 projectedCorner = mul(ubo.projection, float4(0.5 * spriteSize, 0.5 * spriteSize, eyePos.z, eyePos.w));
output.PSize = output.PointSize = clamp(ubo.screendim.x * projectedCorner.x / projectedCorner.w, 1.0, 128.0);
output.Pos = mul(ubo.projection, eyePos);
output.CenterPos = ((output.Pos.xy / output.Pos.w) + 1.0) * 0.5 * ubo.screendim;
output.GradientPos = input.Vel.w;
return output;
}
Binary file not shown.
@@ -1,92 +0,0 @@
/* Copyright (c) 2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2020 Google LLC
// Copyright 2023 Sascha Willems
struct Particle
{
float4 pos;
float4 vel;
};
[[vk::binding(0, 0)]]
RWStructuredBuffer<Particle> particles : register(u0);
struct UBO
{
float deltaT;
int particleCount;
};
[[vk::binding(1, 0)]]
ConstantBuffer<UBO> ubo : register(b1);
// We need to define an upper bound as HLSl doesn't support variable length arrays
#define MAX_SHARED_DATA_SIZE 1024
[[vk::constant_id(1)]] const int SHARED_DATA_SIZE = 512;
[[vk::constant_id(2)]] const float GRAVITY = 0.002;
[[vk::constant_id(3)]] const float POWER = 0.75;
[[vk::constant_id(4)]] const float SOFTEN = 0.05;
// Share data between computer shader invocations to speed up caluclations
groupshared float4 sharedData[MAX_SHARED_DATA_SIZE];
#define TIME_FACTOR 0.05
[numthreads(256, 1, 1)]
void main(uint3 GlobalInvocationID : SV_DispatchThreadID, uint3 LocalInvocationID : SV_GroupThreadID)
{
// Current SSBO index
uint index = GlobalInvocationID.x;
if (index >= ubo.particleCount)
return;
float4 position = particles[index].pos;
float4 velocity = particles[index].vel;
float4 acceleration = float4(0, 0, 0, 0);
for (int i = 0; i < ubo.particleCount; i += SHARED_DATA_SIZE)
{
if (i + LocalInvocationID.x < ubo.particleCount)
{
sharedData[LocalInvocationID.x] = particles[i + LocalInvocationID.x].pos;
}
else
{
sharedData[LocalInvocationID.x] = float4(0, 0, 0, 0);
}
GroupMemoryBarrierWithGroupSync();
for (int j = 0; j < 256; j++)
{
float4 other = sharedData[j];
float3 len = other.xyz - position.xyz;
acceleration.xyz += GRAVITY * len * other.w / pow(dot(len, len) + SOFTEN, POWER);
}
GroupMemoryBarrierWithGroupSync();
}
particles[index].vel.xyz += ubo.deltaT * TIME_FACTOR * acceleration.xyz;
// Gradient texture position
particles[index].vel.w += 0.1 * TIME_FACTOR * ubo.deltaT;
if (particles[index].vel.w > 1.0)
{
particles[index].vel.w -= 1.0;
}
}
@@ -1,44 +0,0 @@
/* Copyright (c) 2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
struct Particle
{
float4 pos;
float4 vel;
};
[[vk::binding(0, 0)]]
RWStructuredBuffer<Particle> particles : register(u0);
struct UBO
{
float deltaT;
int particleCount;
};
[[vk::binding(1, 0)]]
ConstantBuffer<UBO> ubo : register(b1);
#define TIME_FACTOR 0.05
[numthreads(256, 1, 1)]
void main(uint3 GlobalInvocationID : SV_DispatchThreadID)
{
int index = int(GlobalInvocationID.x);
float4 position = particles[index].pos;
float4 velocity = particles[index].vel;
position += ubo.deltaT * TIME_FACTOR * velocity;
particles[index].pos = position;
}
@@ -1,36 +0,0 @@
#version 450
/* Copyright (c) 2022-2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout (location = 0) in vec3 inNormal;
layout (location = 1) in vec3 inColor;
layout (location = 2) in vec3 inViewVec;
layout (location = 3) in vec3 inLightVec;
layout (location = 0) out vec4 outFragColor;
void main()
{
vec3 N = normalize(inNormal);
vec3 L = normalize(inLightVec);
vec3 V = normalize(inViewVec);
vec3 R = reflect(-L, N);
vec3 ambient = vec3(0.25);
vec3 diffuse = max(dot(N, L), 0.0) * vec3(1.0);
vec3 specular = pow(max(dot(R, V), 0.0), 16.0) * vec3(0.75);
outFragColor = vec4((ambient + diffuse) * inColor.rgb + specular, 1.0);
}
Binary file not shown.
@@ -1,46 +0,0 @@
#version 450
/* Copyright (c) 2022-2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout (location = 0) in vec3 inPos;
layout (location = 1) in vec3 inNormal;
layout (set = 0, binding = 0) uniform UBO {
mat4 projection;
mat4 view;
} ubo;
layout(push_constant) uniform Push_Constants {
mat4 model;
vec4 color;
} push_constants;
layout (location = 0) out vec3 outNormal;
layout (location = 1) out vec3 outColor;
layout (location = 2) out vec3 outViewVec;
layout (location = 3) out vec3 outLightVec;
void main()
{
outColor = push_constants.color.rgb;
vec4 localPos = ubo.view * push_constants.model * vec4(inPos, 1.0);
gl_Position = ubo.projection * localPos;
outNormal = mat3(ubo.view * push_constants.model) * inNormal;
vec3 lightPos = vec3(10.0, -10.0, 10.0);
outLightVec = lightPos.xyz - localPos.xyz;
outViewVec = -localPos.xyz;
}
Binary file not shown.
@@ -1,37 +0,0 @@
/* Copyright (c) 2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
struct VSOutput
{
float4 Pos : SV_POSITION;
[[vk::location(0)]] float3 Normal : NORMAL0;
[[vk::location(1)]] float3 Color : COLOR0;
[[vk::location(2)]] float3 ViewVec : TEXCOORD0;
[[vk::location(3)]] float3 LightVec : TEXCOORD1;
};
float4 main(VSOutput input) : SV_TARGET0
{
float3 N = normalize(input.Normal);
float3 L = normalize(input.LightVec);
float3 V = normalize(input.ViewVec);
float3 R = reflect(-L, N);
float3 ambient = (0.25).xxx;
float3 diffuse = max(dot(N, L), 0.0).xxx;
float3 specular = (pow(max(dot(R, V), 0.0), 16.0)).xxx * 0.75;
return float4((ambient + diffuse) * input.Color + specular, 1.0);
}
Binary file not shown.
@@ -1,59 +0,0 @@
/* Copyright (c) 2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
struct VSInput
{
[[vk::location(0)]] float3 Pos : POSITION0;
[[vk::location(1)]] float3 Normal : NORMAL0;
};
struct UBO
{
float4x4 projection;
float4x4 view;
};
[[vk::binding(0, 0)]]
ConstantBuffer<UBO> ubo : register(b0);
struct PushConstants
{
float4x4 model;
float4 color;
};
[[vk::push_constant]] PushConstants push_constants;
struct VSOutput
{
float4 Pos : SV_POSITION;
[[vk::location(0)]] float3 Normal : NORMAL0;
[[vk::location(1)]] float3 Color : COLOR0;
[[vk::location(2)]] float3 ViewVec : TEXCOORD0;
[[vk::location(3)]] float3 LightVec : TEXCOORD1;
};
VSOutput main(VSInput input)
{
VSOutput output = (VSOutput) 0;
float4 localPos = mul(ubo.view, mul(push_constants.model, float4(input.Pos, 1.0)));
output.Normal = input.Normal;
output.Color = push_constants.color.rgb;
output.Pos = mul(ubo.projection, localPos);
const float3 lightPos = float3(10.0, -10.0, 10.0);
output.LightVec = lightPos - localPos.xyz;
output.ViewVec = -localPos.xyz;
return output;
}
Binary file not shown.
@@ -1,27 +0,0 @@
#version 450
/* Copyright (c) 2019-2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout (binding = 1) uniform sampler2D samplerColor;
layout (location = 0) in vec2 inUV;
layout (location = 0) out vec4 outFragColor;
void main()
{
outFragColor = texture(samplerColor, inUV);
}
@@ -1,30 +0,0 @@
#version 450
/* Copyright (c) 2019-2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout (location = 0) out vec2 outUV;
out gl_PerVertex
{
vec4 gl_Position;
};
void main()
{
outUV = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2);
gl_Position = vec4(outUV * 2.0f - 1.0f, 0.0f, 1.0f);
}
@@ -1,26 +0,0 @@
#version 450
/* Copyright (c) 2019-2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
layout (location = 0) in vec3 inColor;
layout (location = 0) out vec4 outFragColor;
void main()
{
outFragColor.rgb = inColor;
}
@@ -1,41 +0,0 @@
#version 450
/* Copyright (c) 2019-2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
precision highp float;
layout (location = 0) in vec3 inPos;
layout (location = 1) in vec3 inColor;
layout (binding = 0) uniform UBO
{
mat4 projection;
mat4 model;
} ubo;
layout (location = 0) out vec3 outColor;
out gl_PerVertex
{
vec4 gl_Position;
};
void main()
{
outColor = inColor;
gl_Position = ubo.projection * ubo.model * vec4(inPos, 1.0);
}
@@ -1,26 +0,0 @@
#version 450
/* Copyright (c) 2019-2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
precision highp float;
layout (location = 0) out vec4 outFragColor;
void main()
{
outFragColor.rgb = vec3(1.0, 1.0, 1.0);
}
@@ -1,30 +0,0 @@
/* Copyright (c) 2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Texture2D textureColor : register(t1);
SamplerState samplerColor : register(s1);
struct VSOutput
{
float4 Pos : SV_POSITION;
[[vk::location(0)]] float2 UV : TEXCOORD0;
};
float4 main(VSOutput input) : SV_TARGET
{
return textureColor.Sample(samplerColor, input.UV);
}
@@ -1,30 +0,0 @@
/* Copyright (c) 2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
struct VSOutput
{
float4 Pos : SV_POSITION;
[[vk::location(0)]] float2 UV : TEXCOORD0;
};
VSOutput main(uint VertexIndex : SV_VertexID)
{
VSOutput output = (VSOutput) 0;
output.UV = float2((VertexIndex << 1) & 2, VertexIndex & 2);
output.Pos = float4(output.UV * 2.0f - 1.0f, 0.0f, 1.0f);
return output;
}
@@ -1,28 +0,0 @@
/* Copyright (c) 2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
struct VSOutput
{
float4 Pos : SV_POSITION;
[[vk::location(0)]] float3 Color : COLOR0;
};
float4 main(VSOutput input) : SV_TARGET
{
return float4(input.Color, 1.0);
}
@@ -1,44 +0,0 @@
/* Copyright (c) 2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
struct VSInput
{
[[vk::location(0)]] float3 Pos : POSITION0;
[[vk::location(1)]] float3 Color : COLOR0;
};
struct UBO
{
float4x4 projection;
float4x4 model;
};
[[vk::binding(0, 0)]]
ConstantBuffer<UBO> ubo : register(b0);
struct VSOutput
{
float4 Pos : SV_POSITION;
[[vk::location(0)]] float3 Color : COLOR0;
};
VSOutput main(VSInput input)
{
VSOutput output = (VSOutput) 0;
output.Color = input.Color;
output.Pos = mul(ubo.projection, mul(ubo.model, float4(input.Pos, 1.0)));
return output;
}

Some files were not shown because too many files have changed in this diff Show More