diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-01-12 10:19:09 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-01-12 10:19:09 -0300 |
commit | 544ce2a1dbaa5548490c975c2f6f6ed7c21377b9 (patch) | |
tree | 946383b4d367311aa186cada9d80c318630da44c /servers | |
parent | f3dc51fc69ec3a16c6b2a6834ff0a6d933b1ddca (diff) |
-Initial working(?) implementation of shaders for 2D. Lighting still not there though.
Check for reference:
https://github.com/okamstudio/godot/wiki/shader
Diffstat (limited to 'servers')
-rw-r--r-- | servers/visual/rasterizer.h | 2 | ||||
-rw-r--r-- | servers/visual/rasterizer_dummy.cpp | 5 | ||||
-rw-r--r-- | servers/visual/rasterizer_dummy.h | 2 | ||||
-rw-r--r-- | servers/visual/shader_language.cpp | 2 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.cpp | 5 |
5 files changed, 15 insertions, 1 deletions
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index ecd44fddfd..346d535ae8 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -210,6 +210,8 @@ public: virtual void shader_set_default_texture_param(RID p_shader, const StringName& p_name, RID p_texture)=0; virtual RID shader_get_default_texture_param(RID p_shader, const StringName& p_name) const=0; + virtual Variant shader_get_default_param(RID p_shader, const StringName& p_name)=0; + /* COMMON MATERIAL API */ virtual RID material_create()=0; diff --git a/servers/visual/rasterizer_dummy.cpp b/servers/visual/rasterizer_dummy.cpp index 1275b2308c..6c1b6697c1 100644 --- a/servers/visual/rasterizer_dummy.cpp +++ b/servers/visual/rasterizer_dummy.cpp @@ -231,6 +231,11 @@ RID RasterizerDummy::shader_get_default_texture_param(RID p_shader, const String return RID(); } +Variant RasterizerDummy::shader_get_default_param(RID p_shader, const StringName& p_name) { + + return Variant(); +} + /* COMMON MATERIAL API */ diff --git a/servers/visual/rasterizer_dummy.h b/servers/visual/rasterizer_dummy.h index 2944bbbaf1..fa7f197692 100644 --- a/servers/visual/rasterizer_dummy.h +++ b/servers/visual/rasterizer_dummy.h @@ -433,6 +433,8 @@ public: virtual void shader_set_default_texture_param(RID p_shader, const StringName& p_name, RID p_texture); virtual RID shader_get_default_texture_param(RID p_shader, const StringName& p_name) const; + virtual Variant shader_get_default_param(RID p_shader, const StringName& p_name); + /* COMMON MATERIAL API */ virtual RID material_create(); diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index 1b076176f4..80f82fdc42 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -1127,11 +1127,13 @@ const ShaderLanguage::BuiltinsDef ShaderLanguage::ci_vertex_builtins_defs[]={ }; const ShaderLanguage::BuiltinsDef ShaderLanguage::ci_fragment_builtins_defs[]={ + { "SRC_COLOR", TYPE_VEC4}, { "POSITION", TYPE_VEC4}, { "NORMAL", TYPE_VEC3}, { "UV", TYPE_VEC2}, { "COLOR", TYPE_VEC4}, { "TEXTURE", TYPE_TEXTURE}, + { "TEXTURE_PIXEL_SIZE", TYPE_VEC2}, { "VAR1", TYPE_VEC4}, { "VAR2", TYPE_VEC4}, { "SCREEN_UV", TYPE_VEC2}, diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index 7e915be3d5..96aa873266 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -3730,7 +3730,10 @@ Variant VisualServerRaster::canvas_item_get_shader_param(RID p_canvas_item, cons CanvasItem *canvas_item = canvas_item_owner.get( p_canvas_item ); ERR_FAIL_COND_V(!canvas_item,Variant()); - ERR_FAIL_COND_V(!canvas_item->shader_param.has(p_param),Variant()); + if (!canvas_item->shader_param.has(p_param)) { + ERR_FAIL_COND_V(!canvas_item->shader.is_valid(),Variant()); + return rasterizer->shader_get_default_param(canvas_item->shader,p_param); + } return canvas_item->shader_param[p_param]; } |