Revert "Start to separate combined image samplers"
This reverts commit a0d92be759
.
This commit is contained in:
parent
71d0eff8dc
commit
dbc03078de
16 changed files with 166 additions and 110 deletions
|
@ -125,6 +125,7 @@ enum class GFXBindingType {
|
||||||
StorageBuffer,
|
StorageBuffer,
|
||||||
StorageImage,
|
StorageImage,
|
||||||
PushConstant,
|
PushConstant,
|
||||||
|
Texture,
|
||||||
Sampler,
|
Sampler,
|
||||||
SampledImage
|
SampledImage
|
||||||
};
|
};
|
||||||
|
@ -262,6 +263,12 @@ struct GFXTextureCreateInfo {
|
||||||
GFXTextureUsage usage;
|
GFXTextureUsage usage;
|
||||||
int array_length = 1;
|
int array_length = 1;
|
||||||
int mip_count = 1;
|
int mip_count = 1;
|
||||||
|
|
||||||
|
// sampler
|
||||||
|
SamplingMode samplingMode = SamplingMode::Repeat;
|
||||||
|
GFXBorderColor border_color = GFXBorderColor::OpaqueWhite;
|
||||||
|
bool compare_enabled = false;
|
||||||
|
GFXCompareFunction compare_function = GFXCompareFunction::Never;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GFXSamplerCreateInfo {
|
struct GFXSamplerCreateInfo {
|
||||||
|
|
|
@ -496,6 +496,26 @@ GFXTexture* GFXVulkan::create_texture(const GFXTextureCreateInfo& info) {
|
||||||
|
|
||||||
vkCreateImageView(device, &viewInfo, nullptr, &texture->view);
|
vkCreateImageView(device, &viewInfo, nullptr, &texture->view);
|
||||||
|
|
||||||
|
const VkSamplerAddressMode samplerMode = toSamplerMode(info.samplingMode);
|
||||||
|
|
||||||
|
// create sampler
|
||||||
|
VkSamplerCreateInfo samplerInfo = {};
|
||||||
|
samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
||||||
|
samplerInfo.magFilter = VK_FILTER_LINEAR;
|
||||||
|
samplerInfo.minFilter = VK_FILTER_LINEAR;
|
||||||
|
samplerInfo.addressModeU = samplerMode;
|
||||||
|
samplerInfo.addressModeV = samplerMode;
|
||||||
|
samplerInfo.addressModeW = samplerMode;
|
||||||
|
samplerInfo.anisotropyEnable = VK_TRUE;
|
||||||
|
samplerInfo.maxAnisotropy = 16;
|
||||||
|
samplerInfo.compareEnable = info.compare_enabled;
|
||||||
|
samplerInfo.borderColor = toBorderColor(info.border_color);
|
||||||
|
samplerInfo.compareOp = toCompareFunc(info.compare_function);
|
||||||
|
samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR;
|
||||||
|
samplerInfo.maxLod = static_cast<float>(info.mip_count);
|
||||||
|
|
||||||
|
vkCreateSampler(device, &samplerInfo, nullptr, &texture->sampler);
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1008,6 +1028,11 @@ GFXPipeline* GFXVulkan::create_graphics_pipeline(const GFXGraphicsPipelineCreate
|
||||||
case GFXBindingType::StorageBuffer:
|
case GFXBindingType::StorageBuffer:
|
||||||
descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
|
descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
|
||||||
break;
|
break;
|
||||||
|
case GFXBindingType::Texture: {
|
||||||
|
descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||||
|
pipeline->bindings_marked_as_normal_images.push_back(binding.binding);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case GFXBindingType::StorageImage:
|
case GFXBindingType::StorageImage:
|
||||||
{
|
{
|
||||||
descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
|
descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
|
||||||
|
@ -1140,6 +1165,11 @@ GFXPipeline* GFXVulkan::create_compute_pipeline(const GFXComputePipelineCreateIn
|
||||||
case GFXBindingType::StorageBuffer:
|
case GFXBindingType::StorageBuffer:
|
||||||
descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
|
descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
|
||||||
break;
|
break;
|
||||||
|
case GFXBindingType::Texture: {
|
||||||
|
descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||||
|
pipeline->bindings_marked_as_normal_images.push_back(binding.binding);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case GFXBindingType::StorageImage:
|
case GFXBindingType::StorageImage:
|
||||||
{
|
{
|
||||||
descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
|
descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
|
||||||
|
@ -2114,7 +2144,7 @@ void GFXVulkan::createSwapchain(NativeSurface* native_surface, VkSwapchainKHR ol
|
||||||
void GFXVulkan::createDescriptorPool() {
|
void GFXVulkan::createDescriptorPool() {
|
||||||
const std::array<VkDescriptorPoolSize, 2> poolSizes = { {
|
const std::array<VkDescriptorPoolSize, 2> poolSizes = { {
|
||||||
{VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 5000},
|
{VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 5000},
|
||||||
{VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 5000}
|
{VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 5000}
|
||||||
}};
|
}};
|
||||||
|
|
||||||
VkDescriptorPoolCreateInfo poolInfo = {};
|
VkDescriptorPoolCreateInfo poolInfo = {};
|
||||||
|
@ -2204,6 +2234,7 @@ void GFXVulkan::cacheDescriptorState(GFXVulkanPipeline* pipeline, VkDescriptorSe
|
||||||
VkDescriptorImageInfo imageInfo = {};
|
VkDescriptorImageInfo imageInfo = {};
|
||||||
imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||||
imageInfo.imageView = vulkanTexture->view;
|
imageInfo.imageView = vulkanTexture->view;
|
||||||
|
imageInfo.sampler = vulkanTexture->sampler;
|
||||||
|
|
||||||
if((vulkanTexture->usage & GFXTextureUsage::Attachment) == GFXTextureUsage::Attachment) {
|
if((vulkanTexture->usage & GFXTextureUsage::Attachment) == GFXTextureUsage::Attachment) {
|
||||||
if(vulkanTexture->format == VK_FORMAT_D32_SFLOAT) {
|
if(vulkanTexture->format == VK_FORMAT_D32_SFLOAT) {
|
||||||
|
@ -2222,6 +2253,8 @@ void GFXVulkan::cacheDescriptorState(GFXVulkanPipeline* pipeline, VkDescriptorSe
|
||||||
imageInfo.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
imageInfo.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
} else if (utility::contains(pipeline->bindings_marked_as_sampled_images, i)) {
|
} else if (utility::contains(pipeline->bindings_marked_as_sampled_images, i)) {
|
||||||
descriptorWrite.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
|
descriptorWrite.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
|
||||||
|
} else {
|
||||||
|
descriptorWrite.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||||
}
|
}
|
||||||
|
|
||||||
descriptorWrite.pImageInfo = &imageInfo;
|
descriptorWrite.pImageInfo = &imageInfo;
|
||||||
|
|
|
@ -9,6 +9,7 @@ public:
|
||||||
VkImage handle = VK_NULL_HANDLE;
|
VkImage handle = VK_NULL_HANDLE;
|
||||||
VkDeviceMemory memory = VK_NULL_HANDLE;
|
VkDeviceMemory memory = VK_NULL_HANDLE;
|
||||||
VkImageView view = VK_NULL_HANDLE;
|
VkImageView view = VK_NULL_HANDLE;
|
||||||
|
VkSampler sampler = VK_NULL_HANDLE;
|
||||||
|
|
||||||
int width = 0, height = 0;
|
int width = 0, height = 0;
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include "shadercompiler.hpp"
|
#include "shadercompiler.hpp"
|
||||||
#include "rendertarget.hpp"
|
#include "rendertarget.hpp"
|
||||||
#include "platform.hpp"
|
#include "platform.hpp"
|
||||||
#include "gfx_sampler.hpp"
|
|
||||||
|
|
||||||
class GFX;
|
class GFX;
|
||||||
class GFXBuffer;
|
class GFXBuffer;
|
||||||
|
@ -144,8 +143,6 @@ namespace prism {
|
||||||
GFXBuffer* histogram_buffer = nullptr;
|
GFXBuffer* histogram_buffer = nullptr;
|
||||||
GFXTexture* average_luminance_texture = nullptr;
|
GFXTexture* average_luminance_texture = nullptr;
|
||||||
|
|
||||||
GFXSampler* global_sampler = nullptr;
|
|
||||||
|
|
||||||
std::unique_ptr<SMAAPass> smaa_pass;
|
std::unique_ptr<SMAAPass> smaa_pass;
|
||||||
std::unique_ptr<DoFPass> dof_pass;
|
std::unique_ptr<DoFPass> dof_pass;
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,4 @@ private:
|
||||||
// point
|
// point
|
||||||
GFXPipeline* static_point_pipeline = nullptr;
|
GFXPipeline* static_point_pipeline = nullptr;
|
||||||
GFXPipeline* skinned_point_pipeline = nullptr;
|
GFXPipeline* skinned_point_pipeline = nullptr;
|
||||||
|
|
||||||
GFXSampler* shadow_sampler = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,8 +34,8 @@ DoFPass::DoFPass(GFX* gfx) {
|
||||||
|
|
||||||
create_info.shader_input.bindings = {
|
create_info.shader_input.bindings = {
|
||||||
{0, GFXBindingType::StorageImage},
|
{0, GFXBindingType::StorageImage},
|
||||||
{1, GFXBindingType::SampledImage},
|
{1, GFXBindingType::Texture},
|
||||||
{3, GFXBindingType::SampledImage},
|
{3, GFXBindingType::Texture},
|
||||||
{2, GFXBindingType::PushConstant}
|
{2, GFXBindingType::PushConstant}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -59,7 +59,8 @@ DoFPass::DoFPass(GFX* gfx) {
|
||||||
textureInfo.height = extent.height;
|
textureInfo.height = extent.height;
|
||||||
textureInfo.format = GFXPixelFormat::RGBA_32F;
|
textureInfo.format = GFXPixelFormat::RGBA_32F;
|
||||||
textureInfo.usage = GFXTextureUsage::Attachment | GFXTextureUsage::Sampled;
|
textureInfo.usage = GFXTextureUsage::Attachment | GFXTextureUsage::Sampled;
|
||||||
|
textureInfo.samplingMode = SamplingMode::ClampToEdge;
|
||||||
|
|
||||||
normal_field = gfx->create_texture(textureInfo);
|
normal_field = gfx->create_texture(textureInfo);
|
||||||
|
|
||||||
textureInfo.label = "Far Field";
|
textureInfo.label = "Far Field";
|
||||||
|
|
|
@ -63,7 +63,7 @@ void ImGuiPass::create_render_target_resources(RenderTarget& target) {
|
||||||
|
|
||||||
createInfo.shader_input.bindings = {
|
createInfo.shader_input.bindings = {
|
||||||
{1, GFXBindingType::PushConstant},
|
{1, GFXBindingType::PushConstant},
|
||||||
{2, GFXBindingType::SampledImage}
|
{2, GFXBindingType::Texture}
|
||||||
};
|
};
|
||||||
|
|
||||||
pipeline = engine->get_gfx()->create_graphics_pipeline(createInfo);
|
pipeline = engine->get_gfx()->create_graphics_pipeline(createInfo);
|
||||||
|
|
|
@ -147,9 +147,8 @@ layout(std430, binding = 1) buffer readonly SceneInformation {{
|
||||||
Probe probes[MAX_PROBES];
|
Probe probes[MAX_PROBES];
|
||||||
int numLights;
|
int numLights;
|
||||||
}} scene;
|
}} scene;
|
||||||
layout (binding = 2) uniform texture2D sun_shadow;
|
layout (binding = 2) uniform sampler2D sun_shadow;
|
||||||
layout (binding = 6) uniform texture2DArray spot_shadow;
|
layout (binding = 6) uniform sampler2DArray spot_shadow;
|
||||||
layout (binding = 10) uniform sampler shadow_sampler;
|
|
||||||
layout(push_constant) uniform PushConstant {{
|
layout(push_constant) uniform PushConstant {{
|
||||||
mat4 model;
|
mat4 model;
|
||||||
}};
|
}};
|
||||||
|
@ -183,7 +182,7 @@ ShaderSource MaterialCompiler::compile_material_fragment(Material& material, boo
|
||||||
if(render_options.enable_point_shadows) {
|
if(render_options.enable_point_shadows) {
|
||||||
format_to(std::back_inserter(src),
|
format_to(std::back_inserter(src),
|
||||||
R"(#define POINT_SHADOWS_SUPPORTED
|
R"(#define POINT_SHADOWS_SUPPORTED
|
||||||
layout (binding = 3) uniform textureCubeArray point_shadow;
|
layout (binding = 3) uniform samplerCubeArray point_shadow;
|
||||||
)");
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,9 +190,9 @@ ShaderSource MaterialCompiler::compile_material_fragment(Material& material, boo
|
||||||
|
|
||||||
if(use_ibl) {
|
if(use_ibl) {
|
||||||
format_to(std::back_inserter(src),
|
format_to(std::back_inserter(src),
|
||||||
R"(layout (binding = 7) uniform textureCubeArray irrandianceSampler;
|
R"(layout (binding = 7) uniform samplerCubeArray irrandianceSampler;
|
||||||
layout (binding = 8) uniform textureCubeArray prefilterSampler;
|
layout (binding = 8) uniform samplerCubeArray prefilterSampler;
|
||||||
layout (binding = 9) uniform texture2D brdfSampler;
|
layout (binding = 9) uniform sampler2D brdfSampler;
|
||||||
)");
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,17 +208,17 @@ ShaderSource MaterialCompiler::compile_material_fragment(Material& material, boo
|
||||||
material.bound_textures.clear();
|
material.bound_textures.clear();
|
||||||
|
|
||||||
// insert samplers as needed
|
// insert samplers as needed
|
||||||
int sampler_index = 11;
|
int sampler_index = 10;
|
||||||
if(material.colorProperty.type == DataType::AssetTexture) {
|
if(material.colorProperty.type == DataType::AssetTexture) {
|
||||||
material.bound_textures[sampler_index] = material.colorProperty.value_tex;
|
material.bound_textures[sampler_index] = material.colorProperty.value_tex;
|
||||||
|
|
||||||
format_to(std::back_inserter(src), "layout(binding = {}) uniform texture2D colorTexture;\n", sampler_index++);
|
format_to(std::back_inserter(src), "layout(binding = {}) uniform sampler2D colorTexture;\n", sampler_index++);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(material.normalProperty.type == DataType::AssetTexture) {
|
if(material.normalProperty.type == DataType::AssetTexture) {
|
||||||
material.bound_textures[sampler_index] = material.normalProperty.value_tex;
|
material.bound_textures[sampler_index] = material.normalProperty.value_tex;
|
||||||
|
|
||||||
format_to(std::back_inserter(src), "layout(binding = {}) uniform texture2D normalTexture;\n", sampler_index++);
|
format_to(std::back_inserter(src), "layout(binding = {}) uniform sampler2D normalTexture;\n", sampler_index++);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(use_ibl) {
|
if(use_ibl) {
|
||||||
|
@ -259,7 +258,7 @@ ShaderSource MaterialCompiler::compile_material_fragment(Material& material, boo
|
||||||
pos = step - step * noise.x;
|
pos = step - step * noise.x;
|
||||||
float shadow = 0.0;
|
float shadow = 0.0;
|
||||||
while(pos <= 1.0) {{
|
while(pos <= 1.0) {{
|
||||||
vec3 tmp_normal = texture(sampler2D(normal_map, shadow_sampler), in_uv + dir * pos).rgb;
|
vec3 tmp_normal = texture(normal_map, in_uv + dir * pos).rgb;
|
||||||
tmp_normal = in_tbn * (tmp_normal * 2.0 - 1.0);
|
tmp_normal = in_tbn * (tmp_normal * 2.0 - 1.0);
|
||||||
float tmp_lighting = dot(light_dir, tmp_normal);
|
float tmp_lighting = dot(light_dir, tmp_normal);
|
||||||
float shadowed = -tmp_lighting;
|
float shadowed = -tmp_lighting;
|
||||||
|
@ -280,9 +279,9 @@ ShaderSource MaterialCompiler::compile_material_fragment(Material& material, boo
|
||||||
R"(vec3 ibl(const int probe, const ComputedSurfaceInfo surface_info, const float intensity) {{
|
R"(vec3 ibl(const int probe, const ComputedSurfaceInfo surface_info, const float intensity) {{
|
||||||
const vec3 F = fresnel_schlick_roughness(surface_info.NdotV, surface_info.F0, surface_info.roughness);
|
const vec3 F = fresnel_schlick_roughness(surface_info.NdotV, surface_info.F0, surface_info.roughness);
|
||||||
const vec3 R = get_reflect(probe, surface_info.N);
|
const vec3 R = get_reflect(probe, surface_info.N);
|
||||||
const vec2 brdf = texture(sampler2D(brdfSampler, shadow_sampler), vec2(surface_info.NdotV, surface_info.roughness)).rg;
|
const vec2 brdf = texture(brdfSampler, vec2(surface_info.NdotV, surface_info.roughness)).rg;
|
||||||
const vec3 sampledIrradiance = texture(samplerCubeArray(irrandianceSampler, shadow_sampler), vec4(surface_info.N, probe)).xyz;
|
const vec3 sampledIrradiance = texture(irrandianceSampler, vec4(surface_info.N, probe)).xyz;
|
||||||
const vec3 prefilteredColor = textureLod(samplerCubeArray(prefilterSampler, shadow_sampler), vec4(R, probe), surface_info.roughness * 4).xyz;
|
const vec3 prefilteredColor = textureLod(prefilterSampler, vec4(R, probe), surface_info.roughness * 4).xyz;
|
||||||
const vec3 diffuse = sampledIrradiance * surface_info.diffuse_color;
|
const vec3 diffuse = sampledIrradiance * surface_info.diffuse_color;
|
||||||
const vec3 specular = prefilteredColor * (F * brdf.x + brdf.y);
|
const vec3 specular = prefilteredColor * (F * brdf.x + brdf.y);
|
||||||
return (diffuse + specular) * intensity;
|
return (diffuse + specular) * intensity;
|
||||||
|
@ -295,7 +294,7 @@ ShaderSource MaterialCompiler::compile_material_fragment(Material& material, boo
|
||||||
if(material.colorProperty.type == DataType::Vector3) {
|
if(material.colorProperty.type == DataType::Vector3) {
|
||||||
format_to(std::back_inserter(src), "vec3 Color = vec3({}, {}, {});\n", material.colorProperty.value.x, material.colorProperty.value.y, material.colorProperty.value.z);
|
format_to(std::back_inserter(src), "vec3 Color = vec3({}, {}, {});\n", material.colorProperty.value.x, material.colorProperty.value.y, material.colorProperty.value.z);
|
||||||
} else if(material.colorProperty.type == DataType::AssetTexture) {
|
} else if(material.colorProperty.type == DataType::AssetTexture) {
|
||||||
format_to(std::back_inserter(src), "vec3 Color = texture(sampler2D(colorTexture, shadow_sampler), in_uv).rgb;\n");
|
format_to(std::back_inserter(src), "vec3 Color = texture(colorTexture, in_uv).rgb;\n");
|
||||||
} else if(material.colorProperty.type == DataType::Float) {
|
} else if(material.colorProperty.type == DataType::Float) {
|
||||||
format_to(std::back_inserter(src),"vec3 Color = vec3({}});\n", material.colorProperty.float_value);
|
format_to(std::back_inserter(src),"vec3 Color = vec3({}});\n", material.colorProperty.float_value);
|
||||||
}
|
}
|
||||||
|
@ -310,7 +309,7 @@ ShaderSource MaterialCompiler::compile_material_fragment(Material& material, boo
|
||||||
prism::log("enabling normal mapping on material..");
|
prism::log("enabling normal mapping on material..");
|
||||||
|
|
||||||
format_to(std::back_inserter(src),
|
format_to(std::back_inserter(src),
|
||||||
R"(vec3 final_normal = texture(sampler2D(normalTexture, shadow_sampler), in_uv).rgb;
|
R"(vec3 final_normal = texture(normalTexture, in_uv).rgb;
|
||||||
final_normal = final_normal * 2.0 - 1.0;
|
final_normal = final_normal * 2.0 - 1.0;
|
||||||
final_normal = in_tbn * final_normal;
|
final_normal = in_tbn * final_normal;
|
||||||
)");
|
)");
|
||||||
|
|
|
@ -88,10 +88,6 @@ renderer::renderer(GFX* gfx, const bool enable_imgui) : gfx(gfx) {
|
||||||
unorm_render_pass = gfx->create_render_pass(renderPassInfo);
|
unorm_render_pass = gfx->create_render_pass(renderPassInfo);
|
||||||
|
|
||||||
create_sky_pipeline();
|
create_sky_pipeline();
|
||||||
|
|
||||||
GFXSamplerCreateInfo sampler_create_info = {};
|
|
||||||
|
|
||||||
global_sampler = gfx->create_sampler(sampler_create_info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer::~renderer() = default;
|
renderer::~renderer() = default;
|
||||||
|
@ -282,8 +278,6 @@ void renderer::render(GFXCommandBuffer* commandbuffer, Scene* scene, RenderTarge
|
||||||
else
|
else
|
||||||
commandbuffer->bind_texture(dummy_texture, 7);
|
commandbuffer->bind_texture(dummy_texture, 7);
|
||||||
|
|
||||||
commandbuffer->bind_sampler(global_sampler, 8);
|
|
||||||
|
|
||||||
PostPushConstants pc;
|
PostPushConstants pc;
|
||||||
pc.options.x = render_options.enable_aa;
|
pc.options.x = render_options.enable_aa;
|
||||||
pc.options.z = render_options.exposure;
|
pc.options.z = render_options.exposure;
|
||||||
|
@ -419,7 +413,6 @@ void renderer::render_camera(GFXCommandBuffer* command_buffer, Scene& scene, Obj
|
||||||
command_buffer->bind_texture(scene.irradianceCubeArray, 7);
|
command_buffer->bind_texture(scene.irradianceCubeArray, 7);
|
||||||
command_buffer->bind_texture(scene.prefilteredCubeArray, 8);
|
command_buffer->bind_texture(scene.prefilteredCubeArray, 8);
|
||||||
command_buffer->bind_texture(brdf_texture, 9);
|
command_buffer->bind_texture(brdf_texture, 9);
|
||||||
command_buffer->bind_sampler(global_sampler, 10);
|
|
||||||
|
|
||||||
if(!mesh.mesh->bones.empty())
|
if(!mesh.mesh->bones.empty())
|
||||||
command_buffer->bind_shader_buffer(part.bone_batrix_buffer, 0, 14, sizeof(Matrix4x4) * 128);
|
command_buffer->bind_shader_buffer(part.bone_batrix_buffer, 0, 14, sizeof(Matrix4x4) * 128);
|
||||||
|
@ -496,13 +489,12 @@ void renderer::create_mesh_pipeline(Material& material) const {
|
||||||
pipelineInfo.shader_input.bindings = {
|
pipelineInfo.shader_input.bindings = {
|
||||||
{1, GFXBindingType::StorageBuffer},
|
{1, GFXBindingType::StorageBuffer},
|
||||||
{0, GFXBindingType::PushConstant},
|
{0, GFXBindingType::PushConstant},
|
||||||
{2, GFXBindingType::SampledImage},
|
{2, GFXBindingType::Texture},
|
||||||
{3, GFXBindingType::SampledImage},
|
{3, GFXBindingType::Texture},
|
||||||
{6, GFXBindingType::SampledImage},
|
{6, GFXBindingType::Texture},
|
||||||
{7, GFXBindingType::SampledImage},
|
{7, GFXBindingType::Texture},
|
||||||
{8, GFXBindingType::SampledImage},
|
{8, GFXBindingType::Texture},
|
||||||
{9, GFXBindingType::SampledImage},
|
{9, GFXBindingType::Texture}
|
||||||
{10, GFXBindingType::Sampler}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pipelineInfo.render_pass = offscreen_render_pass;
|
pipelineInfo.render_pass = offscreen_render_pass;
|
||||||
|
@ -516,7 +508,7 @@ void renderer::create_mesh_pipeline(Material& material) const {
|
||||||
for (auto [index, texture] : material.bound_textures) {
|
for (auto [index, texture] : material.bound_textures) {
|
||||||
GFXShaderBinding binding;
|
GFXShaderBinding binding;
|
||||||
binding.binding = index;
|
binding.binding = index;
|
||||||
binding.type = GFXBindingType::SampledImage;
|
binding.type = GFXBindingType::Texture;
|
||||||
|
|
||||||
pipelineInfo.shader_input.bindings.push_back(binding);
|
pipelineInfo.shader_input.bindings.push_back(binding);
|
||||||
}
|
}
|
||||||
|
@ -559,6 +551,7 @@ void renderer::create_render_target_resources(RenderTarget& target) {
|
||||||
textureInfo.height = extent.height;
|
textureInfo.height = extent.height;
|
||||||
textureInfo.format = GFXPixelFormat::RGBA_32F;
|
textureInfo.format = GFXPixelFormat::RGBA_32F;
|
||||||
textureInfo.usage = GFXTextureUsage::Attachment | GFXTextureUsage::Sampled | GFXTextureUsage::Storage;
|
textureInfo.usage = GFXTextureUsage::Attachment | GFXTextureUsage::Sampled | GFXTextureUsage::Storage;
|
||||||
|
textureInfo.samplingMode = SamplingMode::ClampToEdge;
|
||||||
|
|
||||||
target.offscreenColorTexture = gfx->create_texture(textureInfo);
|
target.offscreenColorTexture = gfx->create_texture(textureInfo);
|
||||||
|
|
||||||
|
@ -576,7 +569,27 @@ void renderer::create_render_target_resources(RenderTarget& target) {
|
||||||
target.offscreenFramebuffer = gfx->create_framebuffer(framebufferInfo);
|
target.offscreenFramebuffer = gfx->create_framebuffer(framebufferInfo);
|
||||||
|
|
||||||
if(post_pipeline == nullptr) {
|
if(post_pipeline == nullptr) {
|
||||||
create_post_pipelines();
|
GFXGraphicsPipelineCreateInfo pipelineInfo = {};
|
||||||
|
pipelineInfo.label = "Post";
|
||||||
|
|
||||||
|
pipelineInfo.shaders.vertex_src = ShaderSource(prism::path("post.vert"));
|
||||||
|
pipelineInfo.shaders.fragment_src = ShaderSource(prism::path("post.frag"));
|
||||||
|
|
||||||
|
pipelineInfo.shader_input.bindings = {
|
||||||
|
{4, GFXBindingType::PushConstant},
|
||||||
|
{1, GFXBindingType::Texture},
|
||||||
|
{2, GFXBindingType::Texture},
|
||||||
|
{3, GFXBindingType::Texture},
|
||||||
|
{5, GFXBindingType::Texture},
|
||||||
|
{6, GFXBindingType::Texture},
|
||||||
|
{7, GFXBindingType::Texture}
|
||||||
|
};
|
||||||
|
|
||||||
|
pipelineInfo.shader_input.push_constants = {
|
||||||
|
{sizeof(PostPushConstants), 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
post_pipeline = gfx->create_graphics_pipeline(pipelineInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
target.sceneBuffer = gfx->create_buffer(nullptr, sizeof(SceneInformation), true, GFXBufferUsage::Storage);
|
target.sceneBuffer = gfx->create_buffer(nullptr, sizeof(SceneInformation), true, GFXBufferUsage::Storage);
|
||||||
|
@ -591,13 +604,12 @@ void renderer::create_post_pipelines() {
|
||||||
|
|
||||||
pipelineInfo.shader_input.bindings = {
|
pipelineInfo.shader_input.bindings = {
|
||||||
{4, GFXBindingType::PushConstant},
|
{4, GFXBindingType::PushConstant},
|
||||||
{1, GFXBindingType::SampledImage},
|
{1, GFXBindingType::Texture},
|
||||||
{2, GFXBindingType::SampledImage},
|
{2, GFXBindingType::Texture},
|
||||||
{3, GFXBindingType::SampledImage},
|
{3, GFXBindingType::Texture},
|
||||||
{5, GFXBindingType::SampledImage},
|
{5, GFXBindingType::Texture},
|
||||||
{6, GFXBindingType::SampledImage},
|
{6, GFXBindingType::Texture},
|
||||||
{7, GFXBindingType::SampledImage},
|
{7, GFXBindingType::Texture}
|
||||||
{8, GFXBindingType::Sampler}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pipelineInfo.shader_input.push_constants = {
|
pipelineInfo.shader_input.push_constants = {
|
||||||
|
|
|
@ -84,7 +84,8 @@ SceneCapture::SceneCapture(GFX* gfx) {
|
||||||
textureInfo.height = scene_cubemap_resolution;
|
textureInfo.height = scene_cubemap_resolution;
|
||||||
textureInfo.format = GFXPixelFormat::R8G8B8A8_UNORM;
|
textureInfo.format = GFXPixelFormat::R8G8B8A8_UNORM;
|
||||||
textureInfo.usage = GFXTextureUsage::Attachment | GFXTextureUsage::TransferSrc | GFXTextureUsage::Sampled;
|
textureInfo.usage = GFXTextureUsage::Attachment | GFXTextureUsage::TransferSrc | GFXTextureUsage::Sampled;
|
||||||
|
textureInfo.samplingMode = SamplingMode::ClampToEdge;
|
||||||
|
|
||||||
offscreenTexture = gfx->create_texture(textureInfo);
|
offscreenTexture = gfx->create_texture(textureInfo);
|
||||||
|
|
||||||
GFXTextureCreateInfo depthTextureInfo = {};
|
GFXTextureCreateInfo depthTextureInfo = {};
|
||||||
|
@ -93,7 +94,8 @@ SceneCapture::SceneCapture(GFX* gfx) {
|
||||||
depthTextureInfo.height = scene_cubemap_resolution;
|
depthTextureInfo.height = scene_cubemap_resolution;
|
||||||
depthTextureInfo.format = GFXPixelFormat::DEPTH_32F;
|
depthTextureInfo.format = GFXPixelFormat::DEPTH_32F;
|
||||||
depthTextureInfo.usage = GFXTextureUsage::Attachment;
|
depthTextureInfo.usage = GFXTextureUsage::Attachment;
|
||||||
|
depthTextureInfo.samplingMode = SamplingMode::ClampToEdge;
|
||||||
|
|
||||||
offscreenDepth = gfx->create_texture(depthTextureInfo);
|
offscreenDepth = gfx->create_texture(depthTextureInfo);
|
||||||
|
|
||||||
GFXFramebufferCreateInfo info;
|
GFXFramebufferCreateInfo info;
|
||||||
|
@ -109,6 +111,7 @@ SceneCapture::SceneCapture(GFX* gfx) {
|
||||||
cubeTextureInfo.height = scene_cubemap_resolution;
|
cubeTextureInfo.height = scene_cubemap_resolution;
|
||||||
cubeTextureInfo.format = GFXPixelFormat::R8G8B8A8_UNORM;
|
cubeTextureInfo.format = GFXPixelFormat::R8G8B8A8_UNORM;
|
||||||
cubeTextureInfo.usage = GFXTextureUsage::Sampled | GFXTextureUsage::TransferDst | GFXTextureUsage::TransferSrc; // dst used for cubemap copy, src used for mipmap gen
|
cubeTextureInfo.usage = GFXTextureUsage::Sampled | GFXTextureUsage::TransferDst | GFXTextureUsage::TransferSrc; // dst used for cubemap copy, src used for mipmap gen
|
||||||
|
cubeTextureInfo.samplingMode = SamplingMode::ClampToEdge;
|
||||||
cubeTextureInfo.mip_count = mipLevels;
|
cubeTextureInfo.mip_count = mipLevels;
|
||||||
|
|
||||||
environmentCube = gfx->create_texture(cubeTextureInfo);
|
environmentCube = gfx->create_texture(cubeTextureInfo);
|
||||||
|
@ -131,6 +134,7 @@ void SceneCapture::create_scene_resources(Scene& scene) {
|
||||||
cubeTextureInfo.height = irradiance_cubemap_resolution;
|
cubeTextureInfo.height = irradiance_cubemap_resolution;
|
||||||
cubeTextureInfo.format = GFXPixelFormat::R8G8B8A8_UNORM;
|
cubeTextureInfo.format = GFXPixelFormat::R8G8B8A8_UNORM;
|
||||||
cubeTextureInfo.usage = GFXTextureUsage::Sampled | GFXTextureUsage::TransferDst;
|
cubeTextureInfo.usage = GFXTextureUsage::Sampled | GFXTextureUsage::TransferDst;
|
||||||
|
cubeTextureInfo.samplingMode = SamplingMode::ClampToEdge;
|
||||||
cubeTextureInfo.array_length = max_environment_probes;
|
cubeTextureInfo.array_length = max_environment_probes;
|
||||||
|
|
||||||
scene.irradianceCubeArray = gfx->create_texture(cubeTextureInfo);
|
scene.irradianceCubeArray = gfx->create_texture(cubeTextureInfo);
|
||||||
|
@ -142,6 +146,7 @@ void SceneCapture::create_scene_resources(Scene& scene) {
|
||||||
cubeTextureInfo.height = scene_cubemap_resolution;
|
cubeTextureInfo.height = scene_cubemap_resolution;
|
||||||
cubeTextureInfo.format = GFXPixelFormat::R8G8B8A8_UNORM;
|
cubeTextureInfo.format = GFXPixelFormat::R8G8B8A8_UNORM;
|
||||||
cubeTextureInfo.usage = GFXTextureUsage::Sampled | GFXTextureUsage::TransferDst;
|
cubeTextureInfo.usage = GFXTextureUsage::Sampled | GFXTextureUsage::TransferDst;
|
||||||
|
cubeTextureInfo.samplingMode = SamplingMode::ClampToEdge;
|
||||||
cubeTextureInfo.array_length = max_environment_probes;
|
cubeTextureInfo.array_length = max_environment_probes;
|
||||||
cubeTextureInfo.mip_count = mipLevels;
|
cubeTextureInfo.mip_count = mipLevels;
|
||||||
|
|
||||||
|
@ -431,7 +436,8 @@ void SceneCapture::createIrradianceResources() {
|
||||||
textureInfo.height = irradiance_cubemap_resolution;
|
textureInfo.height = irradiance_cubemap_resolution;
|
||||||
textureInfo.format = GFXPixelFormat::R8G8B8A8_UNORM;
|
textureInfo.format = GFXPixelFormat::R8G8B8A8_UNORM;
|
||||||
textureInfo.usage = GFXTextureUsage::Attachment | GFXTextureUsage::TransferSrc;
|
textureInfo.usage = GFXTextureUsage::Attachment | GFXTextureUsage::TransferSrc;
|
||||||
|
textureInfo.samplingMode = SamplingMode::ClampToEdge;
|
||||||
|
|
||||||
irradianceOffscreenTexture = gfx->create_texture(textureInfo);
|
irradianceOffscreenTexture = gfx->create_texture(textureInfo);
|
||||||
|
|
||||||
GFXRenderPassCreateInfo renderPassInfo = {};
|
GFXRenderPassCreateInfo renderPassInfo = {};
|
||||||
|
@ -468,7 +474,7 @@ void SceneCapture::createIrradianceResources() {
|
||||||
|
|
||||||
pipelineInfo.shader_input.bindings = {
|
pipelineInfo.shader_input.bindings = {
|
||||||
{1, GFXBindingType::PushConstant},
|
{1, GFXBindingType::PushConstant},
|
||||||
{2, GFXBindingType::SampledImage}
|
{2, GFXBindingType::Texture}
|
||||||
};
|
};
|
||||||
|
|
||||||
pipelineInfo.render_pass = irradianceRenderPass;
|
pipelineInfo.render_pass = irradianceRenderPass;
|
||||||
|
@ -485,7 +491,8 @@ void SceneCapture::createPrefilterResources() {
|
||||||
textureInfo.height = scene_cubemap_resolution;
|
textureInfo.height = scene_cubemap_resolution;
|
||||||
textureInfo.format = GFXPixelFormat::R8G8B8A8_UNORM;
|
textureInfo.format = GFXPixelFormat::R8G8B8A8_UNORM;
|
||||||
textureInfo.usage = GFXTextureUsage::Attachment | GFXTextureUsage::TransferSrc;
|
textureInfo.usage = GFXTextureUsage::Attachment | GFXTextureUsage::TransferSrc;
|
||||||
|
textureInfo.samplingMode = SamplingMode::ClampToEdge;
|
||||||
|
|
||||||
prefilteredOffscreenTexture = gfx->create_texture(textureInfo);
|
prefilteredOffscreenTexture = gfx->create_texture(textureInfo);
|
||||||
|
|
||||||
GFXFramebufferCreateInfo info;
|
GFXFramebufferCreateInfo info;
|
||||||
|
@ -521,7 +528,7 @@ void SceneCapture::createPrefilterResources() {
|
||||||
|
|
||||||
pipelineInfo.shader_input.bindings = {
|
pipelineInfo.shader_input.bindings = {
|
||||||
{1, GFXBindingType::PushConstant},
|
{1, GFXBindingType::PushConstant},
|
||||||
{2, GFXBindingType::SampledImage}
|
{2, GFXBindingType::Texture}
|
||||||
};
|
};
|
||||||
|
|
||||||
pipelineInfo.render_pass = irradianceRenderPass;
|
pipelineInfo.render_pass = irradianceRenderPass;
|
||||||
|
|
|
@ -42,6 +42,8 @@ void ShadowPass::create_scene_resources(Scene& scene) {
|
||||||
textureInfo.height = render_options.shadow_resolution;
|
textureInfo.height = render_options.shadow_resolution;
|
||||||
textureInfo.format = GFXPixelFormat::DEPTH_32F;
|
textureInfo.format = GFXPixelFormat::DEPTH_32F;
|
||||||
textureInfo.usage = GFXTextureUsage::Sampled | GFXTextureUsage::Attachment;
|
textureInfo.usage = GFXTextureUsage::Sampled | GFXTextureUsage::Attachment;
|
||||||
|
textureInfo.samplingMode = SamplingMode::ClampToBorder;
|
||||||
|
textureInfo.border_color = GFXBorderColor::OpaqueWhite;
|
||||||
|
|
||||||
scene.depthTexture = gfx->create_texture(textureInfo);
|
scene.depthTexture = gfx->create_texture(textureInfo);
|
||||||
|
|
||||||
|
@ -62,6 +64,8 @@ void ShadowPass::create_scene_resources(Scene& scene) {
|
||||||
cubeTextureInfo.format = GFXPixelFormat::R_32F;
|
cubeTextureInfo.format = GFXPixelFormat::R_32F;
|
||||||
cubeTextureInfo.usage = GFXTextureUsage::Sampled;
|
cubeTextureInfo.usage = GFXTextureUsage::Sampled;
|
||||||
cubeTextureInfo.array_length = max_point_shadows;
|
cubeTextureInfo.array_length = max_point_shadows;
|
||||||
|
cubeTextureInfo.samplingMode = SamplingMode::ClampToBorder;
|
||||||
|
cubeTextureInfo.border_color = GFXBorderColor::OpaqueWhite;
|
||||||
|
|
||||||
scene.pointLightArray = gfx->create_texture(cubeTextureInfo);
|
scene.pointLightArray = gfx->create_texture(cubeTextureInfo);
|
||||||
}
|
}
|
||||||
|
@ -76,15 +80,11 @@ void ShadowPass::create_scene_resources(Scene& scene) {
|
||||||
spotTextureInfo.format = GFXPixelFormat::DEPTH_32F;
|
spotTextureInfo.format = GFXPixelFormat::DEPTH_32F;
|
||||||
spotTextureInfo.usage = GFXTextureUsage::Sampled;
|
spotTextureInfo.usage = GFXTextureUsage::Sampled;
|
||||||
spotTextureInfo.array_length = max_spot_shadows;
|
spotTextureInfo.array_length = max_spot_shadows;
|
||||||
|
spotTextureInfo.samplingMode = SamplingMode::ClampToBorder;
|
||||||
|
spotTextureInfo.border_color = GFXBorderColor::OpaqueWhite;
|
||||||
|
|
||||||
scene.spotLightArray = gfx->create_texture(spotTextureInfo);
|
scene.spotLightArray = gfx->create_texture(spotTextureInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
GFXSamplerCreateInfo sampler_create_info = {};
|
|
||||||
sampler_create_info.samplingMode = SamplingMode::ClampToBorder;
|
|
||||||
sampler_create_info.border_color = GFXBorderColor::OpaqueWhite;
|
|
||||||
|
|
||||||
shadow_sampler = gfx->create_sampler(sampler_create_info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShadowPass::render(GFXCommandBuffer* command_buffer, Scene& scene) {
|
void ShadowPass::render(GFXCommandBuffer* command_buffer, Scene& scene) {
|
||||||
|
@ -391,6 +391,7 @@ void ShadowPass::create_offscreen_resources() {
|
||||||
textureInfo.height = render_options.shadow_resolution;
|
textureInfo.height = render_options.shadow_resolution;
|
||||||
textureInfo.format = GFXPixelFormat::R_32F;
|
textureInfo.format = GFXPixelFormat::R_32F;
|
||||||
textureInfo.usage = GFXTextureUsage::Attachment | GFXTextureUsage::Sampled;
|
textureInfo.usage = GFXTextureUsage::Attachment | GFXTextureUsage::Sampled;
|
||||||
|
textureInfo.samplingMode = SamplingMode::ClampToEdge;
|
||||||
|
|
||||||
offscreen_color_texture = gfx->create_texture(textureInfo);
|
offscreen_color_texture = gfx->create_texture(textureInfo);
|
||||||
|
|
||||||
|
@ -400,7 +401,8 @@ void ShadowPass::create_offscreen_resources() {
|
||||||
depthTextureInfo.height = render_options.shadow_resolution;
|
depthTextureInfo.height = render_options.shadow_resolution;
|
||||||
depthTextureInfo.format = GFXPixelFormat::DEPTH_32F;
|
depthTextureInfo.format = GFXPixelFormat::DEPTH_32F;
|
||||||
depthTextureInfo.usage = GFXTextureUsage::Attachment | GFXTextureUsage::Sampled;
|
depthTextureInfo.usage = GFXTextureUsage::Attachment | GFXTextureUsage::Sampled;
|
||||||
|
depthTextureInfo.samplingMode = SamplingMode::ClampToEdge;
|
||||||
|
|
||||||
offscreen_depth = gfx->create_texture(depthTextureInfo);
|
offscreen_depth = gfx->create_texture(depthTextureInfo);
|
||||||
|
|
||||||
GFXFramebufferCreateInfo info;
|
GFXFramebufferCreateInfo info;
|
||||||
|
|
|
@ -101,7 +101,8 @@ void SMAAPass::create_textures() {
|
||||||
areaInfo.height = AREATEX_HEIGHT;
|
areaInfo.height = AREATEX_HEIGHT;
|
||||||
areaInfo.format = GFXPixelFormat::R8G8_UNORM;
|
areaInfo.format = GFXPixelFormat::R8G8_UNORM;
|
||||||
areaInfo.usage = GFXTextureUsage::Sampled | GFXTextureUsage::TransferDst;
|
areaInfo.usage = GFXTextureUsage::Sampled | GFXTextureUsage::TransferDst;
|
||||||
|
areaInfo.samplingMode = SamplingMode::ClampToEdge;
|
||||||
|
|
||||||
area_image = gfx->create_texture(areaInfo);
|
area_image = gfx->create_texture(areaInfo);
|
||||||
|
|
||||||
gfx->copy_texture(area_image, (void*)areaTexBytes, AREATEX_SIZE);
|
gfx->copy_texture(area_image, (void*)areaTexBytes, AREATEX_SIZE);
|
||||||
|
@ -113,7 +114,8 @@ void SMAAPass::create_textures() {
|
||||||
searchInfo.height = SEARCHTEX_HEIGHT;
|
searchInfo.height = SEARCHTEX_HEIGHT;
|
||||||
searchInfo.format = GFXPixelFormat::R8_UNORM;
|
searchInfo.format = GFXPixelFormat::R8_UNORM;
|
||||||
searchInfo.usage = GFXTextureUsage::Sampled | GFXTextureUsage::TransferDst;
|
searchInfo.usage = GFXTextureUsage::Sampled | GFXTextureUsage::TransferDst;
|
||||||
|
searchInfo.samplingMode = SamplingMode::ClampToEdge;
|
||||||
|
|
||||||
search_image = gfx->create_texture(searchInfo);
|
search_image = gfx->create_texture(searchInfo);
|
||||||
|
|
||||||
gfx->copy_texture(search_image, (void*)searchTexBytes, SEARCHTEX_SIZE);
|
gfx->copy_texture(search_image, (void*)searchTexBytes, SEARCHTEX_SIZE);
|
||||||
|
@ -143,8 +145,8 @@ void SMAAPass::create_pipelines() {
|
||||||
};
|
};
|
||||||
|
|
||||||
createInfo.shader_input.bindings = {
|
createInfo.shader_input.bindings = {
|
||||||
{0, GFXBindingType::SampledImage},
|
{0, GFXBindingType::Texture},
|
||||||
{1, GFXBindingType::SampledImage},
|
{1, GFXBindingType::Texture},
|
||||||
{2, GFXBindingType::PushConstant}
|
{2, GFXBindingType::PushConstant}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -153,7 +155,7 @@ void SMAAPass::create_pipelines() {
|
||||||
createInfo.label = "SMAA Blend";
|
createInfo.label = "SMAA Blend";
|
||||||
createInfo.shaders.vertex_src = ShaderSource(prism::path("blend.vert"));
|
createInfo.shaders.vertex_src = ShaderSource(prism::path("blend.vert"));
|
||||||
createInfo.shaders.fragment_src = ShaderSource(prism::path("blend.frag"));
|
createInfo.shaders.fragment_src = ShaderSource(prism::path("blend.frag"));
|
||||||
createInfo.shader_input.bindings.push_back({3, GFXBindingType::SampledImage});
|
createInfo.shader_input.bindings.push_back({3, GFXBindingType::Texture});
|
||||||
|
|
||||||
blend_pipeline = gfx->create_graphics_pipeline(createInfo);
|
blend_pipeline = gfx->create_graphics_pipeline(createInfo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,11 @@ layout(push_constant) uniform readonly PushConstant{
|
||||||
vec4 color;
|
vec4 color;
|
||||||
};
|
};
|
||||||
|
|
||||||
layout (binding = 2) uniform texture2D colorSampler;
|
layout (binding = 2) uniform sampler2D colorSampler;
|
||||||
layout (binding = 3) uniform sampler testSampler;
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
if(inUV.y < 0.0 || inUV.x > 1.0)
|
if(inUV.y < 0.0 || inUV.x > 1.0)
|
||||||
discard;
|
discard;
|
||||||
|
|
||||||
outColor = texture(sampler2D(colorSampler, testSampler), inUV) * color;
|
outColor = texture(colorSampler, inUV) * color;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,8 @@ layout(location = 1) in vec2 in_uv;
|
||||||
|
|
||||||
layout(location = 0) out vec4 out_color;
|
layout(location = 0) out vec4 out_color;
|
||||||
|
|
||||||
layout(binding = 2) uniform texture2D bound_texture;
|
layout(binding = 2) uniform sampler2D bound_texture;
|
||||||
layout(binding = 3) uniform sampler testSampler;
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
out_color = in_color * texture(sampler2D(bound_texture, testSampler), in_uv);
|
out_color = in_color * texture(bound_texture, in_uv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,31 +19,30 @@ layout(location = 1) in vec4 inOffset;
|
||||||
|
|
||||||
layout (location = 0) out vec4 outColor;
|
layout (location = 0) out vec4 outColor;
|
||||||
|
|
||||||
layout (binding = 1) uniform texture2D colorSampler;
|
layout (binding = 1) uniform sampler2D colorSampler;
|
||||||
layout (binding = 2) uniform texture2D backSampler;
|
layout (binding = 2) uniform sampler2D backSampler;
|
||||||
layout (binding = 3) uniform texture2D blendSampler;
|
layout (binding = 3) uniform sampler2D blendSampler;
|
||||||
layout (binding = 5) uniform texture2D sobelSampler;
|
layout (binding = 5) uniform sampler2D sobelSampler;
|
||||||
layout (binding = 6) uniform texture2D averageLuminanceSampler;
|
layout (binding = 6) uniform sampler2D averageLuminanceSampler;
|
||||||
layout (binding = 7) uniform texture2D farFieldSampler;
|
layout (binding = 7) uniform sampler2D farFieldSampler;
|
||||||
layout (binding = 8) uniform sampler global_sampler;
|
|
||||||
|
|
||||||
float calculate_sobel() {
|
float calculate_sobel() {
|
||||||
float x = 1.0 / viewport.z;
|
float x = 1.0 / viewport.z;
|
||||||
float y = 1.0 / viewport.w;
|
float y = 1.0 / viewport.w;
|
||||||
vec4 horizEdge = vec4( 0.0 );
|
vec4 horizEdge = vec4( 0.0 );
|
||||||
horizEdge -= texture(sampler2D(sobelSampler, global_sampler), vec2( inUV.x - x, inUV.y - y ) ) * 1.0;
|
horizEdge -= texture( sobelSampler, vec2( inUV.x - x, inUV.y - y ) ) * 1.0;
|
||||||
horizEdge -= texture(sampler2D(sobelSampler, global_sampler), vec2( inUV.x - x, inUV.y ) ) * 2.0;
|
horizEdge -= texture( sobelSampler, vec2( inUV.x - x, inUV.y ) ) * 2.0;
|
||||||
horizEdge -= texture(sampler2D(sobelSampler, global_sampler), vec2( inUV.x - x, inUV.y + y ) ) * 1.0;
|
horizEdge -= texture( sobelSampler, vec2( inUV.x - x, inUV.y + y ) ) * 1.0;
|
||||||
horizEdge += texture(sampler2D(sobelSampler, global_sampler), vec2( inUV.x + x, inUV.y - y ) ) * 1.0;
|
horizEdge += texture( sobelSampler, vec2( inUV.x + x, inUV.y - y ) ) * 1.0;
|
||||||
horizEdge += texture(sampler2D(sobelSampler, global_sampler), vec2( inUV.x + x, inUV.y ) ) * 2.0;
|
horizEdge += texture( sobelSampler, vec2( inUV.x + x, inUV.y ) ) * 2.0;
|
||||||
horizEdge += texture(sampler2D(sobelSampler, global_sampler), vec2( inUV.x + x, inUV.y + y ) ) * 1.0;
|
horizEdge += texture( sobelSampler, vec2( inUV.x + x, inUV.y + y ) ) * 1.0;
|
||||||
vec4 vertEdge = vec4( 0.0 );
|
vec4 vertEdge = vec4( 0.0 );
|
||||||
vertEdge -= texture(sampler2D(sobelSampler, global_sampler), vec2( inUV.x - x, inUV.y - y ) ) * 1.0;
|
vertEdge -= texture( sobelSampler, vec2( inUV.x - x, inUV.y - y ) ) * 1.0;
|
||||||
vertEdge -= texture(sampler2D(sobelSampler, global_sampler), vec2( inUV.x , inUV.y - y ) ) * 2.0;
|
vertEdge -= texture( sobelSampler, vec2( inUV.x , inUV.y - y ) ) * 2.0;
|
||||||
vertEdge -= texture(sampler2D(sobelSampler, global_sampler), vec2( inUV.x + x, inUV.y - y ) ) * 1.0;
|
vertEdge -= texture( sobelSampler, vec2( inUV.x + x, inUV.y - y ) ) * 1.0;
|
||||||
vertEdge += texture(sampler2D(sobelSampler, global_sampler), vec2( inUV.x - x, inUV.y + y ) ) * 1.0;
|
vertEdge += texture( sobelSampler, vec2( inUV.x - x, inUV.y + y ) ) * 1.0;
|
||||||
vertEdge += texture(sampler2D(sobelSampler, global_sampler), vec2( inUV.x , inUV.y + y ) ) * 2.0;
|
vertEdge += texture( sobelSampler, vec2( inUV.x , inUV.y + y ) ) * 2.0;
|
||||||
vertEdge += texture(sampler2D(sobelSampler, global_sampler), vec2( inUV.x + x, inUV.y + y ) ) * 1.0;
|
vertEdge += texture( sobelSampler, vec2( inUV.x + x, inUV.y + y ) ) * 1.0;
|
||||||
return sqrt((horizEdge.rgb * horizEdge.rgb) + (vertEdge.rgb * vertEdge.rgb)).r;
|
return sqrt((horizEdge.rgb * horizEdge.rgb) + (vertEdge.rgb * vertEdge.rgb)).r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,31 +106,31 @@ float reinhard2(float _x, float _whiteSqr)
|
||||||
void main() {
|
void main() {
|
||||||
// passthrough
|
// passthrough
|
||||||
if(options.w == 1) {
|
if(options.w == 1) {
|
||||||
outColor = texture(sampler2D(colorSampler, global_sampler), inUV);
|
outColor = texture(colorSampler, inUV);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool enable_dof = options.w == 2;
|
bool enable_dof = options.w == 2;
|
||||||
vec3 sceneColor = vec3(0);
|
vec3 sceneColor = vec3(0);
|
||||||
if(enable_dof) {
|
if(enable_dof) {
|
||||||
sceneColor = texture(sampler2D(farFieldSampler, global_sampler), inUV).rgb;
|
sceneColor = texture(farFieldSampler, inUV).rgb;
|
||||||
sceneColor += texture(sampler2D(colorSampler, global_sampler), inUV).rgb;
|
sceneColor += texture(colorSampler, inUV).rgb;
|
||||||
} else {
|
} else {
|
||||||
//if(options.x == 1) // enable AA
|
if(options.x == 1) // enable AA
|
||||||
// sceneColor = SMAANeighborhoodBlendingPS(inUV, inOffset, colorSampler, blendSampler).rgb;
|
sceneColor = SMAANeighborhoodBlendingPS(inUV, inOffset, colorSampler, blendSampler).rgb;
|
||||||
//else
|
else
|
||||||
sceneColor = texture(sampler2D(colorSampler, global_sampler), inUV).rgb;
|
sceneColor = texture(colorSampler, inUV).rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
float sobel = 0.0;
|
float sobel = 0.0;
|
||||||
if(textureSize(sampler2D(sobelSampler, global_sampler), 0).x > 1)
|
if(textureSize(sobelSampler, 0).x > 1)
|
||||||
sobel = calculate_sobel();
|
sobel = calculate_sobel();
|
||||||
|
|
||||||
vec3 sobelColor = vec3(0, 1, 1);
|
vec3 sobelColor = vec3(0, 1, 1);
|
||||||
|
|
||||||
vec3 hdrColor = sceneColor; // fading removed
|
vec3 hdrColor = sceneColor; // fading removed
|
||||||
|
|
||||||
float avg_lum = texture(sampler2D(averageLuminanceSampler, global_sampler), inUV).r;
|
float avg_lum = texture(averageLuminanceSampler, inUV).r;
|
||||||
|
|
||||||
vec3 transformed_color = hdrColor;
|
vec3 transformed_color = hdrColor;
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ struct ComputedLightInformation {
|
||||||
float pcf_sun(const vec4 shadowCoords, const float uvRadius) {
|
float pcf_sun(const vec4 shadowCoords, const float uvRadius) {
|
||||||
float sum = 0;
|
float sum = 0;
|
||||||
for(int i = 0; i < 16; i++) {
|
for(int i = 0; i < 16; i++) {
|
||||||
const float z = texture(sampler2D(sun_shadow, shadow_sampler), shadowCoords.xy + PoissionPCFDisk[i] * uvRadius).r;
|
const float z = texture(sun_shadow, shadowCoords.xy + PoissionPCFDisk[i] * uvRadius).r;
|
||||||
sum += (z < (shadowCoords.z - 0.005)) ? 0.0 : 1.0;
|
sum += (z < (shadowCoords.z - 0.005)) ? 0.0 : 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ void blocker_distance_sun(const vec3 shadowCoords, const float uvLightSize, inou
|
||||||
blockers = 0;
|
blockers = 0;
|
||||||
|
|
||||||
for(int i = 0; i < numBlockerSearchSamples; i++) {
|
for(int i = 0; i < numBlockerSearchSamples; i++) {
|
||||||
const float z = texture(sampler2D(sun_shadow, shadow_sampler), shadowCoords.xy + PoissionPCFDisk[i] * searchWidth).r;
|
const float z = texture(sun_shadow, shadowCoords.xy + PoissionPCFDisk[i] * searchWidth).r;
|
||||||
if(z < shadowCoords.z) {
|
if(z < shadowCoords.z) {
|
||||||
blockerSum += z;
|
blockerSum += z;
|
||||||
blockers++;
|
blockers++;
|
||||||
|
@ -126,7 +126,7 @@ ComputedLightInformation calculate_sun(Light light) {
|
||||||
|
|
||||||
if(shadowCoords.z > -1.0 && shadowCoords.z < 1.0) {
|
if(shadowCoords.z > -1.0 && shadowCoords.z < 1.0) {
|
||||||
#ifdef SHADOW_FILTER_NONE
|
#ifdef SHADOW_FILTER_NONE
|
||||||
shadow = (texture(sampler2D(sun_shadow, shadow_sampler), shadowCoords.xy).r < shadowCoords.z - 0.005) ? 0.0 : 1.0;
|
shadow = (texture(sun_shadow, shadowCoords.xy).r < shadowCoords.z - 0.005) ? 0.0 : 1.0;
|
||||||
#endif
|
#endif
|
||||||
#ifdef SHADOW_FILTER_PCF
|
#ifdef SHADOW_FILTER_PCF
|
||||||
shadow = pcf_sun(shadowCoords, 0.1);
|
shadow = pcf_sun(shadowCoords, 0.1);
|
||||||
|
@ -145,7 +145,7 @@ ComputedLightInformation calculate_sun(Light light) {
|
||||||
float pcf_spot(const vec4 shadowCoords, const int index, const float uvRadius) {
|
float pcf_spot(const vec4 shadowCoords, const int index, const float uvRadius) {
|
||||||
float sum = 0;
|
float sum = 0;
|
||||||
for(int i = 0; i < 16; i++) {
|
for(int i = 0; i < 16; i++) {
|
||||||
const float z = texture(sampler2DArray(spot_shadow, shadow_sampler), vec3(shadowCoords.xy + PoissionPCFDisk[i] * uvRadius, index)).r;
|
const float z = texture(spot_shadow, vec3(shadowCoords.xy + PoissionPCFDisk[i] * uvRadius, index)).r;
|
||||||
sum += (z < (shadowCoords.z - 0.001)) ? 0.0 : 1.0;
|
sum += (z < (shadowCoords.z - 0.001)) ? 0.0 : 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ void blocker_distance_spot(const vec3 shadowCoords, const int index, const float
|
||||||
blockers = 0;
|
blockers = 0;
|
||||||
|
|
||||||
for(int i = 0; i < numBlockerSearchSamples; i++) {
|
for(int i = 0; i < numBlockerSearchSamples; i++) {
|
||||||
const float z = texture(sampler2DArray(spot_shadow, shadow_sampler), vec3(shadowCoords.xy + PoissionPCFDisk[i] * searchWidth, index)).r;
|
const float z = texture(spot_shadow, vec3(shadowCoords.xy + PoissionPCFDisk[i] * searchWidth, index)).r;
|
||||||
if(z < shadowCoords.z) {
|
if(z < shadowCoords.z) {
|
||||||
blockerSum += z;
|
blockerSum += z;
|
||||||
blockers++;
|
blockers++;
|
||||||
|
@ -197,7 +197,7 @@ ComputedLightInformation calculate_spot(Light light) {
|
||||||
const vec4 shadowCoord = fragPostSpotLightSpace[last_spot_light] / fragPostSpotLightSpace[last_spot_light].w;
|
const vec4 shadowCoord = fragPostSpotLightSpace[last_spot_light] / fragPostSpotLightSpace[last_spot_light].w;
|
||||||
|
|
||||||
#ifdef SHADOW_FILTER_NONE
|
#ifdef SHADOW_FILTER_NONE
|
||||||
shadow = (texture(sampler2D(spot_shadow, shadow_sampler), vec3(shadowCoord.xy, last_spot_light)).r < shadowCoord.z - 0.005) ? 0.0 : 1.0;
|
shadow = (texture(spot_shadow, vec3(shadowCoord.xy, last_spot_light)).r < shadowCoord.z - 0.005) ? 0.0 : 1.0;
|
||||||
#endif
|
#endif
|
||||||
#ifdef SHADOW_FILTER_PCF
|
#ifdef SHADOW_FILTER_PCF
|
||||||
shadow = pcf_spot(shadowCoord, last_spot_light, 0.01);
|
shadow = pcf_spot(shadowCoord, last_spot_light, 0.01);
|
||||||
|
@ -235,7 +235,7 @@ vec3 sampleOffsetDirections[20] = vec3[]
|
||||||
float pcf_point(const vec3 shadowCoords, const int index, const float uvRadius) {
|
float pcf_point(const vec3 shadowCoords, const int index, const float uvRadius) {
|
||||||
float sum = 0;
|
float sum = 0;
|
||||||
for(int i = 0; i < 20; i++) {
|
for(int i = 0; i < 20; i++) {
|
||||||
const float z = texture(samplerCubeArray(point_shadow, shadow_sampler), vec4(shadowCoords.xyz + sampleOffsetDirections[i] * uvRadius, index)).r;
|
const float z = texture(point_shadow, vec4(shadowCoords.xyz + sampleOffsetDirections[i] * uvRadius, index)).r;
|
||||||
sum += (z < length(shadowCoords) - 0.05) ? 0.0 : 1.0;
|
sum += (z < length(shadowCoords) - 0.05) ? 0.0 : 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ void blocker_distance_point(const vec3 shadowCoords, const int index, const floa
|
||||||
blockers = 0;
|
blockers = 0;
|
||||||
|
|
||||||
for(int i = 0; i < 20; i++) {
|
for(int i = 0; i < 20; i++) {
|
||||||
const float z = texture(samplerCubeArray(point_shadow, shadow_sampler), vec4(shadowCoords + sampleOffsetDirections[i] * 0.05, index)).r;
|
const float z = texture(point_shadow, vec4(shadowCoords + sampleOffsetDirections[i] * 0.05, index)).r;
|
||||||
if(z < length(shadowCoords)) {
|
if(z < length(shadowCoords)) {
|
||||||
blockerSum += z;
|
blockerSum += z;
|
||||||
blockers++;
|
blockers++;
|
||||||
|
@ -289,7 +289,7 @@ ComputedLightInformation calculate_point(Light light) {
|
||||||
#ifdef POINT_SHADOWS_SUPPORTED
|
#ifdef POINT_SHADOWS_SUPPORTED
|
||||||
if(light.shadowsEnable.x == 1.0) {
|
if(light.shadowsEnable.x == 1.0) {
|
||||||
#ifdef SHADOW_FILTER_NONE
|
#ifdef SHADOW_FILTER_NONE
|
||||||
const float sampledDist = texture(sampler2D(point_shadow, shadow_sampler), vec4(lightVec, int(light.shadowsEnable.z))).r;
|
const float sampledDist = texture(point_shadow, vec4(lightVec, int(light.shadowsEnable.z))).r;
|
||||||
const float dist = length(lightVec);
|
const float dist = length(lightVec);
|
||||||
|
|
||||||
shadow = (dist <= sampledDist + 0.05) ? 1.0 : 0.0;
|
shadow = (dist <= sampledDist + 0.05) ? 1.0 : 0.0;
|
||||||
|
|
Reference in a new issue