summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-04-03 01:43:37 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-04-03 01:43:37 -0300
commit9fa1698c7420bae2c6353bf300ce2cdb73434bf6 (patch)
tree7d67492203476b2599621ebe258987c94db79b88 /servers
parent42d41a3fbc79ff1014d3b65666d6f80240520c8c (diff)
Changes to Light
-=-=-=-=-=-=-=-= -Changed material unshaded property for an enum, which supports light-only shading -Added a "Mix" shading mode, useful for using lights as masks -Added energy parameter to Light2D
Diffstat (limited to 'servers')
-rw-r--r--servers/visual/rasterizer.h10
-rw-r--r--servers/visual/shader_language.cpp2
-rw-r--r--servers/visual/visual_server_raster.cpp17
-rw-r--r--servers/visual/visual_server_raster.h8
-rw-r--r--servers/visual/visual_server_wrap_mt.h7
-rw-r--r--servers/visual_server.h19
6 files changed, 47 insertions, 16 deletions
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index ebc210fe3d..62563a0771 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -577,6 +577,7 @@ public:
Color color;
Matrix32 xform;
float height;
+ float energy;
float scale;
int z_min;
int z_max;
@@ -584,7 +585,7 @@ public:
int layer_max;
int item_mask;
int item_shadow_mask;
- bool subtract;
+ VS::CanvasLightMode mode;
RID texture;
Vector2 texture_offset;
RID canvas;
@@ -616,8 +617,9 @@ public:
layer_max=0;
item_mask=1;
scale=1.0;
+ energy=1.0;
item_shadow_mask=-1;
- subtract=false;
+ mode=VS::CANVAS_LIGHT_MODE_ADD;
texture_cache=NULL;
next_ptr=NULL;
filter_next_ptr=NULL;
@@ -635,9 +637,9 @@ public:
Map<StringName,Variant> shader_param;
uint32_t shader_version;
Set<CanvasItem*> owners;
- bool unshaded;
+ VS::CanvasItemShadingMode shading_mode;
- CanvasItemMaterial() {unshaded=false; shader_version=0; }
+ CanvasItemMaterial() {shading_mode=VS::CANVAS_ITEM_SHADING_NORMAL; shader_version=0; }
};
struct CanvasItem {
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp
index af65a7a639..4ad8aa6c71 100644
--- a/servers/visual/shader_language.cpp
+++ b/servers/visual/shader_language.cpp
@@ -1171,7 +1171,9 @@ const ShaderLanguage::BuiltinsDef ShaderLanguage::ci_light_builtins_defs[]={
{ "LIGHT_VEC", TYPE_VEC2},
{ "LIGHT_HEIGHT", TYPE_FLOAT},
{ "LIGHT_COLOR", TYPE_VEC4},
+ { "LIGHT_UV", TYPE_VEC2},
{ "LIGHT", TYPE_VEC4},
+ { "SHADOW", TYPE_VEC4},
{ "POINT_COORD", TYPE_VEC2},
// { "SCREEN_POS", TYPE_VEC2},
// { "SCREEN_TEXEL_SIZE", TYPE_VEC2},
diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp
index 916316a0e2..7a9db4ba11 100644
--- a/servers/visual/visual_server_raster.cpp
+++ b/servers/visual/visual_server_raster.cpp
@@ -3977,6 +3977,15 @@ void VisualServerRaster::canvas_light_set_height(RID p_light, float p_height){
clight->height=p_height;
}
+
+void VisualServerRaster::canvas_light_set_energy(RID p_light, float p_energy){
+
+ Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light);
+ ERR_FAIL_COND(!clight);
+ clight->energy=p_energy;
+
+}
+
void VisualServerRaster::canvas_light_set_z_range(RID p_light, int p_min_z,int p_max_z){
Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light);
@@ -4012,12 +4021,12 @@ void VisualServerRaster::canvas_light_set_item_shadow_mask(RID p_light, int p_ma
}
-void VisualServerRaster::canvas_light_set_subtract_mode(RID p_light, bool p_enable) {
+void VisualServerRaster::canvas_light_set_mode(RID p_light, CanvasLightMode p_mode) {
Rasterizer::CanvasLight *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
- clight->subtract=p_enable;
+ clight->mode=p_mode;
}
void VisualServerRaster::canvas_light_set_shadow_enabled(RID p_light, bool p_enabled){
@@ -4267,12 +4276,12 @@ Variant VisualServerRaster::canvas_item_material_get_shader_param(RID p_material
return material->shader_param[p_param];
}
-void VisualServerRaster::canvas_item_material_set_unshaded(RID p_material, bool p_unshaded){
+void VisualServerRaster::canvas_item_material_set_shading_mode(RID p_material, CanvasItemShadingMode p_mode) {
VS_CHANGED;
Rasterizer::CanvasItemMaterial *material = canvas_item_material_owner.get( p_material );
ERR_FAIL_COND(!material);
- material->unshaded=p_unshaded;
+ material->shading_mode=p_mode;
}
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index 72af793278..a89a685e30 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -1170,12 +1170,13 @@ public:
virtual void canvas_light_set_texture_offset(RID p_light, const Vector2& p_offset);
virtual void canvas_light_set_color(RID p_light, const Color& p_color);
virtual void canvas_light_set_height(RID p_light, float p_height);
+ virtual void canvas_light_set_energy(RID p_light, float p_energy);
virtual void canvas_light_set_z_range(RID p_light, int p_min_z,int p_max_z);
virtual void canvas_light_set_layer_range(RID p_light, int p_min_layer,int p_max_layer);
virtual void canvas_light_set_item_mask(RID p_light, int p_mask);
virtual void canvas_light_set_item_shadow_mask(RID p_light, int p_mask);
- virtual void canvas_light_set_subtract_mode(RID p_light, bool p_enable);
+ virtual void canvas_light_set_mode(RID p_light, CanvasLightMode p_mode);
virtual void canvas_light_set_shadow_enabled(RID p_light, bool p_enabled);
virtual void canvas_light_set_shadow_buffer_size(RID p_light, int p_size);
virtual void canvas_light_set_shadow_esm_multiplier(RID p_light, float p_multiplier);
@@ -1204,8 +1205,9 @@ public:
virtual RID canvas_item_material_create();
virtual void canvas_item_material_set_shader(RID p_material, RID p_shader);
virtual void canvas_item_material_set_shader_param(RID p_material, const StringName& p_param, const Variant& p_value);
- virtual Variant canvas_item_material_get_shader_param(RID p_material, const StringName& p_param) const;
- virtual void canvas_item_material_set_unshaded(RID p_material, bool p_unshaded);
+ virtual Variant canvas_item_material_get_shader_param(RID p_material, const StringName& p_param) const;
+ virtual void canvas_item_material_set_shading_mode(RID p_material, CanvasItemShadingMode p_mode);
+
/* CURSOR */
diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h
index ded4c6fc00..6cd374aa08 100644
--- a/servers/visual/visual_server_wrap_mt.h
+++ b/servers/visual/visual_server_wrap_mt.h
@@ -1160,12 +1160,13 @@ public:
FUNC2(canvas_light_set_texture_offset,RID,const Vector2&);
FUNC2(canvas_light_set_color,RID,const Color&);
FUNC2(canvas_light_set_height,RID,float);
+ FUNC2(canvas_light_set_energy,RID,float);
FUNC3(canvas_light_set_layer_range,RID,int,int);
FUNC3(canvas_light_set_z_range,RID,int,int);
FUNC2(canvas_light_set_item_mask,RID,int);
FUNC2(canvas_light_set_item_shadow_mask,RID,int);
- FUNC2(canvas_light_set_subtract_mode,RID,bool);
+ FUNC2(canvas_light_set_mode,RID,CanvasLightMode);
FUNC2(canvas_light_set_shadow_enabled,RID,bool);
FUNC2(canvas_light_set_shadow_buffer_size,RID,int);
FUNC2(canvas_light_set_shadow_esm_multiplier,RID,float);
@@ -1191,8 +1192,8 @@ public:
FUNC0R(RID,canvas_item_material_create);
FUNC2(canvas_item_material_set_shader,RID,RID);
FUNC3(canvas_item_material_set_shader_param,RID,const StringName&,const Variant&);
- FUNC2RC(Variant,canvas_item_material_get_shader_param,RID,const StringName&);
- FUNC2(canvas_item_material_set_unshaded,RID,bool);
+ FUNC2RC(Variant,canvas_item_material_get_shader_param,RID,const StringName&);
+ FUNC2(canvas_item_material_set_shading_mode,RID,CanvasItemShadingMode);
/* CURSOR */
FUNC2(cursor_set_rotation,float , int ); // radians
diff --git a/servers/visual_server.h b/servers/visual_server.h
index b6d354454e..e9425afbab 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -1014,12 +1014,19 @@ public:
virtual void canvas_light_set_texture_offset(RID p_light, const Vector2& p_offset)=0;
virtual void canvas_light_set_color(RID p_light, const Color& p_color)=0;
virtual void canvas_light_set_height(RID p_light, float p_height)=0;
+ virtual void canvas_light_set_energy(RID p_light, float p_energy)=0;
virtual void canvas_light_set_z_range(RID p_light, int p_min_z,int p_max_z)=0;
virtual void canvas_light_set_layer_range(RID p_light, int p_min_layer,int p_max_layer)=0;
virtual void canvas_light_set_item_mask(RID p_light, int p_mask)=0;
virtual void canvas_light_set_item_shadow_mask(RID p_light, int p_mask)=0;
- virtual void canvas_light_set_subtract_mode(RID p_light, bool p_enable)=0;
+ enum CanvasLightMode {
+ CANVAS_LIGHT_MODE_ADD,
+ CANVAS_LIGHT_MODE_SUB,
+ CANVAS_LIGHT_MODE_MIX,
+ };
+
+ virtual void canvas_light_set_mode(RID p_light, CanvasLightMode p_mode)=0;
virtual void canvas_light_set_shadow_enabled(RID p_light, bool p_enabled)=0;
virtual void canvas_light_set_shadow_buffer_size(RID p_light, int p_size)=0;
virtual void canvas_light_set_shadow_esm_multiplier(RID p_light, float p_multiplier)=0;
@@ -1049,7 +1056,15 @@ public:
virtual void canvas_item_material_set_shader(RID p_material, RID p_shader)=0;
virtual void canvas_item_material_set_shader_param(RID p_material, const StringName& p_param, const Variant& p_value)=0;
virtual Variant canvas_item_material_get_shader_param(RID p_material, const StringName& p_param) const=0;
- virtual void canvas_item_material_set_unshaded(RID p_material, bool p_unshaded)=0;
+
+
+ enum CanvasItemShadingMode {
+ CANVAS_ITEM_SHADING_NORMAL,
+ CANVAS_ITEM_SHADING_UNSHADED,
+ CANVAS_ITEM_SHADING_ONLY_LIGHT,
+ };
+
+ virtual void canvas_item_material_set_shading_mode(RID p_material, CanvasItemShadingMode p_mode)=0;
/* CURSOR */
virtual void cursor_set_rotation(float p_rotation, int p_cursor = 0)=0; // radians