mirror of
https://github.com/godotengine/godot.git
synced 2024-12-27 21:34:53 +00:00
Add normalmap support for drawing in all low level primitives. Only added support in Sprite so far.
This commit is contained in:
parent
f41cc5b590
commit
5c6cac4e53
@ -207,6 +207,26 @@ class CommandQueueMT {
|
||||
virtual void call() { (instance->*method)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); }
|
||||
};
|
||||
|
||||
template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11>
|
||||
struct Command11 : public CommandBase {
|
||||
|
||||
T *instance;
|
||||
M method;
|
||||
typename GetSimpleTypeT<P1>::type_t p1;
|
||||
typename GetSimpleTypeT<P2>::type_t p2;
|
||||
typename GetSimpleTypeT<P3>::type_t p3;
|
||||
typename GetSimpleTypeT<P4>::type_t p4;
|
||||
typename GetSimpleTypeT<P5>::type_t p5;
|
||||
typename GetSimpleTypeT<P6>::type_t p6;
|
||||
typename GetSimpleTypeT<P7>::type_t p7;
|
||||
typename GetSimpleTypeT<P8>::type_t p8;
|
||||
typename GetSimpleTypeT<P9>::type_t p9;
|
||||
typename GetSimpleTypeT<P10>::type_t p10;
|
||||
typename GetSimpleTypeT<P11>::type_t p11;
|
||||
|
||||
virtual void call() { (instance->*method)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); }
|
||||
};
|
||||
|
||||
/* comands that return */
|
||||
|
||||
template <class T, class M, class R>
|
||||
@ -862,6 +882,30 @@ public:
|
||||
if (sync) sync->post();
|
||||
}
|
||||
|
||||
template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10, class P11>
|
||||
void push(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10, P11 p11) {
|
||||
|
||||
Command11<T, M, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11> *cmd = allocate_and_lock<Command11<T, M, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11> >();
|
||||
|
||||
cmd->instance = p_instance;
|
||||
cmd->method = p_method;
|
||||
cmd->p1 = p1;
|
||||
cmd->p2 = p2;
|
||||
cmd->p3 = p3;
|
||||
cmd->p4 = p4;
|
||||
cmd->p5 = p5;
|
||||
cmd->p6 = p6;
|
||||
cmd->p7 = p7;
|
||||
cmd->p8 = p8;
|
||||
cmd->p9 = p9;
|
||||
cmd->p10 = p10;
|
||||
cmd->p11 = p11;
|
||||
|
||||
unlock();
|
||||
|
||||
if (sync) sync->post();
|
||||
}
|
||||
|
||||
/*** PUSH AND RET COMMANDS ***/
|
||||
|
||||
template <class T, class M, class R>
|
||||
|
@ -30,10 +30,8 @@ uniform highp mat4 light_local_matrix;
|
||||
uniform vec2 light_pos;
|
||||
varying vec4 light_uv_interp;
|
||||
|
||||
#if defined(NORMAL_USED)
|
||||
varying vec4 local_rot;
|
||||
uniform vec2 normal_flip;
|
||||
#endif
|
||||
|
||||
#ifdef USE_SHADOWS
|
||||
varying highp vec2 pos;
|
||||
@ -86,10 +84,8 @@ VERTEX_SHADER_CODE
|
||||
pos=outvec.xy;
|
||||
#endif
|
||||
|
||||
#if defined(NORMAL_USED)
|
||||
local_rot.xy=normalize( (modelview_matrix * ( extra_matrix * vec4(1.0,0.0,0.0,0.0) )).xy )*normal_flip.x;
|
||||
local_rot.zw=normalize( (modelview_matrix * ( extra_matrix * vec4(0.0,1.0,0.0,0.0) )).xy )*normal_flip.y;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@ -107,6 +103,7 @@ precision mediump int;
|
||||
|
||||
|
||||
uniform sampler2D texture; // texunit:0
|
||||
uniform sampler2D normal_texture; // texunit:0
|
||||
|
||||
varying vec2 uv_interp;
|
||||
varying vec4 color_interp;
|
||||
@ -157,9 +154,7 @@ uniform float light_height;
|
||||
varying vec4 light_uv_interp;
|
||||
uniform float light_outside_alpha;
|
||||
|
||||
#if defined(NORMAL_USED)
|
||||
varying vec4 local_rot;
|
||||
#endif
|
||||
|
||||
#ifdef USE_SHADOWS
|
||||
|
||||
@ -189,19 +184,19 @@ FRAGMENT_SHADER_GLOBALS
|
||||
void main() {
|
||||
|
||||
vec4 color = color_interp;
|
||||
#if defined(NORMAL_USED)
|
||||
vec3 normal = vec3(0.0,0.0,1.0);
|
||||
#endif
|
||||
|
||||
#ifdef USE_DISTANCE_FIELD
|
||||
const float smoothing = 1.0/32.0;
|
||||
float distance = texture2D(texture, uv_interp).a;
|
||||
float distance = textureLod(texture, uv_interp,0.0).a;
|
||||
color.a = smoothstep(0.5 - smoothing, 0.5 + smoothing, distance) * color.a;
|
||||
#else
|
||||
color *= texture2D( texture, uv_interp );
|
||||
|
||||
#endif
|
||||
|
||||
vec3 normal;
|
||||
normal.xy = textureLod( normal_texture, uv_interp, 0.0 ).xy * 2.0 - 1.0;
|
||||
normal.z = sqrt(1.0-dot(normal.xy,normal.xy));
|
||||
|
||||
#if defined(ENABLE_SCREEN_UV)
|
||||
vec2 screen_uv = gl_FragCoord.xy*screen_uv_mult;
|
||||
@ -236,9 +231,7 @@ FRAGMENT_SHADER_CODE
|
||||
|
||||
vec2 light_vec = light_uv_interp.zw;; //for shadow and normal mapping
|
||||
|
||||
#if defined(NORMAL_USED)
|
||||
normal.xy = mat2(local_rot.xy,local_rot.zw) * normal.xy;
|
||||
#endif
|
||||
|
||||
float att=1.0;
|
||||
|
||||
@ -263,10 +256,8 @@ LIGHT_SHADER_CODE
|
||||
|
||||
#else
|
||||
|
||||
#if defined(NORMAL_USED)
|
||||
vec3 light_normal = normalize(vec3(light_vec,-light_height));
|
||||
light*=max(dot(-light_normal,normal),0.0);
|
||||
#endif
|
||||
|
||||
color*=light;
|
||||
/*
|
||||
|
@ -188,40 +188,74 @@ void RasterizerCanvasGLES3::canvas_end() {
|
||||
state.using_texture_rect = false;
|
||||
}
|
||||
|
||||
RasterizerStorageGLES3::Texture *RasterizerCanvasGLES3::_bind_canvas_texture(const RID &p_texture) {
|
||||
RasterizerStorageGLES3::Texture *RasterizerCanvasGLES3::_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map) {
|
||||
|
||||
RasterizerStorageGLES3::Texture *tex_return = NULL;
|
||||
|
||||
if (p_texture == state.current_tex) {
|
||||
return state.current_tex_ptr;
|
||||
}
|
||||
|
||||
if (p_texture.is_valid()) {
|
||||
tex_return = state.current_tex_ptr;
|
||||
} else if (p_texture.is_valid()) {
|
||||
|
||||
RasterizerStorageGLES3::Texture *texture = storage->texture_owner.getornull(p_texture);
|
||||
|
||||
if (!texture) {
|
||||
state.current_tex = RID();
|
||||
state.current_tex_ptr = NULL;
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, storage->resources.white_tex);
|
||||
return NULL;
|
||||
|
||||
} else {
|
||||
|
||||
if (texture->render_target)
|
||||
texture->render_target->used_in_frame = true;
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, texture->tex_id);
|
||||
state.current_tex = p_texture;
|
||||
state.current_tex_ptr = texture;
|
||||
|
||||
tex_return = texture;
|
||||
}
|
||||
|
||||
if (texture->render_target)
|
||||
texture->render_target->used_in_frame = true;
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texture->tex_id);
|
||||
state.current_tex = p_texture;
|
||||
state.current_tex_ptr = texture;
|
||||
|
||||
return texture;
|
||||
|
||||
} else {
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, storage->resources.white_tex);
|
||||
state.current_tex = RID();
|
||||
state.current_tex_ptr = NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
if (p_normal_map == state.current_normal) {
|
||||
//do none
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES3::USE_DEFAULT_NORMAL, state.current_normal.is_valid());
|
||||
|
||||
} else if (p_normal_map.is_valid()) {
|
||||
|
||||
RasterizerStorageGLES3::Texture *normal_map = storage->texture_owner.getornull(p_normal_map);
|
||||
|
||||
if (!normal_map) {
|
||||
state.current_normal = RID();
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, storage->resources.normal_tex);
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES3::USE_DEFAULT_NORMAL, false);
|
||||
|
||||
} else {
|
||||
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, normal_map->tex_id);
|
||||
state.current_normal = p_normal_map;
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES3::USE_DEFAULT_NORMAL, true);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
state.current_normal = RID();
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, storage->resources.normal_tex);
|
||||
state.canvas_shader.set_uniform(CanvasShaderGLES3::USE_DEFAULT_NORMAL, false);
|
||||
}
|
||||
|
||||
return tex_return;
|
||||
}
|
||||
|
||||
void RasterizerCanvasGLES3::_set_texture_rect_mode(bool p_enable) {
|
||||
@ -372,7 +406,7 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
|
||||
Item::CommandLine *line = static_cast<Item::CommandLine *>(c);
|
||||
_set_texture_rect_mode(false);
|
||||
|
||||
_bind_canvas_texture(RID());
|
||||
_bind_canvas_texture(RID(), RID());
|
||||
|
||||
glVertexAttrib4f(VS::ARRAY_COLOR, line->color.r, line->color.g, line->color.b, line->color.a);
|
||||
|
||||
@ -403,7 +437,7 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
|
||||
//set color
|
||||
glVertexAttrib4f(VS::ARRAY_COLOR, rect->modulate.r, rect->modulate.g, rect->modulate.b, rect->modulate.a);
|
||||
|
||||
RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(rect->texture);
|
||||
RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(rect->texture, rect->normal_map);
|
||||
|
||||
if (texture) {
|
||||
|
||||
@ -460,7 +494,7 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
|
||||
|
||||
glVertexAttrib4f(VS::ARRAY_COLOR, np->color.r, np->color.g, np->color.b, np->color.a);
|
||||
|
||||
RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(np->texture);
|
||||
RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(np->texture, np->normal_map);
|
||||
|
||||
if (!texture) {
|
||||
|
||||
@ -538,7 +572,7 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
|
||||
|
||||
ERR_CONTINUE(primitive->points.size() < 1);
|
||||
|
||||
RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(primitive->texture);
|
||||
RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(primitive->texture, primitive->normal_map);
|
||||
|
||||
if (texture) {
|
||||
Size2 texpixel_size(1.0 / texture->width, 1.0 / texture->height);
|
||||
@ -561,7 +595,7 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
|
||||
Item::CommandPolygon *polygon = static_cast<Item::CommandPolygon *>(c);
|
||||
_set_texture_rect_mode(false);
|
||||
|
||||
RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(polygon->texture);
|
||||
RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(polygon->texture, polygon->normal_map);
|
||||
|
||||
if (texture) {
|
||||
Size2 texpixel_size(1.0 / texture->width, 1.0 / texture->height);
|
||||
@ -588,6 +622,7 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
|
||||
indices[i * 3 + 2] = numpoints;
|
||||
}
|
||||
|
||||
_bind_canvas_texture(RID(), RID());
|
||||
_draw_polygon(indices, numpoints * 3, numpoints + 1, points, NULL, &circle->color, true);
|
||||
|
||||
//_draw_polygon(numpoints*3,indices,points,NULL,&circle->color,RID(),true);
|
||||
@ -705,6 +740,7 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons
|
||||
|
||||
state.current_tex = RID();
|
||||
state.current_tex_ptr = NULL;
|
||||
state.current_normal = RID();
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, storage->resources.white_tex);
|
||||
|
||||
@ -812,7 +848,7 @@ void RasterizerCanvasGLES3::canvas_render_items(Item *p_item_list, int p_z, cons
|
||||
|
||||
for (int i = 0; i < tc; i++) {
|
||||
|
||||
glActiveTexture(GL_TEXTURE1 + i);
|
||||
glActiveTexture(GL_TEXTURE2 + i);
|
||||
|
||||
RasterizerStorageGLES3::Texture *t = storage->texture_owner.getornull(textures[i]);
|
||||
if (!t) {
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
bool using_texture_rect;
|
||||
|
||||
RID current_tex;
|
||||
RID current_normal;
|
||||
RasterizerStorageGLES3::Texture *current_tex_ptr;
|
||||
|
||||
Transform vp;
|
||||
@ -107,7 +108,7 @@ public:
|
||||
virtual void canvas_end();
|
||||
|
||||
_FORCE_INLINE_ void _set_texture_rect_mode(bool p_enable);
|
||||
_FORCE_INLINE_ RasterizerStorageGLES3::Texture *_bind_canvas_texture(const RID &p_texture);
|
||||
_FORCE_INLINE_ RasterizerStorageGLES3::Texture *_bind_canvas_texture(const RID &p_texture, const RID &p_normal_map);
|
||||
|
||||
_FORCE_INLINE_ void _draw_gui_primitive(int p_points, const Vector2 *p_vertices, const Color *p_colors, const Vector2 *p_uvs);
|
||||
_FORCE_INLINE_ void _draw_polygon(const int *p_indices, int p_index_count, int p_vertex_count, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, bool p_singlecolor);
|
||||
|
@ -51,9 +51,9 @@ layout(std140) uniform LightData { //ubo:1
|
||||
|
||||
out vec4 light_uv_interp;
|
||||
|
||||
#if defined(NORMAL_USED)
|
||||
|
||||
out vec4 local_rot;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef USE_SHADOWS
|
||||
out highp vec2 pos;
|
||||
@ -124,7 +124,7 @@ VERTEX_SHADER_CODE
|
||||
pos=outvec.xy;
|
||||
#endif
|
||||
|
||||
#if defined(NORMAL_USED)
|
||||
|
||||
local_rot.xy=normalize( (modelview_matrix * ( extra_matrix * vec4(1.0,0.0,0.0,0.0) )).xy );
|
||||
local_rot.zw=normalize( (modelview_matrix * ( extra_matrix * vec4(0.0,1.0,0.0,0.0) )).xy );
|
||||
#ifdef USE_TEXTURE_RECT
|
||||
@ -132,7 +132,7 @@ VERTEX_SHADER_CODE
|
||||
local_rot.zw*=sign(src_rect.w);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -144,6 +144,7 @@ VERTEX_SHADER_CODE
|
||||
|
||||
uniform mediump sampler2D color_texture; // texunit:0
|
||||
uniform highp vec2 color_texpixel_size;
|
||||
uniform mediump sampler2D normal_texture; // texunit:1
|
||||
|
||||
in mediump vec2 uv_interp;
|
||||
in mediump vec4 color_interp;
|
||||
@ -183,9 +184,8 @@ uniform lowp sampler2D light_texture; // texunit:-1
|
||||
in vec4 light_uv_interp;
|
||||
|
||||
|
||||
#if defined(NORMAL_USED)
|
||||
in vec4 local_rot;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef USE_SHADOWS
|
||||
|
||||
@ -228,20 +228,19 @@ LIGHT_SHADER_CODE
|
||||
|
||||
}
|
||||
|
||||
uniform bool use_default_normal;
|
||||
|
||||
void main() {
|
||||
|
||||
vec4 color = color_interp;
|
||||
#if defined(NORMAL_USED)
|
||||
vec3 normal = vec3(0.0,0.0,1.0);
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(COLOR_USED)
|
||||
//default behavior, texture by color
|
||||
|
||||
#ifdef USE_DISTANCE_FIELD
|
||||
const float smoothing = 1.0/32.0;
|
||||
float distance = texture(color_texture, uv_interp).a;
|
||||
float distance = textureLod(color_texture, uv_interp,0.0).a;
|
||||
color.a = smoothstep(0.5 - smoothing, 0.5 + smoothing, distance) * color.a;
|
||||
#else
|
||||
color *= texture( color_texture, uv_interp );
|
||||
@ -250,6 +249,25 @@ void main() {
|
||||
|
||||
#endif
|
||||
|
||||
vec3 normal;
|
||||
|
||||
#if defined(NORMAL_USED)
|
||||
|
||||
bool normal_used = true;
|
||||
#else
|
||||
bool normal_used = false;
|
||||
#endif
|
||||
|
||||
if (use_default_normal) {
|
||||
normal.xy = textureLod(normal_texture, uv_interp,0.0).xy * 2.0 - 1.0;
|
||||
normal.z = sqrt(1.0-dot(normal.xy,normal.xy));
|
||||
normal_used=true;
|
||||
} else {
|
||||
normal = vec3(0.0,0.0,1.0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if defined(ENABLE_SCREEN_UV)
|
||||
vec2 screen_uv = gl_FragCoord.xy*screen_uv_mult;
|
||||
#endif
|
||||
@ -284,9 +302,9 @@ FRAGMENT_SHADER_CODE
|
||||
|
||||
vec2 light_vec = light_uv_interp.zw;; //for shadow and normal mapping
|
||||
|
||||
#if defined(NORMAL_USED)
|
||||
normal.xy = mat2(local_rot.xy,local_rot.zw) * normal.xy;
|
||||
#endif
|
||||
if (normal_used) {
|
||||
normal.xy = mat2(local_rot.xy,local_rot.zw) * normal.xy;
|
||||
}
|
||||
|
||||
float att=1.0;
|
||||
|
||||
@ -307,10 +325,11 @@ FRAGMENT_SHADER_CODE
|
||||
|
||||
#else
|
||||
|
||||
#if defined(NORMAL_USED)
|
||||
vec3 light_normal = normalize(vec3(light_vec,-light_height));
|
||||
light*=max(dot(-light_normal,normal),0.0);
|
||||
#endif
|
||||
if (normal_used) {
|
||||
|
||||
vec3 light_normal = normalize(vec3(light_vec,-light_height));
|
||||
light*=max(dot(-light_normal,normal),0.0);
|
||||
}
|
||||
|
||||
color*=light;
|
||||
/*
|
||||
|
@ -28,6 +28,7 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#include "canvas_item.h"
|
||||
#include "core/method_bind_ext.inc"
|
||||
#include "message_queue.h"
|
||||
#include "os/input.h"
|
||||
#include "scene/main/canvas_layer.h"
|
||||
@ -436,7 +437,7 @@ 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<Texture> &p_texture, const Point2 &p_pos, const Color &p_modulate) {
|
||||
void CanvasItem::draw_texture(const Ref<Texture> &p_texture, const Point2 &p_pos, const Color &p_modulate, const Ref<Texture> &p_normal_map) {
|
||||
|
||||
if (!drawing) {
|
||||
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
|
||||
@ -448,7 +449,7 @@ void CanvasItem::draw_texture(const Ref<Texture> &p_texture, const Point2 &p_pos
|
||||
p_texture->draw(canvas_item, p_pos, p_modulate);
|
||||
}
|
||||
|
||||
void CanvasItem::draw_texture_rect(const Ref<Texture> &p_texture, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose) {
|
||||
void CanvasItem::draw_texture_rect(const Ref<Texture> &p_texture, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) {
|
||||
|
||||
if (!drawing) {
|
||||
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
|
||||
@ -456,16 +457,16 @@ void CanvasItem::draw_texture_rect(const Ref<Texture> &p_texture, const Rect2 &p
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(p_texture.is_null());
|
||||
p_texture->draw_rect(canvas_item, p_rect, p_tile, p_modulate, p_transpose);
|
||||
p_texture->draw_rect(canvas_item, p_rect, p_tile, p_modulate, p_transpose, p_normal_map);
|
||||
}
|
||||
void CanvasItem::draw_texture_rect_region(const Ref<Texture> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose) {
|
||||
void CanvasItem::draw_texture_rect_region(const Ref<Texture> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) {
|
||||
|
||||
if (!drawing) {
|
||||
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
|
||||
ERR_FAIL();
|
||||
}
|
||||
ERR_FAIL_COND(p_texture.is_null());
|
||||
p_texture->draw_rect_region(canvas_item, p_rect, p_src_rect, p_modulate, p_transpose);
|
||||
p_texture->draw_rect_region(canvas_item, p_rect, p_src_rect, p_modulate, p_transpose, p_normal_map);
|
||||
}
|
||||
|
||||
void CanvasItem::draw_style_box(const Ref<StyleBox> &p_style_box, const Rect2 &p_rect) {
|
||||
@ -478,7 +479,7 @@ 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<Texture> p_texture, float p_width) {
|
||||
void CanvasItem::draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture> p_texture, float p_width, const Ref<Texture> &p_normal_map) {
|
||||
|
||||
if (!drawing) {
|
||||
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
|
||||
@ -486,8 +487,9 @@ void CanvasItem::draw_primitive(const Vector<Point2> &p_points, const Vector<Col
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
VisualServer::get_singleton()->canvas_item_add_primitive(canvas_item, p_points, p_colors, p_uvs, rid, p_width);
|
||||
VisualServer::get_singleton()->canvas_item_add_primitive(canvas_item, p_points, p_colors, p_uvs, rid, p_width, rid_normal);
|
||||
}
|
||||
void CanvasItem::draw_set_transform(const Point2 &p_offset, float p_rot, const Size2 &p_scale) {
|
||||
|
||||
@ -511,7 +513,7 @@ 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<Texture> p_texture) {
|
||||
void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture> p_texture, const Ref<Texture> &p_normal_map) {
|
||||
|
||||
if (!drawing) {
|
||||
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
|
||||
@ -519,11 +521,12 @@ void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<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();
|
||||
|
||||
VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, p_colors, p_uvs, rid);
|
||||
VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, p_colors, p_uvs, rid, rid_normal);
|
||||
}
|
||||
|
||||
void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs, Ref<Texture> p_texture) {
|
||||
void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs, Ref<Texture> p_texture, const Ref<Texture> &p_normal_map) {
|
||||
|
||||
if (!drawing) {
|
||||
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
|
||||
@ -533,8 +536,9 @@ void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Colo
|
||||
Vector<Color> colors;
|
||||
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();
|
||||
|
||||
VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, colors, p_uvs, rid);
|
||||
VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, colors, p_uvs, rid, rid_normal);
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -752,13 +756,13 @@ void CanvasItem::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("draw_line", "from", "to", "color", "width", "antialiased"), &CanvasItem::draw_line, DEFVAL(1.0), DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("draw_rect", "rect", "color"), &CanvasItem::draw_rect);
|
||||
ClassDB::bind_method(D_METHOD("draw_circle", "pos", "radius", "color"), &CanvasItem::draw_circle);
|
||||
ClassDB::bind_method(D_METHOD("draw_texture", "texture:Texture", "pos", "modulate"), &CanvasItem::draw_texture, DEFVAL(Color(1, 1, 1, 1)));
|
||||
ClassDB::bind_method(D_METHOD("draw_texture_rect", "texture:Texture", "rect", "tile", "modulate", "transpose"), &CanvasItem::draw_texture_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("draw_texture_rect_region", "texture:Texture", "rect", "src_rect", "modulate", "transpose"), &CanvasItem::draw_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("draw_texture", "texture:Texture", "pos", "modulate", "normal_map:Texture"), &CanvasItem::draw_texture, DEFVAL(Color(1, 1, 1, 1)), DEFVAL(Variant()));
|
||||
ClassDB::bind_method(D_METHOD("draw_texture_rect", "texture:Texture", "rect", "tile", "modulate", "transpose", "normal_map:Texture"), &CanvasItem::draw_texture_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()));
|
||||
ClassDB::bind_method(D_METHOD("draw_texture_rect_region", "texture:Texture", "rect", "src_rect", "modulate", "transpose", "normal_map:Texture"), &CanvasItem::draw_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()));
|
||||
ClassDB::bind_method(D_METHOD("draw_style_box", "style_box:StyleBox", "rect"), &CanvasItem::draw_style_box);
|
||||
ClassDB::bind_method(D_METHOD("draw_primitive", "points", "colors", "uvs", "texture:Texture", "width"), &CanvasItem::draw_primitive, DEFVAL(Variant()), DEFVAL(1.0));
|
||||
ClassDB::bind_method(D_METHOD("draw_polygon", "points", "colors", "uvs", "texture:Texture"), &CanvasItem::draw_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()));
|
||||
ClassDB::bind_method(D_METHOD("draw_colored_polygon", "points", "color", "uvs", "texture:Texture"), &CanvasItem::draw_colored_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()));
|
||||
ClassDB::bind_method(D_METHOD("draw_primitive", "points", "colors", "uvs", "texture:Texture", "width", "normal_map:Texture"), &CanvasItem::draw_primitive, DEFVAL(Variant()), DEFVAL(1.0), DEFVAL(Variant()));
|
||||
ClassDB::bind_method(D_METHOD("draw_polygon", "points", "colors", "uvs", "texture:Texture", "normal_map:Texture"), &CanvasItem::draw_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()));
|
||||
ClassDB::bind_method(D_METHOD("draw_colored_polygon", "points", "color", "uvs", "texture:Texture", "normal_map:Texture"), &CanvasItem::draw_colored_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()));
|
||||
ClassDB::bind_method(D_METHOD("draw_string", "font:Font", "pos", "text", "modulate", "clip_w"), &CanvasItem::draw_string, DEFVAL(Color(1, 1, 1)), DEFVAL(-1));
|
||||
ClassDB::bind_method(D_METHOD("draw_char", "font:Font", "pos", "char", "next", "modulate"), &CanvasItem::draw_char, DEFVAL(Color(1, 1, 1)));
|
||||
|
||||
|
@ -158,13 +158,13 @@ public:
|
||||
void draw_line(const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width = 1.0, bool p_antialiased = false);
|
||||
void draw_rect(const Rect2 &p_rect, const Color &p_color);
|
||||
void draw_circle(const Point2 &p_pos, float p_radius, const Color &p_color);
|
||||
void draw_texture(const Ref<Texture> &p_texture, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1, 1));
|
||||
void draw_texture_rect(const Ref<Texture> &p_texture, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false);
|
||||
void draw_texture_rect_region(const Ref<Texture> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false);
|
||||
void draw_texture(const Ref<Texture> &p_texture, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1, 1), const Ref<Texture> &p_normal_map = Ref<Texture>());
|
||||
void draw_texture_rect(const Ref<Texture> &p_texture, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>());
|
||||
void draw_texture_rect_region(const Ref<Texture> &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<Texture> &p_normal_map = Ref<Texture>());
|
||||
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<Texture> p_texture = Ref<Texture>(), float p_width = 1);
|
||||
void draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>());
|
||||
void draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>());
|
||||
void draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture> p_texture = Ref<Texture>(), float p_width = 1, const Ref<Texture> &p_normal_map = Ref<Texture>());
|
||||
void draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>(), const Ref<Texture> &p_normal_map = Ref<Texture>());
|
||||
void draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>(), const Ref<Texture> &p_normal_map = Ref<Texture>());
|
||||
|
||||
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));
|
||||
|
@ -93,7 +93,7 @@ void Sprite::_notification(int p_what) {
|
||||
if (vflip)
|
||||
dst_rect.size.y = -dst_rect.size.y;
|
||||
|
||||
texture->draw_rect_region(ci, dst_rect, src_rect);
|
||||
texture->draw_rect_region(ci, dst_rect, src_rect, Color(1, 1, 1), false, normal_map);
|
||||
|
||||
} break;
|
||||
}
|
||||
@ -109,17 +109,30 @@ void Sprite::set_texture(const Ref<Texture> &p_texture) {
|
||||
}
|
||||
#endif
|
||||
texture = p_texture;
|
||||
/* this should no longer be needed in 3.0
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (texture.is_valid()) {
|
||||
texture->set_flags(texture->get_flags()); //remove repeat from texture, it looks bad in sprites
|
||||
texture->connect(CoreStringNames::get_singleton()->changed, this, SceneStringNames::get_singleton()->update);
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
update();
|
||||
emit_signal("texture_changed");
|
||||
item_rect_changed();
|
||||
}
|
||||
|
||||
void Sprite::set_normal_map(const Ref<Texture> &p_texture) {
|
||||
|
||||
normal_map = p_texture;
|
||||
update();
|
||||
}
|
||||
|
||||
Ref<Texture> Sprite::get_normal_map() const {
|
||||
|
||||
return normal_map;
|
||||
}
|
||||
|
||||
Ref<Texture> Sprite::get_texture() const {
|
||||
|
||||
return texture;
|
||||
@ -289,6 +302,9 @@ void Sprite::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_texture", "texture:Texture"), &Sprite::set_texture);
|
||||
ClassDB::bind_method(D_METHOD("get_texture:Texture"), &Sprite::get_texture);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_normal_map", "normal_map:Texture"), &Sprite::set_normal_map);
|
||||
ClassDB::bind_method(D_METHOD("get_normal_map:Texture"), &Sprite::get_normal_map);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_centered", "centered"), &Sprite::set_centered);
|
||||
ClassDB::bind_method(D_METHOD("is_centered"), &Sprite::is_centered);
|
||||
|
||||
@ -320,6 +336,7 @@ void Sprite::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("texture_changed"));
|
||||
|
||||
ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture");
|
||||
ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_normal_map", "get_normal_map");
|
||||
ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "centered"), "set_centered", "is_centered");
|
||||
ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset");
|
||||
ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "flip_h"), "set_flip_h", "is_flipped_h");
|
||||
|
@ -38,6 +38,7 @@ class Sprite : public Node2D {
|
||||
GDCLASS(Sprite, Node2D);
|
||||
|
||||
Ref<Texture> texture;
|
||||
Ref<Texture> normal_map;
|
||||
|
||||
bool centered;
|
||||
Point2 offset;
|
||||
@ -67,6 +68,9 @@ public:
|
||||
void set_texture(const Ref<Texture> &p_texture);
|
||||
Ref<Texture> get_texture() const;
|
||||
|
||||
void set_normal_map(const Ref<Texture> &p_texture);
|
||||
Ref<Texture> get_normal_map() const;
|
||||
|
||||
void set_centered(bool p_center);
|
||||
bool is_centered() const;
|
||||
|
||||
|
@ -28,25 +28,28 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#include "texture.h"
|
||||
#include "core/method_bind_ext.inc"
|
||||
#include "core/os/os.h"
|
||||
#include "io/image_loader.h"
|
||||
|
||||
Size2 Texture::get_size() const {
|
||||
|
||||
return Size2(get_width(), get_height());
|
||||
}
|
||||
|
||||
void Texture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose) const {
|
||||
void Texture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const {
|
||||
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, get_size()), get_rid(), false, p_modulate, p_transpose);
|
||||
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);
|
||||
}
|
||||
void Texture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose) const {
|
||||
void Texture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const {
|
||||
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, get_rid(), p_tile, p_modulate, p_transpose);
|
||||
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);
|
||||
}
|
||||
void Texture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose) const {
|
||||
void Texture::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<Texture> &p_normal_map) const {
|
||||
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, get_rid(), p_src_rect, p_modulate, p_transpose);
|
||||
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);
|
||||
}
|
||||
|
||||
bool Texture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
|
||||
@ -65,9 +68,9 @@ void Texture::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("has_alpha"), &Texture::has_alpha);
|
||||
ClassDB::bind_method(D_METHOD("set_flags", "flags"), &Texture::set_flags);
|
||||
ClassDB::bind_method(D_METHOD("get_flags"), &Texture::get_flags);
|
||||
ClassDB::bind_method(D_METHOD("draw", "canvas_item", "pos", "modulate", "transpose"), &Texture::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("draw_rect", "canvas_item", "rect", "tile", "modulate", "transpose"), &Texture::draw_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("draw_rect_region", "canvas_item", "rect", "src_rect", "modulate", "transpose"), &Texture::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("draw", "canvas_item", "pos", "modulate", "transpose", "normal_map:Texture"), &Texture::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:Texture"), &Texture::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:Texture"), &Texture::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()));
|
||||
|
||||
BIND_CONSTANT(FLAG_MIPMAPS);
|
||||
BIND_CONSTANT(FLAG_REPEAT);
|
||||
@ -265,23 +268,26 @@ 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 {
|
||||
void ImageTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const {
|
||||
|
||||
if ((w | h) == 0)
|
||||
return;
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose);
|
||||
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);
|
||||
}
|
||||
void ImageTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose) 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<Texture> &p_normal_map) const {
|
||||
|
||||
if ((w | h) == 0)
|
||||
return;
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose);
|
||||
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);
|
||||
}
|
||||
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 {
|
||||
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<Texture> &p_normal_map) const {
|
||||
|
||||
if ((w | h) == 0)
|
||||
return;
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose);
|
||||
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);
|
||||
}
|
||||
|
||||
void ImageTexture::set_size_override(const Size2 &p_size) {
|
||||
@ -665,23 +671,26 @@ 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 {
|
||||
void StreamTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const {
|
||||
|
||||
if ((w | h) == 0)
|
||||
return;
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose);
|
||||
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);
|
||||
}
|
||||
void StreamTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose) 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<Texture> &p_normal_map) const {
|
||||
|
||||
if ((w | h) == 0)
|
||||
return;
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose);
|
||||
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);
|
||||
}
|
||||
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 {
|
||||
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<Texture> &p_normal_map) const {
|
||||
|
||||
if ((w | h) == 0)
|
||||
return;
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose);
|
||||
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);
|
||||
}
|
||||
|
||||
bool StreamTexture::has_alpha() const {
|
||||
@ -863,7 +872,7 @@ void AtlasTexture::_bind_methods() {
|
||||
ADD_PROPERTY(PropertyInfo(Variant::RECT2, "margin"), "set_margin", "get_margin");
|
||||
}
|
||||
|
||||
void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose) const {
|
||||
void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const {
|
||||
|
||||
Rect2 rc = region;
|
||||
|
||||
@ -878,10 +887,11 @@ void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_m
|
||||
rc.size.height = atlas->get_height();
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose) 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<Texture> &p_normal_map) const {
|
||||
|
||||
Rect2 rc = region;
|
||||
|
||||
@ -899,9 +909,10 @@ void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile
|
||||
Vector2 scale = p_rect.size / (region.size + margin.size);
|
||||
Rect2 dr(p_rect.position + margin.position * scale, rc.size * scale);
|
||||
|
||||
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), rc, p_modulate, p_transpose);
|
||||
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);
|
||||
}
|
||||
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 {
|
||||
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<Texture> &p_normal_map) const {
|
||||
|
||||
//this might not necessarily work well if using a rect, needs to be fixed properly
|
||||
Rect2 rc = region;
|
||||
@ -929,7 +940,8 @@ void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, cons
|
||||
}
|
||||
Rect2 dr(p_rect.position + ofs * scale, src_c.size * scale);
|
||||
|
||||
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), src_c, p_modulate, p_transpose);
|
||||
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);
|
||||
}
|
||||
|
||||
bool AtlasTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
|
||||
@ -1094,16 +1106,16 @@ void LargeTexture::_bind_methods() {
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_data", "_get_data");
|
||||
}
|
||||
|
||||
void LargeTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose) const {
|
||||
void LargeTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) 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);
|
||||
pieces[i].texture->draw(p_canvas_item, pieces[i].offset + p_pos, p_modulate, p_transpose, p_normal_map);
|
||||
}
|
||||
}
|
||||
|
||||
void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose) 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<Texture> &p_normal_map) const {
|
||||
|
||||
//tiling not supported for this
|
||||
if (size.x == 0 || size.y == 0)
|
||||
@ -1111,13 +1123,14 @@ void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile
|
||||
|
||||
Size2 scale = p_rect.size / size;
|
||||
|
||||
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
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 {
|
||||
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<Texture> &p_normal_map) const {
|
||||
|
||||
//tiling not supported for this
|
||||
if (p_src_rect.size.x == 0 || p_src_rect.size.y == 0)
|
||||
@ -1125,6 +1138,7 @@ void LargeTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, cons
|
||||
|
||||
Size2 scale = p_rect.size / p_src_rect.size;
|
||||
|
||||
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
|
||||
for (int i = 0; i < pieces.size(); i++) {
|
||||
|
||||
// TODO
|
||||
@ -1136,7 +1150,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);
|
||||
pieces[i].texture->draw_rect_region(p_canvas_item, target, local, p_modulate, p_transpose, p_normal_map);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,9 +68,9 @@ public:
|
||||
virtual void set_flags(uint32_t p_flags) = 0;
|
||||
virtual uint32_t get_flags() 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;
|
||||
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;
|
||||
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;
|
||||
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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>()) 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>(); }
|
||||
@ -131,9 +131,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;
|
||||
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;
|
||||
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;
|
||||
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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>()) const;
|
||||
void set_storage(Storage p_storage);
|
||||
Storage get_storage() const;
|
||||
|
||||
@ -203,9 +203,9 @@ public:
|
||||
int get_height() const;
|
||||
virtual RID get_rid() 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;
|
||||
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;
|
||||
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;
|
||||
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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>()) const;
|
||||
|
||||
virtual bool has_alpha() const;
|
||||
virtual void set_flags(uint32_t p_flags);
|
||||
@ -257,9 +257,9 @@ public:
|
||||
void set_margin(const Rect2 &p_margin);
|
||||
Rect2 get_margin() 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;
|
||||
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;
|
||||
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;
|
||||
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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>()) const;
|
||||
virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const;
|
||||
|
||||
AtlasTexture();
|
||||
@ -305,9 +305,9 @@ public:
|
||||
Vector2 get_piece_offset(int p_idx) const;
|
||||
Ref<Texture> get_piece_texture(int p_idx) 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;
|
||||
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;
|
||||
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;
|
||||
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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>()) const;
|
||||
|
||||
LargeTexture();
|
||||
};
|
||||
|
@ -766,3 +766,12 @@
|
||||
server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define FUNC11(m_type, m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8, m_arg9, m_arg10, m_arg11) \
|
||||
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) { \
|
||||
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); \
|
||||
} else { \
|
||||
server_name->m_type(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \
|
||||
} \
|
||||
}
|
||||
|
@ -633,6 +633,7 @@ public:
|
||||
|
||||
Rect2 rect;
|
||||
RID texture;
|
||||
RID normal_map;
|
||||
Color modulate;
|
||||
Rect2 source;
|
||||
uint8_t flags;
|
||||
@ -648,6 +649,7 @@ public:
|
||||
Rect2 rect;
|
||||
Rect2 source;
|
||||
RID texture;
|
||||
RID normal_map;
|
||||
float margin[4];
|
||||
bool draw_center;
|
||||
Color color;
|
||||
@ -665,6 +667,7 @@ public:
|
||||
Vector<Point2> uvs;
|
||||
Vector<Color> colors;
|
||||
RID texture;
|
||||
RID normal_map;
|
||||
float width;
|
||||
|
||||
CommandPrimitive() {
|
||||
@ -680,6 +683,7 @@ public:
|
||||
Vector<Point2> uvs;
|
||||
Vector<Color> colors;
|
||||
RID texture;
|
||||
RID normal_map;
|
||||
int count;
|
||||
|
||||
CommandPolygon() {
|
||||
|
@ -425,7 +425,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) {
|
||||
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) {
|
||||
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
@ -456,11 +456,12 @@ void VisualServerCanvas::canvas_item_add_texture_rect(RID p_item, const Rect2 &p
|
||||
SWAP(rect->rect.size.x, rect->rect.size.y);
|
||||
}
|
||||
rect->texture = p_texture;
|
||||
rect->normal_map = p_normal_map;
|
||||
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) {
|
||||
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) {
|
||||
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
@ -470,6 +471,7 @@ void VisualServerCanvas::canvas_item_add_texture_rect_region(RID p_item, const R
|
||||
rect->modulate = p_modulate;
|
||||
rect->rect = p_rect;
|
||||
rect->texture = p_texture;
|
||||
rect->normal_map = p_normal_map;
|
||||
rect->source = p_src_rect;
|
||||
rect->flags = RasterizerCanvas::CANVAS_RECT_REGION;
|
||||
|
||||
@ -493,7 +495,7 @@ 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) {
|
||||
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) {
|
||||
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
@ -501,6 +503,7 @@ void VisualServerCanvas::canvas_item_add_nine_patch(RID p_item, const Rect2 &p_r
|
||||
Item::CommandNinePatch *style = memnew(Item::CommandNinePatch);
|
||||
ERR_FAIL_COND(!style);
|
||||
style->texture = p_texture;
|
||||
style->normal_map = p_normal_map;
|
||||
style->rect = p_rect;
|
||||
style->source = p_source;
|
||||
style->draw_center = p_draw_center;
|
||||
@ -515,7 +518,7 @@ 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) {
|
||||
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) {
|
||||
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
@ -523,6 +526,7 @@ void VisualServerCanvas::canvas_item_add_primitive(RID p_item, const Vector<Poin
|
||||
Item::CommandPrimitive *prim = memnew(Item::CommandPrimitive);
|
||||
ERR_FAIL_COND(!prim);
|
||||
prim->texture = p_texture;
|
||||
prim->normal_map = p_normal_map;
|
||||
prim->points = p_points;
|
||||
prim->uvs = p_uvs;
|
||||
prim->colors = p_colors;
|
||||
@ -532,7 +536,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) {
|
||||
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) {
|
||||
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
@ -555,6 +559,7 @@ 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->points = p_points;
|
||||
polygon->uvs = p_uvs;
|
||||
polygon->colors = p_colors;
|
||||
@ -565,7 +570,7 @@ void VisualServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2
|
||||
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, RID p_texture, int p_count) {
|
||||
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, RID p_texture, int p_count, RID p_normal_map) {
|
||||
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
@ -593,6 +598,7 @@ 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->points = p_points;
|
||||
polygon->uvs = p_uvs;
|
||||
polygon->colors = p_colors;
|
||||
|
@ -165,12 +165,12 @@ public:
|
||||
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_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);
|
||||
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);
|
||||
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));
|
||||
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);
|
||||
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());
|
||||
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>(), RID p_texture = RID(), int p_count = -1);
|
||||
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());
|
||||
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());
|
||||
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>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID());
|
||||
void canvas_item_add_mesh(RID p_item, const RID &p_mesh, RID p_skeleton = RID());
|
||||
void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_skeleton = RID());
|
||||
void canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform);
|
||||
|
@ -626,6 +626,8 @@ 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) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); }
|
||||
#define BIND10(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10) \
|
||||
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) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10); }
|
||||
#define BIND11(m_name, m_type1, m_type2, m_type3, m_type4, m_type5, m_type6, m_type7, m_type8, m_type9, m_type10, m_type11) \
|
||||
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) { DISPLAY_CHANGED BINDBASE->m_name(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11); }
|
||||
|
||||
//from now on, calls forwarded to this singleton
|
||||
#define BINDBASE VSG::storage
|
||||
@ -1039,12 +1041,12 @@ public:
|
||||
BIND6(canvas_item_add_line, RID, const Point2 &, const Point2 &, const Color &, float, bool)
|
||||
BIND3(canvas_item_add_rect, RID, const Rect2 &, const Color &)
|
||||
BIND4(canvas_item_add_circle, RID, const Point2 &, float, const Color &)
|
||||
BIND6(canvas_item_add_texture_rect, RID, const Rect2 &, RID, bool, const Color &, bool)
|
||||
BIND6(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool)
|
||||
BIND10(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &)
|
||||
BIND6(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, float)
|
||||
BIND5(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID)
|
||||
BIND7(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, int)
|
||||
BIND7(canvas_item_add_texture_rect, RID, const Rect2 &, RID, bool, const Color &, bool, RID)
|
||||
BIND7(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool, RID)
|
||||
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)
|
||||
BIND6(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID)
|
||||
BIND8(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, int, RID)
|
||||
BIND3(canvas_item_add_mesh, RID, const RID &, RID)
|
||||
BIND3(canvas_item_add_multimesh, RID, RID, RID)
|
||||
BIND2(canvas_item_add_set_transform, RID, const Transform2D &)
|
||||
|
@ -468,12 +468,12 @@ public:
|
||||
FUNC6(canvas_item_add_line, RID, const Point2 &, const Point2 &, const Color &, float, bool)
|
||||
FUNC3(canvas_item_add_rect, RID, const Rect2 &, const Color &)
|
||||
FUNC4(canvas_item_add_circle, RID, const Point2 &, float, const Color &)
|
||||
FUNC6(canvas_item_add_texture_rect, RID, const Rect2 &, RID, bool, const Color &, bool)
|
||||
FUNC6(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool)
|
||||
FUNC10(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &)
|
||||
FUNC6(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, float)
|
||||
FUNC5(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID)
|
||||
FUNC7(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, int)
|
||||
FUNC7(canvas_item_add_texture_rect, RID, const Rect2 &, RID, bool, const Color &, bool, RID)
|
||||
FUNC7(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool, RID)
|
||||
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)
|
||||
FUNC6(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID)
|
||||
FUNC8(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, int, RID)
|
||||
FUNC3(canvas_item_add_mesh, RID, const RID &, RID)
|
||||
FUNC3(canvas_item_add_multimesh, RID, RID, RID)
|
||||
FUNC2(canvas_item_add_set_transform, RID, const Transform2D &)
|
||||
|
@ -785,12 +785,12 @@ public:
|
||||
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_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) = 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) = 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)) = 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) = 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()) = 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>(), RID p_texture = RID(), int p_count = -1) = 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()) = 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()) = 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>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID()) = 0;
|
||||
virtual void canvas_item_add_mesh(RID p_item, const RID &p_mesh, RID p_skeleton = RID()) = 0;
|
||||
virtual void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_skeleton = RID()) = 0;
|
||||
virtual void canvas_item_add_set_transform(RID p_item, const Transform2D &p_transform) = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user