Implement MSAA
This commit is contained in:
parent
d160644c88
commit
a57dc398db
14 changed files with 410 additions and 158 deletions
|
@ -6252,7 +6252,7 @@ void RasterizerStorageGLES2::initialize() {
|
|||
#endif
|
||||
|
||||
config.force_vertex_shading = GLOBAL_GET("rendering/quality/shading/force_vertex_shading");
|
||||
config.use_fast_texture_filter = GLOBAL_GET("rendering/quality/filters/use_nearest_mipmap_filter");
|
||||
config.use_fast_texture_filter = GLOBAL_GET("rendering/quality/texture_filters/use_nearest_mipmap_filter");
|
||||
}
|
||||
|
||||
void RasterizerStorageGLES2::finalize() {
|
||||
|
|
|
@ -2676,6 +2676,159 @@ Error RenderingDeviceVulkan::texture_copy(RID p_from_texture, RID p_to_texture,
|
|||
|
||||
return OK;
|
||||
}
|
||||
Error RenderingDeviceVulkan::texture_resolve_multisample(RID p_from_texture, RID p_to_texture, bool p_sync_with_draw) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
Texture *src_tex = texture_owner.getornull(p_from_texture);
|
||||
ERR_FAIL_COND_V(!src_tex, ERR_INVALID_PARAMETER);
|
||||
|
||||
ERR_FAIL_COND_V_MSG(p_sync_with_draw && src_tex->bound, ERR_INVALID_PARAMETER,
|
||||
"Source texture can't be copied while a render pass that uses it is being created. Ensure render pass is finalized (and that it was created with RENDER_PASS_CONTENTS_FINISH) to unbind this texture.");
|
||||
ERR_FAIL_COND_V_MSG(!(src_tex->usage_flags & TEXTURE_USAGE_CAN_COPY_FROM_BIT), ERR_INVALID_PARAMETER,
|
||||
"Source texture requires the TEXTURE_USAGE_CAN_COPY_FROM_BIT in order to be retrieved.");
|
||||
|
||||
ERR_FAIL_COND_V_MSG(src_tex->type != TEXTURE_TYPE_2D, ERR_INVALID_PARAMETER, "Source texture must be 2D (or a slice of a 3D/Cube texture)");
|
||||
ERR_FAIL_COND_V_MSG(src_tex->samples == TEXTURE_SAMPLES_1, ERR_INVALID_PARAMETER, "Source texture must be multisampled.");
|
||||
|
||||
Texture *dst_tex = texture_owner.getornull(p_to_texture);
|
||||
ERR_FAIL_COND_V(!dst_tex, ERR_INVALID_PARAMETER);
|
||||
|
||||
ERR_FAIL_COND_V_MSG(p_sync_with_draw && dst_tex->bound, ERR_INVALID_PARAMETER,
|
||||
"Destination texture can't be copied while a render pass that uses it is being created. Ensure render pass is finalized (and that it was created with RENDER_PASS_CONTENTS_FINISH) to unbind this texture.");
|
||||
ERR_FAIL_COND_V_MSG(!(dst_tex->usage_flags & TEXTURE_USAGE_CAN_COPY_TO_BIT), ERR_INVALID_PARAMETER,
|
||||
"Destination texture requires the TEXTURE_USAGE_CAN_COPY_TO_BIT in order to be retrieved.");
|
||||
|
||||
ERR_FAIL_COND_V_MSG(dst_tex->type != TEXTURE_TYPE_2D, ERR_INVALID_PARAMETER, "Destination texture must be 2D (or a slice of a 3D/Cube texture).");
|
||||
ERR_FAIL_COND_V_MSG(dst_tex->samples != TEXTURE_SAMPLES_1, ERR_INVALID_PARAMETER, "Destination texture must not be multisampled.");
|
||||
|
||||
ERR_FAIL_COND_V_MSG(src_tex->format != dst_tex->format, ERR_INVALID_PARAMETER, "Source and Destionation textures must be the same format.");
|
||||
ERR_FAIL_COND_V_MSG(src_tex->width != dst_tex->width && src_tex->height != dst_tex->height && src_tex->depth != dst_tex->depth, ERR_INVALID_PARAMETER, "Source and Destionation textures must have the same dimensions.");
|
||||
|
||||
ERR_FAIL_COND_V_MSG(src_tex->read_aspect_mask != dst_tex->read_aspect_mask, ERR_INVALID_PARAMETER,
|
||||
"Source and destination texture must be of the same type (color or depth).");
|
||||
|
||||
VkCommandBuffer command_buffer = p_sync_with_draw ? frames[frame].draw_command_buffer : frames[frame].setup_command_buffer;
|
||||
|
||||
{
|
||||
|
||||
//PRE Copy the image
|
||||
|
||||
{ //Source
|
||||
VkImageMemoryBarrier image_memory_barrier;
|
||||
image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||
image_memory_barrier.pNext = nullptr;
|
||||
image_memory_barrier.srcAccessMask = 0;
|
||||
image_memory_barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
|
||||
image_memory_barrier.oldLayout = src_tex->layout;
|
||||
image_memory_barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
|
||||
|
||||
image_memory_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
image_memory_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
image_memory_barrier.image = src_tex->image;
|
||||
image_memory_barrier.subresourceRange.aspectMask = src_tex->barrier_aspect_mask;
|
||||
image_memory_barrier.subresourceRange.baseMipLevel = src_tex->base_mipmap;
|
||||
image_memory_barrier.subresourceRange.levelCount = 1;
|
||||
image_memory_barrier.subresourceRange.baseArrayLayer = src_tex->base_layer;
|
||||
image_memory_barrier.subresourceRange.layerCount = 1;
|
||||
|
||||
vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier);
|
||||
}
|
||||
{ //Dest
|
||||
VkImageMemoryBarrier image_memory_barrier;
|
||||
image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||
image_memory_barrier.pNext = nullptr;
|
||||
image_memory_barrier.srcAccessMask = 0;
|
||||
image_memory_barrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
image_memory_barrier.oldLayout = dst_tex->layout;
|
||||
image_memory_barrier.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
||||
|
||||
image_memory_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
image_memory_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
image_memory_barrier.image = dst_tex->image;
|
||||
image_memory_barrier.subresourceRange.aspectMask = dst_tex->read_aspect_mask;
|
||||
image_memory_barrier.subresourceRange.baseMipLevel = dst_tex->base_mipmap;
|
||||
image_memory_barrier.subresourceRange.levelCount = 1;
|
||||
image_memory_barrier.subresourceRange.baseArrayLayer = dst_tex->base_layer;
|
||||
image_memory_barrier.subresourceRange.layerCount = 1;
|
||||
|
||||
vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier);
|
||||
}
|
||||
|
||||
//COPY
|
||||
|
||||
{
|
||||
|
||||
VkImageResolve image_copy_region;
|
||||
image_copy_region.srcSubresource.aspectMask = src_tex->read_aspect_mask;
|
||||
image_copy_region.srcSubresource.baseArrayLayer = src_tex->base_layer;
|
||||
image_copy_region.srcSubresource.layerCount = 1;
|
||||
image_copy_region.srcSubresource.mipLevel = src_tex->base_mipmap;
|
||||
image_copy_region.srcOffset.x = 0;
|
||||
image_copy_region.srcOffset.y = 0;
|
||||
image_copy_region.srcOffset.z = 0;
|
||||
|
||||
image_copy_region.dstSubresource.aspectMask = dst_tex->read_aspect_mask;
|
||||
image_copy_region.dstSubresource.baseArrayLayer = dst_tex->base_layer;
|
||||
image_copy_region.dstSubresource.layerCount = 1;
|
||||
image_copy_region.dstSubresource.mipLevel = dst_tex->base_mipmap;
|
||||
image_copy_region.dstOffset.x = 0;
|
||||
image_copy_region.dstOffset.y = 0;
|
||||
image_copy_region.dstOffset.z = 0;
|
||||
|
||||
image_copy_region.extent.width = src_tex->width;
|
||||
image_copy_region.extent.height = src_tex->height;
|
||||
image_copy_region.extent.depth = src_tex->depth;
|
||||
|
||||
vkCmdResolveImage(command_buffer, src_tex->image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dst_tex->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &image_copy_region);
|
||||
}
|
||||
|
||||
// RESTORE LAYOUT for SRC and DST
|
||||
|
||||
{ //restore src
|
||||
VkImageMemoryBarrier image_memory_barrier;
|
||||
image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||
image_memory_barrier.pNext = nullptr;
|
||||
image_memory_barrier.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
|
||||
image_memory_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
|
||||
image_memory_barrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
|
||||
image_memory_barrier.newLayout = src_tex->layout;
|
||||
image_memory_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
image_memory_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
image_memory_barrier.image = src_tex->image;
|
||||
image_memory_barrier.subresourceRange.aspectMask = src_tex->barrier_aspect_mask;
|
||||
image_memory_barrier.subresourceRange.baseMipLevel = src_tex->base_mipmap;
|
||||
image_memory_barrier.subresourceRange.levelCount = 1;
|
||||
image_memory_barrier.subresourceRange.baseArrayLayer = src_tex->base_layer;
|
||||
image_memory_barrier.subresourceRange.layerCount = 1;
|
||||
|
||||
vkCmdPipelineBarrier(command_buffer, VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier);
|
||||
}
|
||||
|
||||
{ //make dst readable
|
||||
|
||||
VkImageMemoryBarrier image_memory_barrier;
|
||||
image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||
image_memory_barrier.pNext = nullptr;
|
||||
image_memory_barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
image_memory_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
|
||||
image_memory_barrier.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
||||
image_memory_barrier.newLayout = dst_tex->layout;
|
||||
|
||||
image_memory_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
image_memory_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
image_memory_barrier.image = dst_tex->image;
|
||||
image_memory_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
image_memory_barrier.subresourceRange.baseMipLevel = dst_tex->base_mipmap;
|
||||
image_memory_barrier.subresourceRange.levelCount = 1;
|
||||
image_memory_barrier.subresourceRange.baseArrayLayer = dst_tex->base_layer;
|
||||
image_memory_barrier.subresourceRange.layerCount = 1;
|
||||
|
||||
vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier);
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
Error RenderingDeviceVulkan::texture_clear(RID p_texture, const Color &p_color, uint32_t p_base_mipmap, uint32_t p_mipmaps, uint32_t p_base_layer, uint32_t p_layers, bool p_sync_with_draw) {
|
||||
|
||||
|
|
|
@ -985,6 +985,7 @@ public:
|
|||
|
||||
virtual Error texture_copy(RID p_from_texture, RID p_to_texture, const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_size, uint32_t p_src_mipmap, uint32_t p_dst_mipmap, uint32_t p_src_layer, uint32_t p_dst_layer, bool p_sync_with_draw = false);
|
||||
virtual Error texture_clear(RID p_texture, const Color &p_color, uint32_t p_base_mipmap, uint32_t p_mipmaps, uint32_t p_base_layer, uint32_t p_layers, bool p_sync_with_draw = false);
|
||||
virtual Error texture_resolve_multisample(RID p_from_texture, RID p_to_texture, bool p_sync_with_draw = false);
|
||||
|
||||
/*********************/
|
||||
/**** FRAMEBUFFER ****/
|
||||
|
|
|
@ -358,13 +358,13 @@ void EditorNode::_notification(int p_what) {
|
|||
scene_root->set_default_canvas_item_texture_repeat(tr);
|
||||
}
|
||||
|
||||
RS::DOFBokehShape dof_shape = RS::DOFBokehShape(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_shape")));
|
||||
RS::DOFBokehShape dof_shape = RS::DOFBokehShape(int(GLOBAL_GET("rendering/quality/depth_of_field/depth_of_field_bokeh_shape")));
|
||||
RS::get_singleton()->camera_effects_set_dof_blur_bokeh_shape(dof_shape);
|
||||
RS::DOFBlurQuality dof_quality = RS::DOFBlurQuality(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_quality")));
|
||||
bool dof_jitter = GLOBAL_GET("rendering/quality/filters/depth_of_field_use_jitter");
|
||||
RS::DOFBlurQuality dof_quality = RS::DOFBlurQuality(int(GLOBAL_GET("rendering/quality/depth_of_field/depth_of_field_bokeh_quality")));
|
||||
bool dof_jitter = GLOBAL_GET("rendering/quality/depth_of_field/depth_of_field_use_jitter");
|
||||
RS::get_singleton()->camera_effects_set_dof_blur_quality(dof_quality, dof_jitter);
|
||||
RS::get_singleton()->environment_set_ssao_quality(RS::EnvironmentSSAOQuality(int(GLOBAL_GET("rendering/quality/ssao/quality"))), GLOBAL_GET("rendering/quality/ssao/half_size"));
|
||||
RS::get_singleton()->screen_space_roughness_limiter_set_active(GLOBAL_GET("rendering/quality/filters/screen_space_roughness_limiter"), GLOBAL_GET("rendering/quality/filters/screen_space_roughness_limiter_curve"));
|
||||
RS::get_singleton()->screen_space_roughness_limiter_set_active(GLOBAL_GET("rendering/quality/screen_filters/screen_space_roughness_limiter"), GLOBAL_GET("rendering/quality/screen_filters/screen_space_roughness_limiter_curve"));
|
||||
bool glow_bicubic = int(GLOBAL_GET("rendering/quality/glow/upscale_mode")) > 0;
|
||||
RS::get_singleton()->environment_glow_set_use_bicubic_upscale(glow_bicubic);
|
||||
RS::EnvironmentSSRRoughnessQuality ssr_roughness_quality = RS::EnvironmentSSRRoughnessQuality(int(GLOBAL_GET("rendering/quality/screen_space_reflection/roughness_quality")));
|
||||
|
|
|
@ -2478,9 +2478,9 @@ void Node3DEditorViewport::_notification(int p_what) {
|
|||
|
||||
//update msaa if changed
|
||||
|
||||
int msaa_mode = ProjectSettings::get_singleton()->get("rendering/quality/filters/msaa");
|
||||
int msaa_mode = ProjectSettings::get_singleton()->get("rendering/quality/screen_filters/msaa");
|
||||
viewport->set_msaa(Viewport::MSAA(msaa_mode));
|
||||
int ssaa_mode = GLOBAL_GET("rendering/quality/filters/screen_space_aa");
|
||||
int ssaa_mode = GLOBAL_GET("rendering/quality/screen_filters/screen_space_aa");
|
||||
viewport->set_screen_space_aa(Viewport::ScreenSpaceAA(ssaa_mode));
|
||||
|
||||
bool show_info = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_INFORMATION));
|
||||
|
|
|
@ -1421,12 +1421,12 @@ SceneTree::SceneTree() {
|
|||
root->set_as_audio_listener_2d(true);
|
||||
current_scene = nullptr;
|
||||
|
||||
int msaa_mode = GLOBAL_DEF("rendering/quality/filters/msaa", 0);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/filters/msaa", PropertyInfo(Variant::INT, "rendering/quality/filters/msaa", PROPERTY_HINT_ENUM, "Disabled,2x,4x,8x,16x,AndroidVR 2x,AndroidVR 4x"));
|
||||
int msaa_mode = GLOBAL_DEF("rendering/quality/screen_filters/msaa", 0);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/screen_filters/msaa", PropertyInfo(Variant::INT, "rendering/quality/screen_filters/msaa", PROPERTY_HINT_ENUM, "Disabled,2x,4x,8x,16x,AndroidVR 2x,AndroidVR 4x"));
|
||||
root->set_msaa(Viewport::MSAA(msaa_mode));
|
||||
|
||||
int ssaa_mode = GLOBAL_DEF("rendering/quality/filters/screen_space_aa", 0);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/filters/screen_space_aa", PropertyInfo(Variant::INT, "rendering/quality/filters/screen_space_aa", PROPERTY_HINT_ENUM, "Disabled,FXAA"));
|
||||
int ssaa_mode = GLOBAL_DEF("rendering/quality/screen_filters/screen_space_aa", 0);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/screen_filters/screen_space_aa", PropertyInfo(Variant::INT, "rendering/quality/screen_filters/screen_space_aa", PROPERTY_HINT_ENUM, "Disabled,FXAA"));
|
||||
root->set_screen_space_aa(Viewport::ScreenSpaceAA(ssaa_mode));
|
||||
|
||||
{ //load default fallback environment
|
||||
|
|
|
@ -535,46 +535,100 @@ void RasterizerSceneHighEndRD::RenderBufferDataHighEnd::ensure_specular() {
|
|||
tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT;
|
||||
tf.width = width;
|
||||
tf.height = height;
|
||||
tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT;
|
||||
if (msaa != RS::VIEWPORT_MSAA_DISABLED) {
|
||||
tf.usage_bits |= RD::TEXTURE_USAGE_CAN_COPY_TO_BIT;
|
||||
} else {
|
||||
tf.usage_bits |= RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
}
|
||||
|
||||
specular = RD::get_singleton()->texture_create(tf, RD::TextureView());
|
||||
|
||||
{
|
||||
Vector<RID> fb;
|
||||
fb.push_back(color);
|
||||
fb.push_back(specular);
|
||||
fb.push_back(depth);
|
||||
if (msaa == RS::VIEWPORT_MSAA_DISABLED) {
|
||||
|
||||
color_specular_fb = RD::get_singleton()->framebuffer_create(fb);
|
||||
}
|
||||
{
|
||||
Vector<RID> fb;
|
||||
fb.push_back(specular);
|
||||
{
|
||||
Vector<RID> fb;
|
||||
fb.push_back(color);
|
||||
fb.push_back(specular);
|
||||
fb.push_back(depth);
|
||||
|
||||
specular_only_fb = RD::get_singleton()->framebuffer_create(fb);
|
||||
color_specular_fb = RD::get_singleton()->framebuffer_create(fb);
|
||||
}
|
||||
{
|
||||
Vector<RID> fb;
|
||||
fb.push_back(specular);
|
||||
|
||||
specular_only_fb = RD::get_singleton()->framebuffer_create(fb);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
tf.samples = texture_samples;
|
||||
tf.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT;
|
||||
specular_msaa = RD::get_singleton()->texture_create(tf, RD::TextureView());
|
||||
|
||||
{
|
||||
Vector<RID> fb;
|
||||
fb.push_back(color_msaa);
|
||||
fb.push_back(specular_msaa);
|
||||
fb.push_back(depth_msaa);
|
||||
|
||||
color_specular_fb = RD::get_singleton()->framebuffer_create(fb);
|
||||
}
|
||||
{
|
||||
Vector<RID> fb;
|
||||
fb.push_back(specular_msaa);
|
||||
|
||||
specular_only_fb = RD::get_singleton()->framebuffer_create(fb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RasterizerSceneHighEndRD::RenderBufferDataHighEnd::clear() {
|
||||
|
||||
if (color_msaa.is_valid()) {
|
||||
RD::get_singleton()->free(color_msaa);
|
||||
color_msaa = RID();
|
||||
}
|
||||
|
||||
if (depth_msaa.is_valid()) {
|
||||
RD::get_singleton()->free(depth_msaa);
|
||||
depth_msaa = RID();
|
||||
}
|
||||
|
||||
if (specular.is_valid()) {
|
||||
if (specular_msaa.is_valid()) {
|
||||
RD::get_singleton()->free(specular_msaa);
|
||||
specular_msaa = RID();
|
||||
}
|
||||
RD::get_singleton()->free(specular);
|
||||
specular = RID();
|
||||
}
|
||||
|
||||
color = RID();
|
||||
depth = RID();
|
||||
color_specular_fb = RID();
|
||||
specular_only_fb = RID();
|
||||
color_fb = RID();
|
||||
depth_fb = RID();
|
||||
|
||||
if (normal_buffer.is_valid()) {
|
||||
RD::get_singleton()->free(normal_buffer);
|
||||
if (normal_buffer_msaa.is_valid()) {
|
||||
RD::get_singleton()->free(normal_buffer_msaa);
|
||||
normal_buffer_msaa = RID();
|
||||
}
|
||||
normal_buffer = RID();
|
||||
depth_normal_fb = RID();
|
||||
}
|
||||
|
||||
if (roughness_buffer.is_valid()) {
|
||||
RD::get_singleton()->free(roughness_buffer);
|
||||
if (roughness_buffer_msaa.is_valid()) {
|
||||
RD::get_singleton()->free(roughness_buffer_msaa);
|
||||
roughness_buffer_msaa = RID();
|
||||
}
|
||||
roughness_buffer = RID();
|
||||
depth_normal_roughness_fb = RID();
|
||||
}
|
||||
|
@ -583,24 +637,69 @@ void RasterizerSceneHighEndRD::RenderBufferDataHighEnd::clear() {
|
|||
void RasterizerSceneHighEndRD::RenderBufferDataHighEnd::configure(RID p_color_buffer, RID p_depth_buffer, int p_width, int p_height, RS::ViewportMSAA p_msaa) {
|
||||
clear();
|
||||
|
||||
msaa = p_msaa;
|
||||
|
||||
width = p_width;
|
||||
height = p_height;
|
||||
|
||||
color = p_color_buffer;
|
||||
depth = p_depth_buffer;
|
||||
|
||||
{
|
||||
Vector<RID> fb;
|
||||
fb.push_back(p_color_buffer);
|
||||
fb.push_back(depth);
|
||||
if (p_msaa == RS::VIEWPORT_MSAA_DISABLED) {
|
||||
|
||||
color_fb = RD::get_singleton()->framebuffer_create(fb);
|
||||
}
|
||||
{
|
||||
Vector<RID> fb;
|
||||
fb.push_back(depth);
|
||||
{
|
||||
Vector<RID> fb;
|
||||
fb.push_back(p_color_buffer);
|
||||
fb.push_back(depth);
|
||||
|
||||
depth_fb = RD::get_singleton()->framebuffer_create(fb);
|
||||
color_fb = RD::get_singleton()->framebuffer_create(fb);
|
||||
}
|
||||
{
|
||||
Vector<RID> fb;
|
||||
fb.push_back(depth);
|
||||
|
||||
depth_fb = RD::get_singleton()->framebuffer_create(fb);
|
||||
}
|
||||
} else {
|
||||
|
||||
RD::TextureFormat tf;
|
||||
tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT;
|
||||
tf.width = p_width;
|
||||
tf.height = p_height;
|
||||
tf.type = RD::TEXTURE_TYPE_2D;
|
||||
tf.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT;
|
||||
|
||||
RD::TextureSamples ts[RS::VIEWPORT_MSAA_MAX] = {
|
||||
RD::TEXTURE_SAMPLES_1,
|
||||
RD::TEXTURE_SAMPLES_2,
|
||||
RD::TEXTURE_SAMPLES_4,
|
||||
RD::TEXTURE_SAMPLES_8,
|
||||
RD::TEXTURE_SAMPLES_16
|
||||
};
|
||||
|
||||
texture_samples = ts[p_msaa];
|
||||
tf.samples = texture_samples;
|
||||
|
||||
color_msaa = RD::get_singleton()->texture_create(tf, RD::TextureView());
|
||||
|
||||
tf.format = RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_D24_UNORM_S8_UINT, RD::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) ? RD::DATA_FORMAT_D24_UNORM_S8_UINT : RD::DATA_FORMAT_D32_SFLOAT_S8_UINT;
|
||||
tf.usage_bits = RD::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT;
|
||||
|
||||
depth_msaa = RD::get_singleton()->texture_create(tf, RD::TextureView());
|
||||
|
||||
{
|
||||
Vector<RID> fb;
|
||||
fb.push_back(color_msaa);
|
||||
fb.push_back(depth_msaa);
|
||||
|
||||
color_fb = RD::get_singleton()->framebuffer_create(fb);
|
||||
}
|
||||
{
|
||||
Vector<RID> fb;
|
||||
fb.push_back(depth_msaa);
|
||||
|
||||
depth_fb = RD::get_singleton()->framebuffer_create(fb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -613,13 +712,31 @@ void RasterizerSceneHighEndRD::_allocate_normal_texture(RenderBufferDataHighEnd
|
|||
tf.format = RD::DATA_FORMAT_A2B10G10R10_UNORM_PACK32;
|
||||
tf.width = rb->width;
|
||||
tf.height = rb->height;
|
||||
tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT;
|
||||
|
||||
if (rb->msaa != RS::VIEWPORT_MSAA_DISABLED) {
|
||||
tf.usage_bits |= RD::TEXTURE_USAGE_CAN_COPY_TO_BIT;
|
||||
} else {
|
||||
tf.usage_bits |= RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
}
|
||||
|
||||
rb->normal_buffer = RD::get_singleton()->texture_create(tf, RD::TextureView());
|
||||
Vector<RID> fb;
|
||||
fb.push_back(rb->depth);
|
||||
fb.push_back(rb->normal_buffer);
|
||||
rb->depth_normal_fb = RD::get_singleton()->framebuffer_create(fb);
|
||||
|
||||
if (rb->msaa == RS::VIEWPORT_MSAA_DISABLED) {
|
||||
Vector<RID> fb;
|
||||
fb.push_back(rb->depth);
|
||||
fb.push_back(rb->normal_buffer);
|
||||
rb->depth_normal_fb = RD::get_singleton()->framebuffer_create(fb);
|
||||
} else {
|
||||
tf.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT;
|
||||
tf.samples = rb->texture_samples;
|
||||
rb->normal_buffer_msaa = RD::get_singleton()->texture_create(tf, RD::TextureView());
|
||||
|
||||
Vector<RID> fb;
|
||||
fb.push_back(rb->depth_msaa);
|
||||
fb.push_back(rb->normal_buffer_msaa);
|
||||
rb->depth_normal_fb = RD::get_singleton()->framebuffer_create(fb);
|
||||
}
|
||||
|
||||
_render_buffers_clear_uniform_set(rb);
|
||||
}
|
||||
|
@ -638,12 +755,32 @@ void RasterizerSceneHighEndRD::_allocate_roughness_texture(RenderBufferDataHighE
|
|||
tf.height = rb->height;
|
||||
tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
|
||||
if (rb->msaa != RS::VIEWPORT_MSAA_DISABLED) {
|
||||
tf.usage_bits |= RD::TEXTURE_USAGE_CAN_COPY_TO_BIT;
|
||||
} else {
|
||||
tf.usage_bits |= RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
}
|
||||
|
||||
rb->roughness_buffer = RD::get_singleton()->texture_create(tf, RD::TextureView());
|
||||
Vector<RID> fb;
|
||||
fb.push_back(rb->depth);
|
||||
fb.push_back(rb->normal_buffer);
|
||||
fb.push_back(rb->roughness_buffer);
|
||||
rb->depth_normal_roughness_fb = RD::get_singleton()->framebuffer_create(fb);
|
||||
|
||||
if (rb->msaa == RS::VIEWPORT_MSAA_DISABLED) {
|
||||
|
||||
Vector<RID> fb;
|
||||
fb.push_back(rb->depth);
|
||||
fb.push_back(rb->normal_buffer);
|
||||
fb.push_back(rb->roughness_buffer);
|
||||
rb->depth_normal_roughness_fb = RD::get_singleton()->framebuffer_create(fb);
|
||||
} else {
|
||||
tf.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_CAN_COPY_FROM_BIT;
|
||||
tf.samples = rb->texture_samples;
|
||||
rb->roughness_buffer_msaa = RD::get_singleton()->texture_create(tf, RD::TextureView());
|
||||
|
||||
Vector<RID> fb;
|
||||
fb.push_back(rb->depth_msaa);
|
||||
fb.push_back(rb->normal_buffer_msaa);
|
||||
fb.push_back(rb->roughness_buffer_msaa);
|
||||
rb->depth_normal_roughness_fb = RD::get_singleton()->framebuffer_create(fb);
|
||||
}
|
||||
|
||||
_render_buffers_clear_uniform_set(rb);
|
||||
}
|
||||
|
@ -1777,27 +1914,6 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
|
|||
render_pass++;
|
||||
|
||||
//fill up ubo
|
||||
#if 0
|
||||
storage->info.render.object_count += p_cull_count;
|
||||
|
||||
Environment *env = environment_owner.getornull(p_environment);
|
||||
ShadowAtlas *shadow_atlas = shadow_atlas_owner.getornull(p_shadow_atlas);
|
||||
ReflectionAtlas *reflection_atlas = reflection_atlas_owner.getornull(p_reflection_atlas);
|
||||
|
||||
if (shadow_atlas && shadow_atlas->size) {
|
||||
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 5);
|
||||
glBindTexture(GL_TEXTURE_2D, shadow_atlas->depth);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LESS);
|
||||
scene_state.ubo.shadow_atlas_pixel_size[0] = 1.0 / shadow_atlas->size;
|
||||
scene_state.ubo.shadow_atlas_pixel_size[1] = 1.0 / shadow_atlas->size;
|
||||
}
|
||||
|
||||
if (reflection_atlas && reflection_atlas->size) {
|
||||
glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 3);
|
||||
glBindTexture(GL_TEXTURE_2D, reflection_atlas->color);
|
||||
}
|
||||
#endif
|
||||
|
||||
RENDER_TIMESTAMP("Setup 3D Scene");
|
||||
|
||||
|
@ -1837,6 +1953,7 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
|
|||
bool using_ssr = false;
|
||||
|
||||
if (render_buffer) {
|
||||
|
||||
screen_pixel_size.width = 1.0 / render_buffer->width;
|
||||
screen_pixel_size.height = 1.0 / render_buffer->height;
|
||||
screen_size.x = render_buffer->width;
|
||||
|
@ -1998,9 +2115,23 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
|
|||
if (depth_pre_pass) { //depth pre pass
|
||||
RENDER_TIMESTAMP("Render Depth Pre-Pass");
|
||||
|
||||
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(depth_framebuffer, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CLEAR, using_ssao ? RD::FINAL_ACTION_READ : RD::FINAL_ACTION_CONTINUE, depth_pass_clear);
|
||||
bool finish_depth = using_ssao;
|
||||
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(depth_framebuffer, RD::INITIAL_ACTION_CLEAR, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_CLEAR, finish_depth ? RD::FINAL_ACTION_READ : RD::FINAL_ACTION_CONTINUE, depth_pass_clear);
|
||||
_render_list(draw_list, RD::get_singleton()->framebuffer_get_format(depth_framebuffer), render_list.elements, render_list.element_count, false, depth_pass_mode, render_buffer == nullptr, radiance_uniform_set, RID());
|
||||
RD::get_singleton()->draw_list_end();
|
||||
|
||||
if (render_buffer && render_buffer->msaa != RS::VIEWPORT_MSAA_DISABLED) {
|
||||
if (finish_depth) {
|
||||
RD::get_singleton()->texture_resolve_multisample(render_buffer->depth_msaa, render_buffer->depth, true);
|
||||
}
|
||||
|
||||
if (depth_pass_mode == PASS_MODE_DEPTH_NORMAL || depth_pass_mode == PASS_MODE_DEPTH_NORMAL_ROUGHNESS) {
|
||||
RD::get_singleton()->texture_resolve_multisample(render_buffer->normal_buffer_msaa, render_buffer->normal_buffer, true);
|
||||
if (depth_pass_mode == PASS_MODE_DEPTH_NORMAL_ROUGHNESS) {
|
||||
RD::get_singleton()->texture_resolve_multisample(render_buffer->roughness_buffer_msaa, render_buffer->roughness_buffer, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (using_ssao) {
|
||||
|
@ -2080,6 +2211,19 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
|
|||
_draw_sky(can_continue_color, can_continue_depth, opaque_framebuffer, p_environment, projection, p_cam_transform);
|
||||
}
|
||||
|
||||
if (render_buffer && !can_continue_color && render_buffer->msaa != RS::VIEWPORT_MSAA_DISABLED) {
|
||||
|
||||
RD::get_singleton()->texture_resolve_multisample(render_buffer->color_msaa, render_buffer->color, true);
|
||||
if (using_separate_specular) {
|
||||
RD::get_singleton()->texture_resolve_multisample(render_buffer->specular_msaa, render_buffer->specular, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (render_buffer && !can_continue_depth && render_buffer->msaa != RS::VIEWPORT_MSAA_DISABLED) {
|
||||
|
||||
RD::get_singleton()->texture_resolve_multisample(render_buffer->depth_msaa, render_buffer->depth, true);
|
||||
}
|
||||
|
||||
if (using_separate_specular) {
|
||||
|
||||
if (using_sss) {
|
||||
|
@ -2089,11 +2233,11 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
|
|||
|
||||
if (using_ssr) {
|
||||
RENDER_TIMESTAMP("Screen Space Reflection");
|
||||
_process_ssr(p_render_buffer, render_buffer->color_fb, render_buffer->normal_buffer, render_buffer->roughness_buffer, render_buffer->specular, render_buffer->specular, Color(0, 0, 0, 1), p_environment, p_cam_projection, true);
|
||||
_process_ssr(p_render_buffer, render_buffer->color_fb, render_buffer->normal_buffer, render_buffer->roughness_buffer, render_buffer->specular, render_buffer->specular, Color(0, 0, 0, 1), p_environment, p_cam_projection, render_buffer->msaa == RS::VIEWPORT_MSAA_DISABLED);
|
||||
} else {
|
||||
//just mix specular back
|
||||
RENDER_TIMESTAMP("Merge Specular");
|
||||
storage->get_effects()->merge_specular(render_buffer->color_fb, render_buffer->specular, RID(), RID());
|
||||
storage->get_effects()->merge_specular(render_buffer->color_fb, render_buffer->specular, render_buffer->msaa == RS::VIEWPORT_MSAA_DISABLED ? RID() : render_buffer->color, RID());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2111,77 +2255,12 @@ void RasterizerSceneHighEndRD::_render_scene(RID p_render_buffer, const Transfor
|
|||
RD::get_singleton()->draw_list_end();
|
||||
}
|
||||
|
||||
//_render_list
|
||||
#if 0
|
||||
if (state.directional_light_count == 0) {
|
||||
directional_light = nullptr;
|
||||
_render_list(&render_list.elements[render_list.max_elements - render_list.alpha_element_count], render_list.alpha_element_count, p_cam_transform, p_cam_projection, env_radiance_tex, false, true, false, false, shadow_atlas != nullptr);
|
||||
} else {
|
||||
for (int i = 0; i < state.directional_light_count; i++) {
|
||||
directional_light = directional_lights[i];
|
||||
_setup_directional_light(i, p_cam_transform.affine_inverse(), shadow_atlas != nullptr && shadow_atlas->size > 0);
|
||||
_render_list(&render_list.elements[render_list.max_elements - render_list.alpha_element_count], render_list.alpha_element_count, p_cam_transform, p_cam_projection, env_radiance_tex, false, true, false, i > 0, shadow_atlas != nullptr);
|
||||
}
|
||||
if (render_buffer && render_buffer->msaa != RS::VIEWPORT_MSAA_DISABLED) {
|
||||
|
||||
RD::get_singleton()->texture_resolve_multisample(render_buffer->color_msaa, render_buffer->color, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
_post_process(env, p_cam_projection);
|
||||
// Needed only for debugging
|
||||
/* if (shadow_atlas && storage->frame.current_rt) {
|
||||
|
||||
//_copy_texture_to_front_buffer(shadow_atlas->depth);
|
||||
storage->canvas->canvas_begin();
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, shadow_atlas->depth);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE);
|
||||
storage->canvas->draw_generic_textured_rect(Rect2(0, 0, storage->frame.current_rt->width / 2, storage->frame.current_rt->height / 2), Rect2(0, 0, 1, 1));
|
||||
}
|
||||
|
||||
if (storage->frame.current_rt) {
|
||||
|
||||
//_copy_texture_to_front_buffer(shadow_atlas->depth);
|
||||
storage->canvas->canvas_begin();
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, exposure_shrink[4].color);
|
||||
//glBindTexture(GL_TEXTURE_2D,storage->frame.current_rt->exposure.color);
|
||||
storage->canvas->draw_generic_textured_rect(Rect2(0, 0, storage->frame.current_rt->width / 16, storage->frame.current_rt->height / 16), Rect2(0, 0, 1, 1));
|
||||
}
|
||||
|
||||
if (reflection_atlas && storage->frame.current_rt) {
|
||||
|
||||
//_copy_texture_to_front_buffer(shadow_atlas->depth);
|
||||
storage->canvas->canvas_begin();
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, reflection_atlas->color);
|
||||
storage->canvas->draw_generic_textured_rect(Rect2(0, 0, storage->frame.current_rt->width / 2, storage->frame.current_rt->height / 2), Rect2(0, 0, 1, 1));
|
||||
}
|
||||
|
||||
if (directional_shadow.fbo) {
|
||||
|
||||
//_copy_texture_to_front_buffer(shadow_atlas->depth);
|
||||
storage->canvas->canvas_begin();
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, directional_shadow.depth);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE);
|
||||
storage->canvas->draw_generic_textured_rect(Rect2(0, 0, storage->frame.current_rt->width / 2, storage->frame.current_rt->height / 2), Rect2(0, 0, 1, 1));
|
||||
}
|
||||
|
||||
if ( env_radiance_tex) {
|
||||
|
||||
//_copy_texture_to_front_buffer(shadow_atlas->depth);
|
||||
storage->canvas->canvas_begin();
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, env_radiance_tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
storage->canvas->draw_generic_textured_rect(Rect2(0, 0, storage->frame.current_rt->width / 2, storage->frame.current_rt->height / 2), Rect2(0, 0, 1, 1));
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
}*/
|
||||
//disable all stuff
|
||||
#endif
|
||||
}
|
||||
|
||||
void RasterizerSceneHighEndRD::_render_shadow(RID p_framebuffer, InstanceBase **p_cull_result, int p_cull_count, const CameraMatrix &p_projection, const Transform &p_transform, float p_zfar, float p_bias, float p_normal_bias, bool p_use_dp, bool p_use_dp_flip, bool p_use_pancake) {
|
||||
|
||||
RENDER_TIMESTAMP("Setup Rendering Shadow");
|
||||
|
|
|
@ -198,11 +198,22 @@ class RasterizerSceneHighEndRD : public RasterizerSceneRD {
|
|||
|
||||
struct RenderBufferDataHighEnd : public RenderBufferData {
|
||||
//for rendering, may be MSAAd
|
||||
|
||||
RID color;
|
||||
RID depth;
|
||||
RID specular;
|
||||
RID normal_buffer;
|
||||
RID roughness_buffer;
|
||||
|
||||
RS::ViewportMSAA msaa;
|
||||
RD::TextureSamples texture_samples;
|
||||
|
||||
RID color_msaa;
|
||||
RID depth_msaa;
|
||||
RID specular_msaa;
|
||||
RID normal_buffer_msaa;
|
||||
RID roughness_buffer_msaa;
|
||||
|
||||
RID depth_fb;
|
||||
RID depth_normal_fb;
|
||||
RID depth_normal_roughness_fb;
|
||||
|
|
|
@ -3538,7 +3538,12 @@ void RasterizerSceneRD::render_buffers_configure(RID p_render_buffers, RID p_ren
|
|||
tf.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT;
|
||||
tf.width = rb->width;
|
||||
tf.height = rb->height;
|
||||
tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT;
|
||||
if (rb->msaa != RS::VIEWPORT_MSAA_DISABLED) {
|
||||
tf.usage_bits |= RD::TEXTURE_USAGE_CAN_COPY_TO_BIT;
|
||||
} else {
|
||||
tf.usage_bits |= RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
}
|
||||
|
||||
rb->texture = RD::get_singleton()->texture_create(tf, RD::TextureView());
|
||||
}
|
||||
|
@ -3549,6 +3554,9 @@ void RasterizerSceneRD::render_buffers_configure(RID p_render_buffers, RID p_ren
|
|||
tf.width = p_width;
|
||||
tf.height = p_height;
|
||||
tf.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
if (rb->msaa != RS::VIEWPORT_MSAA_DISABLED) {
|
||||
tf.usage_bits |= RD::TEXTURE_USAGE_CAN_COPY_TO_BIT;
|
||||
}
|
||||
|
||||
rb->depth_texture = RD::get_singleton()->texture_create(tf, RD::TextureView());
|
||||
}
|
||||
|
@ -4132,11 +4140,11 @@ RasterizerSceneRD::RasterizerSceneRD(RasterizerStorageRD *p_storage) {
|
|||
sky_scene_state.sampler_uniform_set = RD::get_singleton()->uniform_set_create(uniforms, sky_shader.default_shader_rd, SKY_SET_SAMPLERS);
|
||||
}
|
||||
|
||||
camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_shape"))));
|
||||
camera_effects_set_dof_blur_quality(RS::DOFBlurQuality(int(GLOBAL_GET("rendering/quality/filters/depth_of_field_bokeh_quality"))), GLOBAL_GET("rendering/quality/filters/depth_of_field_use_jitter"));
|
||||
camera_effects_set_dof_blur_bokeh_shape(RS::DOFBokehShape(int(GLOBAL_GET("rendering/quality/depth_of_field/depth_of_field_bokeh_shape"))));
|
||||
camera_effects_set_dof_blur_quality(RS::DOFBlurQuality(int(GLOBAL_GET("rendering/quality/depth_of_field/depth_of_field_bokeh_quality"))), GLOBAL_GET("rendering/quality/depth_of_field/depth_of_field_use_jitter"));
|
||||
environment_set_ssao_quality(RS::EnvironmentSSAOQuality(int(GLOBAL_GET("rendering/quality/ssao/quality"))), GLOBAL_GET("rendering/quality/ssao/half_size"));
|
||||
screen_space_roughness_limiter = GLOBAL_GET("rendering/quality/filters/screen_space_roughness_limiter");
|
||||
screen_space_roughness_limiter_curve = GLOBAL_GET("rendering/quality/filters/screen_space_roughness_limiter_curve");
|
||||
screen_space_roughness_limiter = GLOBAL_GET("rendering/quality/screen_filters/screen_space_roughness_limiter");
|
||||
screen_space_roughness_limiter_curve = GLOBAL_GET("rendering/quality/screen_filters/screen_space_roughness_limiter_curve");
|
||||
glow_bicubic_upscale = int(GLOBAL_GET("rendering/quality/glow/upscale_mode")) > 0;
|
||||
ssr_roughness_quality = RS::EnvironmentSSRRoughnessQuality(int(GLOBAL_GET("rendering/quality/screen_space_reflection/roughness_quality")));
|
||||
sss_quality = RS::SubSurfaceScatteringQuality(int(GLOBAL_GET("rendering/quality/subsurface_scattering/subsurface_scattering_quality")));
|
||||
|
|
|
@ -4637,14 +4637,14 @@ RasterizerStorageRD::RasterizerStorageRD() {
|
|||
sampler_state.min_filter = RD::SAMPLER_FILTER_LINEAR;
|
||||
sampler_state.mip_filter = RD::SAMPLER_FILTER_LINEAR;
|
||||
sampler_state.use_anisotropy = true;
|
||||
sampler_state.anisotropy_max = GLOBAL_GET("rendering/quality/filters/max_anisotropy");
|
||||
sampler_state.anisotropy_max = GLOBAL_GET("rendering/quality/texture_filters/max_anisotropy");
|
||||
} break;
|
||||
case RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC: {
|
||||
sampler_state.mag_filter = RD::SAMPLER_FILTER_LINEAR;
|
||||
sampler_state.min_filter = RD::SAMPLER_FILTER_LINEAR;
|
||||
sampler_state.mip_filter = RD::SAMPLER_FILTER_LINEAR;
|
||||
sampler_state.use_anisotropy = true;
|
||||
sampler_state.anisotropy_max = GLOBAL_GET("rendering/quality/filters/max_anisotropy");
|
||||
sampler_state.anisotropy_max = GLOBAL_GET("rendering/quality/texture_filters/max_anisotropy");
|
||||
|
||||
} break;
|
||||
default: {
|
||||
|
|
|
@ -976,6 +976,8 @@ void light_process_omni(uint idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 a
|
|||
#ifdef LIGHT_TRANSMITTANCE_USED
|
||||
{
|
||||
|
||||
vec4 clamp_rect = lights.data[idx].atlas_rect;
|
||||
|
||||
//redo shadowmapping, but shrink the model a bit to avoid arctifacts
|
||||
splane = (lights.data[idx].shadow_matrix * vec4(vertex - normalize(normal_interp) * lights.data[idx].transmittance_bias, 1.0));
|
||||
|
||||
|
|
|
@ -428,6 +428,7 @@ public:
|
|||
|
||||
virtual Error texture_copy(RID p_from_texture, RID p_to_texture, const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_size, uint32_t p_src_mipmap, uint32_t p_dst_mipmap, uint32_t p_src_layer, uint32_t p_dst_layer, bool p_sync_with_draw = false) = 0;
|
||||
virtual Error texture_clear(RID p_texture, const Color &p_color, uint32_t p_base_mipmap, uint32_t p_mipmaps, uint32_t p_base_layer, uint32_t p_layers, bool p_sync_with_draw = false) = 0;
|
||||
virtual Error texture_resolve_multisample(RID p_from_texture, RID p_to_texture, bool p_sync_with_draw = false) = 0;
|
||||
|
||||
/*********************/
|
||||
/**** FRAMEBUFFER ****/
|
||||
|
|
|
@ -2071,8 +2071,6 @@ void RenderingServer::_bind_methods() {
|
|||
BIND_ENUM_CONSTANT(VIEWPORT_MSAA_4X);
|
||||
BIND_ENUM_CONSTANT(VIEWPORT_MSAA_8X);
|
||||
BIND_ENUM_CONSTANT(VIEWPORT_MSAA_16X);
|
||||
BIND_ENUM_CONSTANT(VIEWPORT_MSAA_EXT_2X);
|
||||
BIND_ENUM_CONSTANT(VIEWPORT_MSAA_EXT_4X);
|
||||
|
||||
BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_OBJECTS_IN_FRAME);
|
||||
BIND_ENUM_CONSTANT(VIEWPORT_RENDER_INFO_VERTICES_IN_FRAME);
|
||||
|
@ -2337,23 +2335,23 @@ RenderingServer::RenderingServer() {
|
|||
GLOBAL_DEF("rendering/quality/depth_prepass/enable", true);
|
||||
GLOBAL_DEF("rendering/quality/depth_prepass/disable_for_vendors", "PowerVR,Mali,Adreno,Apple");
|
||||
|
||||
GLOBAL_DEF("rendering/quality/filters/use_nearest_mipmap_filter", false);
|
||||
GLOBAL_DEF("rendering/quality/filters/max_anisotropy", 4);
|
||||
GLOBAL_DEF("rendering/quality/texture_filters/use_nearest_mipmap_filter", false);
|
||||
GLOBAL_DEF("rendering/quality/texture_filters/max_anisotropy", 4);
|
||||
|
||||
GLOBAL_DEF("rendering/quality/filters/depth_of_field_bokeh_shape", 1);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/filters/depth_of_field_bokeh_shape", PropertyInfo(Variant::INT, "rendering/quality/filters/depth_of_field_bokeh_shape", PROPERTY_HINT_ENUM, "Box (Fast),Hexagon (Average),Circle (Slow)"));
|
||||
GLOBAL_DEF("rendering/quality/filters/depth_of_field_bokeh_quality", 2);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/filters/depth_of_field_bokeh_quality", PropertyInfo(Variant::INT, "rendering/quality/filters/depth_of_field_bokeh_quality", PROPERTY_HINT_ENUM, "Very Low (Fastest),Low (Fast),Medium (Average),High (Slow)"));
|
||||
GLOBAL_DEF("rendering/quality/filters/depth_of_field_use_jitter", false);
|
||||
GLOBAL_DEF("rendering/quality/depth_of_field/depth_of_field_bokeh_shape", 1);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/depth_of_field/depth_of_field_bokeh_shape", PropertyInfo(Variant::INT, "rendering/quality/depth_of_field/depth_of_field_bokeh_shape", PROPERTY_HINT_ENUM, "Box (Fast),Hexagon (Average),Circle (Slow)"));
|
||||
GLOBAL_DEF("rendering/quality/depth_of_field/depth_of_field_bokeh_quality", 2);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/depth_of_field/depth_of_field_bokeh_quality", PropertyInfo(Variant::INT, "rendering/quality/depth_of_field/depth_of_field_bokeh_quality", PROPERTY_HINT_ENUM, "Very Low (Fastest),Low (Fast),Medium (Average),High (Slow)"));
|
||||
GLOBAL_DEF("rendering/quality/depth_of_field/depth_of_field_use_jitter", false);
|
||||
|
||||
GLOBAL_DEF("rendering/quality/ssao/quality", 1);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/ssao/quality", PropertyInfo(Variant::INT, "rendering/quality/ssao/quality", PROPERTY_HINT_ENUM, "Low (Fast),Medium (Average),High (Slow),Ultra (Slower)"));
|
||||
GLOBAL_DEF("rendering/quality/ssao/half_size", false);
|
||||
|
||||
GLOBAL_DEF("rendering/quality/filters/screen_space_roughness_limiter", 0);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/filters/screen_space_roughness_limiter", PropertyInfo(Variant::INT, "rendering/quality/filters/screen_space_roughness_limiter", PROPERTY_HINT_ENUM, "Disabled (Fast),Enabled (Average)"));
|
||||
GLOBAL_DEF("rendering/quality/filters/screen_space_roughness_limiter_curve", 1.0);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/filters/screen_space_roughness_limiter_curve", PropertyInfo(Variant::FLOAT, "rendering/quality/filters/screen_space_roughness_limiter_curve", PROPERTY_HINT_EXP_EASING, "0.01,8,0.01"));
|
||||
GLOBAL_DEF("rendering/quality/screen_filters/screen_space_roughness_limiter", 0);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/screen_filters/screen_space_roughness_limiter", PropertyInfo(Variant::INT, "rendering/quality/screen_filters/screen_space_roughness_limiter", PROPERTY_HINT_ENUM, "Disabled (Fast),Enabled (Average)"));
|
||||
GLOBAL_DEF("rendering/quality/screen_filters/screen_space_roughness_limiter_curve", 1.0);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/screen_filters/screen_space_roughness_limiter_curve", PropertyInfo(Variant::FLOAT, "rendering/quality/screen_filters/screen_space_roughness_limiter_curve", PROPERTY_HINT_EXP_EASING, "0.01,8,0.01"));
|
||||
|
||||
GLOBAL_DEF("rendering/quality/glow/upscale_mode", 1);
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/glow/upscale_mode", PropertyInfo(Variant::INT, "rendering/quality/glow/upscale_mode", PROPERTY_HINT_ENUM, "Linear (Fast),Bicubic (Slow)"));
|
||||
|
|
|
@ -633,8 +633,7 @@ public:
|
|||
VIEWPORT_MSAA_4X,
|
||||
VIEWPORT_MSAA_8X,
|
||||
VIEWPORT_MSAA_16X,
|
||||
VIEWPORT_MSAA_EXT_2X,
|
||||
VIEWPORT_MSAA_EXT_4X,
|
||||
VIEWPORT_MSAA_MAX,
|
||||
};
|
||||
|
||||
virtual void viewport_set_msaa(RID p_viewport, ViewportMSAA p_msaa) = 0;
|
||||
|
|
Loading…
Reference in a new issue