A lot of progress with canvas rendering, still far from working.
This commit is contained in:
parent
836c2109a0
commit
9b0dd4f571
|
@ -497,6 +497,7 @@ if selected_platform in platform_list:
|
|||
if (not env["platform"] == "server"): # FIXME: detect GLES3
|
||||
env.Append(BUILDERS = { 'GLES3_GLSL' : env.Builder(action=run_in_subprocess(gles_builders.build_gles3_headers), suffix='glsl.gen.h', src_suffix='.glsl')})
|
||||
env.Append(BUILDERS = { 'GLES2_GLSL' : env.Builder(action=run_in_subprocess(gles_builders.build_gles2_headers), suffix='glsl.gen.h', src_suffix='.glsl')})
|
||||
env.Append(BUILDERS = { 'RD_GLSL' : env.Builder(action=run_in_subprocess(gles_builders.build_rd_headers), suffix='glsl.gen.h', src_suffix='.glsl')})
|
||||
|
||||
scons_cache_path = os.environ.get("SCONS_CACHE")
|
||||
if scons_cache_path != None:
|
||||
|
|
|
@ -52,9 +52,17 @@
|
|||
#define _COMMA_11 ,
|
||||
#define _COMMA_12 ,
|
||||
#define _COMMA_13 ,
|
||||
#define _COMMA_14 ,
|
||||
#define _COMMA_15 ,
|
||||
|
||||
// 1-based comma separated list of ITEMs
|
||||
#define COMMA_SEP_LIST(ITEM, LENGTH) _COMMA_SEP_LIST_##LENGTH(ITEM)
|
||||
#define _COMMA_SEP_LIST_15(ITEM) \
|
||||
_COMMA_SEP_LIST_14(ITEM) \
|
||||
, ITEM(15)
|
||||
#define _COMMA_SEP_LIST_14(ITEM) \
|
||||
_COMMA_SEP_LIST_13(ITEM) \
|
||||
, ITEM(14)
|
||||
#define _COMMA_SEP_LIST_13(ITEM) \
|
||||
_COMMA_SEP_LIST_12(ITEM) \
|
||||
, ITEM(13)
|
||||
|
@ -98,6 +106,12 @@
|
|||
|
||||
// 1-based semicolon separated list of ITEMs
|
||||
#define SEMIC_SEP_LIST(ITEM, LENGTH) _SEMIC_SEP_LIST_##LENGTH(ITEM)
|
||||
#define _SEMIC_SEP_LIST_15(ITEM) \
|
||||
_SEMIC_SEP_LIST_14(ITEM); \
|
||||
ITEM(15)
|
||||
#define _SEMIC_SEP_LIST_14(ITEM) \
|
||||
_SEMIC_SEP_LIST_13(ITEM); \
|
||||
ITEM(14)
|
||||
#define _SEMIC_SEP_LIST_13(ITEM) \
|
||||
_SEMIC_SEP_LIST_12(ITEM); \
|
||||
ITEM(13)
|
||||
|
@ -141,6 +155,12 @@
|
|||
|
||||
// 1-based space separated list of ITEMs
|
||||
#define SPACE_SEP_LIST(ITEM, LENGTH) _SPACE_SEP_LIST_##LENGTH(ITEM)
|
||||
#define _SPACE_SEP_LIST_15(ITEM) \
|
||||
_SPACE_SEP_LIST_14(ITEM) \
|
||||
ITEM(15)
|
||||
#define _SPACE_SEP_LIST_14(ITEM) \
|
||||
_SPACE_SEP_LIST_13(ITEM) \
|
||||
ITEM(14)
|
||||
#define _SPACE_SEP_LIST_13(ITEM) \
|
||||
_SPACE_SEP_LIST_12(ITEM) \
|
||||
ITEM(13)
|
||||
|
@ -271,7 +291,7 @@
|
|||
ss->in_use = false; \
|
||||
}
|
||||
|
||||
#define MAX_CMD_PARAMS 13
|
||||
#define MAX_CMD_PARAMS 15
|
||||
|
||||
class CommandQueueMT {
|
||||
|
||||
|
@ -298,15 +318,15 @@ class CommandQueueMT {
|
|||
};
|
||||
|
||||
DECL_CMD(0)
|
||||
SPACE_SEP_LIST(DECL_CMD, 13)
|
||||
SPACE_SEP_LIST(DECL_CMD, 15)
|
||||
|
||||
/* comands that return */
|
||||
DECL_CMD_RET(0)
|
||||
SPACE_SEP_LIST(DECL_CMD_RET, 13)
|
||||
SPACE_SEP_LIST(DECL_CMD_RET, 15)
|
||||
|
||||
/* commands that don't return but sync */
|
||||
DECL_CMD_SYNC(0)
|
||||
SPACE_SEP_LIST(DECL_CMD_SYNC, 13)
|
||||
SPACE_SEP_LIST(DECL_CMD_SYNC, 15)
|
||||
|
||||
/***** BASE *******/
|
||||
|
||||
|
@ -443,15 +463,15 @@ class CommandQueueMT {
|
|||
public:
|
||||
/* NORMAL PUSH COMMANDS */
|
||||
DECL_PUSH(0)
|
||||
SPACE_SEP_LIST(DECL_PUSH, 13)
|
||||
SPACE_SEP_LIST(DECL_PUSH, 15)
|
||||
|
||||
/* PUSH AND RET COMMANDS */
|
||||
DECL_PUSH_AND_RET(0)
|
||||
SPACE_SEP_LIST(DECL_PUSH_AND_RET, 13)
|
||||
SPACE_SEP_LIST(DECL_PUSH_AND_RET, 15)
|
||||
|
||||
/* PUSH AND RET SYNC COMMANDS*/
|
||||
DECL_PUSH_AND_SYNC(0)
|
||||
SPACE_SEP_LIST(DECL_PUSH_AND_SYNC, 13)
|
||||
SPACE_SEP_LIST(DECL_PUSH_AND_SYNC, 15)
|
||||
|
||||
void wait_and_flush_one() {
|
||||
ERR_FAIL_COND(!sync);
|
||||
|
|
|
@ -342,7 +342,7 @@ def make_version(template, nargs, argmax, const, ret):
|
|||
|
||||
def run(target, source, env):
|
||||
|
||||
versions = 13
|
||||
versions = 15
|
||||
versions_ext = 6
|
||||
text = ""
|
||||
text_ext = ""
|
||||
|
|
|
@ -646,6 +646,17 @@ String String::camelcase_to_underscore(bool lowercase) const {
|
|||
return lowercase ? new_string.to_lower() : new_string;
|
||||
}
|
||||
|
||||
String String::get_with_code_lines() const {
|
||||
Vector<String> lines = split("\n");
|
||||
String ret;
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
if (i > 0) {
|
||||
ret += "\n";
|
||||
}
|
||||
ret += itos(i + 1) + " " + lines[i];
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int String::get_slice_count(String p_splitter) const {
|
||||
|
||||
if (empty())
|
||||
|
|
|
@ -258,6 +258,7 @@ public:
|
|||
String capitalize() const;
|
||||
String camelcase_to_underscore(bool lowercase = true) const;
|
||||
|
||||
String get_with_code_lines() const;
|
||||
int get_slice_count(String p_splitter) const;
|
||||
String get_slice(String p_splitter, int p_slice) const;
|
||||
String get_slicec(CharType p_splitter, int p_slice) const;
|
||||
|
|
|
@ -432,8 +432,6 @@
|
|||
</argument>
|
||||
<argument index="10" name="antialiased" type="bool" default="false">
|
||||
</argument>
|
||||
<argument index="11" name="antialiasing_use_indices" type="bool" default="false">
|
||||
</argument>
|
||||
<description>
|
||||
Adds a triangle array to the [CanvasItem]'s draw commands.
|
||||
</description>
|
||||
|
|
|
@ -701,7 +701,7 @@ public:
|
|||
void render_target_set_external_texture(RID p_render_target, unsigned int p_texture_id) {}
|
||||
void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value) {}
|
||||
bool render_target_was_used(RID p_render_target) { return false; }
|
||||
void render_target_clear_used(RID p_render_target) {}
|
||||
void render_target_clear_used_flag(RID p_render_target) {}
|
||||
void render_target_set_msaa(RID p_render_target, VS::ViewportMSAA p_msaa) {}
|
||||
|
||||
/* CANVAS SHADOW */
|
||||
|
|
|
@ -1033,11 +1033,11 @@ void RasterizerCanvasGLES2::_canvas_item_render_commands(Item *p_item, Item *cur
|
|||
#ifdef GLES_OVER_GL
|
||||
if (polygon->antialiased) {
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
if (polygon->antialiasing_use_indices) {
|
||||
_draw_generic_indices(GL_LINE_STRIP, polygon->indices.ptr(), polygon->count, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1);
|
||||
} else {
|
||||
// FIXME: Removed during Vulkan rebase.
|
||||
//if (polygon->antialiasing_use_indices) {
|
||||
// _draw_generic_indices(GL_LINE_STRIP, polygon->indices.ptr(), polygon->count, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1);
|
||||
//} else
|
||||
_draw_generic(GL_LINE_LOOP, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1);
|
||||
}
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -5358,7 +5358,7 @@ bool RasterizerStorageGLES2::render_target_was_used(RID p_render_target) {
|
|||
return rt->used_in_frame;
|
||||
}
|
||||
|
||||
void RasterizerStorageGLES2::render_target_clear_used(RID p_render_target) {
|
||||
void RasterizerStorageGLES2::render_target_clear_used_flag(RID p_render_target) {
|
||||
RenderTarget *rt = render_target_owner.getornull(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
|
||||
|
|
|
@ -1247,7 +1247,7 @@ public:
|
|||
|
||||
virtual void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value);
|
||||
virtual bool render_target_was_used(RID p_render_target);
|
||||
virtual void render_target_clear_used(RID p_render_target);
|
||||
virtual void render_target_clear_used_flag(RID p_render_target);
|
||||
virtual void render_target_set_msaa(RID p_render_target, VS::ViewportMSAA p_msaa);
|
||||
|
||||
/* CANVAS SHADOW */
|
||||
|
|
|
@ -901,11 +901,12 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
|
|||
#ifdef GLES_OVER_GL
|
||||
if (polygon->antialiased) {
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
if (polygon->antialiasing_use_indices) {
|
||||
_draw_generic_indices(GL_LINE_STRIP, polygon->indices.ptr(), polygon->count, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1);
|
||||
} else {
|
||||
// FIXME: Removed during Vulkan rebase.
|
||||
//if (polygon->antialiasing_use_indices) {
|
||||
// _draw_generic_indices(GL_LINE_STRIP, polygon->indices.ptr(), polygon->count, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1);
|
||||
//} else
|
||||
_draw_generic(GL_LINE_LOOP, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1);
|
||||
}
|
||||
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -7594,7 +7594,7 @@ bool RasterizerStorageGLES3::render_target_was_used(RID p_render_target) {
|
|||
return rt->used_in_frame;
|
||||
}
|
||||
|
||||
void RasterizerStorageGLES3::render_target_clear_used(RID p_render_target) {
|
||||
void RasterizerStorageGLES3::render_target_clear_used_flag(RID p_render_target) {
|
||||
|
||||
RenderTarget *rt = render_target_owner.getornull(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
|
|
|
@ -1404,7 +1404,7 @@ public:
|
|||
|
||||
virtual void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value);
|
||||
virtual bool render_target_was_used(RID p_render_target);
|
||||
virtual void render_target_clear_used(RID p_render_target);
|
||||
virtual void render_target_clear_used_flag(RID p_render_target);
|
||||
virtual void render_target_set_msaa(RID p_render_target, VS::ViewportMSAA p_msaa);
|
||||
|
||||
/* CANVAS SHADOW */
|
||||
|
|
|
@ -1023,7 +1023,7 @@ uint32_t RenderingDeviceVulkan::get_image_format_required_size(DataFormat p_form
|
|||
uint32_t blockw, blockh;
|
||||
get_compressed_image_format_block_dimensions(p_format, blockw, blockh);
|
||||
|
||||
for (uint32_t i = 0; i <= p_mipmaps; i++) {
|
||||
for (uint32_t i = 0; i < p_mipmaps; i++) {
|
||||
uint32_t bw = w % blockw != 0 ? w + (blockw - w % blockw) : w;
|
||||
uint32_t bh = h % blockh != 0 ? h + (blockh - h % blockh) : h;
|
||||
|
||||
|
@ -2049,7 +2049,7 @@ Error RenderingDeviceVulkan::texture_update(RID p_texture, uint32_t p_layer, con
|
|||
return OK;
|
||||
}
|
||||
|
||||
bool RenderingDeviceVulkan::texture_is_format_supported_for_usage(DataFormat p_format, TextureUsageBits p_usage) const {
|
||||
bool RenderingDeviceVulkan::texture_is_format_supported_for_usage(DataFormat p_format, uint32_t p_usage) const {
|
||||
ERR_FAIL_INDEX_V(p_format, DATA_FORMAT_MAX, false);
|
||||
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
@ -2745,6 +2745,10 @@ static const char *shader_stage_names[RenderingDevice::SHADER_STAGE_MAX] = {
|
|||
"Compute"
|
||||
};
|
||||
|
||||
static const char *shader_uniform_names[RenderingDevice::UNIFORM_TYPE_MAX] = {
|
||||
"Sampler", "CombinedSampler", "Texture", "Image", "TextureBuffer", "SamplerTextureBuffer", "ImageBuffer", "UniformBuffer", "StorageBuffer", "InputAttachment"
|
||||
};
|
||||
|
||||
static VkShaderStageFlagBits shader_stage_masks[RenderingDevice::SHADER_STAGE_MAX] = {
|
||||
VK_SHADER_STAGE_VERTEX_BIT,
|
||||
VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||
|
@ -2758,26 +2762,24 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa
|
|||
VkDescriptorSetLayoutBinding layout_binding;
|
||||
Shader::UniformInfo info;
|
||||
|
||||
print_line("*** Stage " + itos(p_stage) + " uniform: " + reflection.name.c_str());
|
||||
|
||||
switch (reflection.getType()->getBasicType()) {
|
||||
case glslang::EbtSampler: {
|
||||
|
||||
print_line("DEBUG: IsSampler");
|
||||
//print_line("DEBUG: IsSampler");
|
||||
if (reflection.getType()->getSampler().dim == glslang::EsdBuffer) {
|
||||
//texture buffers
|
||||
if (reflection.getType()->getSampler().isCombined()) {
|
||||
layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
|
||||
info.type = UNIFORM_TYPE_SAMPLER_WITH_TEXTURE_BUFFER;
|
||||
print_line("DEBUG: texel combined");
|
||||
//print_line("DEBUG: SAMPLER: texel combined");
|
||||
} else if (reflection.getType()->getSampler().isTexture()) {
|
||||
layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
|
||||
info.type = UNIFORM_TYPE_TEXTURE_BUFFER;
|
||||
print_line("DEBUG: texel alone");
|
||||
//print_line("DEBUG: SAMPLER: texel alone");
|
||||
} else if (reflection.getType()->getSampler().isImage()) {
|
||||
layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER;
|
||||
info.type = UNIFORM_TYPE_IMAGE_BUFFER;
|
||||
print_line("DEBUG: texel buffer");
|
||||
//print_line("DEBUG: SAMPLER: texel buffer");
|
||||
} else {
|
||||
if (r_error) {
|
||||
*r_error = "On shader stage '" + String(shader_stage_names[p_stage]) + "', uniform '" + reflection.name.c_str() + "' is of unsupported buffer type.";
|
||||
|
@ -2787,21 +2789,21 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa
|
|||
} else if (reflection.getType()->getSampler().isCombined()) {
|
||||
layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||
info.type = UNIFORM_TYPE_SAMPLER_WITH_TEXTURE;
|
||||
print_line("DEBUG: combined");
|
||||
//print_line("DEBUG: SAMPLER: combined");
|
||||
} else if (reflection.getType()->getSampler().isPureSampler()) {
|
||||
layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER;
|
||||
info.type = UNIFORM_TYPE_SAMPLER;
|
||||
print_line("DEBUG: sampler");
|
||||
//print_line("DEBUG: SAMPLER: sampler");
|
||||
} else if (reflection.getType()->getSampler().isTexture()) {
|
||||
layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
|
||||
info.type = UNIFORM_TYPE_TEXTURE;
|
||||
print_line("DEBUG: image");
|
||||
//print_line("DEBUG: SAMPLER: image");
|
||||
} else if (reflection.getType()->getSampler().isImage()) {
|
||||
layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
|
||||
info.type = UNIFORM_TYPE_IMAGE;
|
||||
print_line("DEBUG: storage image");
|
||||
//print_line("DEBUG: SAMPLER: storage image");
|
||||
} else {
|
||||
print_line("DEBUG: sampler unknown");
|
||||
//print_line("DEBUG: sampler unknown");
|
||||
if (r_error) {
|
||||
*r_error = "On shader stage '" + String(shader_stage_names[p_stage]) + "', uniform '" + reflection.name.c_str() + "' is of unsupported sampler type.";
|
||||
}
|
||||
|
@ -2810,7 +2812,7 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa
|
|||
|
||||
if (reflection.getType()->isArray()) {
|
||||
layout_binding.descriptorCount = reflection.getType()->getArraySizes()->getCumulativeSize();
|
||||
print_line("DEBUG: array of size: " + itos(layout_binding.descriptorCount));
|
||||
//print_line("DEBUG: array of size: " + itos(layout_binding.descriptorCount));
|
||||
} else {
|
||||
layout_binding.descriptorCount = 1;
|
||||
}
|
||||
|
@ -2823,7 +2825,7 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa
|
|||
|
||||
} break;*/
|
||||
case glslang::EbtBlock: {
|
||||
print_line("DEBUG: Block");
|
||||
//print_line("DEBUG: Block");
|
||||
if (reflection.getType()->getQualifier().storage == glslang::EvqUniform) {
|
||||
if (reflection.getType()->getQualifier().layoutPushConstant) {
|
||||
uint32_t len = reflection.size;
|
||||
|
@ -2835,13 +2837,13 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa
|
|||
push_constant.push_constants_vk_stage |= shader_stage_masks[p_stage];
|
||||
return true;
|
||||
}
|
||||
print_line("DEBUG: Uniform buffer");
|
||||
//print_line("DEBUG: Uniform buffer");
|
||||
layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
info.type = UNIFORM_TYPE_UNIFORM_BUFFER;
|
||||
} else if (reflection.getType()->getQualifier().storage == glslang::EvqBuffer) {
|
||||
layout_binding.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
|
||||
info.type = UNIFORM_TYPE_STORAGE_BUFFER;
|
||||
print_line("DEBUG: Storage buffer");
|
||||
//print_line("DEBUG: Storage buffer");
|
||||
} else {
|
||||
if (r_error) {
|
||||
*r_error = "On shader stage '" + String(shader_stage_names[p_stage]) + "', uniform '" + reflection.name.c_str() + "' is of unsupported block type: (" + itos(reflection.getType()->getQualifier().storage) + ").";
|
||||
|
@ -2851,7 +2853,7 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa
|
|||
|
||||
if (reflection.getType()->isArray()) {
|
||||
layout_binding.descriptorCount = reflection.getType()->getArraySizes()->getCumulativeSize();
|
||||
print_line("DEBUG: array of size: " + itos(layout_binding.descriptorCount));
|
||||
//print_line("DEBUG: array of size: " + itos(layout_binding.descriptorCount));
|
||||
} else {
|
||||
layout_binding.descriptorCount = 1;
|
||||
}
|
||||
|
@ -2935,14 +2937,16 @@ bool RenderingDeviceVulkan::_uniform_add_binding(Vector<Vector<VkDescriptorSetLa
|
|||
bindings.resize(set + 1);
|
||||
uniform_infos.resize(set + 1);
|
||||
}
|
||||
|
||||
#if 1
|
||||
print_line("stage: " + String(shader_stage_names[p_stage]) + " set: " + itos(set) + " binding: " + itos(info.binding) + " type:" + shader_uniform_names[info.type] + " length: " + itos(info.length));
|
||||
#endif
|
||||
bindings.write[set].push_back(layout_binding);
|
||||
uniform_infos.write[set].push_back(info);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
RID RenderingDeviceVulkan::shader_create_from_source(const Vector<ShaderStageSource> &p_stages, String *r_error, bool p_allow_cache) {
|
||||
RID RenderingDeviceVulkan::shader_create_from_source(const Vector<ShaderStageSource> &p_stages, String *r_error, ShaderStage *r_error_stage, bool p_allow_cache) {
|
||||
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
|
@ -3007,6 +3011,10 @@ RID RenderingDeviceVulkan::shader_create_from_source(const Vector<ShaderStageSou
|
|||
(*r_error) += shader.getInfoDebugLog();
|
||||
}
|
||||
|
||||
if (r_error_stage) {
|
||||
*r_error_stage = p_stages[i].shader_stage;
|
||||
}
|
||||
|
||||
return RID();
|
||||
}
|
||||
//set back..
|
||||
|
@ -3021,6 +3029,10 @@ RID RenderingDeviceVulkan::shader_create_from_source(const Vector<ShaderStageSou
|
|||
(*r_error) += "\n";
|
||||
(*r_error) += shader.getInfoDebugLog();
|
||||
}
|
||||
if (r_error_stage) {
|
||||
*r_error_stage = p_stages[i].shader_stage;
|
||||
}
|
||||
|
||||
return RID();
|
||||
}
|
||||
|
||||
|
@ -3035,13 +3047,17 @@ RID RenderingDeviceVulkan::shader_create_from_source(const Vector<ShaderStageSou
|
|||
(*r_error) += "\n";
|
||||
(*r_error) += program.getInfoDebugLog();
|
||||
}
|
||||
if (r_error_stage) {
|
||||
*r_error_stage = p_stages[i].shader_stage;
|
||||
}
|
||||
|
||||
return RID();
|
||||
}
|
||||
|
||||
//obtain bindings for descriptor layout
|
||||
program.mapIO();
|
||||
program.buildReflection();
|
||||
program.dumpReflection();
|
||||
//program.dumpReflection();
|
||||
|
||||
for (int j = 0; j < program.getNumUniformVariables(); j++) {
|
||||
if (!_uniform_add_binding(bindings, uniform_info, program.getUniform(j), p_stages[i].shader_stage, push_constant, r_error)) {
|
||||
|
@ -3102,6 +3118,8 @@ RID RenderingDeviceVulkan::shader_create_from_source(const Vector<ShaderStageSou
|
|||
shader.fragment_outputs = fragment_outputs;
|
||||
shader.push_constant = push_constant;
|
||||
|
||||
String error_text;
|
||||
|
||||
bool success = true;
|
||||
for (int i = 0; i < p_stages.size(); i++) {
|
||||
VkShaderModuleCreateInfo shader_module_create_info;
|
||||
|
@ -3115,7 +3133,7 @@ RID RenderingDeviceVulkan::shader_create_from_source(const Vector<ShaderStageSou
|
|||
VkResult res = vkCreateShaderModule(device, &shader_module_create_info, NULL, &module);
|
||||
if (res) {
|
||||
success = false;
|
||||
ERR_PRINT("Error creating shader module for stage: " + String(shader_stage_names[p_stages[i].shader_stage]));
|
||||
error_text = "Error creating shader module for stage: " + String(shader_stage_names[p_stages[i].shader_stage]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3155,7 +3173,7 @@ RID RenderingDeviceVulkan::shader_create_from_source(const Vector<ShaderStageSou
|
|||
VkDescriptorSetLayout layout;
|
||||
VkResult res = vkCreateDescriptorSetLayout(device, &layout_create_info, NULL, &layout);
|
||||
if (res) {
|
||||
ERR_PRINT("Error creating descriptor set layout for set " + itos(i));
|
||||
error_text = "Error creating descriptor set layout for set " + itos(i);
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
|
@ -3212,7 +3230,7 @@ RID RenderingDeviceVulkan::shader_create_from_source(const Vector<ShaderStageSou
|
|||
VkResult err = vkCreatePipelineLayout(device, &pipeline_layout_create_info, NULL, &shader.pipeline_layout);
|
||||
|
||||
if (err) {
|
||||
ERR_PRINT("Error creating pipeline layout.");
|
||||
error_text = "Error creating pipeline layout.";
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
@ -3227,12 +3245,25 @@ RID RenderingDeviceVulkan::shader_create_from_source(const Vector<ShaderStageSou
|
|||
vkDestroyDescriptorSetLayout(device, shader.sets[i].descriptor_set_layout, NULL);
|
||||
}
|
||||
|
||||
if (r_error) {
|
||||
*r_error = error_text;
|
||||
}
|
||||
if (r_error_stage) {
|
||||
*r_error_stage = SHADER_STAGE_MAX;
|
||||
}
|
||||
|
||||
return RID();
|
||||
}
|
||||
|
||||
return shader_owner.make_rid(shader);
|
||||
}
|
||||
|
||||
Vector<int> RenderingDeviceVulkan::shader_get_vertex_input_locations_used(RID p_shader) {
|
||||
const Shader *shader = shader_owner.getornull(p_shader);
|
||||
ERR_FAIL_COND_V(!shader, Vector<int>());
|
||||
return shader->vertex_input_locations;
|
||||
}
|
||||
|
||||
/******************/
|
||||
/**** UNIFORMS ****/
|
||||
/******************/
|
||||
|
@ -3789,6 +3820,10 @@ RID RenderingDeviceVulkan::uniform_set_create(const Vector<Uniform> &p_uniforms,
|
|||
return id;
|
||||
}
|
||||
|
||||
bool RenderingDeviceVulkan::uniform_set_is_valid(RID p_uniform_set) {
|
||||
return uniform_set_owner.owns(p_uniform_set);
|
||||
}
|
||||
|
||||
Error RenderingDeviceVulkan::buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, void *p_data, bool p_sync_with_draw) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
|
@ -4113,6 +4148,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma
|
|||
|
||||
graphics_pipeline_create_info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
|
||||
graphics_pipeline_create_info.pNext = NULL;
|
||||
graphics_pipeline_create_info.flags = 0;
|
||||
|
||||
graphics_pipeline_create_info.stageCount = shader->pipeline_stages.size();
|
||||
graphics_pipeline_create_info.pStages = shader->pipeline_stages.ptr();
|
||||
|
|
|
@ -680,7 +680,7 @@ public:
|
|||
virtual RID texture_create_shared(const TextureView &p_view, RID p_with_texture);
|
||||
virtual Error texture_update(RID p_texture, uint32_t p_layer, const PoolVector<uint8_t> &p_data, bool p_sync_with_draw = false);
|
||||
|
||||
virtual bool texture_is_format_supported_for_usage(DataFormat p_format, TextureUsageBits p_usage) const;
|
||||
virtual bool texture_is_format_supported_for_usage(DataFormat p_format, uint32_t p_usage) const;
|
||||
|
||||
/*********************/
|
||||
/**** FRAMEBUFFER ****/
|
||||
|
@ -716,7 +716,8 @@ public:
|
|||
/**** SHADER ****/
|
||||
/****************/
|
||||
|
||||
virtual RID shader_create_from_source(const Vector<ShaderStageSource> &p_stages, String *r_error = NULL, bool p_allow_cache = true);
|
||||
virtual RID shader_create_from_source(const Vector<ShaderStageSource> &p_stages, String *r_error = NULL, ShaderStage *r_error_stage = NULL, bool p_allow_cache = true);
|
||||
virtual Vector<int> shader_get_vertex_input_locations_used(RID p_shader);
|
||||
|
||||
/*****************/
|
||||
/**** UNIFORM ****/
|
||||
|
@ -727,6 +728,7 @@ public:
|
|||
virtual RID texture_buffer_create(uint32_t p_size_elements, DataFormat p_format, const PoolVector<uint8_t> &p_data = PoolVector<uint8_t>());
|
||||
|
||||
virtual RID uniform_set_create(const Vector<Uniform> &p_uniforms, RID p_shader, uint32_t p_shader_set);
|
||||
virtual bool uniform_set_is_valid(RID p_uniform_set);
|
||||
|
||||
virtual Error buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, void *p_data, bool p_sync_with_draw = false); //works for any buffer
|
||||
|
||||
|
@ -765,17 +767,17 @@ public:
|
|||
|
||||
virtual void draw_list_end();
|
||||
|
||||
virtual void free(RID p_id);
|
||||
|
||||
/**************/
|
||||
/**** FREE ****/
|
||||
/**************/
|
||||
|
||||
virtual void free(RID p_id);
|
||||
|
||||
void initialize(VulkanContext *p_context);
|
||||
void finalize();
|
||||
|
||||
void finalize_frame();
|
||||
void advance_frame();
|
||||
virtual void finalize_frame();
|
||||
virtual void advance_frame();
|
||||
|
||||
RenderingDeviceVulkan();
|
||||
};
|
||||
|
|
|
@ -984,11 +984,12 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
|
|||
static const Mesh::PrimitiveType primitives2[7] = {
|
||||
Mesh::PRIMITIVE_POINTS,
|
||||
Mesh::PRIMITIVE_LINES,
|
||||
Mesh::PRIMITIVE_LINE_LOOP,
|
||||
Mesh::PRIMITIVE_LINE_STRIP,
|
||||
Mesh::PRIMITIVE_LINES,
|
||||
Mesh::PRIMITIVE_LINES,
|
||||
Mesh::PRIMITIVE_TRIANGLES,
|
||||
Mesh::PRIMITIVE_TRIANGLE_STRIP,
|
||||
Mesh::PRIMITIVE_TRIANGLE_FAN,
|
||||
Mesh::PRIMITIVE_TRIANGLES,
|
||||
Mesh::PRIMITIVE_TRIANGLES,
|
||||
#warning these will have to be decomposed into proper primitive now that lineloop/strip,etc no longer supported
|
||||
};
|
||||
|
||||
primitive = primitives2[mode];
|
||||
|
|
|
@ -280,8 +280,16 @@ void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material> &p_material,
|
|||
a.resize(Mesh::ARRAY_MAX);
|
||||
a[Mesh::ARRAY_VERTEX] = vs;
|
||||
a[Mesh::ARRAY_TEX_UV] = uv;
|
||||
Vector<int> indices;
|
||||
indices.push_back(0);
|
||||
indices.push_back(1);
|
||||
indices.push_back(2);
|
||||
indices.push_back(0);
|
||||
indices.push_back(2);
|
||||
indices.push_back(3);
|
||||
a[Mesh::ARRAY_INDEX] = indices;
|
||||
a[Mesh::ARRAY_COLOR] = colors;
|
||||
mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLE_FAN, a);
|
||||
mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, a);
|
||||
mesh->surface_set_material(0, p_material);
|
||||
|
||||
float md = 0;
|
||||
|
|
136
gles_builders.py
136
gles_builders.py
|
@ -273,10 +273,7 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2
|
|||
1
|
||||
};
|
||||
|
||||
|
||||
glUniformMatrix4fv(get_uniform(p_uniform),1,false,matrix);
|
||||
|
||||
|
||||
}
|
||||
|
||||
""")
|
||||
|
@ -304,10 +301,7 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2
|
|||
1
|
||||
};
|
||||
|
||||
|
||||
glUniformMatrix4fv(get_uniform(p_uniform),1,false,matrix);
|
||||
|
||||
|
||||
}
|
||||
|
||||
""")
|
||||
|
@ -324,7 +318,9 @@ def build_legacygl_header(filename, include, class_suffix, output_attribs, gles2
|
|||
}
|
||||
|
||||
glUniformMatrix4fv(get_uniform(p_uniform),1,false,matrix);
|
||||
}""")
|
||||
}
|
||||
|
||||
""")
|
||||
|
||||
fd.write("\n\n#undef _FU\n\n\n")
|
||||
|
||||
|
@ -507,5 +503,131 @@ def build_gles2_headers(target, source, env):
|
|||
build_legacygl_header(str(x), include="drivers/gles2/shader_gles2.h", class_suffix="GLES2", output_attribs=True, gles2=True)
|
||||
|
||||
|
||||
|
||||
class RDHeaderStruct:
|
||||
|
||||
def __init__(self):
|
||||
self.vertex_lines = []
|
||||
self.fragment_lines = []
|
||||
|
||||
self.vertex_included_files = []
|
||||
self.fragment_included_files = []
|
||||
|
||||
self.reading = ""
|
||||
self.line_offset = 0
|
||||
self.vertex_offset = 0
|
||||
self.fragment_offset = 0
|
||||
|
||||
|
||||
def include_file_in_rd_header(filename, header_data, depth):
|
||||
fs = open(filename, "r")
|
||||
line = fs.readline()
|
||||
|
||||
while line:
|
||||
|
||||
if line.find("[vertex]") != -1:
|
||||
header_data.reading = "vertex"
|
||||
line = fs.readline()
|
||||
header_data.line_offset += 1
|
||||
header_data.vertex_offset = header_data.line_offset
|
||||
continue
|
||||
|
||||
if line.find("[fragment]") != -1:
|
||||
header_data.reading = "fragment"
|
||||
line = fs.readline()
|
||||
header_data.line_offset += 1
|
||||
header_data.fragment_offset = header_data.line_offset
|
||||
continue
|
||||
|
||||
while line.find("#include ") != -1:
|
||||
includeline = line.replace("#include ", "").strip()[1:-1]
|
||||
|
||||
import os.path
|
||||
|
||||
included_file = os.path.relpath(os.path.dirname(filename) + "/" + includeline)
|
||||
if not included_file in header_data.vertex_included_files and header_data.reading == "vertex":
|
||||
header_data.vertex_included_files += [included_file]
|
||||
if include_file_in_rd_header(included_file, header_data, depth + 1) is None:
|
||||
print("Error in file '" + filename + "': #include " + includeline + "could not be found!")
|
||||
elif not included_file in header_data.fragment_included_files and header_data.reading == "fragment":
|
||||
header_data.fragment_included_files += [included_file]
|
||||
if include_file_in_rd_header(included_file, header_data, depth + 1) is None:
|
||||
print("Error in file '" + filename + "': #include " + includeline + "could not be found!")
|
||||
|
||||
line = fs.readline()
|
||||
|
||||
line = line.replace("\r", "")
|
||||
line = line.replace("\n", "")
|
||||
|
||||
if header_data.reading == "vertex":
|
||||
header_data.vertex_lines += [line]
|
||||
if header_data.reading == "fragment":
|
||||
header_data.fragment_lines += [line]
|
||||
|
||||
line = fs.readline()
|
||||
header_data.line_offset += 1
|
||||
|
||||
fs.close()
|
||||
|
||||
return header_data
|
||||
|
||||
def build_rd_header(filename):
|
||||
header_data = LegacyGLHeaderStruct()
|
||||
include_file_in_rd_header(filename, header_data, 0)
|
||||
|
||||
out_file = filename + ".gen.h"
|
||||
fd = open(out_file, "w")
|
||||
|
||||
enum_constants = []
|
||||
|
||||
fd.write("/* WARNING, THIS FILE WAS GENERATED, DO NOT EDIT */\n")
|
||||
|
||||
out_file_base = out_file
|
||||
out_file_base = out_file_base[out_file_base.rfind("/") + 1:]
|
||||
out_file_base = out_file_base[out_file_base.rfind("\\") + 1:]
|
||||
out_file_ifdef = out_file_base.replace(".", "_").upper()
|
||||
fd.write("#ifndef " + out_file_ifdef + "_RD\n")
|
||||
fd.write("#define " + out_file_ifdef + "_RD\n")
|
||||
|
||||
out_file_class = out_file_base.replace(".glsl.gen.h", "").title().replace("_", "").replace(".", "") + "ShaderRD"
|
||||
fd.write("\n\n")
|
||||
fd.write("#include \"servers/visual/rasterizer/shader_rd.h\"\n\n\n")
|
||||
fd.write("class " + out_file_class + " : public ShaderRD {\n\n")
|
||||
fd.write("public:\n\n")
|
||||
|
||||
|
||||
fd.write("\t"+out_file_class+"() {\n\n")
|
||||
|
||||
|
||||
fd.write("\t\tstatic const char _vertex_code[]={\n")
|
||||
for x in header_data.vertex_lines:
|
||||
for c in x:
|
||||
fd.write(str(ord(c)) + ",")
|
||||
|
||||
fd.write(str(ord('\n')) + ",")
|
||||
fd.write("\t\t0};\n\n")
|
||||
|
||||
fd.write("\t\tstatic const char _fragment_code[]={\n")
|
||||
for x in header_data.fragment_lines:
|
||||
for c in x:
|
||||
fd.write(str(ord(c)) + ",")
|
||||
|
||||
fd.write(str(ord('\n')) + ",")
|
||||
fd.write("\t\t0};\n\n")
|
||||
fd.write("\t\tsetup(_vertex_code,_fragment_code,\""+out_file_class+"\");\n")
|
||||
fd.write("\t}\n")
|
||||
|
||||
|
||||
fd.write("};\n\n")
|
||||
|
||||
fd.write("#endif\n\n")
|
||||
fd.close()
|
||||
|
||||
|
||||
def build_rd_headers(target, source, env):
|
||||
for x in source:
|
||||
build_rd_header(str(x))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
subprocess_main(globals())
|
||||
|
|
|
@ -286,9 +286,10 @@ void GDAPI godot_arvr_blit(godot_int p_eye, godot_rid *p_render_target, godot_re
|
|||
screen_rect.size.x /= 2.0;
|
||||
screen_rect.position.x += screen_rect.size.x;
|
||||
}
|
||||
|
||||
VSG::rasterizer->set_current_render_target(RID());
|
||||
#warning this needs to be redone
|
||||
#if 0
|
||||
VSG::rasterizer->blit_render_target_to_screen(*render_target, screen_rect, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
godot_int GDAPI godot_arvr_get_texid(godot_rid *p_render_target) {
|
||||
|
|
|
@ -426,11 +426,13 @@ void MobileVRInterface::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_t
|
|||
eye_center.y = 0.0;
|
||||
|
||||
// unset our render target so we are outputting to our main screen by making RasterizerStorageGLES3::system_fbo our current FBO
|
||||
#if 0
|
||||
VSG::rasterizer->set_current_render_target(RID());
|
||||
|
||||
// and output
|
||||
VSG::rasterizer->output_lens_distorted_to_screen(p_render_target, dest, k1, k2, eye_center, oversample);
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
void MobileVRInterface::process() {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
|
|
@ -103,7 +103,7 @@ void OS_X11::initialize_core() {
|
|||
int OS_X11::get_current_video_driver() const {
|
||||
return video_driver_index;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static RID test_index_array;
|
||||
static RID test_vertex_array;
|
||||
static RID test_uniform_set;
|
||||
|
@ -111,7 +111,7 @@ static RID test_pipeline;
|
|||
static RID test_framebuffer_pipeline;
|
||||
static RID test_framebuffer_uniform_set;
|
||||
static RID test_framebuffer;
|
||||
|
||||
#endif
|
||||
Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
|
||||
|
||||
long im_event_mask = 0;
|
||||
|
@ -409,7 +409,8 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
|
|||
RasterizerRD::make_current();
|
||||
|
||||
// test shader
|
||||
|
||||
#if 0
|
||||
//test code, remains for reference, ask before removing
|
||||
RID shader;
|
||||
{
|
||||
RenderingDevice::ShaderStageSource vert;
|
||||
|
@ -601,7 +602,9 @@ Error OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_a
|
|||
test_framebuffer_pipeline = rendering_device->render_pipeline_create(shader, rendering_device->screen_get_framebuffer_format(), vertex_desc, RenderingDevice::RENDER_PRIMITIVE_TRIANGLES, RenderingDevice::PipelineRasterizationState(), RenderingDevice::PipelineMultisampleState(), RenderingDevice::PipelineDepthStencilState(), RenderingDevice::PipelineColorBlendState::create_disabled());
|
||||
}
|
||||
|
||||
#endif
|
||||
#if 0
|
||||
//test code, remains for reference, ask before removing
|
||||
Vector<RenderingDevice::ShaderStageSource> source;
|
||||
RenderingDevice::ShaderStageSource frag;
|
||||
frag.shader_stage = RenderingDevice::SHADER_STAGE_FRAGMENT;
|
||||
|
@ -3414,7 +3417,7 @@ void OS_X11::swap_buffers() {
|
|||
#if defined(OPENGL_ENABLED)
|
||||
context_gl->swap_buffers();
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
Vector <Color> clear;
|
||||
float color[4] = { 1, 0, 1, 1 };
|
||||
clear.push_back(Color(0.5, 0.8, 0.2));
|
||||
|
@ -3435,9 +3438,9 @@ void OS_X11::swap_buffers() {
|
|||
rendering_device->draw_list_set_push_constant(cmd_list, color, 4 * 4);
|
||||
rendering_device->draw_list_draw(cmd_list, true);
|
||||
rendering_device->draw_list_end();
|
||||
rendering_device->finalize_frame();
|
||||
#endif
|
||||
|
||||
context_vulkan->swap_buffers();
|
||||
rendering_device->advance_frame();
|
||||
}
|
||||
|
||||
void OS_X11::alert(const String &p_alert, const String &p_title) {
|
||||
|
|
|
@ -831,27 +831,27 @@ void CanvasItem::draw_circle(const Point2 &p_pos, float p_radius, const Color &p
|
|||
VisualServer::get_singleton()->canvas_item_add_circle(canvas_item, p_pos, p_radius, p_color);
|
||||
}
|
||||
|
||||
void CanvasItem::draw_texture(const Ref<Texture2D> &p_texture, const Point2 &p_pos, const Color &p_modulate, const Ref<Texture2D> &p_normal_map) {
|
||||
void CanvasItem::draw_texture(const Ref<Texture2D> &p_texture, const Point2 &p_pos, const Color &p_modulate, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess) {
|
||||
|
||||
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
|
||||
|
||||
ERR_FAIL_COND(p_texture.is_null());
|
||||
|
||||
p_texture->draw(canvas_item, p_pos, p_modulate, false, p_normal_map);
|
||||
p_texture->draw(canvas_item, p_pos, p_modulate, false, p_normal_map, p_specular_map, p_specular_color_shininess);
|
||||
}
|
||||
|
||||
void CanvasItem::draw_texture_rect(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) {
|
||||
void CanvasItem::draw_texture_rect(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess) {
|
||||
|
||||
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
|
||||
|
||||
ERR_FAIL_COND(p_texture.is_null());
|
||||
p_texture->draw_rect(canvas_item, p_rect, p_tile, p_modulate, p_transpose, p_normal_map);
|
||||
p_texture->draw_rect(canvas_item, p_rect, p_tile, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess);
|
||||
}
|
||||
void CanvasItem::draw_texture_rect_region(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, bool p_clip_uv) {
|
||||
void CanvasItem::draw_texture_rect_region(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, bool p_clip_uv) {
|
||||
|
||||
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
|
||||
ERR_FAIL_COND(p_texture.is_null());
|
||||
p_texture->draw_rect_region(canvas_item, p_rect, p_src_rect, p_modulate, p_transpose, p_normal_map, p_clip_uv);
|
||||
p_texture->draw_rect_region(canvas_item, p_rect, p_src_rect, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess, p_clip_uv);
|
||||
}
|
||||
|
||||
void CanvasItem::draw_style_box(const Ref<StyleBox> &p_style_box, const Rect2 &p_rect) {
|
||||
|
@ -861,14 +861,15 @@ void CanvasItem::draw_style_box(const Ref<StyleBox> &p_style_box, const Rect2 &p
|
|||
|
||||
p_style_box->draw(canvas_item, p_rect);
|
||||
}
|
||||
void CanvasItem::draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture, float p_width, const Ref<Texture2D> &p_normal_map) {
|
||||
void CanvasItem::draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture, float p_width, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess) {
|
||||
|
||||
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
|
||||
|
||||
RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
|
||||
RID rid_normal = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
RID rid_specular = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
|
||||
|
||||
VisualServer::get_singleton()->canvas_item_add_primitive(canvas_item, p_points, p_colors, p_uvs, rid, p_width, rid_normal);
|
||||
VisualServer::get_singleton()->canvas_item_add_primitive(canvas_item, p_points, p_colors, p_uvs, rid, p_width, rid_normal, rid_specular, p_specular_color_shininess);
|
||||
}
|
||||
void CanvasItem::draw_set_transform(const Point2 &p_offset, float p_rot, const Size2 &p_scale) {
|
||||
|
||||
|
@ -886,17 +887,18 @@ void CanvasItem::draw_set_transform_matrix(const Transform2D &p_matrix) {
|
|||
VisualServer::get_singleton()->canvas_item_add_set_transform(canvas_item, p_matrix);
|
||||
}
|
||||
|
||||
void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture, const Ref<Texture2D> &p_normal_map, bool p_antialiased) {
|
||||
void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, bool p_antialiased) {
|
||||
|
||||
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
|
||||
|
||||
RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
|
||||
RID rid_normal = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
RID rid_specular = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
|
||||
|
||||
VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, p_colors, p_uvs, rid, rid_normal, p_antialiased);
|
||||
VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, p_colors, p_uvs, rid, rid_normal, rid_specular, p_specular_color_shininess, p_antialiased);
|
||||
}
|
||||
|
||||
void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture, const Ref<Texture2D> &p_normal_map, bool p_antialiased) {
|
||||
void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, bool p_antialiased) {
|
||||
|
||||
ERR_FAIL_COND_MSG(!drawing, "Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
|
||||
|
||||
|
@ -904,24 +906,28 @@ void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Colo
|
|||
colors.push_back(p_color);
|
||||
RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
|
||||
RID rid_normal = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
RID rid_specular = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
|
||||
|
||||
VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, colors, p_uvs, rid, rid_normal, p_antialiased);
|
||||
VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, colors, p_uvs, rid, rid_normal, rid_specular, p_specular_color_shininess, p_antialiased);
|
||||
}
|
||||
|
||||
void CanvasItem::draw_mesh(const Ref<Mesh> &p_mesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map, const Transform2D &p_transform, const Color &p_modulate) {
|
||||
void CanvasItem::draw_mesh(const Ref<Mesh> &p_mesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, const Transform2D &p_transform, const Color &p_modulate) {
|
||||
|
||||
ERR_FAIL_COND(p_mesh.is_null());
|
||||
RID texture_rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
|
||||
RID normal_map_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
RID specular_map_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
|
||||
|
||||
VisualServer::get_singleton()->canvas_item_add_mesh(canvas_item, p_mesh->get_rid(), p_transform, p_modulate, texture_rid, normal_map_rid);
|
||||
VisualServer::get_singleton()->canvas_item_add_mesh(canvas_item, p_mesh->get_rid(), p_transform, p_modulate, texture_rid, normal_map_rid, specular_map_rid, p_specular_color_shininess);
|
||||
}
|
||||
void CanvasItem::draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map) {
|
||||
void CanvasItem::draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess) {
|
||||
|
||||
ERR_FAIL_COND(p_multimesh.is_null());
|
||||
RID texture_rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
|
||||
RID normal_map_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_multimesh(canvas_item, p_multimesh->get_rid(), texture_rid, normal_map_rid);
|
||||
RID specular_map_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
|
||||
|
||||
VisualServer::get_singleton()->canvas_item_add_multimesh(canvas_item, p_multimesh->get_rid(), texture_rid, normal_map_rid, specular_map_rid, p_specular_color_shininess);
|
||||
}
|
||||
|
||||
void CanvasItem::draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, const Color &p_modulate, int p_clip_w) {
|
||||
|
@ -1178,17 +1184,17 @@ void CanvasItem::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("draw_multiline_colors", "points", "colors", "width", "antialiased"), &CanvasItem::draw_multiline_colors, DEFVAL(1.0), DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("draw_rect", "rect", "color", "filled", "width", "antialiased"), &CanvasItem::draw_rect, DEFVAL(true), DEFVAL(1.0), DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("draw_circle", "position", "radius", "color"), &CanvasItem::draw_circle);
|
||||
ClassDB::bind_method(D_METHOD("draw_texture", "texture", "position", "modulate", "normal_map"), &CanvasItem::draw_texture, DEFVAL(Color(1, 1, 1, 1)), DEFVAL(Variant()));
|
||||
ClassDB::bind_method(D_METHOD("draw_texture_rect", "texture", "rect", "tile", "modulate", "transpose", "normal_map"), &CanvasItem::draw_texture_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()));
|
||||
ClassDB::bind_method(D_METHOD("draw_texture_rect_region", "texture", "rect", "src_rect", "modulate", "transpose", "normal_map", "clip_uv"), &CanvasItem::draw_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(true));
|
||||
ClassDB::bind_method(D_METHOD("draw_texture", "texture", "position", "modulate", "normal_map", "specular_map"), &CanvasItem::draw_texture, DEFVAL(Color(1, 1, 1, 1)), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)));
|
||||
ClassDB::bind_method(D_METHOD("draw_texture_rect", "texture", "rect", "tile", "modulate", "transpose", "normal_map", "specular_map"), &CanvasItem::draw_texture_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)));
|
||||
ClassDB::bind_method(D_METHOD("draw_texture_rect_region", "texture", "rect", "src_rect", "modulate", "transpose", "normal_map", "specular_map", "clip_uv"), &CanvasItem::draw_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(true));
|
||||
ClassDB::bind_method(D_METHOD("draw_style_box", "style_box", "rect"), &CanvasItem::draw_style_box);
|
||||
ClassDB::bind_method(D_METHOD("draw_primitive", "points", "colors", "uvs", "texture", "width", "normal_map"), &CanvasItem::draw_primitive, DEFVAL(Variant()), DEFVAL(1.0), DEFVAL(Variant()));
|
||||
ClassDB::bind_method(D_METHOD("draw_polygon", "points", "colors", "uvs", "texture", "normal_map", "antialiased"), &CanvasItem::draw_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("draw_colored_polygon", "points", "color", "uvs", "texture", "normal_map", "antialiased"), &CanvasItem::draw_colored_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("draw_primitive", "points", "colors", "uvs", "texture", "width", "normal_map", "specular_map"), &CanvasItem::draw_primitive, DEFVAL(Variant()), DEFVAL(1.0), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)));
|
||||
ClassDB::bind_method(D_METHOD("draw_polygon", "points", "colors", "uvs", "texture", "normal_map", "specular_map", "antialiased"), &CanvasItem::draw_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("draw_colored_polygon", "points", "color", "uvs", "texture", "normal_map", "specular_map", "antialiased"), &CanvasItem::draw_colored_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("draw_string", "font", "position", "text", "modulate", "clip_w"), &CanvasItem::draw_string, DEFVAL(Color(1, 1, 1)), DEFVAL(-1));
|
||||
ClassDB::bind_method(D_METHOD("draw_char", "font", "position", "char", "next", "modulate"), &CanvasItem::draw_char, DEFVAL(Color(1, 1, 1)));
|
||||
ClassDB::bind_method(D_METHOD("draw_mesh", "mesh", "texture", "normal_map", "transform", "modulate"), &CanvasItem::draw_mesh, DEFVAL(Ref<Texture2D>()), DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1)));
|
||||
ClassDB::bind_method(D_METHOD("draw_multimesh", "multimesh", "texture", "normal_map"), &CanvasItem::draw_multimesh, DEFVAL(Ref<Texture2D>()));
|
||||
ClassDB::bind_method(D_METHOD("draw_mesh", "mesh", "texture", "normal_map", "specular_map", "transform", "modulate"), &CanvasItem::draw_mesh, DEFVAL(Ref<Texture2D>()), DEFVAL(Ref<Texture2D>()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1)));
|
||||
ClassDB::bind_method(D_METHOD("draw_multimesh", "multimesh", "texture", "normal_map", "specular_map"), &CanvasItem::draw_multimesh, DEFVAL(Ref<Texture2D>()), DEFVAL(Ref<Texture2D>()), DEFVAL(Color(1, 1, 1, 1)));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("draw_set_transform", "position", "rotation", "scale"), &CanvasItem::draw_set_transform);
|
||||
ClassDB::bind_method(D_METHOD("draw_set_transform_matrix", "xform"), &CanvasItem::draw_set_transform_matrix);
|
||||
|
|
|
@ -313,16 +313,16 @@ public:
|
|||
void draw_multiline_colors(const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width = 1.0, bool p_antialiased = false);
|
||||
void draw_rect(const Rect2 &p_rect, const Color &p_color, bool p_filled = true, float p_width = 1.0, bool p_antialiased = false);
|
||||
void draw_circle(const Point2 &p_pos, float p_radius, const Color &p_color);
|
||||
void draw_texture(const Ref<Texture2D> &p_texture, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1, 1), const Ref<Texture2D> &p_normal_map = Ref<Texture2D>());
|
||||
void draw_texture_rect(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>());
|
||||
void draw_texture_rect_region(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), bool p_clip_uv = false);
|
||||
void draw_texture(const Ref<Texture2D> &p_texture, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1, 1), const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1));
|
||||
void draw_texture_rect(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1));
|
||||
void draw_texture_rect_region(const Ref<Texture2D> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), bool p_clip_uv = false);
|
||||
void draw_style_box(const Ref<StyleBox> &p_style_box, const Rect2 &p_rect);
|
||||
void draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture = Ref<Texture2D>(), float p_width = 1, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>());
|
||||
void draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture2D> p_texture = Ref<Texture2D>(), const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), bool p_antialiased = false);
|
||||
void draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture2D> p_texture = Ref<Texture2D>(), const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), bool p_antialiased = false);
|
||||
void draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture2D> p_texture = Ref<Texture2D>(), float p_width = 1, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1));
|
||||
void draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture2D> p_texture = Ref<Texture2D>(), const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), bool p_antialiased = false);
|
||||
void draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture2D> p_texture = Ref<Texture2D>(), const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), bool p_antialiased = false);
|
||||
|
||||
void draw_mesh(const Ref<Mesh> &p_mesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1));
|
||||
void draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map);
|
||||
void draw_mesh(const Ref<Mesh> &p_mesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1));
|
||||
void draw_multimesh(const Ref<MultiMesh> &p_multimesh, const Ref<Texture2D> &p_texture, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1));
|
||||
|
||||
void draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, const Color &p_modulate = Color(1, 1, 1), int p_clip_w = -1);
|
||||
float draw_char(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_char, const String &p_next = "", const Color &p_modulate = Color(1, 1, 1));
|
||||
|
|
|
@ -317,8 +317,8 @@ void Line2D::_draw() {
|
|||
lb.vertices,
|
||||
lb.colors,
|
||||
lb.uvs, Vector<int>(), Vector<float>(),
|
||||
texture_rid, -1, RID(),
|
||||
_antialiased, true);
|
||||
texture_rid, -1, RID(), RID(), Color(),
|
||||
_antialiased);
|
||||
|
||||
// DEBUG
|
||||
// Draw wireframe
|
||||
|
|
|
@ -304,13 +304,10 @@ void Polygon2D::_notification(int p_what) {
|
|||
colors.push_back(color);
|
||||
}
|
||||
|
||||
// Vector<int> indices = Geometry::triangulate_polygon(points);
|
||||
// VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, texture.is_valid() ? texture->get_rid() : RID());
|
||||
|
||||
if (invert || polygons.size() == 0) {
|
||||
Vector<int> indices = Geometry::triangulate_polygon(points);
|
||||
if (indices.size()) {
|
||||
VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID(), -1, RID(), antialiased);
|
||||
VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID(), -1, RID(), RID(), Color(), antialiased);
|
||||
}
|
||||
} else {
|
||||
//draw individual polygons
|
||||
|
@ -344,7 +341,7 @@ void Polygon2D::_notification(int p_what) {
|
|||
}
|
||||
|
||||
if (total_indices.size()) {
|
||||
VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), total_indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID(), -1, RID(), antialiased);
|
||||
VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), total_indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID(), -1, RID(), RID(), Color(), antialiased);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ void Sprite::_notification(int p_what) {
|
|||
Rect2 src_rect, dst_rect;
|
||||
bool filter_clip;
|
||||
_get_rects(src_rect, dst_rect, filter_clip);
|
||||
texture->draw_rect_region(ci, dst_rect, src_rect, Color(1, 1, 1), false, normal_map, filter_clip);
|
||||
texture->draw_rect_region(ci, dst_rect, src_rect, Color(1, 1, 1), false, normal_map, Ref<Texture2D>(), Color(1, 1, 1, 1), filter_clip);
|
||||
|
||||
} break;
|
||||
}
|
||||
|
|
|
@ -550,7 +550,7 @@ void TileMap::update_dirty_quadrants() {
|
|||
if (r == Rect2()) {
|
||||
tex->draw_rect(canvas_item, rect, false, modulate, c.transpose, normal_map);
|
||||
} else {
|
||||
tex->draw_rect_region(canvas_item, rect, r, modulate, c.transpose, normal_map, clip_uv);
|
||||
tex->draw_rect_region(canvas_item, rect, r, modulate, c.transpose, normal_map, Ref<Texture2D>(), Color(1, 1, 1, 1), clip_uv);
|
||||
}
|
||||
|
||||
Vector<TileSet::ShapeData> shapes = tile_set->tile_get_shapes(c.id);
|
||||
|
|
|
@ -483,7 +483,7 @@ void Sprite3D::_draw() {
|
|||
RID mat = SpatialMaterial::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == SpatialMaterial::BILLBOARD_ENABLED, get_billboard_mode() == SpatialMaterial::BILLBOARD_FIXED_Y);
|
||||
VS::get_singleton()->immediate_set_material(immediate, mat);
|
||||
|
||||
VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_TRIANGLE_FAN, texture->get_rid());
|
||||
VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_TRIANGLES, texture->get_rid());
|
||||
|
||||
int x_axis = ((axis + 1) % 3);
|
||||
int y_axis = ((axis + 2) % 3);
|
||||
|
@ -504,15 +504,18 @@ void Sprite3D::_draw() {
|
|||
|
||||
AABB aabb;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
|
||||
static const int index[6] = { 0, 1, 2, 0, 2, 3 };
|
||||
|
||||
VS::get_singleton()->immediate_normal(immediate, normal);
|
||||
VS::get_singleton()->immediate_tangent(immediate, tangent);
|
||||
VS::get_singleton()->immediate_color(immediate, color);
|
||||
VS::get_singleton()->immediate_uv(immediate, uvs[i]);
|
||||
|
||||
Vector3 vtx;
|
||||
vtx[x_axis] = vertices[i][0];
|
||||
vtx[y_axis] = vertices[i][1];
|
||||
vtx[x_axis] = vertices[index[i]][0];
|
||||
vtx[y_axis] = vertices[index[i]][1];
|
||||
VS::get_singleton()->immediate_vertex(immediate, vtx);
|
||||
if (i == 0) {
|
||||
aabb.position = vtx;
|
||||
|
@ -811,7 +814,7 @@ void AnimatedSprite3D::_draw() {
|
|||
|
||||
VS::get_singleton()->immediate_set_material(immediate, mat);
|
||||
|
||||
VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_TRIANGLE_FAN, texture->get_rid());
|
||||
VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_TRIANGLES, texture->get_rid());
|
||||
|
||||
int x_axis = ((axis + 1) % 3);
|
||||
int y_axis = ((axis + 2) % 3);
|
||||
|
@ -832,15 +835,21 @@ void AnimatedSprite3D::_draw() {
|
|||
|
||||
AABB aabb;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
|
||||
static const int indices[6] = {
|
||||
0, 1, 2,
|
||||
0, 2, 3
|
||||
};
|
||||
|
||||
VS::get_singleton()->immediate_normal(immediate, normal);
|
||||
VS::get_singleton()->immediate_tangent(immediate, tangent);
|
||||
VS::get_singleton()->immediate_color(immediate, color);
|
||||
VS::get_singleton()->immediate_uv(immediate, uvs[i]);
|
||||
|
||||
Vector3 vtx;
|
||||
vtx[x_axis] = vertices[i][0];
|
||||
vtx[y_axis] = vertices[i][1];
|
||||
vtx[x_axis] = vertices[indices[i]][0];
|
||||
vtx[y_axis] = vertices[indices[i]][1];
|
||||
VS::get_singleton()->immediate_vertex(immediate, vtx);
|
||||
if (i == 0) {
|
||||
aabb.position = vtx;
|
||||
|
|
|
@ -336,7 +336,7 @@ float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharT
|
|||
modulate.r = modulate.g = modulate.b = 1.0;
|
||||
}
|
||||
RID texture = font->textures[ch->texture_idx].texture->get_rid();
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, ch->rect.size), texture, ch->rect_uv, modulate, false, RID(), false);
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, ch->rect.size), texture, ch->rect_uv, modulate, false, RID(), RID(), Color(1, 1, 1, 1), false);
|
||||
}
|
||||
|
||||
advance = ch->advance;
|
||||
|
|
|
@ -556,7 +556,7 @@ float BitmapFont::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_c
|
|||
cpos.x += c->h_align;
|
||||
cpos.y -= ascent;
|
||||
cpos.y += c->v_align;
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, c->rect.size), textures[c->texture_idx]->get_rid(), c->rect, p_modulate, false, RID(), false);
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, c->rect.size), textures[c->texture_idx]->get_rid(), c->rect, p_modulate, false, RID(), RID(), Color(1, 1, 1, 1), false);
|
||||
}
|
||||
|
||||
return get_char_size(p_char, p_next).width;
|
||||
|
|
|
@ -499,11 +499,7 @@ void Mesh::_bind_methods() {
|
|||
|
||||
BIND_ENUM_CONSTANT(PRIMITIVE_POINTS);
|
||||
BIND_ENUM_CONSTANT(PRIMITIVE_LINES);
|
||||
BIND_ENUM_CONSTANT(PRIMITIVE_LINE_STRIP);
|
||||
BIND_ENUM_CONSTANT(PRIMITIVE_LINE_LOOP);
|
||||
BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLES);
|
||||
BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLE_STRIP);
|
||||
BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLE_FAN);
|
||||
|
||||
BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_NORMALIZED);
|
||||
BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_RELATIVE);
|
||||
|
|
|
@ -104,11 +104,8 @@ public:
|
|||
enum PrimitiveType {
|
||||
PRIMITIVE_POINTS = VisualServer::PRIMITIVE_POINTS,
|
||||
PRIMITIVE_LINES = VisualServer::PRIMITIVE_LINES,
|
||||
PRIMITIVE_LINE_STRIP = VisualServer::PRIMITIVE_LINE_STRIP,
|
||||
PRIMITIVE_LINE_LOOP = VisualServer::PRIMITIVE_LINE_LOOP,
|
||||
PRIMITIVE_TRIANGLES = VisualServer::PRIMITIVE_TRIANGLES,
|
||||
PRIMITIVE_TRIANGLE_STRIP = VisualServer::PRIMITIVE_TRIANGLE_STRIP,
|
||||
PRIMITIVE_TRIANGLE_FAN = VisualServer::PRIMITIVE_TRIANGLE_FAN,
|
||||
PRIMITIVE_MAX = VisualServer::PRIMITIVE_MAX,
|
||||
};
|
||||
|
||||
enum BlendShapeMode {
|
||||
|
|
|
@ -46,20 +46,23 @@ Size2 Texture2D::get_size() const {
|
|||
bool Texture2D::is_pixel_opaque(int p_x, int p_y) const {
|
||||
return true;
|
||||
}
|
||||
void Texture2D::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const {
|
||||
void Texture2D::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess) const {
|
||||
|
||||
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, get_size()), get_rid(), false, p_modulate, p_transpose, normal_rid);
|
||||
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, get_size()), get_rid(), false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess);
|
||||
}
|
||||
void Texture2D::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const {
|
||||
void Texture2D::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess) const {
|
||||
|
||||
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, get_rid(), p_tile, p_modulate, p_transpose, normal_rid);
|
||||
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, get_rid(), p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess);
|
||||
}
|
||||
void Texture2D::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, bool p_clip_uv) const {
|
||||
void Texture2D::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, bool p_clip_uv) const {
|
||||
|
||||
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, get_rid(), p_src_rect, p_modulate, p_transpose, normal_rid, p_clip_uv);
|
||||
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, get_rid(), p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv);
|
||||
}
|
||||
|
||||
bool Texture2D::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
|
||||
|
@ -76,9 +79,9 @@ void Texture2D::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_height"), &Texture2D::get_height);
|
||||
ClassDB::bind_method(D_METHOD("get_size"), &Texture2D::get_size);
|
||||
ClassDB::bind_method(D_METHOD("has_alpha"), &Texture2D::has_alpha);
|
||||
ClassDB::bind_method(D_METHOD("draw", "canvas_item", "position", "modulate", "transpose", "normal_map"), &Texture2D::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()));
|
||||
ClassDB::bind_method(D_METHOD("draw_rect", "canvas_item", "rect", "tile", "modulate", "transpose", "normal_map"), &Texture2D::draw_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()));
|
||||
ClassDB::bind_method(D_METHOD("draw_rect_region", "canvas_item", "rect", "src_rect", "modulate", "transpose", "normal_map", "clip_uv"), &Texture2D::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(true));
|
||||
ClassDB::bind_method(D_METHOD("draw", "canvas_item", "position", "modulate", "transpose", "normal_map", "specular_map", "specular_color_shininess"), &Texture2D::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)));
|
||||
ClassDB::bind_method(D_METHOD("draw_rect", "canvas_item", "rect", "tile", "modulate", "transpose", "normal_map", "specular_map", "specular_color_shininess"), &Texture2D::draw_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)));
|
||||
ClassDB::bind_method(D_METHOD("draw_rect_region", "canvas_item", "rect", "src_rect", "modulate", "transpose", "normal_map", "clip_uv", "specular_map", "specular_color_shininess"), &Texture2D::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(true));
|
||||
ClassDB::bind_method(D_METHOD("get_data"), &Texture2D::get_data);
|
||||
|
||||
ADD_GROUP("", "");
|
||||
|
@ -243,26 +246,29 @@ bool ImageTexture::has_alpha() const {
|
|||
return (format == Image::FORMAT_LA8 || format == Image::FORMAT_RGBA8);
|
||||
}
|
||||
|
||||
void ImageTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const {
|
||||
void ImageTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess) const {
|
||||
|
||||
if ((w | h) == 0)
|
||||
return;
|
||||
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose, normal_rid);
|
||||
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess);
|
||||
}
|
||||
void ImageTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const {
|
||||
void ImageTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess) const {
|
||||
|
||||
if ((w | h) == 0)
|
||||
return;
|
||||
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose, normal_rid);
|
||||
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess);
|
||||
}
|
||||
void ImageTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, bool p_clip_uv) const {
|
||||
void ImageTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, bool p_clip_uv) const {
|
||||
|
||||
if ((w | h) == 0)
|
||||
return;
|
||||
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose, normal_rid, p_clip_uv);
|
||||
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv);
|
||||
}
|
||||
|
||||
bool ImageTexture::is_pixel_opaque(int p_x, int p_y) const {
|
||||
|
@ -657,26 +663,29 @@ RID StreamTexture::get_rid() const {
|
|||
return texture;
|
||||
}
|
||||
|
||||
void StreamTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const {
|
||||
void StreamTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess) const {
|
||||
|
||||
if ((w | h) == 0)
|
||||
return;
|
||||
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose, normal_rid);
|
||||
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess);
|
||||
}
|
||||
void StreamTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const {
|
||||
void StreamTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess) const {
|
||||
|
||||
if ((w | h) == 0)
|
||||
return;
|
||||
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose, normal_rid);
|
||||
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess);
|
||||
}
|
||||
void StreamTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, bool p_clip_uv) const {
|
||||
void StreamTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, bool p_clip_uv) const {
|
||||
|
||||
if ((w | h) == 0)
|
||||
return;
|
||||
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose, normal_rid, p_clip_uv);
|
||||
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv);
|
||||
}
|
||||
|
||||
bool StreamTexture::has_alpha() const {
|
||||
|
@ -907,7 +916,7 @@ void AtlasTexture::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "filter_clip"), "set_filter_clip", "has_filter_clip");
|
||||
}
|
||||
|
||||
void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const {
|
||||
void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess) const {
|
||||
|
||||
if (!atlas.is_valid())
|
||||
return;
|
||||
|
@ -923,10 +932,11 @@ void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_m
|
|||
}
|
||||
|
||||
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(p_pos + margin.position, rc.size), atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid, filter_clip);
|
||||
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
|
||||
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(p_pos + margin.position, rc.size), atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, filter_clip);
|
||||
}
|
||||
|
||||
void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const {
|
||||
void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess) const {
|
||||
|
||||
if (!atlas.is_valid())
|
||||
return;
|
||||
|
@ -945,9 +955,10 @@ void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile
|
|||
Rect2 dr(p_rect.position + margin.position * scale, rc.size * scale);
|
||||
|
||||
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid, filter_clip);
|
||||
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
|
||||
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, filter_clip);
|
||||
}
|
||||
void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, bool p_clip_uv) const {
|
||||
void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, bool p_clip_uv) const {
|
||||
|
||||
//this might not necessarily work well if using a rect, needs to be fixed properly
|
||||
if (!atlas.is_valid())
|
||||
|
@ -958,7 +969,8 @@ void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, cons
|
|||
get_rect_region(p_rect, p_src_rect, dr, src_c);
|
||||
|
||||
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), src_c, p_modulate, p_transpose, normal_rid, filter_clip);
|
||||
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
|
||||
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), src_c, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, filter_clip);
|
||||
}
|
||||
|
||||
bool AtlasTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
|
||||
|
@ -1056,7 +1068,7 @@ Ref<Texture2D> MeshTexture::get_base_texture() const {
|
|||
return base_texture;
|
||||
}
|
||||
|
||||
void MeshTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const {
|
||||
void MeshTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess) const {
|
||||
|
||||
if (mesh.is_null() || base_texture.is_null()) {
|
||||
return;
|
||||
|
@ -1068,9 +1080,10 @@ void MeshTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_mo
|
|||
SWAP(xform.elements[0][0], xform.elements[1][1]);
|
||||
}
|
||||
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid);
|
||||
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess);
|
||||
}
|
||||
void MeshTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const {
|
||||
void MeshTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess) const {
|
||||
if (mesh.is_null() || base_texture.is_null()) {
|
||||
return;
|
||||
}
|
||||
|
@ -1090,9 +1103,10 @@ void MeshTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile,
|
|||
SWAP(xform.elements[0][0], xform.elements[1][1]);
|
||||
}
|
||||
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid);
|
||||
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess);
|
||||
}
|
||||
void MeshTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, bool p_clip_uv) const {
|
||||
void MeshTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, bool p_clip_uv) const {
|
||||
|
||||
if (mesh.is_null() || base_texture.is_null()) {
|
||||
return;
|
||||
|
@ -1113,7 +1127,8 @@ void MeshTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const
|
|||
SWAP(xform.elements[0][0], xform.elements[1][1]);
|
||||
}
|
||||
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid);
|
||||
RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
|
||||
VisualServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess);
|
||||
}
|
||||
bool MeshTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
|
||||
r_rect = p_rect;
|
||||
|
@ -1266,16 +1281,16 @@ void LargeTexture::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_data", "_get_data");
|
||||
}
|
||||
|
||||
void LargeTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const {
|
||||
void LargeTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess) const {
|
||||
|
||||
for (int i = 0; i < pieces.size(); i++) {
|
||||
|
||||
// TODO
|
||||
pieces[i].texture->draw(p_canvas_item, pieces[i].offset + p_pos, p_modulate, p_transpose, p_normal_map);
|
||||
pieces[i].texture->draw(p_canvas_item, pieces[i].offset + p_pos, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess);
|
||||
}
|
||||
}
|
||||
|
||||
void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const {
|
||||
void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess) const {
|
||||
|
||||
//tiling not supported for this
|
||||
if (size.x == 0 || size.y == 0)
|
||||
|
@ -1286,10 +1301,10 @@ void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile
|
|||
for (int i = 0; i < pieces.size(); i++) {
|
||||
|
||||
// TODO
|
||||
pieces[i].texture->draw_rect(p_canvas_item, Rect2(pieces[i].offset * scale + p_rect.position, pieces[i].texture->get_size() * scale), false, p_modulate, p_transpose, p_normal_map);
|
||||
pieces[i].texture->draw_rect(p_canvas_item, Rect2(pieces[i].offset * scale + p_rect.position, pieces[i].texture->get_size() * scale), false, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess);
|
||||
}
|
||||
}
|
||||
void LargeTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, bool p_clip_uv) const {
|
||||
void LargeTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, bool p_clip_uv) const {
|
||||
|
||||
//tiling not supported for this
|
||||
if (p_src_rect.size.x == 0 || p_src_rect.size.y == 0)
|
||||
|
@ -1308,7 +1323,7 @@ void LargeTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, cons
|
|||
target.size *= scale;
|
||||
target.position = p_rect.position + (p_src_rect.position + rect.position) * scale;
|
||||
local.position -= rect.position;
|
||||
pieces[i].texture->draw_rect_region(p_canvas_item, target, local, p_modulate, p_transpose, p_normal_map, false);
|
||||
pieces[i].texture->draw_rect_region(p_canvas_item, target, local, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,9 +59,9 @@ public:
|
|||
|
||||
virtual bool has_alpha() const = 0;
|
||||
|
||||
virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const;
|
||||
virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), bool p_clip_uv = true) const;
|
||||
virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1)) const;
|
||||
virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1)) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), bool p_clip_uv = true) const;
|
||||
virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const;
|
||||
|
||||
virtual Ref<Image> get_data() const { return Ref<Image>(); }
|
||||
|
@ -109,9 +109,9 @@ public:
|
|||
virtual RID get_rid() const;
|
||||
|
||||
bool has_alpha() const;
|
||||
virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const;
|
||||
virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), bool p_clip_uv = true) const;
|
||||
virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1)) const;
|
||||
virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1)) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), bool p_clip_uv = true) const;
|
||||
|
||||
bool is_pixel_opaque(int p_x, int p_y) const;
|
||||
|
||||
|
@ -182,9 +182,9 @@ public:
|
|||
|
||||
virtual void set_path(const String &p_path, bool p_take_over);
|
||||
|
||||
virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const;
|
||||
virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), bool p_clip_uv = true) const;
|
||||
virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1)) const;
|
||||
virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1)) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), bool p_clip_uv = true) const;
|
||||
|
||||
virtual bool has_alpha() const;
|
||||
bool is_pixel_opaque(int p_x, int p_y) const;
|
||||
|
@ -235,9 +235,9 @@ public:
|
|||
void set_filter_clip(const bool p_enable);
|
||||
bool has_filter_clip() const;
|
||||
|
||||
virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const;
|
||||
virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), bool p_clip_uv = true) const;
|
||||
virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1)) const;
|
||||
virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1)) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), bool p_clip_uv = true) const;
|
||||
virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const;
|
||||
|
||||
bool is_pixel_opaque(int p_x, int p_y) const;
|
||||
|
@ -275,9 +275,9 @@ public:
|
|||
void set_base_texture(const Ref<Texture2D> &p_texture);
|
||||
Ref<Texture2D> get_base_texture() const;
|
||||
|
||||
virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const;
|
||||
virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), bool p_clip_uv = true) const;
|
||||
virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1)) const;
|
||||
virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1)) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), bool p_clip_uv = true) const;
|
||||
virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const;
|
||||
|
||||
bool is_pixel_opaque(int p_x, int p_y) const;
|
||||
|
@ -323,9 +323,9 @@ public:
|
|||
Ref<Texture2D> get_piece_texture(int p_idx) const;
|
||||
Ref<Image> to_image() const;
|
||||
|
||||
virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const;
|
||||
virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), bool p_clip_uv = true) const;
|
||||
virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1)) const;
|
||||
virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1)) const;
|
||||
virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), bool p_clip_uv = true) const;
|
||||
|
||||
bool is_pixel_opaque(int p_x, int p_y) const;
|
||||
|
||||
|
|
|
@ -820,3 +820,21 @@
|
|||
server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define FUNC14(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8, m_arg9, m_arg10, m_arg11, m_arg12, m_arg13, m_arg14) \
|
||||
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8, m_arg9 p9, m_arg10 p10, m_arg11 p11, m_arg12 p12, m_arg13 p13, m_arg14 p14) { \
|
||||
if (Thread::get_caller_id() != server_thread) { \
|
||||
command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); \
|
||||
} else { \
|
||||
server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define FUNC15(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8, m_arg9, m_arg10, m_arg11, m_arg12, m_arg13, m_arg14, m_arg15) \
|
||||
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7, m_arg8 p8, m_arg9 p9, m_arg10 p10, m_arg11 p11, m_arg12 p12, m_arg13 p13, m_arg14 p14, m_arg15 p15) { \
|
||||
if (Thread::get_caller_id() != server_thread) { \
|
||||
command_queue.push(server_name, &ServerName::m_type, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15); \
|
||||
} else { \
|
||||
server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15); \
|
||||
} \
|
||||
}
|
||||
|
|
|
@ -4,3 +4,4 @@ Import('env')
|
|||
|
||||
env.add_source_files(env.servers_sources, "*.cpp")
|
||||
|
||||
SConscript("shaders/SCsub")
|
||||
|
|
|
@ -40,6 +40,8 @@ Rasterizer *Rasterizer::create() {
|
|||
return _create_func();
|
||||
}
|
||||
|
||||
RasterizerCanvas *RasterizerCanvas::singleton = NULL;
|
||||
|
||||
RasterizerStorage *RasterizerStorage::base_singleton = NULL;
|
||||
|
||||
RasterizerStorage::RasterizerStorage() {
|
||||
|
|
|
@ -549,12 +549,11 @@ public:
|
|||
virtual RID render_target_create() = 0;
|
||||
virtual void render_target_set_position(RID p_render_target, int p_x, int p_y) = 0;
|
||||
virtual void render_target_set_size(RID p_render_target, int p_width, int p_height) = 0;
|
||||
virtual RID render_target_get_texture(RID p_render_target) const = 0;
|
||||
virtual RID render_target_get_texture(RID p_render_target) = 0;
|
||||
virtual void render_target_set_external_texture(RID p_render_target, unsigned int p_texture_id) = 0;
|
||||
virtual void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value) = 0;
|
||||
virtual bool render_target_was_used(RID p_render_target) = 0;
|
||||
virtual void render_target_clear_used(RID p_render_target) = 0;
|
||||
virtual void render_target_set_msaa(RID p_render_target, VS::ViewportMSAA p_msaa) = 0;
|
||||
virtual void render_target_clear_used_flag(RID p_render_target) = 0;
|
||||
|
||||
/* CANVAS SHADOW */
|
||||
|
||||
|
@ -589,6 +588,8 @@ public:
|
|||
|
||||
class RasterizerCanvas {
|
||||
public:
|
||||
static RasterizerCanvas *singleton;
|
||||
|
||||
enum CanvasRectFlags {
|
||||
|
||||
CANVAS_RECT_REGION = 1,
|
||||
|
@ -669,6 +670,38 @@ public:
|
|||
virtual void light_internal_update(RID p_rid, Light *p_light) = 0;
|
||||
virtual void light_internal_free(RID p_rid) = 0;
|
||||
|
||||
typedef uint64_t TextureBindingID;
|
||||
|
||||
virtual TextureBindingID request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, VS::CanvasItemTextureFilter p_filter, VS::CanvasItemTextureRepeat p_repeat, RID p_multimesh) = 0;
|
||||
virtual void free_texture_binding(TextureBindingID p_binding) = 0;
|
||||
|
||||
//easier wrap to avoid mistakes
|
||||
|
||||
struct Item;
|
||||
|
||||
struct TextureBinding {
|
||||
|
||||
TextureBindingID binding_id;
|
||||
|
||||
_FORCE_INLINE_ void create(VS::CanvasItemTextureFilter p_item_filter, VS::CanvasItemTextureRepeat p_item_repeat, RID p_texture, RID p_normalmap, RID p_specular, VS::CanvasItemTextureFilter p_filter, VS::CanvasItemTextureRepeat p_repeat, RID p_multimesh) {
|
||||
if (p_filter == VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT) {
|
||||
p_filter = p_item_filter;
|
||||
}
|
||||
if (p_repeat == VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) {
|
||||
p_repeat = p_item_repeat;
|
||||
}
|
||||
if (p_texture != RID() || p_normalmap != RID() || p_specular != RID() || p_filter != VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT || p_repeat != VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT || p_multimesh.is_valid()) {
|
||||
ERR_FAIL_COND(binding_id != 0);
|
||||
binding_id = singleton->request_texture_binding(p_texture, p_normalmap, p_specular, p_filter, p_repeat, p_multimesh);
|
||||
}
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ TextureBinding() { binding_id = 0; }
|
||||
_FORCE_INLINE_ ~TextureBinding() {
|
||||
if (binding_id) singleton->free_texture_binding(binding_id);
|
||||
}
|
||||
};
|
||||
|
||||
struct Item {
|
||||
|
||||
struct Command {
|
||||
|
@ -719,11 +752,12 @@ public:
|
|||
struct CommandRect : public Command {
|
||||
|
||||
Rect2 rect;
|
||||
RID texture;
|
||||
RID normal_map;
|
||||
Color modulate;
|
||||
Rect2 source;
|
||||
uint8_t flags;
|
||||
Color specular_shininess;
|
||||
|
||||
TextureBinding texture_binding;
|
||||
|
||||
CommandRect() {
|
||||
flags = 0;
|
||||
|
@ -735,13 +769,13 @@ public:
|
|||
|
||||
Rect2 rect;
|
||||
Rect2 source;
|
||||
RID texture;
|
||||
RID normal_map;
|
||||
float margin[4];
|
||||
bool draw_center;
|
||||
Color color;
|
||||
VS::NinePatchAxisMode axis_x;
|
||||
VS::NinePatchAxisMode axis_y;
|
||||
Color specular_shininess;
|
||||
TextureBinding texture_binding;
|
||||
CommandNinePatch() {
|
||||
draw_center = true;
|
||||
type = TYPE_NINEPATCH;
|
||||
|
@ -753,10 +787,9 @@ public:
|
|||
Vector<Point2> points;
|
||||
Vector<Point2> uvs;
|
||||
Vector<Color> colors;
|
||||
RID texture;
|
||||
RID normal_map;
|
||||
float width;
|
||||
|
||||
Color specular_shininess;
|
||||
TextureBinding texture_binding;
|
||||
CommandPrimitive() {
|
||||
type = TYPE_PRIMITIVE;
|
||||
width = 1;
|
||||
|
@ -771,11 +804,11 @@ public:
|
|||
Vector<Color> colors;
|
||||
Vector<int> bones;
|
||||
Vector<float> weights;
|
||||
RID texture;
|
||||
RID normal_map;
|
||||
int count;
|
||||
bool antialiased;
|
||||
bool antialiasing_use_indices;
|
||||
|
||||
Color specular_shininess;
|
||||
TextureBinding texture_binding;
|
||||
|
||||
CommandPolygon() {
|
||||
type = TYPE_POLYGON;
|
||||
|
@ -786,26 +819,26 @@ public:
|
|||
struct CommandMesh : public Command {
|
||||
|
||||
RID mesh;
|
||||
RID texture;
|
||||
RID normal_map;
|
||||
Transform2D transform;
|
||||
Color modulate;
|
||||
Color specular_shininess;
|
||||
TextureBinding texture_binding;
|
||||
CommandMesh() { type = TYPE_MESH; }
|
||||
};
|
||||
|
||||
struct CommandMultiMesh : public Command {
|
||||
|
||||
RID multimesh;
|
||||
RID texture;
|
||||
RID normal_map;
|
||||
Color specular_shininess;
|
||||
TextureBinding texture_binding;
|
||||
CommandMultiMesh() { type = TYPE_MULTIMESH; }
|
||||
};
|
||||
|
||||
struct CommandParticles : public Command {
|
||||
|
||||
RID particles;
|
||||
RID texture;
|
||||
RID normal_map;
|
||||
Color specular_shininess;
|
||||
TextureBinding texture_binding;
|
||||
CommandParticles() { type = TYPE_PARTICLES; }
|
||||
};
|
||||
|
||||
|
@ -1050,10 +1083,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
virtual void canvas_begin() = 0;
|
||||
virtual void canvas_end() = 0;
|
||||
|
||||
virtual void canvas_render_items(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_base_transform) = 0;
|
||||
virtual void canvas_render_items(RID p_to_render_target, bool p_clear, const Color &p_clear_color, Item *p_item_list, const Color &p_modulate, Light *p_light_list, const Transform2D &p_canvas_transform) = 0;
|
||||
virtual void canvas_debug_viewport_shadows(Light *p_lights_with_shadow) = 0;
|
||||
|
||||
struct LightOccluderInstance {
|
||||
|
@ -1084,6 +1114,9 @@ public:
|
|||
|
||||
virtual void draw_window_margins(int *p_margins, RID *p_margin_textures) = 0;
|
||||
|
||||
virtual void update() = 0;
|
||||
|
||||
RasterizerCanvas() { singleton = this; }
|
||||
virtual ~RasterizerCanvas() {}
|
||||
};
|
||||
|
||||
|
@ -1102,11 +1135,15 @@ public:
|
|||
|
||||
virtual void initialize() = 0;
|
||||
virtual void begin_frame(double frame_step) = 0;
|
||||
virtual void set_current_render_target(RID p_render_target) = 0;
|
||||
virtual void restore_render_target(bool p_3d) = 0;
|
||||
virtual void clear_render_target(const Color &p_color) = 0;
|
||||
virtual void blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect, int p_screen = 0) = 0;
|
||||
virtual void output_lens_distorted_to_screen(RID p_render_target, const Rect2 &p_screen_rect, float p_k1, float p_k2, const Vector2 &p_eye_center, float p_oversample) = 0;
|
||||
|
||||
struct BlitToScreen {
|
||||
RID render_target;
|
||||
Rect2i rect;
|
||||
//lens distorted parameters for VR should go here
|
||||
};
|
||||
|
||||
virtual void blit_render_targets_to_screen(int p_screen, const BlitToScreen *p_render_targets, int p_amount) = 0;
|
||||
|
||||
virtual void end_frame(bool p_swap_buffers) = 0;
|
||||
virtual void finalize() = 0;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,17 +2,218 @@
|
|||
#define RASTERIZER_CANVAS_RD_H
|
||||
|
||||
#include "servers/visual/rasterizer/rasterizer.h"
|
||||
#include "servers/visual/rasterizer/rasterizer_storage_rd.h"
|
||||
#include "servers/visual/rasterizer/shaders/canvas.glsl.gen.h"
|
||||
#include "servers/visual/rendering_device.h"
|
||||
|
||||
class RasterizerCanvasRD : public RasterizerCanvas {
|
||||
|
||||
RasterizerStorageRD *storage;
|
||||
|
||||
enum ShaderVariant {
|
||||
SHADER_VARIANT_QUAD,
|
||||
SHADER_VARIANT_NINEPATCH,
|
||||
SHADER_VARIANT_VERTICES,
|
||||
SHADER_VARIANT_POINTS,
|
||||
SHADER_VARIANT_MAX
|
||||
};
|
||||
|
||||
enum RenderTargetFormat {
|
||||
RENDER_TARGET_FORMAT_8_BIT_INT,
|
||||
RENDER_TARGET_FORMAT_16_BIT_FLOAT,
|
||||
RENDER_TARGET_FORMAT_MAX
|
||||
};
|
||||
|
||||
enum {
|
||||
FLAGS_INSTANCING_STRIDE_MASK = 0xF,
|
||||
FLAGS_INSTANCING_ENABLED = (1 << 4),
|
||||
FLAGS_INSTANCING_HAS_COLORS = (1 << 5),
|
||||
FLAGS_INSTANCING_COLOR_8BIT = (1 << 6),
|
||||
FLAGS_INSTANCING_HAS_CUSTOM_DATA = (1 << 7),
|
||||
FLAGS_INSTANCING_CUSTOM_DATA_8_BIT = (1 << 8),
|
||||
|
||||
FLAGS_CLIP_RECT_UV = (1 << 9),
|
||||
FLAGS_TRANSPOSE_RECT = (1 << 10),
|
||||
FLAGS_NINEPACH_DRAW_CENTER = (1 << 12),
|
||||
FLAGS_USING_PARTICLES = (1 << 13),
|
||||
FLAGS_USE_PIXEL_SNAP = (1 << 14),
|
||||
|
||||
FLAGS_USE_SKELETON = (1 << 16)
|
||||
};
|
||||
|
||||
/****************/
|
||||
/**** SHADER ****/
|
||||
/****************/
|
||||
|
||||
enum PipelineVariant {
|
||||
PIPELINE_VARIANT_QUAD,
|
||||
PIPELINE_VARIANT_NINEPATCH,
|
||||
PIPELINE_VARIANT_TRIANGLES,
|
||||
PIPELINE_VARIANT_LINES,
|
||||
PIPELINE_VARIANT_POINTS,
|
||||
PIPELINE_VARIANT_TRIANGLES_COMPRESSED,
|
||||
PIPELINE_VARIANT_LINES_COMPRESSED,
|
||||
PIPELINE_VARIANT_POINTS_COMPRESSED,
|
||||
PIPELINE_VARIANT_MAX
|
||||
};
|
||||
struct PipelineVariants {
|
||||
RID variants[RENDER_TARGET_FORMAT_MAX][PIPELINE_VARIANT_MAX];
|
||||
};
|
||||
|
||||
struct {
|
||||
CanvasShaderRD canvas_shader;
|
||||
RD::FramebufferFormatID framebuffer_formats[RENDER_TARGET_FORMAT_MAX];
|
||||
RID default_version;
|
||||
RID default_version_rd_shader;
|
||||
RID quad_index_array;
|
||||
PipelineVariants pipeline_variants;
|
||||
|
||||
// default_skeleton uniform set
|
||||
RID default_material_skeleton_uniform;
|
||||
RID default_material_uniform_set;
|
||||
|
||||
} shader;
|
||||
|
||||
/**************************/
|
||||
/**** TEXTURE BINDINGS ****/
|
||||
/**************************/
|
||||
|
||||
// bindings used to render commands,
|
||||
// cached for performance.
|
||||
|
||||
struct TextureBindingKey {
|
||||
RID texture;
|
||||
RID normalmap;
|
||||
RID specular;
|
||||
RID multimesh;
|
||||
VS::CanvasItemTextureFilter texture_filter;
|
||||
VS::CanvasItemTextureRepeat texture_repeat;
|
||||
bool operator==(const TextureBindingKey &p_key) const {
|
||||
return texture == p_key.texture && normalmap == p_key.normalmap && specular == p_key.specular && multimesh == p_key.specular && texture_filter == p_key.texture_filter && texture_repeat == p_key.texture_repeat;
|
||||
}
|
||||
};
|
||||
|
||||
struct TextureBindingKeyHasher {
|
||||
static _FORCE_INLINE_ uint32_t hash(const TextureBindingKey &p_key) {
|
||||
uint32_t hash = hash_djb2_one_64(p_key.texture.get_id());
|
||||
hash = hash_djb2_one_64(p_key.normalmap.get_id(), hash);
|
||||
hash = hash_djb2_one_64(p_key.specular.get_id(), hash);
|
||||
hash = hash_djb2_one_64(p_key.multimesh.get_id(), hash);
|
||||
hash = hash_djb2_one_32(uint32_t(p_key.texture_filter) << 16 | uint32_t(p_key.texture_repeat), hash);
|
||||
return hash;
|
||||
}
|
||||
};
|
||||
|
||||
struct TextureBinding {
|
||||
TextureBindingID id;
|
||||
TextureBindingKey key;
|
||||
SelfList<TextureBinding> to_dispose;
|
||||
uint32_t reference_count;
|
||||
RID uniform_set;
|
||||
TextureBinding() :
|
||||
to_dispose(this) {
|
||||
reference_count = 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct {
|
||||
SelfList<TextureBinding>::List to_dispose_list;
|
||||
|
||||
TextureBindingID id_generator;
|
||||
HashMap<TextureBindingKey, TextureBindingID, TextureBindingKeyHasher> texture_key_bindings;
|
||||
HashMap<TextureBindingID, TextureBinding *> texture_bindings;
|
||||
|
||||
TextureBindingID default_empty;
|
||||
} bindings;
|
||||
|
||||
void _dispose_bindings();
|
||||
struct {
|
||||
RID white_texture;
|
||||
RID black_texture;
|
||||
RID normal_texture;
|
||||
RID aniso_texture;
|
||||
|
||||
RID default_multimesh_tb;
|
||||
|
||||
} default_textures;
|
||||
|
||||
struct {
|
||||
RID samplers[VS::CANVAS_ITEM_TEXTURE_FILTER_MAX][VS::CANVAS_ITEM_TEXTURE_REPEAT_MAX];
|
||||
VS::CanvasItemTextureFilter default_filter;
|
||||
VS::CanvasItemTextureRepeat default_repeat;
|
||||
} default_samplers;
|
||||
|
||||
/*******************/
|
||||
/**** MATERIALS ****/
|
||||
/*******************/
|
||||
|
||||
/***************/
|
||||
/**** STATE ****/
|
||||
/***************/
|
||||
|
||||
//state that does not vary across rendering all items
|
||||
|
||||
struct State {
|
||||
|
||||
//state buffer
|
||||
struct Buffer {
|
||||
float canvas_transform[16];
|
||||
float screen_transform[16];
|
||||
//uint32_t light_count;
|
||||
//uint32_t pad[3];
|
||||
};
|
||||
RID canvas_state_buffer;
|
||||
//light buffer
|
||||
RID canvas_state_light_buffer;
|
||||
|
||||
//uniform set for all the above
|
||||
RID canvas_state_uniform_set;
|
||||
} state;
|
||||
|
||||
struct PushConstant {
|
||||
float world[8];
|
||||
float modulation[4];
|
||||
float ninepatch_margins[4];
|
||||
float dst_rect[4];
|
||||
float src_rect[4];
|
||||
uint32_t flags;
|
||||
uint32_t ninepatch_repeat;
|
||||
float color_texture_pixel_size[2];
|
||||
uint32_t specular_shininess;
|
||||
uint32_t pad[3];
|
||||
};
|
||||
|
||||
struct SkeletonUniform {
|
||||
float skeleton_transform[16];
|
||||
float skeleton_inverse[16];
|
||||
};
|
||||
|
||||
enum {
|
||||
MAX_RENDER_ITEMS = 256 * 1024
|
||||
};
|
||||
|
||||
Item *items[MAX_RENDER_ITEMS];
|
||||
|
||||
void _render_item(RenderingDevice::DrawListID p_draw_list, const Item *p_item, RenderTargetFormat p_render_target_format, const Color &p_modulate, const Transform2D &p_canvas_transform_inverse);
|
||||
void _render_items(RID p_to_render_target, bool p_clear, const Color &p_clear_color, int p_item_count, const Color &p_modulate, const Transform2D &p_transform);
|
||||
|
||||
void _update_transform_2d_to_mat2x4(const Transform2D &p_transform, float *p_mat2x4);
|
||||
|
||||
void _update_transform_2d_to_mat4(const Transform2D &p_transform, float *p_mat4);
|
||||
void _update_transform_to_mat4(const Transform &p_transform, float *p_mat4);
|
||||
|
||||
void _update_canvas_state_uniform_set();
|
||||
|
||||
public:
|
||||
TextureBindingID request_texture_binding(RID p_texture, RID p_normalmap, RID p_specular, VS::CanvasItemTextureFilter p_filter, VS::CanvasItemTextureRepeat p_repeat, RID p_multimesh);
|
||||
void free_texture_binding(TextureBindingID p_binding);
|
||||
|
||||
RID light_internal_create() { return RID(); }
|
||||
void light_internal_update(RID p_rid, Light *p_light) {}
|
||||
void light_internal_free(RID p_rid) {}
|
||||
|
||||
void canvas_begin(){};
|
||||
void canvas_end(){};
|
||||
void canvas_render_items(RID p_to_render_target, bool p_clear, const Color &p_clear_color, Item *p_item_list, const Color &p_modulate, Light *p_light_list, const Transform2D &p_canvas_transform);
|
||||
|
||||
void canvas_render_items(Item *p_item_list, int p_z, const Color &p_modulate, Light *p_light, const Transform2D &p_transform){};
|
||||
void canvas_debug_viewport_shadows(Light *p_lights_with_shadow){};
|
||||
|
||||
void canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D &p_light_xform, int p_light_mask, float p_near, float p_far, LightOccluderInstance *p_occluders, CameraMatrix *p_xform_cache) {}
|
||||
|
@ -21,7 +222,8 @@ public:
|
|||
|
||||
void draw_window_margins(int *p_margins, RID *p_margin_textures) {}
|
||||
|
||||
RasterizerCanvasRD() {}
|
||||
void update();
|
||||
RasterizerCanvasRD(RasterizerStorageRD *p_storage);
|
||||
~RasterizerCanvasRD() {}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,127 @@
|
|||
#include "rasterizer_rd.h"
|
||||
|
||||
RasterizerRD::RasterizerRD() {
|
||||
canvas = memnew(RasterizerCanvasRD);
|
||||
storage = memnew(RasterizerStorageRD);
|
||||
scene = memnew(RasterizerSceneForwardRD);
|
||||
void RasterizerRD::blit_render_targets_to_screen(int p_screen, const BlitToScreen *p_render_targets, int p_amount) {
|
||||
|
||||
RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin_for_screen(p_screen);
|
||||
for (int i = 0; i < p_amount; i++) {
|
||||
RID texture = storage->render_target_get_texture(p_render_targets[i].render_target);
|
||||
ERR_CONTINUE(texture.is_null());
|
||||
RID rd_texture = storage->texture_get_rd_texture(texture);
|
||||
ERR_CONTINUE(rd_texture.is_null());
|
||||
if (!render_target_descriptors.has(rd_texture) || !RD::get_singleton()->uniform_set_is_valid(render_target_descriptors[rd_texture])) {
|
||||
Vector<RD::Uniform> uniforms;
|
||||
RD::Uniform u;
|
||||
u.type = RD::UNIFORM_TYPE_SAMPLER_WITH_TEXTURE;
|
||||
u.binding = 0;
|
||||
u.ids.push_back(copy_viewports_sampler);
|
||||
u.ids.push_back(rd_texture);
|
||||
RID uniform_set = RD::get_singleton()->uniform_set_create(uniforms, copy_viewports_rd_shader, 0);
|
||||
|
||||
render_target_descriptors[rd_texture] = uniform_set;
|
||||
}
|
||||
|
||||
Size2 screen_size(RD::get_singleton()->screen_get_width(p_screen), RD::get_singleton()->screen_get_height(p_screen));
|
||||
|
||||
RD::get_singleton()->draw_list_bind_render_pipeline(draw_list, copy_viewports_rd_pipeline);
|
||||
RD::get_singleton()->draw_list_bind_index_array(draw_list, copy_viewports_rd_array);
|
||||
RD::get_singleton()->draw_list_bind_uniform_set(draw_list, render_target_descriptors[rd_texture], 0);
|
||||
|
||||
float push_constant[4] = {
|
||||
p_render_targets[i].rect.position.x / screen_size.width,
|
||||
p_render_targets[i].rect.position.y / screen_size.height,
|
||||
p_render_targets[i].rect.size.width / screen_size.width,
|
||||
p_render_targets[i].rect.size.height / screen_size.height,
|
||||
};
|
||||
RD::get_singleton()->draw_list_set_push_constant(draw_list, push_constant, 4 * sizeof(float));
|
||||
RD::get_singleton()->draw_list_draw(draw_list, true);
|
||||
}
|
||||
}
|
||||
|
||||
void RasterizerRD::begin_frame(double frame_step) {
|
||||
}
|
||||
|
||||
void RasterizerRD::end_frame(bool p_swap_buffers) {
|
||||
RD::get_singleton()->finalize_frame();
|
||||
#warning not swapping buffers likely not an option for now, find another way
|
||||
OS::get_singleton()->swap_buffers(); //probably should pass some bool to avoid display?
|
||||
RD::get_singleton()->advance_frame(); //advance frame here, so any new call happens on new frame
|
||||
}
|
||||
|
||||
void RasterizerRD::initialize() {
|
||||
storage = memnew(RasterizerStorageRD);
|
||||
canvas = memnew(RasterizerCanvasRD(storage));
|
||||
scene = memnew(RasterizerSceneForwardRD);
|
||||
|
||||
{ //create framebuffer copy shader
|
||||
RenderingDevice::ShaderStageSource vert;
|
||||
vert.shader_stage = RenderingDevice::SHADER_STAGE_VERTEX;
|
||||
vert.shader_source =
|
||||
"#version 450\n"
|
||||
"layout(push_constant, binding = 0, std140) uniform Pos { vec4 dst_rect; } pos;\n"
|
||||
"layout(location =0) out vec2 uv;\n"
|
||||
"void main() { \n"
|
||||
" vec2 base_arr[4] = float[](vec2(0.0,0.0),vec2(0.0,1.0),vec2(1.0,1.0),vec2(1.0,0.0));\n"
|
||||
" uv = base_arr[gl_VertexIndex];\n"
|
||||
" gl_Position = vec4(dst_rect.xy,uv*dst_rect.zw);\n"
|
||||
"}\n";
|
||||
|
||||
RenderingDevice::ShaderStageSource frag;
|
||||
frag.shader_stage = RenderingDevice::SHADER_STAGE_FRAGMENT;
|
||||
frag.shader_source =
|
||||
"#version 450\n"
|
||||
"layout (location = 0) in vec2 uv;\n"
|
||||
"layout (location = 0) out vec4 color;\n"
|
||||
"layout (binding = 0) uniform sampler2D src_rt;\n"
|
||||
"void main() { color=texture(src_rt,uv); }\n";
|
||||
|
||||
Vector<RenderingDevice::ShaderStageSource> source;
|
||||
source.push_back(vert);
|
||||
source.push_back(frag);
|
||||
String error;
|
||||
copy_viewports_rd_shader = RD::get_singleton()->shader_create_from_source(source, &error);
|
||||
if (!copy_viewports_rd_shader.is_valid()) {
|
||||
print_line("failed compilation: " + error);
|
||||
} else {
|
||||
print_line("compilation success");
|
||||
}
|
||||
}
|
||||
|
||||
{ //create index array for copy shader
|
||||
PoolVector<uint8_t> pv;
|
||||
pv.resize(6 * 4);
|
||||
{
|
||||
PoolVector<uint8_t>::Write w = pv.write();
|
||||
int *p32 = (int *)w.ptr();
|
||||
p32[0] = 0;
|
||||
p32[1] = 1;
|
||||
p32[2] = 2;
|
||||
p32[3] = 0;
|
||||
p32[4] = 2;
|
||||
p32[5] = 3;
|
||||
}
|
||||
copy_viewports_rd_index_buffer = RD::get_singleton()->index_buffer_create(6, RenderingDevice::INDEX_BUFFER_FORMAT_UINT32, pv);
|
||||
copy_viewports_rd_array = RD::get_singleton()->index_array_create(copy_viewports_rd_index_buffer, 0, 6);
|
||||
}
|
||||
|
||||
{ //pipeline
|
||||
copy_viewports_rd_pipeline = RD::get_singleton()->render_pipeline_create(copy_viewports_rd_shader, RD::get_singleton()->screen_get_framebuffer_format(), RD::INVALID_ID, RD::RENDER_PRIMITIVE_TRIANGLES, RD::PipelineRasterizationState(), RD::PipelineMultisampleState(), RD::PipelineDepthStencilState(), RenderingDevice::PipelineColorBlendState::create_disabled(), 0);
|
||||
}
|
||||
{ // sampler
|
||||
copy_viewports_sampler = RD::get_singleton()->sampler_create(RD::SamplerState());
|
||||
}
|
||||
}
|
||||
|
||||
void RasterizerRD::finalize() {
|
||||
|
||||
memdelete(scene);
|
||||
memdelete(canvas);
|
||||
memdelete(storage);
|
||||
|
||||
//only need to erase these, the rest are erased by cascade
|
||||
RD::get_singleton()->free(copy_viewports_rd_index_buffer);
|
||||
RD::get_singleton()->free(copy_viewports_rd_shader);
|
||||
RD::get_singleton()->free(copy_viewports_sampler);
|
||||
}
|
||||
|
||||
RasterizerRD::RasterizerRD() {
|
||||
}
|
||||
|
|
|
@ -12,6 +12,14 @@ protected:
|
|||
RasterizerStorageRD *storage;
|
||||
RasterizerSceneForwardRD *scene;
|
||||
|
||||
RID copy_viewports_rd_shader;
|
||||
RID copy_viewports_rd_pipeline;
|
||||
RID copy_viewports_rd_index_buffer;
|
||||
RID copy_viewports_rd_array;
|
||||
RID copy_viewports_sampler;
|
||||
|
||||
Map<RID, RID> render_target_descriptors;
|
||||
|
||||
public:
|
||||
RasterizerStorage *get_storage() { return storage; }
|
||||
RasterizerCanvas *get_canvas() { return canvas; }
|
||||
|
@ -19,15 +27,12 @@ public:
|
|||
|
||||
void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {}
|
||||
|
||||
void initialize() {}
|
||||
void begin_frame(double frame_step) {}
|
||||
void set_current_render_target(RID p_render_target) {}
|
||||
void restore_render_target(bool p_3d_was_drawn) {}
|
||||
void clear_render_target(const Color &p_color) {}
|
||||
void blit_render_target_to_screen(RID p_render_target, const Rect2 &p_screen_rect, int p_screen = 0) {}
|
||||
void output_lens_distorted_to_screen(RID p_render_target, const Rect2 &p_screen_rect, float p_k1, float p_k2, const Vector2 &p_eye_center, float p_oversample) {}
|
||||
void end_frame(bool p_swap_buffers) { OS::get_singleton()->swap_buffers(); }
|
||||
void finalize() {}
|
||||
void initialize();
|
||||
void begin_frame(double frame_step);
|
||||
void blit_render_targets_to_screen(int p_screen, const BlitToScreen *p_render_targets, int p_amount);
|
||||
|
||||
void end_frame(bool p_swap_buffers);
|
||||
void finalize();
|
||||
|
||||
static Error is_viable() {
|
||||
return OK;
|
||||
|
|
|
@ -1,8 +1,539 @@
|
|||
#include "rasterizer_storage_rd.h"
|
||||
|
||||
RID RasterizerStorageRD::texture_2d_create(const Ref<Image> &p_image) {
|
||||
Ref<Image> RasterizerStorageRD::_validate_texture_format(const Ref<Image> &p_image, TextureToRDFormat &r_format) {
|
||||
|
||||
return RID();
|
||||
Ref<Image> image = p_image->duplicate();
|
||||
|
||||
switch (p_image->get_format()) {
|
||||
case Image::FORMAT_L8: {
|
||||
r_format.format = RD::DATA_FORMAT_R8_UNORM;
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
} break; //luminance
|
||||
case Image::FORMAT_LA8: {
|
||||
r_format.format = RD::DATA_FORMAT_R8G8_UNORM;
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_G;
|
||||
} break; //luminance-alpha
|
||||
case Image::FORMAT_R8: {
|
||||
r_format.format = RD::DATA_FORMAT_R8_UNORM;
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_ZERO;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_ZERO;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
} break;
|
||||
case Image::FORMAT_RG8: {
|
||||
r_format.format = RD::DATA_FORMAT_R8G8_UNORM;
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_ZERO;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
} break;
|
||||
case Image::FORMAT_RGB8: {
|
||||
//this format is not mandatory for specification, check if supported first
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_R8G8B8_UNORM, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT) && RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_R8G8B8_SRGB, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_R8G8B8_UNORM;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_R8G8B8_SRGB;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
image->convert(Image::FORMAT_RGBA8);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
|
||||
} break;
|
||||
case Image::FORMAT_RGBA8: {
|
||||
r_format.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
} break;
|
||||
case Image::FORMAT_RGBA4444: {
|
||||
r_format.format = RD::DATA_FORMAT_B4G4R4A4_UNORM_PACK16;
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_B; //needs swizzle
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
} break;
|
||||
case Image::FORMAT_RGBA5551: {
|
||||
r_format.format = RD::DATA_FORMAT_A1R5G5B5_UNORM_PACK16;
|
||||
#warning TODO needs something in Texture to convert to this format internally
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
} break;
|
||||
case Image::FORMAT_RF: {
|
||||
r_format.format = RD::DATA_FORMAT_R32_SFLOAT;
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_ZERO;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_ZERO;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
} break; //float
|
||||
case Image::FORMAT_RGF: {
|
||||
r_format.format = RD::DATA_FORMAT_R32G32_SFLOAT;
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_ZERO;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
} break;
|
||||
case Image::FORMAT_RGBF: {
|
||||
//this format is not mandatory for specification, check if supported first
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_R32G32B32_SFLOAT, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_R32G32B32_SFLOAT;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R32G32B32A32_SFLOAT;
|
||||
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;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
} break;
|
||||
case 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;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
|
||||
} break;
|
||||
case Image::FORMAT_RH: {
|
||||
r_format.format = RD::DATA_FORMAT_R16_SFLOAT;
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_ZERO;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_ZERO;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
|
||||
} break; //half float
|
||||
case Image::FORMAT_RGH: {
|
||||
r_format.format = RD::DATA_FORMAT_R16G16_SFLOAT;
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_ZERO;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
|
||||
} break;
|
||||
case Image::FORMAT_RGBH: {
|
||||
//this format is not mandatory for specification, check if supported first
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_R16G16B16_SFLOAT, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_R16G16B16_SFLOAT;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT;
|
||||
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;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
} break;
|
||||
case 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;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
|
||||
} break;
|
||||
case Image::FORMAT_RGBE9995: {
|
||||
r_format.format = RD::DATA_FORMAT_E5B9G9R9_UFLOAT_PACK32;
|
||||
#warning TODO need to make a function in Image to swap bits for this
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_IDENTITY;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_IDENTITY;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_IDENTITY;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_IDENTITY;
|
||||
} break;
|
||||
case Image::FORMAT_DXT1: {
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_BC1_RGB_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_BC1_RGB_UNORM_BLOCK;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_BC1_RGBA_SRGB_BLOCK;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
image->decompress();
|
||||
image->convert(Image::FORMAT_RGBA8);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
|
||||
} break; //s3tc bc1
|
||||
case Image::FORMAT_DXT3: {
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_BC2_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_BC2_UNORM_BLOCK;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_BC2_SRGB_BLOCK;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
image->decompress();
|
||||
image->convert(Image::FORMAT_RGBA8);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
|
||||
} break; //bc2
|
||||
case Image::FORMAT_DXT5: {
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_BC3_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_BC3_UNORM_BLOCK;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_BC3_SRGB_BLOCK;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
image->decompress();
|
||||
image->convert(Image::FORMAT_RGBA8);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
} break; //bc3
|
||||
case Image::FORMAT_RGTC_R: {
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_BC4_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_BC4_UNORM_BLOCK;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R8_UNORM;
|
||||
image->decompress();
|
||||
image->convert(Image::FORMAT_R8);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_ZERO;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_ZERO;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
|
||||
} break;
|
||||
case Image::FORMAT_RGTC_RG: {
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_BC5_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_BC5_UNORM_BLOCK;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R8G8_UNORM;
|
||||
image->decompress();
|
||||
image->convert(Image::FORMAT_RG8);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_ZERO;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
|
||||
} break;
|
||||
case Image::FORMAT_BPTC_RGBA: {
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_BC7_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_BC7_UNORM_BLOCK;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_BC7_SRGB_BLOCK;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
image->decompress();
|
||||
image->convert(Image::FORMAT_RGBA8);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
|
||||
} break; //btpc bc7
|
||||
case Image::FORMAT_BPTC_RGBF: {
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_BC6H_SFLOAT_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_BC6H_SFLOAT_BLOCK;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT;
|
||||
image->decompress();
|
||||
image->convert(Image::FORMAT_RGBAH);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
} break; //float bc6h
|
||||
case Image::FORMAT_BPTC_RGBFU: {
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_BC6H_UFLOAT_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_BC6H_UFLOAT_BLOCK;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT;
|
||||
image->decompress();
|
||||
image->convert(Image::FORMAT_RGBAH);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
} break; //unsigned float bc6hu
|
||||
case Image::FORMAT_PVRTC2: {
|
||||
//this is not properly supported by MoltekVK it seems, so best to use ETC2
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
image->decompress();
|
||||
image->convert(Image::FORMAT_RGBA8);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
|
||||
} break; //pvrtc
|
||||
case Image::FORMAT_PVRTC2A: {
|
||||
//this is not properly supported by MoltekVK it seems, so best to use ETC2
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
image->decompress();
|
||||
image->convert(Image::FORMAT_RGBA8);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
} break;
|
||||
case Image::FORMAT_PVRTC4: {
|
||||
//this is not properly supported by MoltekVK it seems, so best to use ETC2
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
image->decompress();
|
||||
image->convert(Image::FORMAT_RGBA8);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
} break;
|
||||
case Image::FORMAT_PVRTC4A: {
|
||||
//this is not properly supported by MoltekVK it seems, so best to use ETC2
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
image->decompress();
|
||||
image->convert(Image::FORMAT_RGBA8);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
} break;
|
||||
case Image::FORMAT_ETC2_R11: {
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_EAC_R11_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_EAC_R11_UNORM_BLOCK;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R8_UNORM;
|
||||
image->decompress();
|
||||
image->convert(Image::FORMAT_R8);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_ZERO;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_ZERO;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
|
||||
} break; //etc2
|
||||
case Image::FORMAT_ETC2_R11S: {
|
||||
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_EAC_R11_SNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_EAC_R11_SNORM_BLOCK;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R8_SNORM;
|
||||
image->decompress();
|
||||
image->convert(Image::FORMAT_R8);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_ZERO;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_ZERO;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
} break; //signed: {} break; NOT srgb.
|
||||
case Image::FORMAT_ETC2_RG11: {
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_EAC_R11G11_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_EAC_R11G11_UNORM_BLOCK;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R8G8_UNORM;
|
||||
image->decompress();
|
||||
image->convert(Image::FORMAT_RG8);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_ZERO;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
} break;
|
||||
case Image::FORMAT_ETC2_RG11S: {
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_EAC_R11G11_SNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_EAC_R11G11_SNORM_BLOCK;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R8G8_SNORM;
|
||||
image->decompress();
|
||||
image->convert(Image::FORMAT_RG8);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_ZERO;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
} break;
|
||||
case Image::FORMAT_ETC:
|
||||
case Image::FORMAT_ETC2_RGB8: {
|
||||
//ETC2 is backwards compatible with ETC1, and all modern platforms support it
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_ETC2_R8G8B8_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_ETC2_R8G8B8_UNORM_BLOCK;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_ETC2_R8G8B8_SRGB_BLOCK;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
image->decompress();
|
||||
image->convert(Image::FORMAT_RGBA8);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_ONE;
|
||||
|
||||
} break;
|
||||
case Image::FORMAT_ETC2_RGBA8: {
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
image->decompress();
|
||||
image->convert(Image::FORMAT_RGBA8);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
} break;
|
||||
case Image::FORMAT_ETC2_RGB8A1: {
|
||||
|
||||
if (RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK, RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT)) {
|
||||
r_format.format = RD::DATA_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK;
|
||||
} else {
|
||||
//not supported, reconvert
|
||||
r_format.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
r_format.format_srgb = RD::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
image->decompress();
|
||||
image->convert(Image::FORMAT_RGBA8);
|
||||
}
|
||||
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
r_format.swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
} break;
|
||||
default: {
|
||||
}
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
RID RasterizerStorageRD::texture_2d_create(const Ref<Image> &p_image) {
|
||||
ERR_FAIL_COND_V(p_image.is_null(), RID());
|
||||
ERR_FAIL_COND_V(p_image->empty(), RID());
|
||||
|
||||
TextureToRDFormat ret_format;
|
||||
Ref<Image> image = _validate_texture_format(p_image, ret_format);
|
||||
|
||||
Texture texture;
|
||||
|
||||
texture.type = Texture::TYPE_2D;
|
||||
|
||||
texture.width = p_image->get_width();
|
||||
texture.height = p_image->get_height();
|
||||
texture.layers = 1;
|
||||
texture.mipmaps = p_image->get_mipmap_count();
|
||||
texture.depth = 1;
|
||||
|
||||
texture.rd_type = RD::TEXTURE_TYPE_2D;
|
||||
texture.rd_format = ret_format.format;
|
||||
texture.rd_format_srgb = ret_format.format_srgb;
|
||||
|
||||
RD::TextureFormat rd_format;
|
||||
RD::TextureView rd_view;
|
||||
{ //attempt register
|
||||
rd_format.format = texture.rd_format;
|
||||
rd_format.width = texture.width;
|
||||
rd_format.height = texture.height;
|
||||
rd_format.depth = 1;
|
||||
rd_format.array_layers = 1;
|
||||
rd_format.mipmaps = texture.mipmaps;
|
||||
rd_format.type = texture.rd_type;
|
||||
rd_format.samples = RD::TEXTURE_SAMPLES_1;
|
||||
rd_format.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT;
|
||||
}
|
||||
{
|
||||
rd_view.swizzle_r = ret_format.swizzle_r;
|
||||
rd_view.swizzle_g = ret_format.swizzle_g;
|
||||
rd_view.swizzle_b = ret_format.swizzle_b;
|
||||
rd_view.swizzle_a = ret_format.swizzle_a;
|
||||
}
|
||||
PoolVector<uint8_t> data = image->get_data(); //use image data
|
||||
Vector<PoolVector<uint8_t> > data_slices;
|
||||
data_slices.push_back(data);
|
||||
texture.rd_texture = RD::get_singleton()->texture_create(rd_format, rd_view, data_slices);
|
||||
ERR_FAIL_COND_V(texture.rd_texture.is_null(), RID());
|
||||
if (texture.rd_format_srgb != RD::DATA_FORMAT_MAX) {
|
||||
rd_view.format_override = texture.rd_format_srgb;
|
||||
texture.rd_texture_srgb = RD::get_singleton()->texture_create_shared(rd_view, texture.rd_texture);
|
||||
if (texture.rd_texture_srgb.is_null()) {
|
||||
RD::get_singleton()->free(texture.rd_texture);
|
||||
ERR_FAIL_COND_V(texture.rd_texture_srgb.is_null(), RID());
|
||||
}
|
||||
}
|
||||
|
||||
//used for 2D, overridable
|
||||
texture.width_2d = texture.width;
|
||||
texture.height_2d = texture.height;
|
||||
texture.is_render_target = false;
|
||||
|
||||
#warning TODO this is temporary to get things to work
|
||||
texture.image_cache_2d = p_image;
|
||||
|
||||
#warning texture owner needs a spinlock to make this really callable from any thread
|
||||
return texture_owner.make_rid(texture);
|
||||
}
|
||||
|
||||
RID RasterizerStorageRD::texture_2d_layered_create(const Vector<Ref<Image> > &p_layers, VS::TextureLayeredType p_layered_type) {
|
||||
|
@ -14,9 +545,34 @@ RID RasterizerStorageRD::texture_3d_create(const Vector<Ref<Image> > &p_slices)
|
|||
return RID();
|
||||
}
|
||||
|
||||
void RasterizerStorageRD::_texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer, bool p_immediate) {
|
||||
|
||||
ERR_FAIL_COND(p_image.is_null() || p_image->empty());
|
||||
|
||||
Texture *tex = texture_owner.getornull(p_texture);
|
||||
ERR_FAIL_COND(!tex);
|
||||
ERR_FAIL_COND(tex->is_render_target);
|
||||
ERR_FAIL_COND(p_image->get_width() != tex->width || p_image->get_height() != tex->height);
|
||||
ERR_FAIL_COND(p_image->get_format() != tex->format);
|
||||
|
||||
if (tex->type == Texture::TYPE_LAYERED) {
|
||||
ERR_FAIL_INDEX(p_layer, tex->layers);
|
||||
}
|
||||
|
||||
#warning TODO this is temporary to get things to work
|
||||
tex->image_cache_2d = p_image;
|
||||
|
||||
TextureToRDFormat f;
|
||||
Ref<Image> validated = _validate_texture_format(p_image, f);
|
||||
|
||||
RD::get_singleton()->texture_update(tex->rd_texture, p_layer, validated->get_data(), !p_immediate);
|
||||
}
|
||||
|
||||
void RasterizerStorageRD::texture_2d_update_immediate(RID p_texture, const Ref<Image> &p_image, int p_layer) {
|
||||
_texture_2d_update(p_texture, p_image, p_layer, true);
|
||||
}
|
||||
void RasterizerStorageRD::texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer) {
|
||||
_texture_2d_update(p_texture, p_image, p_layer, false);
|
||||
}
|
||||
void RasterizerStorageRD::texture_3d_update(RID p_texture, const Ref<Image> &p_image, int p_depth, int p_mipmap) {
|
||||
}
|
||||
|
@ -24,7 +580,20 @@ void RasterizerStorageRD::texture_3d_update(RID p_texture, const Ref<Image> &p_i
|
|||
//these two APIs can be used together or in combination with the others.
|
||||
RID RasterizerStorageRD::texture_2d_placeholder_create() {
|
||||
|
||||
return RID();
|
||||
//this could be better optimized to reuse an existing image , done this way
|
||||
//for now to get it working
|
||||
Ref<Image> image;
|
||||
image.instance();
|
||||
image->create(4, 4, false, Image::FORMAT_RGBA8);
|
||||
image->lock();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
image->set_pixel(i, j, Color(1, 0, 1, 1));
|
||||
}
|
||||
}
|
||||
image->unlock();
|
||||
|
||||
return texture_2d_create(image);
|
||||
}
|
||||
RID RasterizerStorageRD::texture_2d_layered_placeholder_create() {
|
||||
|
||||
|
@ -37,7 +606,11 @@ RID RasterizerStorageRD::texture_3d_placeholder_create() {
|
|||
|
||||
Ref<Image> RasterizerStorageRD::texture_2d_get(RID p_texture) const {
|
||||
|
||||
return Ref<Image>();
|
||||
Texture *tex = texture_owner.getornull(p_texture);
|
||||
ERR_FAIL_COND_V(!tex, Ref<Image>());
|
||||
|
||||
#warning TODO this is temporary to get things to work
|
||||
return tex->image_cache_2d;
|
||||
}
|
||||
Ref<Image> RasterizerStorageRD::texture_2d_layer_get(RID p_texture, int p_layer) const {
|
||||
|
||||
|
@ -49,8 +622,31 @@ Ref<Image> RasterizerStorageRD::texture_3d_slice_get(RID p_texture, int p_depth,
|
|||
}
|
||||
|
||||
void RasterizerStorageRD::texture_replace(RID p_texture, RID p_by_texture) {
|
||||
|
||||
Texture *tex = texture_owner.getornull(p_texture);
|
||||
ERR_FAIL_COND(!tex);
|
||||
Texture *by_tex = texture_owner.getornull(p_by_texture);
|
||||
ERR_FAIL_COND(!by_tex);
|
||||
|
||||
if (tex == by_tex) {
|
||||
return;
|
||||
}
|
||||
|
||||
RD::get_singleton()->free(tex->rd_texture);
|
||||
if (tex->rd_texture_srgb.is_valid()) {
|
||||
RD::get_singleton()->free(tex->rd_texture_srgb);
|
||||
}
|
||||
|
||||
*tex = *by_tex;
|
||||
|
||||
texture_owner.free(p_by_texture);
|
||||
}
|
||||
void RasterizerStorageRD::texture_set_size_override(RID p_texture, int p_width, int p_height) {
|
||||
Texture *tex = texture_owner.getornull(p_texture);
|
||||
ERR_FAIL_COND(!tex);
|
||||
ERR_FAIL_COND(tex->type != Texture::TYPE_2D);
|
||||
tex->width_2d = p_width;
|
||||
tex->height_2d = p_width;
|
||||
}
|
||||
|
||||
void RasterizerStorageRD::texture_set_path(RID p_texture, const String &p_path) {
|
||||
|
@ -76,3 +672,219 @@ void RasterizerStorageRD::texture_set_force_redraw_if_visible(RID p_texture, boo
|
|||
Size2 RasterizerStorageRD::texture_size_with_proxy(RID p_proxy) const {
|
||||
return Size2();
|
||||
}
|
||||
|
||||
/* RENDER TARGET API */
|
||||
|
||||
void RasterizerStorageRD::_clear_render_target(RenderTarget *rt) {
|
||||
|
||||
//free in reverse dependency order
|
||||
if (rt->framebuffer.is_valid()) {
|
||||
RD::get_singleton()->free(rt->framebuffer);
|
||||
}
|
||||
if (rt->color_srgb.is_valid()) {
|
||||
RD::get_singleton()->free(rt->color_srgb);
|
||||
}
|
||||
|
||||
if (rt->color.is_valid()) {
|
||||
RD::get_singleton()->free(rt->color);
|
||||
}
|
||||
|
||||
rt->framebuffer = RID();
|
||||
rt->color = RID();
|
||||
rt->color_srgb = RID();
|
||||
|
||||
rt->dirty = true;
|
||||
rt->texture_dirty = true;
|
||||
}
|
||||
|
||||
void RasterizerStorageRD::_update_render_target(RenderTarget *rt) {
|
||||
|
||||
_clear_render_target(rt);
|
||||
|
||||
//until we implement suport for HDR monitors (and render target is attached to screen), this is enough.
|
||||
rt->color_format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
|
||||
rt->color_format_srgb = RD::DATA_FORMAT_R8G8B8A8_SRGB;
|
||||
rt->image_format = rt->flags[RENDER_TARGET_TRANSPARENT] ? Image::FORMAT_RGBA8 : Image::FORMAT_RGB8;
|
||||
|
||||
RD::TextureFormat rd_format;
|
||||
RD::TextureView rd_view;
|
||||
{ //attempt register
|
||||
rd_format.format = rt->color_format;
|
||||
rd_format.width = rt->size.width;
|
||||
rd_format.height = rt->size.height;
|
||||
rd_format.depth = 1;
|
||||
rd_format.array_layers = 1;
|
||||
rd_format.mipmaps = 1;
|
||||
rd_format.type = RD::TEXTURE_TYPE_2D;
|
||||
rd_format.samples = RD::TEXTURE_SAMPLES_1;
|
||||
rd_format.usage_bits = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
}
|
||||
{
|
||||
rd_view.swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
rd_view.swizzle_g = RD::TEXTURE_SWIZZLE_R;
|
||||
rd_view.swizzle_b = RD::TEXTURE_SWIZZLE_R;
|
||||
rd_view.swizzle_a = rt->flags[RENDER_TARGET_TRANSPARENT] ? RD::TEXTURE_SWIZZLE_A : RD::TEXTURE_SWIZZLE_ONE;
|
||||
}
|
||||
|
||||
rt->color = RD::get_singleton()->texture_create(rd_format, rd_view);
|
||||
ERR_FAIL_COND(rt->color.is_null());
|
||||
if (rt->color_format_srgb != RD::DATA_FORMAT_MAX) {
|
||||
rd_view.format_override = rt->color_format_srgb;
|
||||
rt->color_srgb = RD::get_singleton()->texture_create_shared(rd_view, rt->color);
|
||||
if (rt->color_srgb.is_null()) {
|
||||
_clear_render_target(rt);
|
||||
ERR_FAIL_COND(rt->color_srgb.is_null());
|
||||
}
|
||||
}
|
||||
|
||||
Vector<RID> fb_textures;
|
||||
fb_textures.push_back(rt->color);
|
||||
rt->framebuffer = RD::get_singleton()->framebuffer_create(fb_textures);
|
||||
if (rt->framebuffer.is_null()) {
|
||||
_clear_render_target(rt);
|
||||
ERR_FAIL_COND(rt->framebuffer.is_null());
|
||||
}
|
||||
}
|
||||
|
||||
RID RasterizerStorageRD::render_target_create() {
|
||||
RenderTarget render_target;
|
||||
render_target.dirty = true;
|
||||
render_target.texture_dirty = true;
|
||||
render_target.was_used = false;
|
||||
|
||||
for (int i = 0; i < RENDER_TARGET_FLAG_MAX; i++) {
|
||||
render_target.flags[i] = false;
|
||||
}
|
||||
return render_target_owner.make_rid(render_target);
|
||||
}
|
||||
|
||||
void RasterizerStorageRD::render_target_set_position(RID p_render_target, int p_x, int p_y) {
|
||||
//unused for this render target
|
||||
}
|
||||
|
||||
void RasterizerStorageRD::render_target_set_size(RID p_render_target, int p_width, int p_height) {
|
||||
RenderTarget *rt = render_target_owner.getornull(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
rt->size.x = p_width;
|
||||
rt->size.y = p_height;
|
||||
rt->dirty = true;
|
||||
rt->texture_dirty = true;
|
||||
}
|
||||
|
||||
RID RasterizerStorageRD::render_target_get_texture(RID p_render_target) {
|
||||
RenderTarget *rt = render_target_owner.getornull(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RID());
|
||||
|
||||
if (rt->texture_dirty) {
|
||||
if (rt->dirty) {
|
||||
_update_render_target(rt);
|
||||
}
|
||||
|
||||
if (rt->texture.is_null()) {
|
||||
//kinda hacky, but not terrible
|
||||
rt->texture = texture_2d_placeholder_create();
|
||||
}
|
||||
|
||||
Texture *tex = texture_owner.getornull(rt->texture);
|
||||
|
||||
if (!tex->is_render_target) {
|
||||
//first allocation, fix it up
|
||||
RD::get_singleton()->free(tex->rd_texture);
|
||||
if (tex->rd_texture_srgb.is_null()) {
|
||||
RD::get_singleton()->free(tex->rd_texture_srgb);
|
||||
}
|
||||
tex->is_render_target = true;
|
||||
}
|
||||
|
||||
if (!rt->color.is_null()) {
|
||||
//there is a color buffer, update to it
|
||||
tex->rd_texture = rt->color;
|
||||
tex->rd_texture_srgb = rt->color_srgb;
|
||||
tex->width = rt->size.width;
|
||||
tex->height = rt->size.height;
|
||||
tex->width_2d = rt->size.width;
|
||||
tex->height_2d = rt->size.height;
|
||||
tex->rd_format = rt->color_format;
|
||||
tex->rd_format_srgb = rt->color_format_srgb;
|
||||
tex->format = rt->image_format;
|
||||
}
|
||||
|
||||
rt->texture_dirty = false;
|
||||
}
|
||||
|
||||
return rt->texture;
|
||||
}
|
||||
|
||||
void RasterizerStorageRD::render_target_set_external_texture(RID p_render_target, unsigned int p_texture_id) {
|
||||
}
|
||||
|
||||
void RasterizerStorageRD::render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value) {
|
||||
RenderTarget *rt = render_target_owner.getornull(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
rt->flags[p_flag] = p_value;
|
||||
rt->dirty = true;
|
||||
rt->texture_dirty = true;
|
||||
}
|
||||
|
||||
bool RasterizerStorageRD::render_target_was_used(RID p_render_target) {
|
||||
|
||||
RenderTarget *rt = render_target_owner.getornull(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, false);
|
||||
return rt->was_used;
|
||||
}
|
||||
|
||||
void RasterizerStorageRD::render_target_clear_used_flag(RID p_render_target) {
|
||||
|
||||
RenderTarget *rt = render_target_owner.getornull(p_render_target);
|
||||
ERR_FAIL_COND(!rt);
|
||||
rt->was_used = false;
|
||||
}
|
||||
|
||||
Size2 RasterizerStorageRD::render_target_get_size(RID p_render_target) {
|
||||
RenderTarget *rt = render_target_owner.getornull(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, Size2());
|
||||
|
||||
return rt->size;
|
||||
}
|
||||
|
||||
RID RasterizerStorageRD::render_target_get_rd_framebuffer(RID p_render_target) {
|
||||
RenderTarget *rt = render_target_owner.getornull(p_render_target);
|
||||
ERR_FAIL_COND_V(!rt, RID());
|
||||
|
||||
if (rt->dirty) {
|
||||
_update_render_target(rt);
|
||||
}
|
||||
|
||||
return rt->framebuffer;
|
||||
}
|
||||
|
||||
bool RasterizerStorageRD::free(RID p_rid) {
|
||||
|
||||
if (texture_owner.owns(p_rid)) {
|
||||
Texture *t = texture_owner.getornull(p_rid);
|
||||
|
||||
ERR_FAIL_COND_V(t->is_render_target, false);
|
||||
|
||||
RD::get_singleton()->free(t->rd_texture);
|
||||
if (t->rd_texture_srgb.is_valid()) {
|
||||
RD::get_singleton()->free(t->rd_texture_srgb);
|
||||
}
|
||||
texture_owner.free(p_rid);
|
||||
|
||||
} else if (render_target_owner.owns(p_rid)) {
|
||||
RenderTarget *rt = render_target_owner.getornull(p_rid);
|
||||
|
||||
_clear_render_target(rt);
|
||||
|
||||
if (rt->texture.is_valid()) {
|
||||
//no memory to be freed from here
|
||||
texture_owner.free(rt->texture);
|
||||
}
|
||||
|
||||
render_target_owner.free(p_rid);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -3,44 +3,100 @@
|
|||
|
||||
#include "core/rid_owner.h"
|
||||
#include "servers/visual/rasterizer/rasterizer.h"
|
||||
|
||||
#include "servers/visual/rendering_device.h"
|
||||
class RasterizerStorageRD : public RasterizerStorage {
|
||||
public:
|
||||
/* TEXTURE API */
|
||||
struct RDTexture {
|
||||
struct Texture {
|
||||
|
||||
enum Type {
|
||||
TYPE_2D,
|
||||
TYPE_LAYERED,
|
||||
TYPE_3D
|
||||
};
|
||||
|
||||
Type type;
|
||||
|
||||
RenderingDevice::TextureType rd_type;
|
||||
RID rd_texture;
|
||||
RID rd_texture_srgb;
|
||||
RenderingDevice::DataFormat rd_format;
|
||||
RenderingDevice::DataFormat rd_format_srgb;
|
||||
|
||||
Image::Format format;
|
||||
int width;
|
||||
int height;
|
||||
uint32_t flags;
|
||||
Image::Format format;
|
||||
Ref<Image> image;
|
||||
int depth;
|
||||
int layers;
|
||||
int mipmaps;
|
||||
|
||||
int height_2d;
|
||||
int width_2d;
|
||||
|
||||
bool is_render_target;
|
||||
|
||||
Ref<Image> image_cache_2d;
|
||||
String path;
|
||||
};
|
||||
|
||||
struct RDSurface {
|
||||
uint32_t format;
|
||||
VS::PrimitiveType primitive;
|
||||
PoolVector<uint8_t> array;
|
||||
int vertex_count;
|
||||
PoolVector<uint8_t> index_array;
|
||||
int index_count;
|
||||
AABB aabb;
|
||||
Vector<PoolVector<uint8_t> > blend_shapes;
|
||||
Vector<AABB> bone_aabbs;
|
||||
struct TextureToRDFormat {
|
||||
RD::DataFormat format;
|
||||
RD::DataFormat format_srgb;
|
||||
RD::TextureSwizzle swizzle_r;
|
||||
RD::TextureSwizzle swizzle_g;
|
||||
RD::TextureSwizzle swizzle_b;
|
||||
RD::TextureSwizzle swizzle_a;
|
||||
TextureToRDFormat() {
|
||||
format = RD::DATA_FORMAT_MAX;
|
||||
format_srgb = RD::DATA_FORMAT_MAX;
|
||||
swizzle_r = RD::TEXTURE_SWIZZLE_R;
|
||||
swizzle_g = RD::TEXTURE_SWIZZLE_G;
|
||||
swizzle_b = RD::TEXTURE_SWIZZLE_B;
|
||||
swizzle_a = RD::TEXTURE_SWIZZLE_A;
|
||||
}
|
||||
};
|
||||
|
||||
struct RDMesh {
|
||||
Vector<RDSurface> surfaces;
|
||||
int blend_shape_count;
|
||||
VS::BlendShapeMode blend_shape_mode;
|
||||
mutable RID_Owner<Texture> texture_owner;
|
||||
|
||||
Ref<Image> _validate_texture_format(const Ref<Image> &p_image, TextureToRDFormat &r_format);
|
||||
|
||||
/* RENDER TARGET */
|
||||
|
||||
struct RenderTarget {
|
||||
|
||||
Size2i size;
|
||||
RID framebuffer;
|
||||
RID color;
|
||||
RID color_srgb;
|
||||
|
||||
//used for retrieving from CPU
|
||||
RD::DataFormat color_format;
|
||||
RD::DataFormat color_format_srgb;
|
||||
Image::Format image_format;
|
||||
|
||||
bool flags[RENDER_TARGET_FLAG_MAX];
|
||||
|
||||
//texture generated for this owner (nor RD).
|
||||
RID texture;
|
||||
bool dirty;
|
||||
bool texture_dirty;
|
||||
bool was_used;
|
||||
};
|
||||
|
||||
mutable RID_PtrOwner<RDTexture> texture_owner;
|
||||
mutable RID_PtrOwner<RDMesh> mesh_owner;
|
||||
RID_Owner<RenderTarget> render_target_owner;
|
||||
|
||||
void _clear_render_target(RenderTarget *rt);
|
||||
void _update_render_target(RenderTarget *rt);
|
||||
|
||||
public:
|
||||
/* TEXTURE API */
|
||||
|
||||
virtual RID texture_2d_create(const Ref<Image> &p_image);
|
||||
virtual RID texture_2d_layered_create(const Vector<Ref<Image> > &p_layers, VS::TextureLayeredType p_layered_type);
|
||||
virtual RID texture_3d_create(const Vector<Ref<Image> > &p_slices); //all slices, then all the mipmaps, must be coherent
|
||||
|
||||
virtual void _texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer, bool p_immediate);
|
||||
|
||||
virtual void texture_2d_update_immediate(RID p_texture, const Ref<Image> &p_image, int p_layer = 0); //mostly used for video and streaming
|
||||
virtual void texture_2d_update(RID p_texture, const Ref<Image> &p_image, int p_layer = 0);
|
||||
virtual void texture_3d_update(RID p_texture, const Ref<Image> &p_image, int p_depth, int p_mipmap);
|
||||
|
@ -71,10 +127,54 @@ public:
|
|||
|
||||
virtual Size2 texture_size_with_proxy(RID p_proxy) const;
|
||||
|
||||
//internal usage
|
||||
|
||||
_FORCE_INLINE_ RID texture_get_rd_texture(RID p_texture, bool p_srgb = false) {
|
||||
if (p_texture.is_null()) {
|
||||
return RID();
|
||||
}
|
||||
Texture *tex = texture_owner.getornull(p_texture);
|
||||
|
||||
if (!tex) {
|
||||
return RID();
|
||||
}
|
||||
return (p_srgb && tex->rd_texture_srgb.is_valid()) ? tex->rd_texture_srgb : tex->rd_texture;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Size2i texture_2d_get_size(RID p_texture) {
|
||||
if (p_texture.is_null()) {
|
||||
return Size2i();
|
||||
}
|
||||
Texture *tex = texture_owner.getornull(p_texture);
|
||||
|
||||
if (!tex) {
|
||||
return Size2i();
|
||||
}
|
||||
return Size2i(tex->width_2d, tex->height_2d);
|
||||
}
|
||||
|
||||
/* SKY API */
|
||||
|
||||
struct RDSurface {
|
||||
uint32_t format;
|
||||
VS::PrimitiveType primitive;
|
||||
PoolVector<uint8_t> array;
|
||||
int vertex_count;
|
||||
PoolVector<uint8_t> index_array;
|
||||
int index_count;
|
||||
AABB aabb;
|
||||
Vector<PoolVector<uint8_t> > blend_shapes;
|
||||
Vector<AABB> bone_aabbs;
|
||||
};
|
||||
|
||||
struct RDMesh {
|
||||
Vector<RDSurface> surfaces;
|
||||
int blend_shape_count;
|
||||
VS::BlendShapeMode blend_shape_mode;
|
||||
};
|
||||
RID sky_create() { return RID(); }
|
||||
void sky_set_texture(RID p_sky, RID p_cube_map, int p_radiance_size) {}
|
||||
mutable RID_PtrOwner<RDMesh> mesh_owner;
|
||||
|
||||
/* SHADER API */
|
||||
|
||||
|
@ -516,17 +616,19 @@ public:
|
|||
|
||||
virtual bool particles_is_inactive(RID p_particles) const { return false; }
|
||||
|
||||
/* RENDER TARGET */
|
||||
/* RENDER TARGET API */
|
||||
|
||||
RID render_target_create() { return RID(); }
|
||||
void render_target_set_position(RID p_render_target, int p_x, int p_y) {}
|
||||
void render_target_set_size(RID p_render_target, int p_width, int p_height) {}
|
||||
RID render_target_get_texture(RID p_render_target) const { return RID(); }
|
||||
void render_target_set_external_texture(RID p_render_target, unsigned int p_texture_id) {}
|
||||
void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value) {}
|
||||
bool render_target_was_used(RID p_render_target) { return false; }
|
||||
void render_target_clear_used(RID p_render_target) {}
|
||||
void render_target_set_msaa(RID p_render_target, VS::ViewportMSAA p_msaa) {}
|
||||
RID render_target_create();
|
||||
void render_target_set_position(RID p_render_target, int p_x, int p_y);
|
||||
void render_target_set_size(RID p_render_target, int p_width, int p_height);
|
||||
RID render_target_get_texture(RID p_render_target);
|
||||
void render_target_set_external_texture(RID p_render_target, unsigned int p_texture_id);
|
||||
void render_target_set_flag(RID p_render_target, RenderTargetFlags p_flag, bool p_value);
|
||||
bool render_target_was_used(RID p_render_target);
|
||||
void render_target_clear_used_flag(RID p_render_target);
|
||||
|
||||
Size2 render_target_get_size(RID p_render_target);
|
||||
RID render_target_get_rd_framebuffer(RID p_render_target);
|
||||
|
||||
/* CANVAS SHADOW */
|
||||
|
||||
|
@ -545,16 +647,7 @@ public:
|
|||
return VS::INSTANCE_NONE;
|
||||
}
|
||||
|
||||
bool free(RID p_rid) {
|
||||
|
||||
if (texture_owner.owns(p_rid)) {
|
||||
// delete the texture
|
||||
RDTexture *texture = texture_owner.getornull(p_rid);
|
||||
texture_owner.free(p_rid);
|
||||
memdelete(texture);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool free(RID p_rid);
|
||||
|
||||
bool has_os_feature(const String &p_feature) const { return false; }
|
||||
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
#include "render_pipeline_cache_rd.h"
|
||||
#include "core/os/memory.h"
|
||||
|
||||
RID RenderPipelineCacheRD::_generate_version(RD::VertexFormatID p_format_id) {
|
||||
RID pipeline = RD::get_singleton()->render_pipeline_create(shader, framebuffer_format, p_format_id, render_primitive, rasterization_state, multisample_state, depth_stencil_state, blend_state, dynamic_state_flags);
|
||||
ERR_FAIL_COND_V(pipeline.is_null(), RID());
|
||||
versions = (Version *)memrealloc(versions, sizeof(Version) * (version_count + 1));
|
||||
versions[version_count].format_id = p_format_id;
|
||||
versions[version_count].pipeline = pipeline;
|
||||
version_count++;
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
void RenderPipelineCacheRD::_clear() {
|
||||
|
||||
if (versions) {
|
||||
for (uint32_t i = 0; i < version_count; i++) {
|
||||
RD::get_singleton()->free(versions[i].pipeline);
|
||||
}
|
||||
version_count = 0;
|
||||
memfree(versions);
|
||||
versions = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void RenderPipelineCacheRD::setup(RID p_shader, RD::FramebufferFormatID p_framebuffer_format, RD::RenderPrimitive p_primitive, const RD::PipelineRasterizationState &p_rasterization_state, RD::PipelineMultisampleState p_multisample, const RD::PipelineDepthStencilState &p_depth_stencil_state, const RD::PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags) {
|
||||
ERR_FAIL_COND(p_shader.is_null());
|
||||
shader = p_shader;
|
||||
framebuffer_format = p_framebuffer_format;
|
||||
render_primitive = p_primitive;
|
||||
rasterization_state = p_rasterization_state;
|
||||
multisample_state = p_multisample;
|
||||
depth_stencil_state = p_depth_stencil_state;
|
||||
blend_state = p_blend_state;
|
||||
dynamic_state_flags = p_dynamic_state_flags;
|
||||
}
|
||||
|
||||
void RenderPipelineCacheRD::update_shader(RID p_shader) {
|
||||
ERR_FAIL_COND(p_shader.is_null());
|
||||
_clear();
|
||||
setup(p_shader, framebuffer_format, render_primitive, rasterization_state, multisample_state, depth_stencil_state, blend_state, dynamic_state_flags);
|
||||
}
|
||||
|
||||
RenderPipelineCacheRD::RenderPipelineCacheRD() {
|
||||
version_count = 0;
|
||||
versions = NULL;
|
||||
}
|
||||
|
||||
RenderPipelineCacheRD::~RenderPipelineCacheRD() {
|
||||
_clear();
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
#ifndef RENDER_PIPELINE_CACHE_RD_H
|
||||
#define RENDER_PIPELINE_CACHE_RD_H
|
||||
|
||||
#include "servers/visual/rendering_device.h"
|
||||
|
||||
class RenderPipelineCacheRD {
|
||||
|
||||
RID shader;
|
||||
|
||||
RD::FramebufferFormatID framebuffer_format;
|
||||
RD::RenderPrimitive render_primitive;
|
||||
RD::PipelineRasterizationState rasterization_state;
|
||||
RD::PipelineMultisampleState multisample_state;
|
||||
RD::PipelineDepthStencilState depth_stencil_state;
|
||||
RD::PipelineColorBlendState blend_state;
|
||||
int dynamic_state_flags;
|
||||
|
||||
struct Version {
|
||||
RD::VertexFormatID format_id;
|
||||
RID pipeline;
|
||||
};
|
||||
|
||||
Version *versions;
|
||||
uint32_t version_count;
|
||||
|
||||
RID _generate_version(RD::VertexFormatID p_format_id);
|
||||
|
||||
void _clear();
|
||||
|
||||
public:
|
||||
void setup(RID p_shader, RD::FramebufferFormatID p_framebuffer_format, RD::RenderPrimitive p_primitive, const RD::PipelineRasterizationState &p_rasterization_state, RD::PipelineMultisampleState p_multisample, const RD::PipelineDepthStencilState &p_depth_stencil_state, const RD::PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags = 0);
|
||||
void update_shader(RID p_shader);
|
||||
|
||||
_FORCE_INLINE_ RID get_render_pipeline(RD::VertexFormatID p_format_id) {
|
||||
for (uint32_t i = 0; i < version_count; i++) {
|
||||
if (versions[i].format_id == p_format_id) {
|
||||
return versions[i].pipeline;
|
||||
}
|
||||
}
|
||||
return _generate_version(p_format_id);
|
||||
}
|
||||
|
||||
RenderPipelineCacheRD();
|
||||
~RenderPipelineCacheRD();
|
||||
};
|
||||
|
||||
#endif // RENDER_PIPELINE_CACHE_RD_H
|
|
@ -0,0 +1,328 @@
|
|||
/*************************************************************************/
|
||||
/* shader_rd.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "shader_rd.h"
|
||||
#include "core/string_builder.h"
|
||||
#include "servers/visual/rendering_device.h"
|
||||
|
||||
void ShaderRD::setup(const char *p_vertex_code, const char *p_fragment_code, const char *p_name) {
|
||||
|
||||
name = p_name;
|
||||
//split vertex and shader code (thank you, shader compiler programmers from you know what company).
|
||||
{
|
||||
String defines_tag = "\nVERSION_DEFINES";
|
||||
String globals_tag = "\nVERTEX_SHADER_GLOBALS";
|
||||
String material_tag = "\nMATERIAL_UNIFORMS";
|
||||
String code_tag = "\nVERTEX_SHADER_CODE";
|
||||
String code = p_vertex_code;
|
||||
|
||||
int cpos = code.find(defines_tag);
|
||||
if (cpos != -1) {
|
||||
vertex_codev = code.substr(0, cpos).ascii();
|
||||
code = code.substr(cpos + defines_tag.length(), code.length());
|
||||
}
|
||||
|
||||
cpos = code.find(material_tag);
|
||||
|
||||
if (cpos == -1) {
|
||||
vertex_code0 = code.ascii();
|
||||
} else {
|
||||
vertex_code0 = code.substr(0, cpos).ascii();
|
||||
code = code.substr(cpos + material_tag.length(), code.length());
|
||||
|
||||
cpos = code.find(globals_tag);
|
||||
|
||||
if (cpos == -1) {
|
||||
vertex_code1 = code.ascii();
|
||||
} else {
|
||||
|
||||
vertex_code1 = code.substr(0, cpos).ascii();
|
||||
String code2 = code.substr(cpos + globals_tag.length(), code.length());
|
||||
|
||||
cpos = code2.find(code_tag);
|
||||
if (cpos == -1) {
|
||||
vertex_code2 = code2.ascii();
|
||||
} else {
|
||||
|
||||
vertex_code2 = code2.substr(0, cpos).ascii();
|
||||
vertex_code3 = code2.substr(cpos + code_tag.length(), code2.length()).ascii();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
String defines_tag = "\nVERSION_DEFINES";
|
||||
String globals_tag = "\nFRAGMENT_SHADER_GLOBALS";
|
||||
String material_tag = "\nMATERIAL_UNIFORMS";
|
||||
String code_tag = "\nFRAGMENT_SHADER_CODE";
|
||||
String light_code_tag = "\nLIGHT_SHADER_CODE";
|
||||
String code = p_fragment_code;
|
||||
|
||||
int cpos = code.find(defines_tag);
|
||||
if (cpos != -1) {
|
||||
fragment_codev = code.substr(0, cpos).ascii();
|
||||
code = code.substr(cpos + defines_tag.length(), code.length());
|
||||
}
|
||||
|
||||
cpos = code.find(material_tag);
|
||||
if (cpos == -1) {
|
||||
fragment_code0 = code.ascii();
|
||||
} else {
|
||||
fragment_code0 = code.substr(0, cpos).ascii();
|
||||
//print_line("CODE0:\n"+String(fragment_code0.get_data()));
|
||||
code = code.substr(cpos + material_tag.length(), code.length());
|
||||
cpos = code.find(globals_tag);
|
||||
|
||||
if (cpos == -1) {
|
||||
fragment_code1 = code.ascii();
|
||||
} else {
|
||||
|
||||
fragment_code1 = code.substr(0, cpos).ascii();
|
||||
//print_line("CODE1:\n"+String(fragment_code1.get_data()));
|
||||
|
||||
String code2 = code.substr(cpos + globals_tag.length(), code.length());
|
||||
cpos = code2.find(light_code_tag);
|
||||
|
||||
if (cpos == -1) {
|
||||
fragment_code2 = code2.ascii();
|
||||
} else {
|
||||
|
||||
fragment_code2 = code2.substr(0, cpos).ascii();
|
||||
//print_line("CODE2:\n"+String(fragment_code2.get_data()));
|
||||
|
||||
String code3 = code2.substr(cpos + light_code_tag.length(), code2.length());
|
||||
|
||||
cpos = code3.find(code_tag);
|
||||
if (cpos == -1) {
|
||||
fragment_code3 = code3.ascii();
|
||||
} else {
|
||||
|
||||
fragment_code3 = code3.substr(0, cpos).ascii();
|
||||
//print_line("CODE3:\n"+String(fragment_code3.get_data()));
|
||||
fragment_code4 = code3.substr(cpos + code_tag.length(), code3.length()).ascii();
|
||||
//print_line("CODE4:\n"+String(fragment_code4.get_data()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RID ShaderRD::version_create() {
|
||||
|
||||
//initialize() was never called
|
||||
ERR_FAIL_COND_V(variant_defines.size() == 0, RID());
|
||||
|
||||
Version version;
|
||||
version.dirty = true;
|
||||
version.valid = false;
|
||||
version.initialize_needed = true;
|
||||
version.variants = NULL;
|
||||
return version_owner.make_rid(version);
|
||||
}
|
||||
|
||||
void ShaderRD::_clear_version(Version *p_version) {
|
||||
//clear versions if they exist
|
||||
if (p_version->variants) {
|
||||
for (int i = 0; i < variant_defines.size(); i++) {
|
||||
RD::get_singleton()->free(p_version->variants[i]);
|
||||
}
|
||||
|
||||
memdelete_arr(p_version->variants);
|
||||
p_version->variants = NULL;
|
||||
}
|
||||
}
|
||||
void ShaderRD::_compile_version(Version *p_version) {
|
||||
|
||||
_clear_version(p_version);
|
||||
|
||||
p_version->valid = false;
|
||||
p_version->dirty = false;
|
||||
|
||||
p_version->variants = memnew_arr(RID, variant_defines.size());
|
||||
|
||||
for (int i = 0; i < variant_defines.size(); i++) {
|
||||
|
||||
Vector<RD::ShaderStageSource> stages;
|
||||
|
||||
{
|
||||
//vertex stage
|
||||
|
||||
StringBuilder builder;
|
||||
|
||||
builder.append(vertex_codev.get_data()); // version info (if exists)
|
||||
|
||||
builder.append(variant_defines[i].get_data());
|
||||
for (int j = 0; j < p_version->custom_defines.size(); j++) {
|
||||
builder.append(p_version->custom_defines[j].get_data());
|
||||
}
|
||||
|
||||
builder.append(vertex_code0.get_data()); //first part of vertex
|
||||
|
||||
builder.append(p_version->uniforms.get_data()); //uniforms (same for vertex and fragment)
|
||||
|
||||
builder.append(vertex_code1.get_data()); //second part of vertex
|
||||
|
||||
builder.append(p_version->vertex_globals.get_data()); // vertex globals
|
||||
|
||||
builder.append(vertex_code2.get_data()); //third part of vertex
|
||||
|
||||
builder.append(p_version->vertex_code.get_data()); // code
|
||||
|
||||
builder.append(vertex_code3.get_data()); //fourth of vertex
|
||||
|
||||
RD::ShaderStageSource stage;
|
||||
stage.shader_source = builder.as_string();
|
||||
stage.shader_stage = RD::SHADER_STAGE_VERTEX;
|
||||
|
||||
stages.push_back(stage);
|
||||
}
|
||||
|
||||
{
|
||||
//fragment stage
|
||||
|
||||
StringBuilder builder;
|
||||
|
||||
builder.append(fragment_codev.get_data()); // version info (if exists)
|
||||
|
||||
builder.append(variant_defines[i].get_data());
|
||||
for (int j = 0; j < p_version->custom_defines.size(); j++) {
|
||||
builder.append(p_version->custom_defines[j].get_data());
|
||||
}
|
||||
|
||||
builder.append(fragment_code0.get_data()); //first part of fragment
|
||||
|
||||
builder.append(p_version->uniforms.get_data()); //uniforms (same for fragment and fragment)
|
||||
|
||||
builder.append(fragment_code1.get_data()); //first part of fragment
|
||||
|
||||
builder.append(p_version->fragment_globals.get_data()); // fragment globals
|
||||
|
||||
builder.append(fragment_code2.get_data()); //third part of fragment
|
||||
|
||||
builder.append(p_version->fragment_light.get_data()); // fragment light
|
||||
|
||||
builder.append(fragment_code3.get_data()); //fourth part of fragment
|
||||
|
||||
builder.append(p_version->fragment_code.get_data()); // fragment code
|
||||
|
||||
builder.append(fragment_code4.get_data()); //fourth part of fragment
|
||||
|
||||
RD::ShaderStageSource stage;
|
||||
stage.shader_source = builder.as_string();
|
||||
stage.shader_stage = RD::SHADER_STAGE_FRAGMENT;
|
||||
|
||||
stages.push_back(stage);
|
||||
}
|
||||
|
||||
String error;
|
||||
RD::ShaderStage error_stage;
|
||||
RID shader = RD::get_singleton()->shader_create_from_source(stages, &error, &error_stage);
|
||||
|
||||
if (shader.is_null() && error != String()) {
|
||||
ERR_PRINT("Error compiling shader, variant #" + itos(i) + " (" + variant_defines[i].get_data() + ").");
|
||||
ERR_PRINT(error);
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (error_stage < RD::SHADER_STAGE_MAX) {
|
||||
ERR_PRINT("code:\n" + stages[error_stage].shader_source.get_with_code_lines());
|
||||
}
|
||||
#endif
|
||||
//clear versions if they exist
|
||||
for (int j = 0; j < i; j++) {
|
||||
RD::get_singleton()->free(p_version->variants[j]);
|
||||
}
|
||||
|
||||
memdelete_arr(p_version->variants);
|
||||
p_version->variants = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
p_version->variants[i] = shader;
|
||||
}
|
||||
|
||||
p_version->valid = true;
|
||||
}
|
||||
|
||||
void ShaderRD::version_set_code(RID p_version, const String &p_uniforms, const String &p_vertex_globals, const String &p_vertex_code, const String &p_fragment_globals, const String &p_fragment_light, const String &p_fragment_code, const Vector<String> &p_custom_defines) {
|
||||
|
||||
Version *version = version_owner.getornull(p_version);
|
||||
ERR_FAIL_COND(!version);
|
||||
version->vertex_globals = p_vertex_globals.utf8();
|
||||
version->vertex_code = p_vertex_code.utf8();
|
||||
version->fragment_light = p_fragment_light.utf8();
|
||||
version->fragment_globals = p_fragment_globals.utf8();
|
||||
version->fragment_code = p_fragment_code.utf8();
|
||||
version->custom_defines.clear();
|
||||
for (int i = 0; i < p_custom_defines.size(); i++) {
|
||||
version->custom_defines.push_back(p_custom_defines[i].utf8());
|
||||
}
|
||||
|
||||
version->dirty = true;
|
||||
if (version->initialize_needed) {
|
||||
_compile_version(version);
|
||||
version->initialize_needed = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool ShaderRD::version_free(RID p_version) {
|
||||
|
||||
if (version_owner.owns(p_version)) {
|
||||
Version *version = version_owner.getornull(p_version);
|
||||
_clear_version(version);
|
||||
version_owner.free(p_version);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ShaderRD::initialize(const Vector<String> &p_variant_defines) {
|
||||
ERR_FAIL_COND(variant_defines.size());
|
||||
ERR_FAIL_COND(p_variant_defines.size() == 0);
|
||||
for (int i = 0; i < p_variant_defines.size(); i++) {
|
||||
|
||||
variant_defines.push_back(p_variant_defines[i].utf8());
|
||||
}
|
||||
}
|
||||
|
||||
ShaderRD::~ShaderRD() {
|
||||
List<RID> remaining;
|
||||
version_owner.get_owned_list(&remaining);
|
||||
if (remaining.size()) {
|
||||
ERR_PRINT(itos(remaining.size()) + " shaders of type " + name + " were never freed");
|
||||
while (remaining.size()) {
|
||||
version_free(remaining.front()->get());
|
||||
remaining.pop_front();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
/*************************************************************************/
|
||||
/* shader_rd.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef SHADER_RD_H
|
||||
#define SHADER_RD_H
|
||||
|
||||
#include "core/hash_map.h"
|
||||
#include "core/map.h"
|
||||
#include "core/rid_owner.h"
|
||||
#include "core/variant.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/**
|
||||
@author Juan Linietsky <reduzio@gmail.com>
|
||||
*/
|
||||
|
||||
class ShaderRD {
|
||||
|
||||
//versions
|
||||
Vector<CharString> variant_defines;
|
||||
|
||||
int vertex_code_start;
|
||||
int fragment_code_start;
|
||||
|
||||
struct Version {
|
||||
|
||||
CharString uniforms;
|
||||
CharString vertex_globals;
|
||||
CharString vertex_code;
|
||||
CharString fragment_light;
|
||||
CharString fragment_globals;
|
||||
CharString fragment_code;
|
||||
Vector<CharString> custom_defines;
|
||||
|
||||
RID *variants; //same size as version defines
|
||||
|
||||
bool valid;
|
||||
bool dirty;
|
||||
bool initialize_needed;
|
||||
};
|
||||
|
||||
void _clear_version(Version *p_version);
|
||||
void _compile_version(Version *p_version);
|
||||
|
||||
RID_Owner<Version> version_owner;
|
||||
|
||||
CharString fragment_codev; //for version and extensions
|
||||
CharString fragment_code0;
|
||||
CharString fragment_code1;
|
||||
CharString fragment_code2;
|
||||
CharString fragment_code3;
|
||||
CharString fragment_code4;
|
||||
|
||||
CharString vertex_codev; //for version and extensions
|
||||
CharString vertex_code0;
|
||||
CharString vertex_code1;
|
||||
CharString vertex_code2;
|
||||
CharString vertex_code3;
|
||||
|
||||
const char *name;
|
||||
|
||||
protected:
|
||||
ShaderRD() {}
|
||||
void setup(const char *p_vertex_code, const char *p_fragment_code, const char *p_name);
|
||||
|
||||
public:
|
||||
RID version_create();
|
||||
|
||||
void version_set_code(RID p_version, const String &p_uniforms, const String &p_vertex_globals, const String &p_vertex_code, const String &p_fragment_globals, const String &p_fragment_light, const String &p_fragment_code, const Vector<String> &p_custom_defines);
|
||||
|
||||
_FORCE_INLINE_ RID version_get_shader(RID p_version, int p_variant) {
|
||||
ERR_FAIL_INDEX_V(p_variant, variant_defines.size(), RID());
|
||||
|
||||
Version *version = version_owner.getornull(p_version);
|
||||
ERR_FAIL_COND_V(!version, RID());
|
||||
|
||||
if (version->dirty) {
|
||||
_compile_version(version);
|
||||
}
|
||||
|
||||
if (!version->valid) {
|
||||
return RID();
|
||||
}
|
||||
|
||||
return version->variants[p_variant];
|
||||
}
|
||||
|
||||
bool version_free(RID p_version);
|
||||
|
||||
void initialize(const Vector<String> &p_variant_defines);
|
||||
virtual ~ShaderRD();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
Import('env')
|
||||
|
||||
if 'RD_GLSL' in env['BUILDERS']:
|
||||
env.RD_GLSL('canvas.glsl');
|
|
@ -0,0 +1,372 @@
|
|||
/* clang-format off */
|
||||
[vertex]
|
||||
/* clang-format on */
|
||||
|
||||
#version 450
|
||||
|
||||
/* clang-format off */
|
||||
VERSION_DEFINES
|
||||
/* clang-format on */
|
||||
|
||||
#ifdef USE_VERTEX_ARRAYS
|
||||
layout(location = 0) in vec2 vertex_attrib;
|
||||
layout(location = 3) in vec4 color_attrib;
|
||||
layout(location = 4) in vec2 uv_attrib;
|
||||
|
||||
layout(location = 6) in uvec4 bone_indices_attrib;
|
||||
layout(location = 7) in vec4 bone_weights_attrib;
|
||||
#endif
|
||||
|
||||
#include "canvas_uniforms_inc.glsl"
|
||||
|
||||
|
||||
layout(location=0) out vec2 uv_interp;
|
||||
layout(location=1) out vec4 color_interp;
|
||||
|
||||
#ifdef USE_NINEPATCH
|
||||
|
||||
layout(location=3) out vec2 pixel_size_interp;
|
||||
|
||||
#endif
|
||||
|
||||
/* clang-format off */
|
||||
MATERIAL_UNIFORMS
|
||||
/* clang-format on */
|
||||
|
||||
|
||||
/* clang-format off */
|
||||
VERTEX_SHADER_GLOBALS
|
||||
/* clang-format on */
|
||||
|
||||
|
||||
void main() {
|
||||
|
||||
vec4 instance_custom = vec4(0.0);
|
||||
|
||||
#ifdef USE_VERTEX_ARRAYS
|
||||
|
||||
vec2 vertex = vertex_attrib;
|
||||
vec4 color = color_attrib;
|
||||
vec2 uv = uv_attrib;
|
||||
uvec4 bone_indices = bone_indices_attrib;
|
||||
vec4 bone_weights = bone_weights_attrib;
|
||||
#else
|
||||
|
||||
vec2 vertex_base_arr[4] = vec2[](vec2(0.0,0.0),vec2(0.0,1.0),vec2(1.0,1.0),vec2(1.0,0.0));
|
||||
vec2 vertex_base = vertex_base_arr[gl_VertexIndex];
|
||||
|
||||
vec2 uv = draw_data.src_rect.xy + draw_data.src_rect.zw * ((draw_data.flags&FLAGS_TRANSPOSE_RECT)!=0 ? vertex_base.xy : vertex_base.yx);
|
||||
vec4 color = vec4(1.0);
|
||||
vec2 vertex = draw_data.dst_rect.xy + abs(draw_data.dst_rect.zw) * mix(vertex_base, vec2(1.0, 1.0) - vertex_base, lessThan(draw_data.src_rect.zw, vec2(0.0, 0.0)));
|
||||
uvec4 bone_indices = uvec4(0,0,0,0);
|
||||
vec4 bone_weights = vec4(0,0,0,0);
|
||||
|
||||
#endif
|
||||
|
||||
mat4 world_matrix = mat4(draw_data.world[0],draw_data.world[1],vec4(0.0,0.0,1.0,0.0),vec4(0.0,0.0,0.0,1.0));
|
||||
#if 0
|
||||
if (draw_data.flags&FLAGS_INSTANCING_ENABLED) {
|
||||
|
||||
uint offset = draw_data.flags&FLAGS_INSTANCING_STRIDE_MASK;
|
||||
offset *= gl_InstanceIndex;
|
||||
mat4 instance_xform = mat4(
|
||||
vec4( texelFetch(instancing_buffer,offset+0),texelFetch(instancing_buffer,offset+1),0.0,texelFetch(instancing_buffer,offset+3) ),
|
||||
vec4( texelFetch(instancing_buffer,offset+4),texelFetch(instancing_buffer,offset+5),0.0,texelFetch(instancing_buffer,offset+7) ),
|
||||
vec4( 0.0,0.0,1.0,0.0),
|
||||
vec4( 0.0,0.0,0.0,1.0 ) );
|
||||
offset+=8;
|
||||
if ( draw_data.flags&FLAGS_INSTANCING_HAS_COLORS ) {
|
||||
vec4 instance_color;
|
||||
if (draw_data.flags&FLAGS_INSTANCING_COLOR_8_BIT ) {
|
||||
uint bits = floatBitsToUint(texelFetch(instancing_buffer,offset));
|
||||
instance_color = unpackUnorm4x8(bits);
|
||||
offset+=1;
|
||||
} else {
|
||||
instance_color = vec4(texelFetch(instancing_buffer,offset+0),texelFetch(instancing_buffer,offset+1),texelFetch(instancing_buffer,offset+2),texelFetch(instancing_buffer,offset+3));
|
||||
offser+=4;
|
||||
}
|
||||
|
||||
color*=instance_color;
|
||||
}
|
||||
if ( draw_data.flags&FLAGS_INSTANCING_HAS_CUSTOM_DATA ) {
|
||||
if (draw_data.flags&FLAGS_INSTANCING_CUSTOM_DATA_8_BIT ) {
|
||||
uint bits = floatBitsToUint(texelFetch(instancing_buffer,offset));
|
||||
instance_custom = unpackUnorm4x8(bits);
|
||||
} else {
|
||||
instance_custom = vec4(texelFetch(instancing_buffer,offset+0),texelFetch(instancing_buffer,offset+1),texelFetch(instancing_buffer,offset+2),texelFetch(instancing_buffer,offset+3));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (bool(draw_data.flags&FLAGS_USING_PARTICLES)) {
|
||||
//scale by texture size
|
||||
vertex /= draw_data.color_texture_pixel_size;
|
||||
}
|
||||
#ifdef USE_POINT_SIZE
|
||||
float point_size = 1.0;
|
||||
#endif
|
||||
{
|
||||
/* clang-format off */
|
||||
VERTEX_SHADER_CODE
|
||||
/* clang-format on */
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef USE_NINEPATCH
|
||||
pixel_size_interp = abs(draw_data.dst_rect.zw) * vertex;
|
||||
#endif
|
||||
|
||||
#if !defined(SKIP_TRANSFORM_USED)
|
||||
vertex = (world_matrix * vec4(vertex,0.0,1.0)).xy;
|
||||
#endif
|
||||
|
||||
color_interp = color;
|
||||
|
||||
if (bool(draw_data.flags&FLAGS_USE_PIXEL_SNAP)) {
|
||||
|
||||
vertex = floor(vertex + 0.5);
|
||||
// precision issue on some hardware creates artifacts within texture
|
||||
// offset uv by a small amount to avoid
|
||||
uv += 1e-5;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (bool(draw_data.flags&FLAGS_USE_SKELETON) && bone_weights != vec4(0.0)) { //must be a valid bone
|
||||
//skeleton transform
|
||||
|
||||
ivec4 bone_indicesi = ivec4(bone_indices);
|
||||
|
||||
uvec2 tex_ofs = bone_indicesi.x *2;
|
||||
|
||||
mat2x4 m;
|
||||
m = mat2x4(
|
||||
texelFetch(skeleton_buffer, tex_ofs+0),
|
||||
texelFetch(skeleton_buffer, tex_ofs+1) ) *
|
||||
bone_weights.x;
|
||||
|
||||
tex_ofs = bone_indicesi.y * 2;
|
||||
|
||||
m += mat2x4(
|
||||
texelFetch(skeleton_buffer, tex_ofs+0),
|
||||
texelFetch(skeleton_buffer, tex_ofs+1) ) *
|
||||
bone_weights.y;
|
||||
|
||||
tex_ofs = bone_indicesi.z * 2;
|
||||
|
||||
m += mat2x4(
|
||||
texelFetch(skeleton_buffer, tex_ofs+0),
|
||||
texelFetch(skeleton_buffer, tex_ofs+1) ) *
|
||||
bone_weights.z;
|
||||
|
||||
tex_ofs = bone_indicesi.w * 2;
|
||||
|
||||
m += mat2x4(
|
||||
texelFetch(skeleton_buffer, tex_ofs+0),
|
||||
texelFetch(skeleton_buffer, tex_ofs+1) ) *
|
||||
bone_weights.w;
|
||||
|
||||
mat4 bone_matrix = skeleton_data.skeleton_transform * transpose(mat4(m[0], m[1], vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0))) * skeleton_data.skeleton_transform_inverse;
|
||||
|
||||
//outvec = bone_matrix * outvec;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(SKIP_TRANSFORM_USED)
|
||||
gl_Position = (canvas_data.screen_transform * canvas_data.canvas_transform) * vec4(vertex,0.0,1.0);
|
||||
#else
|
||||
gl_Position = vec4(vertex,0.0,1.0);
|
||||
#endif
|
||||
|
||||
#ifdef USE_POINT_SIZE
|
||||
gl_PointSize=point_size;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
[fragment]
|
||||
|
||||
#version 450
|
||||
|
||||
/* clang-format off */
|
||||
VERSION_DEFINES
|
||||
/* clang-format on */
|
||||
|
||||
#include "canvas_uniforms_inc.glsl"
|
||||
|
||||
layout(location=0) in vec2 uv_interp;
|
||||
layout(location=1) in vec4 color_interp;
|
||||
|
||||
#ifdef USE_NINEPATCH
|
||||
|
||||
layout(location=3) in vec2 pixel_size_interp;
|
||||
|
||||
#endif
|
||||
|
||||
layout(location = 0) out vec4 frag_color;
|
||||
|
||||
/* clang-format off */
|
||||
MATERIAL_UNIFORMS
|
||||
/* clang-format on */
|
||||
|
||||
|
||||
/* clang-format off */
|
||||
FRAGMENT_SHADER_GLOBALS
|
||||
/* clang-format on */
|
||||
|
||||
|
||||
void light_compute(
|
||||
inout vec4 light,
|
||||
inout vec2 light_vec,
|
||||
inout float light_height,
|
||||
inout vec4 light_color,
|
||||
vec2 light_uv,
|
||||
inout vec4 shadow_color,
|
||||
vec3 normal,
|
||||
vec2 uv,
|
||||
vec2 screen_uv,
|
||||
vec4 color) {
|
||||
|
||||
/* clang-format off */
|
||||
LIGHT_SHADER_CODE
|
||||
/* clang-format on */
|
||||
}
|
||||
|
||||
|
||||
#ifdef USE_NINEPATCH
|
||||
|
||||
float map_ninepatch_axis(float pixel, float draw_size, float tex_pixel_size, float margin_begin, float margin_end, int np_repeat, inout int draw_center) {
|
||||
|
||||
float tex_size = 1.0 / tex_pixel_size;
|
||||
|
||||
if (pixel < margin_begin) {
|
||||
return pixel * tex_pixel_size;
|
||||
} else if (pixel >= draw_size - margin_end) {
|
||||
return (tex_size - (draw_size - pixel)) * tex_pixel_size;
|
||||
} else {
|
||||
if (!bool(draw_data.flags&FLAGS_NINEPACH_DRAW_CENTER)) {
|
||||
draw_center--;
|
||||
}
|
||||
|
||||
if (np_repeat == 0) { //stretch
|
||||
//convert to ratio
|
||||
float ratio = (pixel - margin_begin) / (draw_size - margin_begin - margin_end);
|
||||
//scale to source texture
|
||||
return (margin_begin + ratio * (tex_size - margin_begin - margin_end)) * tex_pixel_size;
|
||||
} else if (np_repeat == 1) { //tile
|
||||
//convert to ratio
|
||||
float ofs = mod((pixel - margin_begin), tex_size - margin_begin - margin_end);
|
||||
//scale to source texture
|
||||
return (margin_begin + ofs) * tex_pixel_size;
|
||||
} else if (np_repeat == 2) { //tile fit
|
||||
//convert to ratio
|
||||
float src_area = draw_size - margin_begin - margin_end;
|
||||
float dst_area = tex_size - margin_begin - margin_end;
|
||||
float scale = max(1.0, floor(src_area / max(dst_area, 0.0000001) + 0.5));
|
||||
|
||||
//convert to ratio
|
||||
float ratio = (pixel - margin_begin) / src_area;
|
||||
ratio = mod(ratio * scale, 1.0);
|
||||
return (margin_begin + ratio * dst_area) * tex_pixel_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
vec4 color = color_interp;
|
||||
vec2 uv = uv_interp;
|
||||
|
||||
#ifdef USE_TEXTURE_RECT
|
||||
|
||||
#ifdef USE_NINEPATCH
|
||||
|
||||
int draw_center = 2;
|
||||
uv = vec2(
|
||||
map_ninepatch_axis(pixel_size_interp.x, abs(draw_data.dst_rect.z), draw_data.color_texture_pixel_size.x, draw_data.ninepatch_margins.x, draw_data.ninepatch_margins.z, (draw_data.ninepatch_repeat>>16), draw_center),
|
||||
map_ninepatch_axis(pixel_size_interp.y, abs(draw_data.dst_rect.w), draw_data.color_texture_pixel_size.y, draw_data.ninepatch_margins.y, draw_data.ninepatch_margins.w, (draw_data.ninepatch_repeat&0xFFFF), draw_center));
|
||||
|
||||
if (draw_center == 0) {
|
||||
color.a = 0.0;
|
||||
}
|
||||
|
||||
uv = uv * draw_data.src_rect.zw + draw_data.src_rect.xy; //apply region if needed
|
||||
#endif
|
||||
|
||||
if (bool(draw_data.flags&FLAGS_CLIP_RECT_UV)) {
|
||||
|
||||
uv = clamp(uv, draw_data.src_rect.xy, draw_data.src_rect.xy + abs(draw_data.src_rect.zw));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined(COLOR_USED)
|
||||
//default behavior, texture by color
|
||||
|
||||
color *= texture(sampler2D(color_texture,texture_sampler), uv);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
vec3 normal;
|
||||
|
||||
#if defined(NORMAL_USED)
|
||||
|
||||
bool normal_used = true;
|
||||
#else
|
||||
bool normal_used = false;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if (false /*normal_used || canvas_data.light_count > 0*/ ) {
|
||||
normal.xy = texture(sampler2D(normal_texture,texture_sampler ), uv).xy * 2.0 - 1.0;
|
||||
normal.z = sqrt(1.0 - dot(normal.xy, normal.xy));
|
||||
normal_used = true;
|
||||
} else {
|
||||
#endif
|
||||
normal = vec3(0.0, 0.0, 1.0);
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SCREEN_UV_USED)
|
||||
vec2 screen_uv = gl_FragCoord.xy * screen_pixel_size;
|
||||
#endif
|
||||
|
||||
{
|
||||
float normal_depth = 1.0;
|
||||
|
||||
#if defined(NORMALMAP_USED)
|
||||
vec3 normal_map = vec3(0.0, 0.0, 1.0);
|
||||
normal_used = true;
|
||||
#endif
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
FRAGMENT_SHADER_CODE
|
||||
|
||||
/* clang-format on */
|
||||
|
||||
#if defined(NORMALMAP_USED)
|
||||
normal = mix(vec3(0.0, 0.0, 1.0), normal_map * vec3(2.0, -2.0, 1.0) - vec3(1.0, -1.0, 0.0), normal_depth);
|
||||
#endif
|
||||
}
|
||||
|
||||
color *= draw_data.modulation;
|
||||
#if 0
|
||||
if (canvas_data.light_count > 0 ) {
|
||||
//do lighting
|
||||
|
||||
}
|
||||
#endif
|
||||
//color.rgb *= color.a;
|
||||
frag_color = color;
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
|
||||
/* SET0: Per draw primitive settings */
|
||||
|
||||
|
||||
#define MAX_LIGHTS 128
|
||||
|
||||
#define FLAGS_INSTANCING_STRIDE_MASK 0xF
|
||||
#define FLAGS_INSTANCING_ENABLED (1<<4)
|
||||
#define FLAGS_INSTANCING_HAS_COLORS (1 << 5)
|
||||
#define FLAGS_INSTANCING_COLOR_8BIT (1 << 6)
|
||||
#define FLAGS_INSTANCING_HAS_CUSTOM_DATA (1 << 7)
|
||||
#define FLAGS_INSTANCING_CUSTOM_DATA_8_BIT (1 << 8)
|
||||
|
||||
#define FLAGS_CLIP_RECT_UV (1 << 9)
|
||||
#define FLAGS_TRANSPOSE_RECT (1 << 10)
|
||||
#define FLAGS_NINEPACH_DRAW_CENTER (1 << 12)
|
||||
#define FLAGS_USING_PARTICLES (1 << 13)
|
||||
#define FLAGS_USE_PIXEL_SNAP (1 << 14)
|
||||
|
||||
#define FLAGS_USE_SKELETON (1 << 16)
|
||||
|
||||
layout(push_constant, binding = 0, std140) uniform DrawData {
|
||||
mat2x4 world;
|
||||
vec4 modulation;
|
||||
vec4 ninepatch_margins;
|
||||
vec4 dst_rect; //for built-in rect and UV
|
||||
vec4 src_rect;
|
||||
uint flags;
|
||||
uint ninepatch_repeat;
|
||||
vec2 color_texture_pixel_size;
|
||||
} draw_data;
|
||||
|
||||
// The values passed per draw primitives are cached within it
|
||||
|
||||
layout(set = 0, binding = 1) uniform texture2D color_texture;
|
||||
layout(set = 0, binding = 2) uniform texture2D normal_texture;
|
||||
layout(set = 0, binding = 3) uniform texture2D specular_texture;
|
||||
layout(set = 0, binding = 4) uniform sampler texture_sampler;
|
||||
|
||||
layout(set = 0, binding = 5) uniform textureBuffer instancing_buffer;
|
||||
|
||||
/* SET1: Is reserved for the material */
|
||||
|
||||
//
|
||||
|
||||
/* SET2: Per Canvas Item Settings */
|
||||
|
||||
layout(set = 1, binding = 1) uniform textureBuffer skeleton_buffer;
|
||||
|
||||
layout(set = 1, binding = 2, std140) uniform SkeletonData {
|
||||
mat4 skeleton_transform;
|
||||
mat4 skeleton_transform_inverse;
|
||||
} skeleton_data;
|
||||
|
||||
// this set (set 2) is also used for instance specific uniforms
|
||||
|
||||
/* SET3: Per Scene settings */
|
||||
|
||||
layout(set = 3, binding = 0, std140) uniform CanvasData {
|
||||
mat4 canvas_transform;
|
||||
mat4 screen_transform;
|
||||
//uint light_count;
|
||||
} canvas_data;
|
||||
|
||||
struct Light {
|
||||
// light matrices
|
||||
mat4 light_matrix;
|
||||
mat4 light_local_matrix;
|
||||
mat4 shadow_matrix;
|
||||
vec4 light_color;
|
||||
vec4 light_shadow_color;
|
||||
vec2 light_pos;
|
||||
float shadowpixel_size;
|
||||
float shadow_gradient;
|
||||
float light_height;
|
||||
float light_outside_alpha;
|
||||
float shadow_distance_mult;
|
||||
};
|
||||
|
||||
layout(set = 3, binding = 1, std140) uniform LightData {
|
||||
Light lights[MAX_LIGHTS];
|
||||
} light_data;
|
||||
|
||||
layout(set = 3, binding = 2) uniform texture2D light_textures[MAX_LIGHTS];
|
|
@ -1,6 +1,13 @@
|
|||
#include "rendering_device.h"
|
||||
|
||||
RenderingDevice::RenderingDevice()
|
||||
{
|
||||
|
||||
RenderingDevice *RenderingDevice::singleton=NULL;
|
||||
|
||||
RenderingDevice *RenderingDevice::get_singleton() {
|
||||
return singleton;
|
||||
}
|
||||
|
||||
RenderingDevice::RenderingDevice() {
|
||||
|
||||
singleton=this;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
class RenderingDevice : public Object {
|
||||
GDCLASS(RenderingDevice, Object)
|
||||
|
||||
static RenderingDevice *singleton;
|
||||
public:
|
||||
//base numeric ID for all types
|
||||
enum {
|
||||
|
@ -352,7 +354,7 @@ public:
|
|||
virtual RID texture_create_shared(const TextureView& p_view, RID p_with_texture) = 0;
|
||||
virtual Error texture_update(RID p_texture,uint32_t p_layer,const PoolVector<uint8_t>&p_data, bool p_sync_with_draw = false) =0; //this function can be used from any thread and it takes effect at the begining of the frame, unless sync with draw is used, which is used to mix updates with draw calls
|
||||
|
||||
virtual bool texture_is_format_supported_for_usage(DataFormat p_format,TextureUsageBits p_usage) const = 0;
|
||||
virtual bool texture_is_format_supported_for_usage(DataFormat p_format,uint32_t p_usage) const = 0;
|
||||
|
||||
|
||||
/*********************/
|
||||
|
@ -505,7 +507,8 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
virtual RID shader_create_from_source(const Vector<ShaderStageSource> &p_stages,String *r_error=NULL,bool p_allow_cache=true) = 0;
|
||||
virtual RID shader_create_from_source(const Vector<ShaderStageSource> &p_stages,String *r_error=NULL,ShaderStage *r_error_stage=NULL,bool p_allow_cache=true) = 0;
|
||||
virtual Vector<int> shader_get_vertex_input_locations_used(RID p_shader) = 0;
|
||||
|
||||
|
||||
/******************/
|
||||
|
@ -514,7 +517,7 @@ public:
|
|||
|
||||
enum UniformType {
|
||||
UNIFORM_TYPE_SAMPLER, //for sampling only (sampler GLSL type)
|
||||
UNIFORM_TYPE_SAMPLER_WITH_TEXTURE, // for sampling only, but includes a texture, (samplerXX GLSL type)
|
||||
UNIFORM_TYPE_SAMPLER_WITH_TEXTURE, // for sampling only, but includes a texture, (samplerXX GLSL type), first a sampler then a texture
|
||||
UNIFORM_TYPE_TEXTURE, //only texture, (textureXX GLSL type)
|
||||
UNIFORM_TYPE_IMAGE, // storage image (imageXX GLSL type), for compute mostly
|
||||
UNIFORM_TYPE_TEXTURE_BUFFER, // buffer texture (or TBO, textureBuffer type)
|
||||
|
@ -548,6 +551,8 @@ public:
|
|||
};
|
||||
|
||||
virtual RID uniform_set_create(const Vector<Uniform>& p_uniforms,RID p_shader,uint32_t p_shader_set) = 0;
|
||||
virtual bool uniform_set_is_valid(RID p_uniform_set) =0;
|
||||
|
||||
|
||||
virtual Error buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, void *p_data,bool p_sync_with_draw=false) =0; //this function can be used from any thread and it takes effect at the begining of the frame, unless sync with draw is used, which is used to mix updates with draw calls
|
||||
|
||||
|
@ -774,6 +779,22 @@ public:
|
|||
return bs;
|
||||
}
|
||||
|
||||
static PipelineColorBlendState create_blend(int p_attachments=1) {
|
||||
PipelineColorBlendState bs;
|
||||
for(int i=0;i<p_attachments;i++) {
|
||||
|
||||
Attachment ba;
|
||||
ba.enable_blend=true;
|
||||
ba.src_color_blend_factor = BLEND_FACTOR_SRC_ALPHA;
|
||||
ba.dst_color_blend_factor = BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
||||
ba.src_alpha_blend_factor = BLEND_FACTOR_SRC_ALPHA;
|
||||
ba.dst_alpha_blend_factor = BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
|
||||
|
||||
bs.attachments.push_back(ba);
|
||||
}
|
||||
return bs;
|
||||
}
|
||||
|
||||
Vector<Attachment> attachments; //one per render target texture
|
||||
Color blend_constant;
|
||||
|
||||
|
@ -849,7 +870,17 @@ public:
|
|||
/***************/
|
||||
|
||||
virtual void free(RID p_id) =0;
|
||||
|
||||
//methods below not exposed, used by RenderingDeviceRD
|
||||
virtual void finalize_frame() =0;
|
||||
virtual void advance_frame() =0;
|
||||
|
||||
static RenderingDevice *get_singleton();
|
||||
|
||||
RenderingDevice();
|
||||
};
|
||||
|
||||
|
||||
typedef RenderingDevice RD;
|
||||
|
||||
#endif // RENDERING_DEVICE_H
|
||||
|
|
|
@ -35,20 +35,36 @@
|
|||
|
||||
static const int z_range = VS::CANVAS_ITEM_Z_MAX - VS::CANVAS_ITEM_Z_MIN + 1;
|
||||
|
||||
void VisualServerCanvas::_render_canvas_item_tree(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, RasterizerCanvas::Light *p_lights) {
|
||||
void VisualServerCanvas::_render_canvas_item_tree(RID p_to_render_target, bool p_clear, const Color &p_clear_color, Canvas::ChildItem *p_child_items, int p_child_item_count, Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, RasterizerCanvas::Light *p_lights) {
|
||||
|
||||
memset(z_list, 0, z_range * sizeof(RasterizerCanvas::Item *));
|
||||
memset(z_last_list, 0, z_range * sizeof(RasterizerCanvas::Item *));
|
||||
|
||||
_render_canvas_item(p_canvas_item, p_transform, p_clip_rect, Color(1, 1, 1, 1), 0, z_list, z_last_list, NULL, NULL);
|
||||
for (int i = 0; i < p_child_item_count; i++) {
|
||||
_cull_canvas_item(p_child_items[i].item, p_transform, p_clip_rect, Color(1, 1, 1, 1), 0, z_list, z_last_list, NULL, NULL);
|
||||
}
|
||||
if (p_canvas_item) {
|
||||
_cull_canvas_item(p_canvas_item, p_transform, p_clip_rect, Color(1, 1, 1, 1), 0, z_list, z_last_list, NULL, NULL);
|
||||
}
|
||||
|
||||
RasterizerCanvas::Item *list = NULL;
|
||||
RasterizerCanvas::Item *list_end = NULL;
|
||||
|
||||
for (int i = 0; i < z_range; i++) {
|
||||
if (!z_list[i])
|
||||
continue;
|
||||
VSG::canvas_render->canvas_render_items(z_list[i], VS::CANVAS_ITEM_Z_MIN + i, p_modulate, p_lights, p_transform);
|
||||
if (!list) {
|
||||
list = z_list[i];
|
||||
list_end = z_last_list[i];
|
||||
} else {
|
||||
list_end->next = z_list[i];
|
||||
list_end = z_last_list[i];
|
||||
}
|
||||
}
|
||||
|
||||
VSG::canvas_render->canvas_render_items(p_to_render_target, p_clear, p_clear_color, list, p_modulate, p_lights, p_transform);
|
||||
}
|
||||
|
||||
void _collect_ysort_children(VisualServerCanvas::Item *p_canvas_item, Transform2D p_transform, VisualServerCanvas::Item *p_material_owner, const Color p_modulate, VisualServerCanvas::Item **r_items, int &r_index) {
|
||||
int child_item_count = p_canvas_item->child_items.size();
|
||||
VisualServerCanvas::Item **child_items = p_canvas_item->child_items.ptrw();
|
||||
|
@ -81,7 +97,7 @@ void _mark_ysort_dirty(VisualServerCanvas::Item *ysort_owner, RID_PtrOwner<Visua
|
|||
} while (ysort_owner && ysort_owner->sort_y);
|
||||
}
|
||||
|
||||
void VisualServerCanvas::_render_canvas_item(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RasterizerCanvas::Item **z_list, RasterizerCanvas::Item **z_last_list, Item *p_canvas_clip, Item *p_material_owner) {
|
||||
void VisualServerCanvas::_cull_canvas_item(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RasterizerCanvas::Item **z_list, RasterizerCanvas::Item **z_last_list, Item *p_canvas_clip, Item *p_material_owner) {
|
||||
|
||||
Item *ci = p_canvas_item;
|
||||
|
||||
|
@ -153,9 +169,9 @@ void VisualServerCanvas::_render_canvas_item(Item *p_canvas_item, const Transfor
|
|||
if (!child_items[i]->behind || (ci->sort_y && child_items[i]->sort_y))
|
||||
continue;
|
||||
if (ci->sort_y) {
|
||||
_render_canvas_item(child_items[i], xform * child_items[i]->ysort_xform, p_clip_rect, modulate * child_items[i]->ysort_modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, (Item *)child_items[i]->material_owner);
|
||||
_cull_canvas_item(child_items[i], xform * child_items[i]->ysort_xform, p_clip_rect, modulate * child_items[i]->ysort_modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, (Item *)child_items[i]->material_owner);
|
||||
} else {
|
||||
_render_canvas_item(child_items[i], xform, p_clip_rect, modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, p_material_owner);
|
||||
_cull_canvas_item(child_items[i], xform, p_clip_rect, modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, p_material_owner);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,6 +203,8 @@ void VisualServerCanvas::_render_canvas_item(Item *p_canvas_item, const Transfor
|
|||
z_last_list[zidx] = ci;
|
||||
}
|
||||
|
||||
ci->z_final = p_z;
|
||||
|
||||
ci->next = NULL;
|
||||
}
|
||||
|
||||
|
@ -195,9 +213,9 @@ void VisualServerCanvas::_render_canvas_item(Item *p_canvas_item, const Transfor
|
|||
if (child_items[i]->behind || (ci->sort_y && child_items[i]->sort_y))
|
||||
continue;
|
||||
if (ci->sort_y) {
|
||||
_render_canvas_item(child_items[i], xform * child_items[i]->ysort_xform, p_clip_rect, modulate * child_items[i]->ysort_modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, (Item *)child_items[i]->material_owner);
|
||||
_cull_canvas_item(child_items[i], xform * child_items[i]->ysort_xform, p_clip_rect, modulate * child_items[i]->ysort_modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, (Item *)child_items[i]->material_owner);
|
||||
} else {
|
||||
_render_canvas_item(child_items[i], xform, p_clip_rect, modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, p_material_owner);
|
||||
_cull_canvas_item(child_items[i], xform, p_clip_rect, modulate, p_z, z_list, z_last_list, (Item *)ci->final_clip_owner, p_material_owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -225,9 +243,7 @@ void VisualServerCanvas::_light_mask_canvas_items(int p_z, RasterizerCanvas::Ite
|
|||
}
|
||||
}
|
||||
|
||||
void VisualServerCanvas::render_canvas(Canvas *p_canvas, const Transform2D &p_transform, RasterizerCanvas::Light *p_lights, RasterizerCanvas::Light *p_masked_lights, const Rect2 &p_clip_rect) {
|
||||
|
||||
VSG::canvas_render->canvas_begin();
|
||||
void VisualServerCanvas::render_canvas(RID p_render_target, bool p_clear, const Color &p_clear_color, Canvas *p_canvas, const Transform2D &p_transform, RasterizerCanvas::Light *p_lights, RasterizerCanvas::Light *p_masked_lights, const Rect2 &p_clip_rect) {
|
||||
|
||||
if (p_canvas->children_order_dirty) {
|
||||
|
||||
|
@ -248,54 +264,33 @@ void VisualServerCanvas::render_canvas(Canvas *p_canvas, const Transform2D &p_tr
|
|||
|
||||
if (!has_mirror) {
|
||||
|
||||
static const int z_range = VS::CANVAS_ITEM_Z_MAX - VS::CANVAS_ITEM_Z_MIN + 1;
|
||||
RasterizerCanvas::Item *z_list[z_range];
|
||||
RasterizerCanvas::Item *z_last_list[z_range];
|
||||
_render_canvas_item_tree(p_render_target, p_clear, p_clear_color, ci, l, NULL, p_transform, p_clip_rect, p_canvas->modulate, p_lights);
|
||||
|
||||
memset(z_list, 0, z_range * sizeof(RasterizerCanvas::Item *));
|
||||
memset(z_last_list, 0, z_range * sizeof(RasterizerCanvas::Item *));
|
||||
|
||||
for (int i = 0; i < l; i++) {
|
||||
_render_canvas_item(ci[i].item, p_transform, p_clip_rect, Color(1, 1, 1, 1), 0, z_list, z_last_list, NULL, NULL);
|
||||
}
|
||||
|
||||
for (int i = 0; i < z_range; i++) {
|
||||
if (!z_list[i])
|
||||
continue;
|
||||
|
||||
if (p_masked_lights) {
|
||||
_light_mask_canvas_items(VS::CANVAS_ITEM_Z_MIN + i, z_list[i], p_masked_lights);
|
||||
}
|
||||
|
||||
VSG::canvas_render->canvas_render_items(z_list[i], VS::CANVAS_ITEM_Z_MIN + i, p_canvas->modulate, p_lights, p_transform);
|
||||
}
|
||||
} else {
|
||||
|
||||
//used for parallaxlayer mirroring
|
||||
for (int i = 0; i < l; i++) {
|
||||
|
||||
const Canvas::ChildItem &ci2 = p_canvas->child_items[i];
|
||||
_render_canvas_item_tree(ci2.item, p_transform, p_clip_rect, p_canvas->modulate, p_lights);
|
||||
_render_canvas_item_tree(p_render_target, p_clear, p_clear_color, NULL, 0, ci2.item, p_transform, p_clip_rect, p_canvas->modulate, p_lights);
|
||||
|
||||
//mirroring (useful for scrolling backgrounds)
|
||||
if (ci2.mirror.x != 0) {
|
||||
|
||||
Transform2D xform2 = p_transform * Transform2D(0, Vector2(ci2.mirror.x, 0));
|
||||
_render_canvas_item_tree(ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights);
|
||||
_render_canvas_item_tree(p_render_target, false, Color(), NULL, 0, ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights);
|
||||
}
|
||||
if (ci2.mirror.y != 0) {
|
||||
|
||||
Transform2D xform2 = p_transform * Transform2D(0, Vector2(0, ci2.mirror.y));
|
||||
_render_canvas_item_tree(ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights);
|
||||
_render_canvas_item_tree(p_render_target, false, Color(), NULL, 0, ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights);
|
||||
}
|
||||
if (ci2.mirror.y != 0 && ci2.mirror.x != 0) {
|
||||
|
||||
Transform2D xform2 = p_transform * Transform2D(0, ci2.mirror);
|
||||
_render_canvas_item_tree(ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights);
|
||||
_render_canvas_item_tree(p_render_target, false, Color(), NULL, 0, ci2.item, xform2, p_clip_rect, p_canvas->modulate, p_lights);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VSG::canvas_render->canvas_end();
|
||||
}
|
||||
|
||||
RID VisualServerCanvas::canvas_create() {
|
||||
|
@ -473,6 +468,20 @@ void VisualServerCanvas::canvas_item_set_update_when_visible(RID p_item, bool p_
|
|||
canvas_item->update_when_visible = p_update;
|
||||
}
|
||||
|
||||
void VisualServerCanvas::canvas_item_set_default_texture_filter(RID p_item, VS::CanvasItemTextureFilter p_filter) {
|
||||
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
canvas_item->texture_filter = p_filter;
|
||||
}
|
||||
|
||||
void VisualServerCanvas::canvas_item_set_default_texture_repeat(RID p_item, VS::CanvasItemTextureRepeat p_repeat) {
|
||||
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
canvas_item->texture_repeat = p_repeat;
|
||||
}
|
||||
|
||||
void VisualServerCanvas::canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width, bool p_antialiased) {
|
||||
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
|
@ -627,7 +636,7 @@ void VisualServerCanvas::canvas_item_add_circle(RID p_item, const Point2 &p_pos,
|
|||
canvas_item->commands.push_back(circle);
|
||||
}
|
||||
|
||||
void VisualServerCanvas::canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile, const Color &p_modulate, bool p_transpose, RID p_normal_map) {
|
||||
void VisualServerCanvas::canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile, const Color &p_modulate, bool p_transpose, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) {
|
||||
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
|
@ -657,13 +666,13 @@ void VisualServerCanvas::canvas_item_add_texture_rect(RID p_item, const Rect2 &p
|
|||
rect->flags |= RasterizerCanvas::CANVAS_RECT_TRANSPOSE;
|
||||
SWAP(rect->rect.size.x, rect->rect.size.y);
|
||||
}
|
||||
rect->texture = p_texture;
|
||||
rect->normal_map = p_normal_map;
|
||||
rect->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, p_texture, p_normal_map, p_specular_map, p_filter, p_repeat, RID());
|
||||
rect->specular_shininess = p_specular_color_shininess;
|
||||
canvas_item->rect_dirty = true;
|
||||
canvas_item->commands.push_back(rect);
|
||||
}
|
||||
|
||||
void VisualServerCanvas::canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, RID p_normal_map, bool p_clip_uv) {
|
||||
void VisualServerCanvas::canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, bool p_clip_uv, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) {
|
||||
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
|
@ -672,8 +681,8 @@ void VisualServerCanvas::canvas_item_add_texture_rect_region(RID p_item, const R
|
|||
ERR_FAIL_COND(!rect);
|
||||
rect->modulate = p_modulate;
|
||||
rect->rect = p_rect;
|
||||
rect->texture = p_texture;
|
||||
rect->normal_map = p_normal_map;
|
||||
rect->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, p_texture, p_normal_map, p_specular_map, p_filter, p_repeat, RID());
|
||||
rect->specular_shininess = p_specular_color_shininess;
|
||||
rect->source = p_src_rect;
|
||||
rect->flags = RasterizerCanvas::CANVAS_RECT_REGION;
|
||||
|
||||
|
@ -712,15 +721,15 @@ void VisualServerCanvas::canvas_item_add_texture_rect_region(RID p_item, const R
|
|||
canvas_item->commands.push_back(rect);
|
||||
}
|
||||
|
||||
void VisualServerCanvas::canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, VS::NinePatchAxisMode p_x_axis_mode, VS::NinePatchAxisMode p_y_axis_mode, bool p_draw_center, const Color &p_modulate, RID p_normal_map) {
|
||||
void VisualServerCanvas::canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, VS::NinePatchAxisMode p_x_axis_mode, VS::NinePatchAxisMode p_y_axis_mode, bool p_draw_center, const Color &p_modulate, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) {
|
||||
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
|
||||
Item::CommandNinePatch *style = memnew(Item::CommandNinePatch);
|
||||
ERR_FAIL_COND(!style);
|
||||
style->texture = p_texture;
|
||||
style->normal_map = p_normal_map;
|
||||
style->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, p_texture, p_normal_map, p_specular_map, p_filter, p_repeat, RID());
|
||||
style->specular_shininess = p_specular_color_shininess;
|
||||
style->rect = p_rect;
|
||||
style->source = p_source;
|
||||
style->draw_center = p_draw_center;
|
||||
|
@ -735,15 +744,15 @@ void VisualServerCanvas::canvas_item_add_nine_patch(RID p_item, const Rect2 &p_r
|
|||
|
||||
canvas_item->commands.push_back(style);
|
||||
}
|
||||
void VisualServerCanvas::canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width, RID p_normal_map) {
|
||||
void VisualServerCanvas::canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) {
|
||||
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
|
||||
Item::CommandPrimitive *prim = memnew(Item::CommandPrimitive);
|
||||
ERR_FAIL_COND(!prim);
|
||||
prim->texture = p_texture;
|
||||
prim->normal_map = p_normal_map;
|
||||
prim->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, p_texture, p_normal_map, p_specular_map, p_filter, p_repeat, RID());
|
||||
prim->specular_shininess = p_specular_color_shininess;
|
||||
prim->points = p_points;
|
||||
prim->uvs = p_uvs;
|
||||
prim->colors = p_colors;
|
||||
|
@ -753,7 +762,7 @@ void VisualServerCanvas::canvas_item_add_primitive(RID p_item, const Vector<Poin
|
|||
canvas_item->commands.push_back(prim);
|
||||
}
|
||||
|
||||
void VisualServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, RID p_normal_map, bool p_antialiased) {
|
||||
void VisualServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, bool p_antialiased, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) {
|
||||
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
|
@ -770,21 +779,20 @@ void VisualServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2
|
|||
|
||||
Item::CommandPolygon *polygon = memnew(Item::CommandPolygon);
|
||||
ERR_FAIL_COND(!polygon);
|
||||
polygon->texture = p_texture;
|
||||
polygon->normal_map = p_normal_map;
|
||||
polygon->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, p_texture, p_normal_map, p_specular_map, p_filter, p_repeat, RID());
|
||||
polygon->specular_shininess = p_specular_color_shininess;
|
||||
polygon->points = p_points;
|
||||
polygon->uvs = p_uvs;
|
||||
polygon->colors = p_colors;
|
||||
polygon->indices = indices;
|
||||
polygon->count = indices.size();
|
||||
polygon->antialiased = p_antialiased;
|
||||
polygon->antialiasing_use_indices = false;
|
||||
canvas_item->rect_dirty = true;
|
||||
|
||||
canvas_item->commands.push_back(polygon);
|
||||
}
|
||||
|
||||
void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, const Vector<int> &p_bones, const Vector<float> &p_weights, RID p_texture, int p_count, RID p_normal_map, bool p_antialiased, bool p_antialiasing_use_indices) {
|
||||
void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, const Vector<int> &p_bones, const Vector<float> &p_weights, RID p_texture, int p_count, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, bool p_antialiased, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) {
|
||||
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
|
@ -814,8 +822,8 @@ void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector
|
|||
|
||||
Item::CommandPolygon *polygon = memnew(Item::CommandPolygon);
|
||||
ERR_FAIL_COND(!polygon);
|
||||
polygon->texture = p_texture;
|
||||
polygon->normal_map = p_normal_map;
|
||||
polygon->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, p_texture, p_normal_map, p_specular_map, p_filter, p_repeat, RID());
|
||||
polygon->specular_shininess = p_specular_color_shininess;
|
||||
polygon->points = p_points;
|
||||
polygon->uvs = p_uvs;
|
||||
polygon->colors = p_colors;
|
||||
|
@ -824,7 +832,6 @@ void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector
|
|||
polygon->indices = indices;
|
||||
polygon->count = count;
|
||||
polygon->antialiased = p_antialiased;
|
||||
polygon->antialiasing_use_indices = p_antialiasing_use_indices;
|
||||
canvas_item->rect_dirty = true;
|
||||
|
||||
canvas_item->commands.push_back(polygon);
|
||||
|
@ -842,7 +849,7 @@ void VisualServerCanvas::canvas_item_add_set_transform(RID p_item, const Transfo
|
|||
canvas_item->commands.push_back(tr);
|
||||
}
|
||||
|
||||
void VisualServerCanvas::canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform, const Color &p_modulate, RID p_texture, RID p_normal_map) {
|
||||
void VisualServerCanvas::canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform, const Color &p_modulate, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) {
|
||||
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
|
@ -850,14 +857,14 @@ void VisualServerCanvas::canvas_item_add_mesh(RID p_item, const RID &p_mesh, con
|
|||
Item::CommandMesh *m = memnew(Item::CommandMesh);
|
||||
ERR_FAIL_COND(!m);
|
||||
m->mesh = p_mesh;
|
||||
m->texture = p_texture;
|
||||
m->normal_map = p_normal_map;
|
||||
m->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, p_texture, p_normal_map, p_specular_map, p_filter, p_repeat, RID());
|
||||
m->specular_shininess = p_specular_color_shininess;
|
||||
m->transform = p_transform;
|
||||
m->modulate = p_modulate;
|
||||
|
||||
canvas_item->commands.push_back(m);
|
||||
}
|
||||
void VisualServerCanvas::canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal) {
|
||||
void VisualServerCanvas::canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) {
|
||||
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
|
@ -865,8 +872,8 @@ void VisualServerCanvas::canvas_item_add_particles(RID p_item, RID p_particles,
|
|||
Item::CommandParticles *part = memnew(Item::CommandParticles);
|
||||
ERR_FAIL_COND(!part);
|
||||
part->particles = p_particles;
|
||||
part->texture = p_texture;
|
||||
part->normal_map = p_normal;
|
||||
part->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, p_texture, p_normal_map, p_specular_map, p_filter, p_repeat, RID());
|
||||
part->specular_shininess = p_specular_color_shininess;
|
||||
|
||||
//take the chance and request processing for them, at least once until they become visible again
|
||||
VSG::storage->particles_request_process(p_particles);
|
||||
|
@ -875,7 +882,7 @@ void VisualServerCanvas::canvas_item_add_particles(RID p_item, RID p_particles,
|
|||
canvas_item->commands.push_back(part);
|
||||
}
|
||||
|
||||
void VisualServerCanvas::canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture, RID p_normal_map) {
|
||||
void VisualServerCanvas::canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture, RID p_normal_map, RID p_specular_map, const Color &p_specular_color_shininess, VisualServer::CanvasItemTextureFilter p_filter, VisualServer::CanvasItemTextureRepeat p_repeat) {
|
||||
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
|
@ -883,8 +890,8 @@ void VisualServerCanvas::canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p
|
|||
Item::CommandMultiMesh *mm = memnew(Item::CommandMultiMesh);
|
||||
ERR_FAIL_COND(!mm);
|
||||
mm->multimesh = p_mesh;
|
||||
mm->texture = p_texture;
|
||||
mm->normal_map = p_normal_map;
|
||||
mm->texture_binding.create(canvas_item->texture_filter, canvas_item->texture_repeat, p_texture, p_normal_map, p_specular_map, p_filter, p_repeat, mm->multimesh);
|
||||
mm->specular_shininess = p_specular_color_shininess;
|
||||
|
||||
canvas_item->rect_dirty = true;
|
||||
canvas_item->commands.push_back(mm);
|
||||
|
|
|
@ -52,6 +52,9 @@ public:
|
|||
Color ysort_modulate;
|
||||
Transform2D ysort_xform;
|
||||
Vector2 ysort_pos;
|
||||
VS::CanvasItemTextureFilter texture_filter;
|
||||
VS::CanvasItemTextureRepeat texture_repeat;
|
||||
int z_final;
|
||||
|
||||
Vector<Item *> child_items;
|
||||
|
||||
|
@ -68,6 +71,8 @@ public:
|
|||
ysort_children_count = -1;
|
||||
ysort_xform = Transform2D();
|
||||
ysort_pos = Vector2();
|
||||
texture_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT;
|
||||
texture_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -157,15 +162,15 @@ public:
|
|||
bool disable_scale;
|
||||
|
||||
private:
|
||||
void _render_canvas_item_tree(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, RasterizerCanvas::Light *p_lights);
|
||||
void _render_canvas_item(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RasterizerCanvas::Item **z_list, RasterizerCanvas::Item **z_last_list, Item *p_canvas_clip, Item *p_material_owner);
|
||||
void _render_canvas_item_tree(RID p_to_render_target, bool p_clear, const Color &p_clear_color, Canvas::ChildItem *p_child_items, int p_child_item_count, Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, RasterizerCanvas::Light *p_lights);
|
||||
void _cull_canvas_item(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RasterizerCanvas::Item **z_list, RasterizerCanvas::Item **z_last_list, Item *p_canvas_clip, Item *p_material_owner);
|
||||
void _light_mask_canvas_items(int p_z, RasterizerCanvas::Item *p_canvas_item, RasterizerCanvas::Light *p_masked_lights);
|
||||
|
||||
RasterizerCanvas::Item **z_list;
|
||||
RasterizerCanvas::Item **z_last_list;
|
||||
|
||||
public:
|
||||
void render_canvas(Canvas *p_canvas, const Transform2D &p_transform, RasterizerCanvas::Light *p_lights, RasterizerCanvas::Light *p_masked_lights, const Rect2 &p_clip_rect);
|
||||
void render_canvas(RID p_render_target, bool p_clear, const Color &p_clear_color, Canvas *p_canvas, const Transform2D &p_transform, RasterizerCanvas::Light *p_lights, RasterizerCanvas::Light *p_masked_lights, const Rect2 &p_clip_rect);
|
||||
|
||||
RID canvas_create();
|
||||
void canvas_set_item_mirroring(RID p_canvas, RID p_item, const Point2 &p_mirroring);
|
||||
|
@ -190,20 +195,23 @@ public:
|
|||
|
||||
void canvas_item_set_update_when_visible(RID p_item, bool p_update);
|
||||
|
||||
void canvas_item_set_default_texture_filter(RID p_item, VS::CanvasItemTextureFilter p_filter);
|
||||
void canvas_item_set_default_texture_repeat(RID p_item, VS::CanvasItemTextureRepeat p_repeat);
|
||||
|
||||
void canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width = 1.0, bool p_antialiased = false);
|
||||
void canvas_item_add_polyline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width = 1.0, bool p_antialiased = false);
|
||||
void canvas_item_add_multiline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width = 1.0, bool p_antialiased = false);
|
||||
void canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color);
|
||||
void canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color);
|
||||
void canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID());
|
||||
void canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), bool p_clip_uv = false);
|
||||
void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, VS::NinePatchAxisMode p_x_axis_mode = VS::NINE_PATCH_STRETCH, VS::NinePatchAxisMode p_y_axis_mode = VS::NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID());
|
||||
void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID());
|
||||
void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), bool p_antialiased = false);
|
||||
void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID(), bool p_antialiased = false, bool p_antialiasing_use_indices = false);
|
||||
void canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1), RID p_texture = RID(), RID p_normal_map = RID());
|
||||
void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture = RID(), RID p_normal_map = RID());
|
||||
void canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal);
|
||||
void canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
|
||||
void canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), bool p_clip_uv = false, VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
|
||||
void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, VS::NinePatchAxisMode p_x_axis_mode = VS::NINE_PATCH_STRETCH, VS::NinePatchAxisMode p_y_axis_mode = VS::NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
|
||||
void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
|
||||
void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), bool p_antialiased = false, VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
|
||||
void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), bool p_antialiased = false, VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
|
||||
void canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1), RID p_texture = RID(), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
|
||||
void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture = RID(), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
|
||||
void canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal_map, RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), VS::CanvasItemTextureFilter p_filter = VS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, VS::CanvasItemTextureRepeat p_repeat = VS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT);
|
||||
void canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform);
|
||||
void canvas_item_add_clip_ignore(RID p_item, bool p_ignore);
|
||||
void canvas_item_set_sort_children_by_y(RID p_item, bool p_enable);
|
||||
|
|
|
@ -107,6 +107,8 @@ void VisualServerRaster::draw(bool p_swap_buffers, double frame_step) {
|
|||
|
||||
VSG::viewport->draw_viewports();
|
||||
VSG::scene->render_probes();
|
||||
VSG::canvas_render->update();
|
||||
|
||||
_draw_margins();
|
||||
VSG::rasterizer->end_frame(p_swap_buffers);
|
||||
|
||||
|
|
|
@ -136,6 +136,10 @@ public:
|
|||
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12); }
|
||||
#define BIND13(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12, m_type13) \
|
||||
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12, m_type13 arg13) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13); }
|
||||
#define BIND14(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12, m_type13, m_type14) \
|
||||
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12, m_type13 arg13, m_type14 arg14) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14); }
|
||||
#define BIND15(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11, m_type12, m_type13, m_type14, m_type15) \
|
||||
void m_name(m_type1 arg1, m_type2 arg2, m_type3 arg3, m_type4 arg4, m_type5 arg5, m_type6 arg6, m_type7 arg7, m_type8 arg8, m_type9 arg9, m_type10 arg10, m_type11 arg11, m_type12 arg12, m_type13 arg13, m_type14 arg14, m_type15 arg15) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15); }
|
||||
|
||||
//from now on, calls forwarded to this singleton
|
||||
#define BINDBASE VSG::storage
|
||||
|
@ -603,20 +607,23 @@ public:
|
|||
|
||||
BIND2(canvas_item_set_draw_behind_parent, RID, bool)
|
||||
|
||||
BIND2(canvas_item_set_default_texture_filter, RID, CanvasItemTextureFilter)
|
||||
BIND2(canvas_item_set_default_texture_repeat, RID, CanvasItemTextureRepeat)
|
||||
|
||||
BIND6(canvas_item_add_line, RID, const Point2 &, const Point2 &, const Color &, float, bool)
|
||||
BIND5(canvas_item_add_polyline, RID, const Vector<Point2> &, const Vector<Color> &, float, bool)
|
||||
BIND5(canvas_item_add_multiline, RID, const Vector<Point2> &, const Vector<Color> &, float, bool)
|
||||
BIND3(canvas_item_add_rect, RID, const Rect2 &, const Color &)
|
||||
BIND4(canvas_item_add_circle, RID, const Point2 &, float, const Color &)
|
||||
BIND7(canvas_item_add_texture_rect, RID, const Rect2 &, RID, bool, const Color &, bool, RID)
|
||||
BIND8(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool, RID, bool)
|
||||
BIND11(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &, RID)
|
||||
BIND7(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, float, RID)
|
||||
BIND7(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID, bool)
|
||||
BIND12(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, const Vector<int> &, const Vector<float> &, RID, int, RID, bool, bool)
|
||||
BIND6(canvas_item_add_mesh, RID, const RID &, const Transform2D &, const Color &, RID, RID)
|
||||
BIND4(canvas_item_add_multimesh, RID, RID, RID, RID)
|
||||
BIND4(canvas_item_add_particles, RID, RID, RID, RID)
|
||||
BIND11(canvas_item_add_texture_rect, RID, const Rect2 &, RID, bool, const Color &, bool, RID, RID, const Color &, CanvasItemTextureFilter, CanvasItemTextureRepeat)
|
||||
BIND12(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool, RID, RID, const Color &, bool, CanvasItemTextureFilter, CanvasItemTextureRepeat)
|
||||
BIND15(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &, RID, RID, const Color &, CanvasItemTextureFilter, CanvasItemTextureRepeat)
|
||||
BIND11(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, float, RID, RID, const Color &, CanvasItemTextureFilter, CanvasItemTextureRepeat)
|
||||
BIND11(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID, RID, const Color &, bool, CanvasItemTextureFilter, CanvasItemTextureRepeat)
|
||||
BIND15(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, const Vector<int> &, const Vector<float> &, RID, int, RID, RID, const Color &, bool, CanvasItemTextureFilter, CanvasItemTextureRepeat)
|
||||
BIND10(canvas_item_add_mesh, RID, const RID &, const Transform2D &, const Color &, RID, RID, RID, const Color &, CanvasItemTextureFilter, CanvasItemTextureRepeat)
|
||||
BIND8(canvas_item_add_multimesh, RID, RID, RID, RID, RID, const Color &, CanvasItemTextureFilter, CanvasItemTextureRepeat)
|
||||
BIND8(canvas_item_add_particles, RID, RID, RID, RID, RID, const Color &, CanvasItemTextureFilter, CanvasItemTextureRepeat)
|
||||
BIND2(canvas_item_add_set_transform, RID, const Transform2D &)
|
||||
BIND2(canvas_item_add_clip_ignore, RID, bool)
|
||||
BIND2(canvas_item_set_sort_children_by_y, RID, bool)
|
||||
|
|
|
@ -81,6 +81,8 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
|
|||
|
||||
bool scenario_draw_canvas_bg = false; //draw canvas, or some layer of it, as BG for 3D instead of in front
|
||||
int scenario_canvas_max_layer = 0;
|
||||
bool cleared = false;
|
||||
Color bgcolor = clear_color;
|
||||
|
||||
if (!p_viewport->hide_canvas && !p_viewport->disable_environment && VSG::scene->scenario_owner.owns(p_viewport->scenario)) {
|
||||
|
||||
|
@ -96,7 +98,9 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
|
|||
bool can_draw_3d = !p_viewport->disable_3d && !p_viewport->disable_3d_by_usage && VSG::scene->camera_owner.owns(p_viewport->camera);
|
||||
|
||||
if (p_viewport->clear_mode != VS::VIEWPORT_CLEAR_NEVER) {
|
||||
VSG::rasterizer->clear_render_target(p_viewport->transparent_bg ? Color(0, 0, 0, 0) : clear_color);
|
||||
if (p_viewport->transparent_bg) {
|
||||
bgcolor = Color(0, 0, 0, 0);
|
||||
}
|
||||
if (p_viewport->clear_mode == VS::VIEWPORT_CLEAR_ONLY_NEXT_FRAME) {
|
||||
p_viewport->clear_mode = VS::VIEWPORT_CLEAR_NEVER;
|
||||
}
|
||||
|
@ -104,6 +108,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
|
|||
|
||||
if (!scenario_draw_canvas_bg && can_draw_3d) {
|
||||
_draw_3d(p_viewport, p_eye);
|
||||
cleared = true; //if 3D has drawn, 2D is cleared.
|
||||
}
|
||||
|
||||
if (!p_viewport->hide_canvas) {
|
||||
|
@ -209,8 +214,6 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
|
|||
//VSG::canvas_render->reset_canvas();
|
||||
}
|
||||
|
||||
VSG::rasterizer->restore_render_target(!scenario_draw_canvas_bg && can_draw_3d);
|
||||
|
||||
if (scenario_draw_canvas_bg && canvas_map.front() && canvas_map.front()->key().get_layer() > scenario_canvas_max_layer) {
|
||||
if (!can_draw_3d) {
|
||||
VSG::scene->render_empty_scene(p_viewport->scenario, p_viewport->shadow_atlas);
|
||||
|
@ -237,7 +240,8 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
|
|||
ptr = ptr->filter_next_ptr;
|
||||
}
|
||||
|
||||
VSG::canvas->render_canvas(canvas, xform, canvas_lights, lights_with_mask, clip_rect);
|
||||
VSG::canvas->render_canvas(p_viewport->render_target, !cleared, bgcolor, canvas, xform, canvas_lights, lights_with_mask, clip_rect);
|
||||
cleared = true;
|
||||
i++;
|
||||
|
||||
if (scenario_draw_canvas_bg && E->key().get_layer() >= scenario_canvas_max_layer) {
|
||||
|
@ -265,6 +269,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
|
|||
|
||||
void VisualServerViewport::draw_viewports() {
|
||||
|
||||
#if 0
|
||||
// get our arvr interface in case we need it
|
||||
Ref<ARVRInterface> arvr_interface;
|
||||
|
||||
|
@ -274,6 +279,7 @@ void VisualServerViewport::draw_viewports() {
|
|||
// process all our active interfaces
|
||||
ARVRServer::get_singleton()->_process();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Engine::get_singleton()->is_editor_hint()) {
|
||||
clear_color = GLOBAL_GET("rendering/environment/default_clear_color");
|
||||
|
@ -282,6 +288,7 @@ void VisualServerViewport::draw_viewports() {
|
|||
//sort viewports
|
||||
active_viewports.sort_custom<ViewportSort>();
|
||||
|
||||
Map<int, Vector<Rasterizer::BlitToScreen> > blit_to_screen_list;
|
||||
//draw viewports
|
||||
for (int i = 0; i < active_viewports.size(); i++) {
|
||||
|
||||
|
@ -301,8 +308,8 @@ void VisualServerViewport::draw_viewports() {
|
|||
if (!visible)
|
||||
continue;
|
||||
|
||||
VSG::storage->render_target_clear_used(vp->render_target);
|
||||
|
||||
VSG::storage->render_target_clear_used_flag(vp->render_target);
|
||||
#if 0
|
||||
if (vp->use_arvr && arvr_interface.is_valid()) {
|
||||
// override our size, make sure it matches our required size
|
||||
vp->size = arvr_interface->get_render_targetsize();
|
||||
|
@ -336,8 +343,9 @@ void VisualServerViewport::draw_viewports() {
|
|||
// and for our frame timing, mark when we've finished committing our eyes
|
||||
ARVRServer::get_singleton()->_mark_commit();
|
||||
} else {
|
||||
#endif
|
||||
{
|
||||
VSG::storage->render_target_set_external_texture(vp->render_target, 0);
|
||||
VSG::rasterizer->set_current_render_target(vp->render_target);
|
||||
|
||||
VSG::scene_render->set_debug_draw_mode(vp->debug_draw);
|
||||
VSG::storage->render_info_begin_capture();
|
||||
|
@ -355,15 +363,26 @@ void VisualServerViewport::draw_viewports() {
|
|||
|
||||
if (vp->viewport_to_screen_rect != Rect2() && (!vp->viewport_render_direct_to_screen || !VSG::rasterizer->is_low_end())) {
|
||||
//copy to screen if set as such
|
||||
VSG::rasterizer->set_current_render_target(RID());
|
||||
VSG::rasterizer->blit_render_target_to_screen(vp->render_target, vp->viewport_to_screen_rect, vp->viewport_to_screen);
|
||||
Rasterizer::BlitToScreen blit;
|
||||
blit.render_target = vp->render_target;
|
||||
blit.rect = vp->viewport_to_screen_rect;
|
||||
|
||||
if (!blit_to_screen_list.has(vp->viewport_to_screen)) {
|
||||
blit_to_screen_list[vp->viewport_to_screen] = Vector<Rasterizer::BlitToScreen>();
|
||||
}
|
||||
|
||||
blit_to_screen_list[vp->viewport_to_screen].push_back(blit);
|
||||
}
|
||||
}
|
||||
|
||||
if (vp->update_mode == VS::VIEWPORT_UPDATE_ONCE) {
|
||||
vp->update_mode = VS::VIEWPORT_UPDATE_DISABLED;
|
||||
}
|
||||
}
|
||||
VSG::scene_render->set_debug_draw_mode(VS::VIEWPORT_DEBUG_DRAW_DISABLED);
|
||||
|
||||
for (Map<int, Vector<Rasterizer::BlitToScreen> >::Element *E = blit_to_screen_list.front(); E; E = E->next()) {
|
||||
VSG::rasterizer->blit_render_targets_to_screen(E->key(), E->get().ptr(), E->get().size());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -650,7 +669,8 @@ void VisualServerViewport::viewport_set_msaa(RID p_viewport, VS::ViewportMSAA p_
|
|||
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
|
||||
VSG::storage->render_target_set_msaa(viewport->render_target, p_msaa);
|
||||
#warning this will no longer go in the render target, but in the 3D view
|
||||
//VSG::storage->render_target_set_msaa(viewport->render_target, p_msaa);
|
||||
}
|
||||
|
||||
void VisualServerViewport::viewport_set_hdr(RID p_viewport, bool p_enabled) {
|
||||
|
|
|
@ -520,20 +520,23 @@ public:
|
|||
|
||||
FUNC2(canvas_item_set_draw_behind_parent, RID, bool)
|
||||
|
||||
FUNC2(canvas_item_set_default_texture_filter, RID, CanvasItemTextureFilter)
|
||||
FUNC2(canvas_item_set_default_texture_repeat, RID, CanvasItemTextureRepeat)
|
||||
|
||||
FUNC6(canvas_item_add_line, RID, const Point2 &, const Point2 &, const Color &, float, bool)
|
||||
FUNC5(canvas_item_add_polyline, RID, const Vector<Point2> &, const Vector<Color> &, float, bool)
|
||||
FUNC5(canvas_item_add_multiline, RID, const Vector<Point2> &, const Vector<Color> &, float, bool)
|
||||
FUNC3(canvas_item_add_rect, RID, const Rect2 &, const Color &)
|
||||
FUNC4(canvas_item_add_circle, RID, const Point2 &, float, const Color &)
|
||||
FUNC7(canvas_item_add_texture_rect, RID, const Rect2 &, RID, bool, const Color &, bool, RID)
|
||||
FUNC8(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool, RID, bool)
|
||||
FUNC11(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &, RID)
|
||||
FUNC7(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, float, RID)
|
||||
FUNC7(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID, bool)
|
||||
FUNC12(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, const Vector<int> &, const Vector<float> &, RID, int, RID, bool, bool)
|
||||
FUNC6(canvas_item_add_mesh, RID, const RID &, const Transform2D &, const Color &, RID, RID)
|
||||
FUNC4(canvas_item_add_multimesh, RID, RID, RID, RID)
|
||||
FUNC4(canvas_item_add_particles, RID, RID, RID, RID)
|
||||
FUNC11(canvas_item_add_texture_rect, RID, const Rect2 &, RID, bool, const Color &, bool, RID, RID, const Color &, CanvasItemTextureFilter, CanvasItemTextureRepeat)
|
||||
FUNC12(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool, RID, RID, const Color &, bool, CanvasItemTextureFilter, CanvasItemTextureRepeat)
|
||||
FUNC15(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &, RID, RID, const Color &, CanvasItemTextureFilter, CanvasItemTextureRepeat)
|
||||
FUNC11(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, float, RID, RID, const Color &, CanvasItemTextureFilter, CanvasItemTextureRepeat)
|
||||
FUNC11(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID, RID, const Color &, bool, CanvasItemTextureFilter, CanvasItemTextureRepeat)
|
||||
FUNC15(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, const Vector<int> &, const Vector<float> &, RID, int, RID, RID, const Color &, bool, CanvasItemTextureFilter, CanvasItemTextureRepeat)
|
||||
FUNC10(canvas_item_add_mesh, RID, const RID &, const Transform2D &, const Color &, RID, RID, RID, const Color &, CanvasItemTextureFilter, CanvasItemTextureRepeat)
|
||||
FUNC8(canvas_item_add_multimesh, RID, RID, RID, RID, RID, const Color &, CanvasItemTextureFilter, CanvasItemTextureRepeat)
|
||||
FUNC8(canvas_item_add_particles, RID, RID, RID, RID, RID, const Color &, CanvasItemTextureFilter, CanvasItemTextureRepeat)
|
||||
FUNC2(canvas_item_add_set_transform, RID, const Transform2D &)
|
||||
FUNC2(canvas_item_add_clip_ignore, RID, bool)
|
||||
FUNC2(canvas_item_set_sort_children_by_y, RID, bool)
|
||||
|
|
|
@ -1940,7 +1940,7 @@ void VisualServer::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("canvas_item_add_nine_patch", "item", "rect", "source", "texture", "topleft", "bottomright", "x_axis_mode", "y_axis_mode", "draw_center", "modulate", "normal_map"), &VisualServer::canvas_item_add_nine_patch, DEFVAL(NINE_PATCH_STRETCH), DEFVAL(NINE_PATCH_STRETCH), DEFVAL(true), DEFVAL(Color(1, 1, 1)), DEFVAL(RID()));
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_add_primitive", "item", "points", "colors", "uvs", "texture", "width", "normal_map"), &VisualServer::canvas_item_add_primitive, DEFVAL(1.0), DEFVAL(RID()));
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_add_polygon", "item", "points", "colors", "uvs", "texture", "normal_map", "antialiased"), &VisualServer::canvas_item_add_polygon, DEFVAL(Vector<Point2>()), DEFVAL(RID()), DEFVAL(RID()), DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_add_triangle_array", "item", "indices", "points", "colors", "uvs", "bones", "weights", "texture", "count", "normal_map", "antialiased", "antialiasing_use_indices"), &VisualServer::canvas_item_add_triangle_array, DEFVAL(Vector<Point2>()), DEFVAL(Vector<int>()), DEFVAL(Vector<float>()), DEFVAL(RID()), DEFVAL(-1), DEFVAL(RID()), DEFVAL(false), DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_add_triangle_array", "item", "indices", "points", "colors", "uvs", "bones", "weights", "texture", "count", "normal_map", "antialiased"), &VisualServer::canvas_item_add_triangle_array, DEFVAL(Vector<Point2>()), DEFVAL(Vector<int>()), DEFVAL(Vector<float>()), DEFVAL(RID()), DEFVAL(-1), DEFVAL(RID()), DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_add_mesh", "item", "mesh", "transform", "modulate", "texture", "normal_map"), &VisualServer::canvas_item_add_mesh, DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1)), DEFVAL(RID()), DEFVAL(RID()));
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_add_multimesh", "item", "mesh", "texture", "normal_map"), &VisualServer::canvas_item_add_multimesh, DEFVAL(RID()));
|
||||
ClassDB::bind_method(D_METHOD("canvas_item_add_particles", "item", "particles", "texture", "normal_map"), &VisualServer::canvas_item_add_particles);
|
||||
|
@ -2075,11 +2075,7 @@ void VisualServer::_bind_methods() {
|
|||
|
||||
BIND_ENUM_CONSTANT(PRIMITIVE_POINTS);
|
||||
BIND_ENUM_CONSTANT(PRIMITIVE_LINES);
|
||||
BIND_ENUM_CONSTANT(PRIMITIVE_LINE_STRIP);
|
||||
BIND_ENUM_CONSTANT(PRIMITIVE_LINE_LOOP);
|
||||
BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLES);
|
||||
BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLE_STRIP);
|
||||
BIND_ENUM_CONSTANT(PRIMITIVE_TRIANGLE_FAN);
|
||||
BIND_ENUM_CONSTANT(PRIMITIVE_MAX);
|
||||
|
||||
BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_NORMALIZED);
|
||||
|
|
|
@ -249,14 +249,10 @@ public:
|
|||
};
|
||||
|
||||
enum PrimitiveType {
|
||||
PRIMITIVE_POINTS = 0,
|
||||
PRIMITIVE_LINES = 1,
|
||||
PRIMITIVE_LINE_STRIP = 2,
|
||||
PRIMITIVE_LINE_LOOP = 3,
|
||||
PRIMITIVE_TRIANGLES = 4,
|
||||
PRIMITIVE_TRIANGLE_STRIP = 5,
|
||||
PRIMITIVE_TRIANGLE_FAN = 6,
|
||||
PRIMITIVE_MAX = 7,
|
||||
PRIMITIVE_POINTS,
|
||||
PRIMITIVE_LINES,
|
||||
PRIMITIVE_TRIANGLES,
|
||||
PRIMITIVE_MAX,
|
||||
};
|
||||
|
||||
virtual RID mesh_create() = 0;
|
||||
|
@ -884,20 +880,41 @@ public:
|
|||
NINE_PATCH_TILE_FIT,
|
||||
};
|
||||
|
||||
enum CanvasItemTextureFilter {
|
||||
CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, //uses canvas item setting for draw command, uses global setting for canvas item
|
||||
CANVAS_ITEM_TEXTURE_FILTER_NEAREST,
|
||||
CANVAS_ITEM_TEXTURE_FILTER_LINEAR,
|
||||
CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS,
|
||||
CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIMPAMPS,
|
||||
CANVAS_ITEM_TEXTURE_FILTER_MAX
|
||||
};
|
||||
|
||||
enum CanvasItemTextureRepeat {
|
||||
CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, //uses canvas item setting for draw command, uses global setting for canvas item
|
||||
CANVAS_ITEM_TEXTURE_REPEAT_DISABLED,
|
||||
CANVAS_ITEM_TEXTURE_REPEAT_ENABLED,
|
||||
CANVAS_ITEM_TEXTURE_REPEAT_MIRROR,
|
||||
CANVAS_ITEM_TEXTURE_REPEAT_MAX,
|
||||
};
|
||||
|
||||
//takes effect only for new draw commands
|
||||
virtual void canvas_item_set_default_texture_filter(RID p_item, CanvasItemTextureFilter p_filter) = 0;
|
||||
virtual void canvas_item_set_default_texture_repeat(RID p_item, CanvasItemTextureRepeat p_repeat) = 0;
|
||||
|
||||
virtual void canvas_item_add_line(RID p_item, const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width = 1.0, bool p_antialiased = false) = 0;
|
||||
virtual void canvas_item_add_polyline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width = 1.0, bool p_antialiased = false) = 0;
|
||||
virtual void canvas_item_add_multiline(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width = 1.0, bool p_antialiased = false) = 0;
|
||||
virtual void canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color) = 0;
|
||||
virtual void canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color) = 0;
|
||||
virtual void canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID()) = 0;
|
||||
virtual void canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), bool p_clip_uv = false) = 0;
|
||||
virtual void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, NinePatchAxisMode p_x_axis_mode = NINE_PATCH_STRETCH, NinePatchAxisMode p_y_axis_mode = NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID()) = 0;
|
||||
virtual void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID()) = 0;
|
||||
virtual void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), bool p_antialiased = false) = 0;
|
||||
virtual void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID(), bool p_antialiased = false, bool p_antialiasing_use_indices = false) = 0;
|
||||
virtual void canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1), RID p_texture = RID(), RID p_normal_map = RID()) = 0;
|
||||
virtual void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture = RID(), RID p_normal_map = RID()) = 0;
|
||||
virtual void canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal_map) = 0;
|
||||
virtual void canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), CanvasItemTextureFilter p_texture_filter = CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, CanvasItemTextureRepeat = CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) = 0;
|
||||
virtual void canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), bool p_clip_uv = false, CanvasItemTextureFilter p_texture_filter = CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, CanvasItemTextureRepeat = CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) = 0;
|
||||
virtual void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, NinePatchAxisMode p_x_axis_mode = NINE_PATCH_STRETCH, NinePatchAxisMode p_y_axis_mode = NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), CanvasItemTextureFilter p_texture_filter = CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, CanvasItemTextureRepeat = CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) = 0;
|
||||
virtual void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), CanvasItemTextureFilter p_texture_filter = CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, CanvasItemTextureRepeat = CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) = 0;
|
||||
virtual void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), bool p_antialiased = false, CanvasItemTextureFilter p_texture_filter = CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, CanvasItemTextureRepeat = CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) = 0;
|
||||
virtual void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), const Vector<int> &p_bones = Vector<int>(), const Vector<float> &p_weights = Vector<float>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), bool p_antialiased = false, CanvasItemTextureFilter p_texture_filter = CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, CanvasItemTextureRepeat = CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) = 0;
|
||||
virtual void canvas_item_add_mesh(RID p_item, const RID &p_mesh, const Transform2D &p_transform = Transform2D(), const Color &p_modulate = Color(1, 1, 1), RID p_texture = RID(), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), CanvasItemTextureFilter p_texture_filter = CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, CanvasItemTextureRepeat = CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) = 0;
|
||||
virtual void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_texture = RID(), RID p_normal_map = RID(), RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), CanvasItemTextureFilter p_texture_filter = CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, CanvasItemTextureRepeat = CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) = 0;
|
||||
virtual void canvas_item_add_particles(RID p_item, RID p_particles, RID p_texture, RID p_normal_map, RID p_specular_map = RID(), const Color &p_specular_color_shininess = Color(), CanvasItemTextureFilter p_texture_filter = CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, CanvasItemTextureRepeat = CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) = 0;
|
||||
virtual void canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform) = 0;
|
||||
virtual void canvas_item_add_clip_ignore(RID p_item, bool p_ignore) = 0;
|
||||
virtual void canvas_item_set_sort_children_by_y(RID p_item, bool p_enable) = 0;
|
||||
|
@ -1088,6 +1105,8 @@ VARIANT_ENUM_CAST(VisualServer::EnvironmentSSAOQuality);
|
|||
VARIANT_ENUM_CAST(VisualServer::EnvironmentSSAOBlur);
|
||||
VARIANT_ENUM_CAST(VisualServer::InstanceFlags);
|
||||
VARIANT_ENUM_CAST(VisualServer::ShadowCastingSetting);
|
||||
VARIANT_ENUM_CAST(VisualServer::CanvasItemTextureFilter);
|
||||
VARIANT_ENUM_CAST(VisualServer::CanvasItemTextureRepeat);
|
||||
|
||||
//typedef VisualServer VS; // makes it easier to use
|
||||
#define VS VisualServer
|
||||
|
|
Loading…
Reference in New Issue