Skip to content
Snippets Groups Projects
Commit 366b2060 authored by Artur Wasmut's avatar Artur Wasmut
Browse files

some blur/bloom project.

parent 055a35fb
No related branches found
No related tags found
1 merge request!62Resolve "Lens Flares"
Pipeline #25737 passed
Showing
with 153 additions and 3 deletions
......@@ -279,5 +279,6 @@ namespace vkcv
void submitCommandStream(const CommandStreamHandle handle);
void prepareSwapchainImageForPresent(const CommandStreamHandle handle);
void prepareImageForSampling(const CommandStreamHandle cmdStream, const ImageHandle image);
void prepareImageForStorage(const CommandStreamHandle cmdStream, const ImageHandle image);
};
}
......@@ -36,8 +36,8 @@ namespace vkcv {
struct DescriptorWrites {
std::vector<SampledImageDescriptorWrite> sampledImageWrites;
std::vector<StorageImageDescriptorWrite> storageImageWrites;
std::vector<UniformBufferDescriptorWrite> uniformBufferWrites;
std::vector<StorageBufferDescriptorWrite> storageBufferWrites;
std::vector<SamplerDescriptorWrite> samplerWrites;
std::vector<UniformBufferDescriptorWrite> uniformBufferWrites;
std::vector<StorageBufferDescriptorWrite> storageBufferWrites;
std::vector<SamplerDescriptorWrite> samplerWrites;
};
}
\ No newline at end of file
# Add new projects/examples here:
add_subdirectory(bloom)
add_subdirectory(first_triangle)
add_subdirectory(first_mesh)
add_subdirectory(cmd_sync_test)
\ No newline at end of file
bloom
\ No newline at end of file
cmake_minimum_required(VERSION 3.16)
project(bloom)
# setting c++ standard for the project
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# adding source files to the project
add_executable(bloom src/main.cpp)
# this should fix the execution path to load local files from the project (for MSVC)
if(MSVC)
set_target_properties(bloom PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set_target_properties(bloom PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# in addition to setting the output directory, the working directory has to be set
# by default visual studio sets the working directory to the build directory, when using the debugger
set_target_properties(bloom PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
# including headers of dependencies and the VkCV framework
target_include_directories(bloom SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_asset_loader_include} ${vkcv_camera_include})
# linking with libraries from all dependencies and the VkCV framework
target_link_libraries(bloom vkcv ${vkcv_libraries} vkcv_asset_loader ${vkcv_asset_loader_libraries} vkcv_camera)
projects/bloom/resources/cube/boards2_vcyc_jpg.jpg

132 B

File added
File added
File added
File added
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
# version 450
layout(local_size_x = 8, local_size_y = 8) in;
layout(set=0, binding=0) uniform texture2D offscreenAttachment;
layout(set=0, binding=1) uniform sampler offscreenSampler;
layout(r11f_g11f_b10f, set=0, binding=2) uniform writeonly image2D blurAttachment;
void main()
{
ivec2 pixel_coords = ivec2(gl_GlobalInvocationID.xy);
vec2 uv = vec2(pixel_coords) / imageSize(blurAttachment);
// TODO: BLUR
imageStore(blurAttachment, pixel_coords, vec4(1.0, 0.0 ,0.0, 0.0));
}
\ No newline at end of file
File added
%VULKAN_SDK%\Bin32\glslc.exe shader.vert -o vert.spv
%VULKAN_SDK%\Bin32\glslc.exe shader.frag -o frag.spv
%VULKAN_SDK%\Bin32\glslc.exe shadow.vert -o shadow_vert.spv
%VULKAN_SDK%\Bin32\glslc.exe shadow.frag -o shadow_frag.spv
%VULKAN_SDK%\Bin32\glslc.exe quad.vert -o quad_vert.spv
%VULKAN_SDK%\Bin32\glslc.exe quad.frag -o quad_frag.spv
%VULKAN_SDK%\Bin32\glslc.exe blur.comp -o blur_comp.spv
pause
\ No newline at end of file
File added
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec2 inUV;
layout(location = 0) out vec3 outColor;
layout(set=0, binding=0) uniform texture2D renderAttachment;
layout(set=0, binding=1) uniform texture2D blurAttachment;
layout(set=0, binding=2) uniform sampler samp;
void main()
{
outColor = texture(sampler2D(renderAttachment, samp), inUV).rgb;
}
\ No newline at end of file
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 inPosition;
layout(location = 0) out vec2 outUV;
void main()
{
outUV = inPosition.xy;
gl_Position = vec4(inPosition, 1.0);
}
\ No newline at end of file
File added
File added
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 passNormal;
layout(location = 1) in vec2 passUV;
layout(location = 2) in vec3 passPos;
layout(location = 0) out vec3 outColor;
layout(set=0, binding=0) uniform texture2D meshTexture;
layout(set=0, binding=1) uniform sampler textureSampler;
layout(set=0, binding=2) uniform sunBuffer {
vec3 L; float padding;
mat4 lightMatrix;
};
layout(set=0, binding=3) uniform texture2D shadowMap;
layout(set=0, binding=4) uniform sampler shadowMapSampler;
float shadowTest(vec3 worldPos){
vec4 lightPos = lightMatrix * vec4(worldPos, 1);
lightPos /= lightPos.w;
lightPos.xy = lightPos.xy * 0.5 + 0.5;
if(any(lessThan(lightPos.xy, vec2(0))) || any(greaterThan(lightPos.xy, vec2(1)))){
return 1;
}
lightPos.z = clamp(lightPos.z, 0, 1);
float shadowMapSample = texture(sampler2D(shadowMap, shadowMapSampler), lightPos.xy).r;
float bias = 0.01f;
shadowMapSample += bias;
return shadowMapSample < lightPos.z ? 0 : 1;
}
void main() {
/*
vec3 N = normalize(passNormal);
vec3 sunColor = vec3(1);
vec3 sun = sunColor * clamp(dot(N, L), 0, 1);
sun *= shadowTest(passPos);
vec3 ambient = vec3(0.1);
vec3 albedo = texture(sampler2D(meshTexture, textureSampler), passUV).rgb;
*/
outColor = passNormal;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment