diff options
Diffstat (limited to 'servers/rendering')
-rw-r--r-- | servers/rendering/rasterizer_rd/rasterizer_canvas_rd.cpp | 20 | ||||
-rw-r--r-- | servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp | 14 | ||||
-rw-r--r-- | servers/rendering/rasterizer_rd/shader_compiler_rd.cpp | 15 | ||||
-rw-r--r-- | servers/rendering/rasterizer_rd/shaders/specular_merge.glsl | 4 | ||||
-rw-r--r-- | servers/rendering/rendering_device.cpp | 24 | ||||
-rw-r--r-- | servers/rendering/rendering_device.h | 19 | ||||
-rw-r--r-- | servers/rendering/rendering_device_binds.h | 97 | ||||
-rw-r--r-- | servers/rendering/rendering_server_scene.cpp | 19 | ||||
-rw-r--r-- | servers/rendering/shader_language.cpp | 3 | ||||
-rw-r--r-- | servers/rendering/shader_language.h | 2 |
10 files changed, 92 insertions, 125 deletions
diff --git a/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.cpp index 1a21fdb4d7..956bf54d01 100644 --- a/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.cpp +++ b/servers/rendering/rasterizer_rd/rasterizer_canvas_rd.cpp @@ -273,7 +273,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int Vector<uint8_t> polygon_buffer; polygon_buffer.resize(buffer_size * sizeof(float)); - Vector<RD::VertexDescription> descriptions; + Vector<RD::VertexAttribute> descriptions; descriptions.resize(4); Vector<RID> buffers; buffers.resize(4); @@ -284,7 +284,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int uint32_t *uptr = (uint32_t *)r; uint32_t base_offset = 0; { //vertices - RD::VertexDescription vd; + RD::VertexAttribute vd; vd.format = RD::DATA_FORMAT_R32G32_SFLOAT; vd.offset = base_offset * sizeof(float); vd.location = RS::ARRAY_VERTEX; @@ -304,7 +304,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int //colors if ((uint32_t)p_colors.size() == vertex_count || p_colors.size() == 1) { - RD::VertexDescription vd; + RD::VertexAttribute vd; vd.format = RD::DATA_FORMAT_R32G32B32A32_SFLOAT; vd.offset = base_offset * sizeof(float); vd.location = RS::ARRAY_COLOR; @@ -332,7 +332,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int } base_offset += 4; } else { - RD::VertexDescription vd; + RD::VertexAttribute vd; vd.format = RD::DATA_FORMAT_R32G32B32A32_SFLOAT; vd.offset = 0; vd.location = RS::ARRAY_COLOR; @@ -344,7 +344,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int //uvs if ((uint32_t)p_uvs.size() == vertex_count) { - RD::VertexDescription vd; + RD::VertexAttribute vd; vd.format = RD::DATA_FORMAT_R32G32_SFLOAT; vd.offset = base_offset * sizeof(float); vd.location = RS::ARRAY_TEX_UV; @@ -360,7 +360,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int } base_offset += 2; } else { - RD::VertexDescription vd; + RD::VertexAttribute vd; vd.format = RD::DATA_FORMAT_R32G32_SFLOAT; vd.offset = 0; vd.location = RS::ARRAY_TEX_UV; @@ -372,7 +372,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int //bones if ((uint32_t)p_indices.size() == vertex_count * 4 && (uint32_t)p_weights.size() == vertex_count * 4) { - RD::VertexDescription vd; + RD::VertexAttribute vd; vd.format = RD::DATA_FORMAT_R32G32B32A32_UINT; vd.offset = base_offset * sizeof(float); vd.location = RS::ARRAY_BONES; @@ -401,7 +401,7 @@ RasterizerCanvas::PolygonID RasterizerCanvasRD::request_polygon(const Vector<int base_offset += 4; } else { - RD::VertexDescription vd; + RD::VertexAttribute vd; vd.format = RD::DATA_FORMAT_R32G32B32A32_UINT; vd.offset = 0; vd.location = RS::ARRAY_BONES; @@ -2423,8 +2423,8 @@ RasterizerCanvasRD::RasterizerCanvasRD(RasterizerStorageRD *p_storage) { } //pipelines - Vector<RD::VertexDescription> vf; - RD::VertexDescription vd; + Vector<RD::VertexAttribute> vf; + RD::VertexAttribute vd; vd.format = RD::DATA_FORMAT_R32G32B32_SFLOAT; vd.location = 0; vd.offset = 0; diff --git a/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp index 97ef604dd2..c2bd41a746 100644 --- a/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp +++ b/servers/rendering/rasterizer_rd/rasterizer_storage_rd.cpp @@ -131,7 +131,6 @@ Ref<Image> RasterizerStorageRD::_validate_texture_format(const Ref<Image> &p_ima image->convert(Image::FORMAT_RGBAF); } - r_format.format = RD::DATA_FORMAT_R32G32B32A32_SFLOAT; r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R; r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G; r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B; @@ -171,7 +170,6 @@ Ref<Image> RasterizerStorageRD::_validate_texture_format(const Ref<Image> &p_ima image->convert(Image::FORMAT_RGBAH); } - r_format.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R; r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G; r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B; @@ -2341,14 +2339,14 @@ void RasterizerStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Su Mesh::Surface::Version &v = s->versions[version]; - Vector<RD::VertexDescription> attributes; + Vector<RD::VertexAttribute> attributes; Vector<RID> buffers; uint32_t stride = 0; for (int i = 0; i < RS::ARRAY_WEIGHTS; i++) { - RD::VertexDescription vd; + RD::VertexAttribute vd; RID buffer; vd.location = i; @@ -5063,10 +5061,10 @@ void RasterizerStorageRD::_global_variable_store_in_buffer(int32_t p_index, RS:: bv[2].z = v.basis.elements[2][2]; bv[2].w = 0; - bv[2].x = v.origin.x; - bv[2].y = v.origin.y; - bv[2].z = v.origin.z; - bv[2].w = 1; + bv[3].x = v.origin.x; + bv[3].y = v.origin.y; + bv[3].z = v.origin.z; + bv[3].w = 1; } break; default: { diff --git a/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp b/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp index 9cbff2571a..d4e6576125 100644 --- a/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp +++ b/servers/rendering/rasterizer_rd/shader_compiler_rd.cpp @@ -650,18 +650,19 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge index++; } - for (Map<StringName, SL::ShaderNode::Constant>::Element *E = pnode->constants.front(); E; E = E->next()) { + for (int i = 0; i < pnode->vconstants.size(); i++) { + const SL::ShaderNode::Constant &cnode = pnode->vconstants[i]; String gcode; gcode += "const "; - gcode += _prestr(E->get().precision); - if (E->get().type == SL::TYPE_STRUCT) { - gcode += _mkid(E->get().type_str); + gcode += _prestr(cnode.precision); + if (cnode.type == SL::TYPE_STRUCT) { + gcode += _mkid(cnode.type_str); } else { - gcode += _typestr(E->get().type); + gcode += _typestr(cnode.type); } - gcode += " " + _mkid(E->key()); + gcode += " " + _mkid(String(cnode.name)); gcode += "="; - gcode += _dump_node_code(E->get().initializer, p_level, r_gen_code, p_actions, p_default_actions, p_assigning); + gcode += _dump_node_code(cnode.initializer, p_level, r_gen_code, p_actions, p_default_actions, p_assigning); gcode += ";\n"; r_gen_code.vertex_global += gcode; r_gen_code.fragment_global += gcode; diff --git a/servers/rendering/rasterizer_rd/shaders/specular_merge.glsl b/servers/rendering/rasterizer_rd/shaders/specular_merge.glsl index b28250318e..b24f7dccc7 100644 --- a/servers/rendering/rasterizer_rd/shaders/specular_merge.glsl +++ b/servers/rendering/rasterizer_rd/shaders/specular_merge.glsl @@ -48,8 +48,8 @@ void main() { frag_color.a = 0.0; #ifdef MODE_SSR - vec4 ssr = texture(ssr, uv_interp); - frag_color.rgb = mix(frag_color.rgb, ssr.rgb, ssr.a); + vec4 ssr_color = texture(ssr, uv_interp); + frag_color.rgb = mix(frag_color.rgb, ssr_color.rgb, ssr_color.a); #endif #ifdef MODE_MERGE diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp index 0c15d4645b..a3bb39cd90 100644 --- a/servers/rendering/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -61,7 +61,7 @@ Vector<uint8_t> RenderingDevice::shader_compile_from_source(ShaderStage p_stage, return compile_function(p_stage, p_source_code, p_language, r_error); } -RID RenderingDevice::_texture_create(const Ref<RDTextureFormat> &p_format, const Ref<RDTextureView> &p_view, const Array &p_data) { +RID RenderingDevice::_texture_create(const Ref<RDTextureFormat> &p_format, const Ref<RDTextureView> &p_view, const TypedArray<PackedByteArray> &p_data) { ERR_FAIL_COND_V(p_format.is_null(), RID()); ERR_FAIL_COND_V(p_view.is_null(), RID()); @@ -86,7 +86,7 @@ RID RenderingDevice::_texture_create_shared_from_slice(const Ref<RDTextureView> return texture_create_shared_from_slice(p_view->base, p_with_texture, p_layer, p_mipmap, p_slice_type); } -RenderingDevice::FramebufferFormatID RenderingDevice::_framebuffer_format_create(const Array &p_attachments) { +RenderingDevice::FramebufferFormatID RenderingDevice::_framebuffer_format_create(const TypedArray<RDAttachmentFormat> &p_attachments) { Vector<AttachmentFormat> attachments; attachments.resize(p_attachments.size()); @@ -111,20 +111,20 @@ RID RenderingDevice::_sampler_create(const Ref<RDSamplerState> &p_state) { return sampler_create(p_state->base); } -RenderingDevice::VertexFormatID RenderingDevice::_vertex_format_create(const Array &p_vertex_formats) { +RenderingDevice::VertexFormatID RenderingDevice::_vertex_format_create(const TypedArray<RDVertexAttribute> &p_vertex_formats) { - Vector<VertexDescription> descriptions; + Vector<VertexAttribute> descriptions; descriptions.resize(p_vertex_formats.size()); for (int i = 0; i < p_vertex_formats.size(); i++) { - Ref<RDVertexDescription> af = p_vertex_formats[i]; + Ref<RDVertexAttribute> af = p_vertex_formats[i]; ERR_FAIL_COND_V(af.is_null(), INVALID_FORMAT_ID); descriptions.write[i] = af->base; } return vertex_format_create(descriptions); } -RID RenderingDevice::_vertex_array_create(uint32_t p_vertex_count, VertexFormatID p_vertex_format, const Array &p_src_buffers) { +RID RenderingDevice::_vertex_array_create(uint32_t p_vertex_count, VertexFormatID p_vertex_format, const TypedArray<RID> &p_src_buffers) { Vector<RID> buffers = Variant(p_src_buffers); @@ -194,6 +194,10 @@ RID RenderingDevice::_render_pipeline_create(RID p_shader, FramebufferFormatID p PipelineMultisampleState multisample_state; if (p_multisample_state.is_valid()) { multisample_state = p_multisample_state->base; + for (int i = 0; i < p_multisample_state->sample_masks.size(); i++) { + int64_t mask = p_multisample_state->sample_masks[i]; + multisample_state.sample_mask.push_back(mask); + } } PipelineDepthStencilState depth_stencil_state; @@ -204,6 +208,12 @@ RID RenderingDevice::_render_pipeline_create(RID p_shader, FramebufferFormatID p PipelineColorBlendState color_blend_state; if (p_blend_state.is_valid()) { color_blend_state = p_blend_state->base; + for (int i = 0; i < p_blend_state->attachments.size(); i++) { + Ref<RDPipelineColorBlendStateAttachment> attachment = p_blend_state->attachments[i]; + if (attachment.is_valid()) { + color_blend_state.attachments.push_back(attachment->base); + } + } } return render_pipeline_create(p_shader, p_framebuffer_format, p_vertex_format, p_render_primitive, rasterization_state, multisample_state, depth_stencil_state, color_blend_state, p_dynamic_state_flags); @@ -262,7 +272,7 @@ void RenderingDevice::_bind_methods() { ClassDB::bind_method(D_METHOD("vertex_buffer_create", "size_bytes", "data"), &RenderingDevice::vertex_buffer_create, DEFVAL(Vector<uint8_t>())); ClassDB::bind_method(D_METHOD("vertex_format_create", "vertex_descriptions"), &RenderingDevice::_vertex_format_create); - ClassDB::bind_method(D_METHOD("index_buffer_create", "size_indices", "format", "data"), &RenderingDevice::index_buffer_create, DEFVAL(Vector<uint8_t>())); + ClassDB::bind_method(D_METHOD("index_buffer_create", "size_indices", "format", "data"), &RenderingDevice::index_buffer_create, DEFVAL(Vector<uint8_t>()), DEFVAL(false)); ClassDB::bind_method(D_METHOD("index_array_create", "index_buffer", "index_offset", "index_count"), &RenderingDevice::index_array_create); ClassDB::bind_method(D_METHOD("shader_compile_from_source", "shader_source", "allow_cache"), &RenderingDevice::_shader_compile_from_source, DEFVAL(true)); diff --git a/servers/rendering/rendering_device.h b/servers/rendering/rendering_device.h index 6de83c9b5b..c76fce5b5c 100644 --- a/servers/rendering/rendering_device.h +++ b/servers/rendering/rendering_device.h @@ -32,13 +32,14 @@ #define RENDERING_DEVICE_H #include "core/object.h" +#include "core/typed_array.h" #include "servers/display_server.h" class RDTextureFormat; class RDTextureView; -class RDAttachments; +class RDAttachmentFormat; class RDSamplerState; -class RDVertexDescriptions; +class RDVertexAttribute; class RDShaderSource; class RDShaderBytecode; class RDUniforms; @@ -547,13 +548,13 @@ public: VERTEX_FREQUENCY_INSTANCE, }; - struct VertexDescription { + struct VertexAttribute { uint32_t location; //shader location uint32_t offset; DataFormat format; uint32_t stride; VertexFrequency frequency; - VertexDescription() { + VertexAttribute() { location = 0; offset = 0; stride = 0; @@ -566,7 +567,7 @@ public: typedef int64_t VertexFormatID; // This ID is warranted to be unique for the same formats, does not need to be freed - virtual VertexFormatID vertex_format_create(const Vector<VertexDescription> &p_vertex_formats) = 0; + virtual VertexFormatID vertex_format_create(const Vector<VertexAttribute> &p_vertex_formats) = 0; virtual RID vertex_array_create(uint32_t p_vertex_count, VertexFormatID p_vertex_format, const Vector<RID> &p_src_buffers) = 0; enum IndexBufferFormat { @@ -1051,15 +1052,15 @@ public: protected: //binders to script API - RID _texture_create(const Ref<RDTextureFormat> &p_format, const Ref<RDTextureView> &p_view, const Array &p_data = Array()); + RID _texture_create(const Ref<RDTextureFormat> &p_format, const Ref<RDTextureView> &p_view, const TypedArray<PackedByteArray> &p_data = Array()); RID _texture_create_shared(const Ref<RDTextureView> &p_view, RID p_with_texture); RID _texture_create_shared_from_slice(const Ref<RDTextureView> &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, TextureSliceType p_slice_type = TEXTURE_SLICE_2D); - FramebufferFormatID _framebuffer_format_create(const Array &p_attachments); + FramebufferFormatID _framebuffer_format_create(const TypedArray<RDAttachmentFormat> &p_attachments); RID _framebuffer_create(const Array &p_textures, FramebufferFormatID p_format_check = INVALID_ID); RID _sampler_create(const Ref<RDSamplerState> &p_state); - VertexFormatID _vertex_format_create(const Array &p_vertex_formats); - RID _vertex_array_create(uint32_t p_vertex_count, VertexFormatID p_vertex_format, const Array &p_src_buffers); + VertexFormatID _vertex_format_create(const TypedArray<RDVertexAttribute> &p_vertex_formats); + RID _vertex_array_create(uint32_t p_vertex_count, VertexFormatID p_vertex_format, const TypedArray<RID> &p_src_buffers); Ref<RDShaderBytecode> _shader_compile_from_source(const Ref<RDShaderSource> &p_source, bool p_allow_cache = true); RID _shader_create(const Ref<RDShaderBytecode> &p_bytecode); diff --git a/servers/rendering/rendering_device_binds.h b/servers/rendering/rendering_device_binds.h index b3d943be79..f57f59876d 100644 --- a/servers/rendering/rendering_device_binds.h +++ b/servers/rendering/rendering_device_binds.h @@ -142,10 +142,10 @@ protected: } }; -class RDVertexDescription : public Reference { - GDCLASS(RDVertexDescription, Reference) +class RDVertexAttribute : public Reference { + GDCLASS(RDVertexAttribute, Reference) friend class RenderingDevice; - RD::VertexDescription base; + RD::VertexAttribute base; public: RD_SETGET(uint32_t, location) @@ -156,11 +156,11 @@ public: protected: static void _bind_methods() { - RD_BIND(Variant::INT, RDVertexDescription, location); - RD_BIND(Variant::INT, RDVertexDescription, offset); - RD_BIND(Variant::INT, RDVertexDescription, format); - RD_BIND(Variant::INT, RDVertexDescription, stride); - RD_BIND(Variant::INT, RDVertexDescription, frequency); + RD_BIND(Variant::INT, RDVertexAttribute, location); + RD_BIND(Variant::INT, RDVertexAttribute, offset); + RD_BIND(Variant::INT, RDVertexAttribute, format); + RD_BIND(Variant::INT, RDVertexAttribute, stride); + RD_BIND(Variant::INT, RDVertexAttribute, frequency); } }; class RDShaderSource : public Reference { @@ -412,6 +412,7 @@ class RDPipelineMultisampleState : public Reference { friend class RenderingDevice; RD::PipelineMultisampleState base; + TypedArray<int64_t> sample_masks; public: RD_SETGET(RD::TextureSamples, sample_count) @@ -420,24 +421,10 @@ public: RD_SETGET(bool, enable_alpha_to_coverage) RD_SETGET(bool, enable_alpha_to_one) - void add_sample_mask(uint32_t p_sample_mask) { base.sample_mask.push_back(p_sample_mask); } - void clear_sample_masks() { base.sample_mask.clear(); } - Vector<int64_t> get_sample_masks() const { - Vector<int64_t> sample_masks; - for (int i = 0; i < base.sample_mask.size(); i++) { - sample_masks.push_back(base.sample_mask[i]); - } - return sample_masks; - } + void set_sample_masks(const TypedArray<int64_t> &p_masks) { sample_masks = p_masks; } + TypedArray<int64_t> get_sample_masks() const { return sample_masks; } protected: - void _set_sample_masks(const Vector<int64_t> &p_masks) { - base.sample_mask.clear(); - for (int i = 0; i < p_masks.size(); i++) { - int64_t mask = p_masks[i]; - base.sample_mask.push_back(mask); - } - } static void _bind_methods() { RD_BIND(Variant::INT, RDPipelineMultisampleState, sample_count); RD_BIND(Variant::BOOL, RDPipelineMultisampleState, enable_sample_shading); @@ -445,11 +432,9 @@ protected: RD_BIND(Variant::BOOL, RDPipelineMultisampleState, enable_alpha_to_coverage); RD_BIND(Variant::BOOL, RDPipelineMultisampleState, enable_alpha_to_one); - ClassDB::bind_method(D_METHOD("add_sample_mask", "mask"), &RDPipelineMultisampleState::add_sample_mask); - ClassDB::bind_method(D_METHOD("clear_sample_masks"), &RDPipelineMultisampleState::clear_sample_masks); - ClassDB::bind_method(D_METHOD("_set_sample_masks", "sample_masks"), &RDPipelineMultisampleState::_set_sample_masks); + ClassDB::bind_method(D_METHOD("set_sample_masks", "masks"), &RDPipelineMultisampleState::set_sample_masks); ClassDB::bind_method(D_METHOD("get_sample_masks"), &RDPipelineMultisampleState::get_sample_masks); - ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT64_ARRAY, "_sample_masks", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "_set_sample_masks", "get_sample_masks"); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "sample_masks", PROPERTY_HINT_ARRAY_TYPE, "int"), "set_sample_masks", "get_sample_masks"); } }; @@ -514,6 +499,7 @@ protected: class RDPipelineColorBlendStateAttachment : public Reference { GDCLASS(RDPipelineColorBlendStateAttachment, Reference) + friend class RenderingDevice; RD::PipelineColorBlendState::Attachment base; public: @@ -529,10 +515,6 @@ public: RD_SETGET(bool, write_b) RD_SETGET(bool, write_a) - void set_as_disabled() { - base = RD::PipelineColorBlendState::Attachment(); - } - void set_as_mix() { base = RD::PipelineColorBlendState::Attachment(); @@ -545,6 +527,9 @@ public: protected: static void _bind_methods() { + + ClassDB::bind_method(D_METHOD("set_as_mix"), &RDPipelineColorBlendStateAttachment::set_as_mix); + RD_BIND(Variant::BOOL, RDPipelineColorBlendStateAttachment, enable_blend); RD_BIND(Variant::INT, RDPipelineColorBlendStateAttachment, src_color_blend_factor); RD_BIND(Variant::INT, RDPipelineColorBlendStateAttachment, dst_color_blend_factor); @@ -564,49 +549,19 @@ class RDPipelineColorBlendState : public Reference { friend class RenderingDevice; RD::PipelineColorBlendState base; - Vector<Ref<RDPipelineColorBlendStateAttachment>> attachments; + TypedArray<RDPipelineColorBlendStateAttachment> attachments; public: RD_SETGET(bool, enable_logic_op) RD_SETGET(RD::LogicOperation, logic_op) RD_SETGET(Color, blend_constant) - void add_attachment(const Ref<RDPipelineColorBlendStateAttachment> &p_attachment) { - attachments.push_back(p_attachment); + void set_attachments(const TypedArray<RDPipelineColorBlendStateAttachment> &p_attachments) { + attachments.push_back(p_attachments); } - void add_no_blend_attachment() { - Ref<RDPipelineColorBlendStateAttachment> attachment; - attachment.instance(); - attachment->set_as_disabled(); - add_attachment(attachment); - } - - void add_blend_mix_attachment() { - Ref<RDPipelineColorBlendStateAttachment> attachment; - attachment.instance(); - attachment->set_as_mix(); - add_attachment(attachment); - } - - void clear_attachments() { - attachments.clear(); - } - - Array get_attachments() const { - Array ret; - for (int i = 0; i < attachments.size(); i++) { - ret.push_back(attachments[i]); - } - return ret; - } - void _set_attachments(const Array &p_attachments) { - attachments.clear(); - for (int i = 0; i < p_attachments.size(); i++) { - Ref<RDPipelineColorBlendStateAttachment> attachment = p_attachments[i]; - ERR_FAIL_COND(!attachment.is_valid()); - attachments.push_back(attachment); - } + TypedArray<RDPipelineColorBlendStateAttachment> get_attachments() const { + return attachments; } protected: @@ -615,13 +570,9 @@ protected: RD_BIND(Variant::INT, RDPipelineColorBlendState, logic_op); RD_BIND(Variant::COLOR, RDPipelineColorBlendState, blend_constant); - ClassDB::bind_method(D_METHOD("add_attachment", "atachment"), &RDPipelineColorBlendState::add_attachment); - ClassDB::bind_method(D_METHOD("add_no_blend_attachment"), &RDPipelineColorBlendState::add_no_blend_attachment); - ClassDB::bind_method(D_METHOD("add_blend_mix_attachment"), &RDPipelineColorBlendState::add_blend_mix_attachment); - ClassDB::bind_method(D_METHOD("clear_attachments"), &RDPipelineColorBlendState::clear_attachments); - ClassDB::bind_method(D_METHOD("_set_attachments", "attachments"), &RDPipelineColorBlendState::_set_attachments); + ClassDB::bind_method(D_METHOD("set_attachments", "atachments"), &RDPipelineColorBlendState::set_attachments); ClassDB::bind_method(D_METHOD("get_attachments"), &RDPipelineColorBlendState::get_attachments); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_attachments", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "_set_attachments", "get_attachments"); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "attachments", PROPERTY_HINT_ARRAY_TYPE, "RDPipelineColorBlendStateAttachment"), "set_attachments", "get_attachments"); } }; diff --git a/servers/rendering/rendering_server_scene.cpp b/servers/rendering/rendering_server_scene.cpp index 9d141ea570..2c3c2730d5 100644 --- a/servers/rendering/rendering_server_scene.cpp +++ b/servers/rendering/rendering_server_scene.cpp @@ -1348,15 +1348,15 @@ _FORCE_INLINE_ static void _light_capture_sample_octree(const RasterizerStorage: for (int i = 0; i < 2; i++) { - Vector3 color_x00 = color[i][0].linear_interpolate(color[i][1], pos_fract[i].x); - Vector3 color_xy0 = color[i][2].linear_interpolate(color[i][3], pos_fract[i].x); - Vector3 blend_z0 = color_x00.linear_interpolate(color_xy0, pos_fract[i].y); + Vector3 color_x00 = color[i][0].lerp(color[i][1], pos_fract[i].x); + Vector3 color_xy0 = color[i][2].lerp(color[i][3], pos_fract[i].x); + Vector3 blend_z0 = color_x00.lerp(color_xy0, pos_fract[i].y); - Vector3 color_x0z = color[i][4].linear_interpolate(color[i][5], pos_fract[i].x); - Vector3 color_xyz = color[i][6].linear_interpolate(color[i][7], pos_fract[i].x); - Vector3 blend_z1 = color_x0z.linear_interpolate(color_xyz, pos_fract[i].y); + Vector3 color_x0z = color[i][4].lerp(color[i][5], pos_fract[i].x); + Vector3 color_xyz = color[i][6].lerp(color[i][7], pos_fract[i].x); + Vector3 blend_z1 = color_x0z.lerp(color_xyz, pos_fract[i].y); - color_interp[i] = blend_z0.linear_interpolate(blend_z1, pos_fract[i].z); + color_interp[i] = blend_z0.lerp(blend_z1, pos_fract[i].z); float alpha_x00 = Math::lerp(alpha[i][0], alpha[i][1], pos_fract[i].x); float alpha_xy0 = Math::lerp(alpha[i][2], alpha[i][3], pos_fract[i].x); @@ -1369,7 +1369,7 @@ _FORCE_INLINE_ static void _light_capture_sample_octree(const RasterizerStorage: alpha_interp[i] = Math::lerp(alpha_z0, alpha_z1, pos_fract[i].z); } - r_color = color_interp[0].linear_interpolate(color_interp[1], level_filter); + r_color = color_interp[0].lerp(color_interp[1], level_filter); r_alpha = Math::lerp(alpha_interp[0], alpha_interp[1], level_filter); //print_line("pos: " + p_posf + " level " + rtos(p_level) + " down to " + itos(target_level) + "." + rtos(level_filter) + " color " + r_color + " alpha " + rtos(r_alpha)); @@ -1850,12 +1850,13 @@ bool RenderingServerScene::_light_instance_update_shadow(Instance *p_instance, c real_t z = i == 0 ? -1 : 1; Vector<Plane> planes; - planes.resize(5); + planes.resize(6); planes.write[0] = light_transform.xform(Plane(Vector3(0, 0, z), radius)); planes.write[1] = light_transform.xform(Plane(Vector3(1, 0, z).normalized(), radius)); planes.write[2] = light_transform.xform(Plane(Vector3(-1, 0, z).normalized(), radius)); planes.write[3] = light_transform.xform(Plane(Vector3(0, 1, z).normalized(), radius)); planes.write[4] = light_transform.xform(Plane(Vector3(0, -1, z).normalized(), radius)); + planes.write[5] = light_transform.xform(Plane(Vector3(0, 0, -z), 0)); int cull_count = p_scenario->octree.cull_convex(planes, instance_shadow_cull_result, MAX_INSTANCE_CULL, RS::INSTANCE_GEOMETRY_MASK); Plane near_plane(light_transform.origin, light_transform.basis.get_axis(2) * z); diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index bec0958f71..93593effd4 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -6334,6 +6334,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct while (true) { ShaderNode::Constant constant; + constant.name = name; constant.type = is_struct ? TYPE_STRUCT : type; constant.type_str = struct_name; constant.precision = precision; @@ -6373,6 +6374,8 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct } shader->constants[name] = constant; + shader->vconstants.push_back(constant); + if (tk.type == TK_COMMA) { tk = _get_token(); if (tk.type != TK_IDENTIFIER) { diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h index 48f1d1440f..973e1c4937 100644 --- a/servers/rendering/shader_language.h +++ b/servers/rendering/shader_language.h @@ -607,6 +607,7 @@ public: struct ShaderNode : public Node { struct Constant { + StringName name; DataType type; StringName type_str; DataPrecision precision; @@ -698,6 +699,7 @@ public: Vector<StringName> render_modes; Vector<Function> functions; + Vector<Constant> vconstants; Vector<Struct> vstructs; ShaderNode() : |