diff options
-rw-r--r-- | editor/import/resource_importer_texture.cpp | 1 | ||||
-rw-r--r-- | servers/visual/rasterizer/rasterizer.h | 2 | ||||
-rw-r--r-- | servers/visual/rasterizer/rasterizer_canvas_rd.cpp | 26 | ||||
-rw-r--r-- | servers/visual/rasterizer/rasterizer_canvas_rd.h | 28 | ||||
-rw-r--r-- | servers/visual/rasterizer/shaders/canvas.glsl | 11 | ||||
-rw-r--r-- | servers/visual/rasterizer/shaders/canvas_uniforms_inc.glsl | 14 | ||||
-rw-r--r-- | servers/visual/visual_server_canvas.h | 1 |
7 files changed, 57 insertions, 26 deletions
diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index f1da5af31c..1c373fbcf2 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -213,6 +213,7 @@ void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options, r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/fix_alpha_border"), p_preset != PRESET_3D)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/premult_alpha"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/invert_color"), false)); + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/HDR_as_SRGB"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "stream"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "size_limit", PROPERTY_HINT_RANGE, "0,4096,1"), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "detect_3d"), p_preset == PRESET_DETECT)); diff --git a/servers/visual/rasterizer/rasterizer.h b/servers/visual/rasterizer/rasterizer.h index 215845d3b7..5f92ffe515 100644 --- a/servers/visual/rasterizer/rasterizer.h +++ b/servers/visual/rasterizer/rasterizer.h @@ -872,6 +872,7 @@ public: bool update_when_visible; //VS::MaterialBlendMode blend_mode; int light_mask; + int z_final; Vector<Command *> commands; mutable bool custom_rect; mutable bool rect_dirty; @@ -1032,6 +1033,7 @@ public: distance_field = false; light_masked = false; update_when_visible = false; + z_final = 0; } virtual ~Item() { clear(); diff --git a/servers/visual/rasterizer/rasterizer_canvas_rd.cpp b/servers/visual/rasterizer/rasterizer_canvas_rd.cpp index 92136c7f9a..4d6910af32 100644 --- a/servers/visual/rasterizer/rasterizer_canvas_rd.cpp +++ b/servers/visual/rasterizer/rasterizer_canvas_rd.cpp @@ -512,9 +512,10 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_ push_constant.specular_shininess = 0xFFFFFFFF; push_constant.color_texture_pixel_size[0] = 0; push_constant.color_texture_pixel_size[1] = 0; - push_constant.pad[0] = 0; + push_constant.pad[1] = 0; push_constant.pad[2] = 0; + push_constant.pad[3] = 0; PipelineVariants *pipeline_variants = &shader.pipeline_variants; @@ -760,7 +761,9 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_ _bind_texture_binding(primitive->texture_binding.binding_id, p_draw_list); } - for (uint32_t j = 0; j < primitive->point_count; j++) { + RD::get_singleton()->draw_list_bind_index_array(p_draw_list, primitive_arrays.index_array[MIN(3, primitive->point_count) - 1]); + + for (uint32_t j = 0; j < MIN(3, primitive->point_count); j++) { push_constant.points[j * 2 + 0] = primitive->points[j].x; push_constant.points[j * 2 + 1] = primitive->points[j].y; push_constant.uvs[j * 2 + 0] = primitive->uvs[j].x; @@ -770,10 +773,23 @@ void RasterizerCanvasRD::_render_item(RD::DrawListID p_draw_list, const Item *p_ push_constant.colors[j * 2 + 1] = (uint32_t(Math::make_half_float(col.a)) << 16) | Math::make_half_float(col.b); } RD::get_singleton()->draw_list_set_push_constant(p_draw_list, &push_constant, sizeof(PushConstant)); + RD::get_singleton()->draw_list_draw(p_draw_list, true); - RD::get_singleton()->draw_list_bind_index_array(p_draw_list, primitive_arrays.index_array[primitive->point_count - 1]); + if (primitive->point_count == 4) { + for (uint32_t j = 1; j < 3; j++) { + //second half of triangle + push_constant.points[j * 2 + 0] = primitive->points[j + 1].x; + push_constant.points[j * 2 + 1] = primitive->points[j + 1].y; + push_constant.uvs[j * 2 + 0] = primitive->uvs[j + 1].x; + push_constant.uvs[j * 2 + 1] = primitive->uvs[j + 1].y; + Color col = primitive->colors[j + 1] * p_modulate; + push_constant.colors[j * 2 + 0] = (uint32_t(Math::make_half_float(col.g)) << 16) | Math::make_half_float(col.r); + push_constant.colors[j * 2 + 1] = (uint32_t(Math::make_half_float(col.a)) << 16) | Math::make_half_float(col.b); + } - RD::get_singleton()->draw_list_draw(p_draw_list, true); + RD::get_singleton()->draw_list_set_push_constant(p_draw_list, &push_constant, sizeof(PushConstant)); + RD::get_singleton()->draw_list_draw(p_draw_list, true); + } } break; @@ -1364,7 +1380,7 @@ RasterizerCanvasRD::RasterizerCanvasRD(RasterizerStorageRD *p_storage) { RD::AttachmentFormat af; af.format = RD::DATA_FORMAT_R8G8B8A8_UNORM; af.samples = RD::TEXTURE_SAMPLES_1; - af.usage_flags = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT; + af.usage_flags = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_RETRIEVE_BIT; Vector<RD::AttachmentFormat> formats; formats.push_back(af); shader.framebuffer_formats[RENDER_TARGET_FORMAT_8_BIT_INT] = RD::get_singleton()->framebuffer_format_create(formats); diff --git a/servers/visual/rasterizer/rasterizer_canvas_rd.h b/servers/visual/rasterizer/rasterizer_canvas_rd.h index 911a3b6225..91870a20fd 100644 --- a/servers/visual/rasterizer/rasterizer_canvas_rd.h +++ b/servers/visual/rasterizer/rasterizer_canvas_rd.h @@ -179,6 +179,23 @@ class RasterizerCanvasRD : public RasterizerCanvas { /**** MATERIALS ****/ /*******************/ + /******************/ + /**** LIGHTING ****/ + /******************/ + + enum { + LIGHT_GRID_WIDTH = 16, + LIGHT_GRID_HEIGHT = 16, + MAX_LIGHTS = 128 + }; + + struct { + RID grid_texture; + RID grid_buffer; + PoolVector<uint8_t> grid_texture_data; + PoolVector<uint8_t> grid_buffer_data; + } lighting; + /***************/ /**** STATE ****/ /***************/ @@ -213,16 +230,17 @@ class RasterizerCanvasRD : public RasterizerCanvas { float ninepatch_margins[4]; float dst_rect[4]; float src_rect[4]; - float color_texture_pixel_size[2]; - uint32_t pad[6]; + float pad[2]; }; //primitive struct { - float points[8]; // vec2 points[4] - uint32_t colors[8]; // colors encoded as half - float uvs[8]; // vec2 points[4] + float points[6]; // vec2 points[4] + float uvs[6]; // vec2 points[4] + uint32_t colors[6]; // colors encoded as half }; }; + float color_texture_pixel_size[2]; + uint32_t lights[4]; }; struct SkeletonUniform { diff --git a/servers/visual/rasterizer/shaders/canvas.glsl b/servers/visual/rasterizer/shaders/canvas.glsl index 50782f99b0..734974ba81 100644 --- a/servers/visual/rasterizer/shaders/canvas.glsl +++ b/servers/visual/rasterizer/shaders/canvas.glsl @@ -59,20 +59,11 @@ void main() { vertex = draw_data.points[1]; uv = draw_data.uvs[1]; color = vec4(unpackHalf2x16(draw_data.colors[2]),unpackHalf2x16(draw_data.colors[3])); - } else if (gl_VertexIndex==2) { + } else { vertex = draw_data.points[2]; uv = draw_data.uvs[2]; color = vec4(unpackHalf2x16(draw_data.colors[4]),unpackHalf2x16(draw_data.colors[5])); - - } else { - vertex = draw_data.points[3]; - uv = draw_data.uvs[3]; - color = vec4(unpackHalf2x16(draw_data.colors[6]),unpackHalf2x16(draw_data.colors[7])); } -// this does not -// vec2 vertex = draw_data.points[gl_VertexIndex]; -// vec2 uv = draw_data.uvs[gl_VertexIndex]; -// vec4 color = vec4(unpackHalf2x16(draw_data.colors[gl_VertexIndex*2+0]),unpackHalf2x16(draw_data.colors[gl_VertexIndex*2+1])); uvec4 bone_indices = uvec4(0,0,0,0); vec4 bone_weights = vec4(0,0,0,0); diff --git a/servers/visual/rasterizer/shaders/canvas_uniforms_inc.glsl b/servers/visual/rasterizer/shaders/canvas_uniforms_inc.glsl index e0f9e202ae..e205170292 100644 --- a/servers/visual/rasterizer/shaders/canvas_uniforms_inc.glsl +++ b/servers/visual/rasterizer/shaders/canvas_uniforms_inc.glsl @@ -21,6 +21,8 @@ #define FLAGS_NINEPATCH_H_MODE_SHIFT 16 #define FLAGS_NINEPATCH_V_MODE_SHIFT 18 +#define FLAGS_LIGHT_COUNT_SHIFT 20 + layout(push_constant, binding = 0, std430) uniform DrawData { vec2 world_x; vec2 world_y; @@ -28,17 +30,19 @@ layout(push_constant, binding = 0, std430) uniform DrawData { uint flags; uint specular_shininess; #ifdef USE_PRIMITIVE - vec2 points[4]; - uint colors[8]; - vec2 uvs[4]; + vec2 points[3]; + vec2 uvs[3]; + uint colors[6]; #else vec4 modulation; vec4 ninepatch_margins; vec4 dst_rect; //for built-in rect and UV vec4 src_rect; - vec2 color_texture_pixel_size; - uint pad[6]; + vec2 pad; + #endif + vec2 color_texture_pixel_size; + uint lights[4]; } draw_data; diff --git a/servers/visual/visual_server_canvas.h b/servers/visual/visual_server_canvas.h index b18e3aaace..1f8d0bba59 100644 --- a/servers/visual/visual_server_canvas.h +++ b/servers/visual/visual_server_canvas.h @@ -54,7 +54,6 @@ public: Vector2 ysort_pos; VS::CanvasItemTextureFilter texture_filter; VS::CanvasItemTextureRepeat texture_repeat; - int z_final; Vector<Item *> child_items; |