Misc Fixes

==========

-NOTIFICATION_WM_QUIT fixed on android (seems tha way this is reported changed in newer sdk)
-WIP implementation of APK Expansion APIs for publishing games larger than 50mb in Play Store
-Feaures in the new tutorials are all present in the sourcecode
-This (hopefully) should get rid of the animation list order getting corrupted
-Improved 3D Scene Importer (Skeletons, Animations and other stuff were not being merged). Anything missing?
-In code editor, the automatic syntax checker will only use file_exists() to check preload() else it might freeze the editor too much while typing if the preload is a big resource
-Fixed bugs in PolygonPathFinder, stil pending to do a node and a demo
This commit is contained in:
Juan Linietsky 2014-06-27 23:21:45 -03:00
parent 1cc96a4d74
commit 2af2a84a03
74 changed files with 1416 additions and 662 deletions

View File

@ -176,7 +176,7 @@ public:
vs->camera_set_transform(camera, Transform( Matrix3(), Vector3(0,0,2 ) ) );
RID lightaux = vs->light_create( VisualServer::LIGHT_DIRECTIONAL );
vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.3,0.3,0.3) );
//vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.3,0.3,0.3) );
light = vs->instance_create2( lightaux,scenario );
vs->instance_set_transform(light,Transform(Matrix3(Vector3(0.1,0.4,0.7).normalized(),0.9)));

View File

@ -407,7 +407,7 @@ public:
RID cylinder_material = vs->fixed_material_create();
vs->fixed_material_set_param( cylinder_material, VisualServer::FIXED_MATERIAL_PARAM_DIFFUSE, Color(0.8,0.2,0.9));
vs->material_set_flag( cylinder_material, VisualServer::MATERIAL_FLAG_ONTOP,true);
vs->material_set_flag( cylinder_material, VisualServer::MATERIAL_FLAG_WIREFRAME,true);
//vs->material_set_flag( cylinder_material, VisualServer::MATERIAL_FLAG_WIREFRAME,true);
vs->material_set_flag( cylinder_material, VisualServer::MATERIAL_FLAG_DOUBLE_SIDED,true);
vs->material_set_flag( cylinder_material, VisualServer::MATERIAL_FLAG_UNSHADED,true);
@ -429,7 +429,7 @@ public:
light = vs->instance_create2( lightaux );
*/
RID lightaux = vs->light_create( VisualServer::LIGHT_DIRECTIONAL );
vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) );
//vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) );
//vs->light_set_shadow( lightaux, true );
RID light = vs->instance_create2( lightaux,scenario );

View File

@ -87,7 +87,7 @@ public:
light = vs->instance_create2( lightaux );
*/
RID lightaux = vs->light_create( VisualServer::LIGHT_DIRECTIONAL );
vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) );
// vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) );
light = vs->instance_create2( lightaux, scenario );
ofs=0;

View File

@ -185,7 +185,7 @@ public:
//*
lightaux = vs->light_create( VisualServer::LIGHT_DIRECTIONAL );
vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) );
//vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) );
vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_DIFFUSE, Color(1.0,1.0,1.0) );
//vs->light_set_shadow( lightaux, true );
light = vs->instance_create2( lightaux, scenario );
@ -198,7 +198,7 @@ public:
//*
lightaux = vs->light_create( VisualServer::LIGHT_OMNI );
vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,1.0) );
// vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,1.0) );
vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_DIFFUSE, Color(1.0,1.0,0.0) );
vs->light_set_param( lightaux, VisualServer::LIGHT_PARAM_RADIUS, 4 );
vs->light_set_param( lightaux, VisualServer::LIGHT_PARAM_ENERGY, 8 );

View File

@ -264,13 +264,15 @@ static String dump_node_code(SL::Node *p_node,int p_level) {
}
static void recreate_code(void *p_str,SL::ProgramNode *p_program) {
static Error recreate_code(void *p_str,SL::ProgramNode *p_program) {
print_line("recr");
String *str=(String*)p_str;
*str=dump_node_code(p_program,0);
return OK;
}

View File

@ -243,12 +243,27 @@ bool Globals::_load_resource_pack(const String& p_pack) {
return true;
}
Error Globals::setup(const String& p_path) {
Error Globals::setup(const String& p_path,const String & p_main_pack) {
//an absolute mess of a function, must be cleaned up and reorganized somehow at some point
//_load_settings(p_path+"/override.cfg");
if (p_main_pack!="") {
bool ok = _load_resource_pack(p_main_pack);
ERR_FAIL_COND_V(!ok,ERR_CANT_OPEN);
if (_load_settings("res://engine.cfg")==OK || _load_settings_binary("res://engine.cfb")==OK) {
_load_settings("res://override.cfg");
}
return OK;
}
if (OS::get_singleton()->get_executable_path()!="") {
if (_load_resource_pack(OS::get_singleton()->get_executable_path())) {

View File

@ -110,7 +110,7 @@ public:
int get_order(const String& p_name) const;
void set_order(const String& p_name, int p_order);
Error setup(const String& p_path);
Error setup(const String& p_path, const String &p_main_pack);
Error save_custom(const String& p_path="",const CustomMap& p_custom=CustomMap(),const Set<String>& p_ignore_masks=Set<String>());
Error save();

View File

@ -1751,7 +1751,10 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_
skip_editor=p_flags&ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES;
bundle_resources=p_flags&ResourceSaver::FLAG_BUNDLE_RESOURCES;
big_endian=p_flags&ResourceSaver::FLAG_SAVE_BIG_ENDIAN;
takeover_paths=p_flags&ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS;
if (!p_path.begins_with("res://"))
takeover_paths=false;
local_path=p_path.get_base_dir();
//bin_meta_idx = get_string_index("__bin_meta__"); //is often used, so create
@ -1841,9 +1844,12 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_
for(List<RES>::Element *E=saved_resources.front();E;E=E->next()) {
RES r = E->get();
if (r->get_path()=="" || r->get_path().find("::")!=-1)
if (r->get_path()=="" || r->get_path().find("::")!=-1) {
save_unicode_string("local://"+itos(ofs_pos.size()));
else
if (takeover_paths) {
r->set_path(p_path+"::"+itos(ofs_pos.size()),true);
}
} else
save_unicode_string(r->get_path()); //actual external
ofs_pos.push_back(f->get_pos());
f->store_64(0); //offset in 64 bits

View File

@ -125,6 +125,7 @@ class ResourceFormatSaverBinaryInstance {
bool bundle_resources;
bool skip_editor;
bool big_endian;
bool takeover_paths;
int bin_meta_idx;
FileAccess *f;
String magic;

View File

@ -2505,6 +2505,10 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res
relative_paths=p_flags&ResourceSaver::FLAG_RELATIVE_PATHS;
skip_editor=p_flags&ResourceSaver::FLAG_OMIT_EDITOR_PROPERTIES;
bundle_resources=p_flags&ResourceSaver::FLAG_BUNDLE_RESOURCES;
takeover_paths=p_flags&ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS;
if (!p_path.begins_with("res://")) {
takeover_paths=false;
}
depth=0;
// save resources
@ -2541,8 +2545,14 @@ Error ResourceFormatSaverXMLInstance::save(const String &p_path,const RES& p_res
enter_tag("main_resource",""); //bundled
else if (res->get_path().length() && res->get_path().find("::") == -1 )
enter_tag("resource","type=\""+res->get_type()+"\" path=\""+res->get_path()+"\""); //bundled
else
enter_tag("resource","type=\""+res->get_type()+"\" path=\"local://"+itos(resource_map[res])+"\"");
else {
int idx = resource_map[res];
enter_tag("resource","type=\""+res->get_type()+"\" path=\"local://"+itos(idx)+"\"");
if (takeover_paths) {
res->set_path(p_path+"::"+itos(idx),true);
}
}
write_string("\n",false);

View File

@ -117,6 +117,7 @@ class ResourceFormatSaverXMLInstance {
bool takeover_paths;
bool relative_paths;
bool bundle_resources;
bool skip_editor;

View File

@ -74,6 +74,7 @@ public:
FLAG_OMIT_EDITOR_PROPERTIES=8,
FLAG_SAVE_BIG_ENDIAN=16,
FLAG_COMPRESS=32,
FLAG_REPLACE_SUBRESOURCE_PATHS=64,
};

View File

@ -157,7 +157,7 @@ void Resource::_resource_path_changed() {
}
void Resource::set_path(const String& p_path) {
void Resource::set_path(const String& p_path, bool p_take_over) {
if (path_cache==p_path)
return;
@ -168,7 +168,16 @@ void Resource::set_path(const String& p_path) {
}
path_cache="";
ERR_FAIL_COND( ResourceCache::resources.has( p_path ) );
if (ResourceCache::resources.has( p_path )) {
if (p_take_over) {
ResourceCache::resources.get(p_path)->set_name("");
} else {
ERR_EXPLAIN("Another resource is loaded from path: "+p_path);
ERR_FAIL_COND( ResourceCache::resources.has( p_path ) );
}
}
path_cache=p_path;
if (path_cache!="") {
@ -240,7 +249,7 @@ void Resource::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_path","path"),&Resource::set_path);
ObjectTypeDB::bind_method(_MD("get_path"),&Resource::get_path);
ObjectTypeDB::bind_method(_MD("set_name","name"),&Resource::set_name);
ObjectTypeDB::bind_method(_MD("set_name","name","take_over"),&Resource::set_name,DEFVAL(false));
ObjectTypeDB::bind_method(_MD("get_name"),&Resource::get_name);
ObjectTypeDB::bind_method(_MD("get_rid"),&Resource::get_rid);
ObjectTypeDB::bind_method(_MD("set_import_metadata","metadata"),&Resource::set_import_metadata);

View File

@ -126,7 +126,7 @@ public:
void set_name(const String& p_name);
String get_name() const;
void set_path(const String& p_path);
void set_path(const String& p_path,bool p_take_over=false);
String get_path() const;
Ref<Resource> duplicate(bool p_subresources=false);

View File

@ -673,7 +673,7 @@ static const int caps_table[CAPS_LEN][2]={
{0xFF5A,0xFF3A},
};
static const int reverse_caps_table[CAPS_LEN][2]={
static const int reverse_caps_table[CAPS_LEN-1][2]={
{0x41,0x61},
{0x42,0x62},
{0x43,0x63},
@ -755,7 +755,7 @@ static const int reverse_caps_table[CAPS_LEN][2]={
{0x12a,0x12b},
{0x12c,0x12d},
{0x12e,0x12f},
{0x49,0x131},
//{0x49,0x131},
{0x132,0x133},
{0x134,0x135},
{0x136,0x137},
@ -1370,7 +1370,7 @@ static int _find_lower(int ch) {
int low = 0;
int high = CAPS_LEN -1;
int high = CAPS_LEN -2;
int middle;
while( low <= high )

View File

@ -24,3 +24,5 @@ max_shadow_buffer_size=1024
framebuffer_shrink=1
shadow_filter=3
debug_shadow_maps=false
fp16_framebuffer=true
debug_hdr=false

View File

@ -1,11 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<resource_file type="PackedScene" subresource_count="7" version="1.0" version_name="Godot Engine v1.0.3917-beta1">
<ext_resource path="res://enemy.scn" type="PackedScene"></ext_resource>
<ext_resource path="res://player.xml" type="PackedScene"></ext_resource>
<ext_resource path="res://sb.cube" type="CubeMap"></ext_resource>
<ext_resource path="res://tiles.res" type="MeshLibrary"></ext_resource>
<ext_resource path="res://enemy.scn" type="PackedScene"></ext_resource>
<ext_resource path="res://coin.scn" type="PackedScene"></ext_resource>
<ext_resource path="res://player.xml" type="PackedScene"></ext_resource>
<resource type="Environment" path="local://1">
<bool name="ambient_light/enabled"> True </bool>
<color name="ambient_light/color"> 0, 0.409429, 0.596681, 1 </color>
<real name="ambient_light/energy"> 1 </real>
<bool name="fxaa/enabled"> False </bool>
<int name="background/mode"> 4 </int>
<color name="background/color"> 0, 0, 0, 1 </color>
@ -43,16 +46,17 @@
<real name="bcs/brightness"> 1 </real>
<real name="bcs/contrast"> 1 </real>
<real name="bcs/saturation"> 1.608 </real>
<bool name="gamma/enabled"> False </bool>
<real name="gamma/gamma"> 1.414214 </real>
<bool name="srgb/enabled"> False </bool>
</resource>
<main_resource>
<dictionary name="_bundled" shared="false">
<string> "names" </string>
<string_array len="89">
<string_array len="92">
<string> "world" </string>
<string> "Spatial" </string>
<string> "_import_path" </string>
<string> "_import_transform" </string>
<string> "__meta__" </string>
<string> "GridMap" </string>
<string> "theme/theme" </string>
@ -71,13 +75,14 @@
<string> "params/enabled" </string>
<string> "params/bake_mode" </string>
<string> "params/energy" </string>
<string> "colors/ambient" </string>
<string> "colors/diffuse" </string>
<string> "colors/specular" </string>
<string> "shadow/shadow" </string>
<string> "shadow/darkening" </string>
<string> "shadow/z_offset" </string>
<string> "shadow/z_slope_scale" </string>
<string> "shadow/esm_multiplier" </string>
<string> "shadow/blur_passes" </string>
<string> "projector" </string>
<string> "operator" </string>
<string> "shadow/mode" </string>
@ -148,7 +153,9 @@
<string> "node_count" </string>
<int> 55 </int>
<string> "variants" </string>
<array len="76" shared="false">
<array len="79" shared="false">
<node_path> "" </node_path>
<transform> 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 </transform>
<dictionary shared="false">
<string> "__editor_plugin_states__" </string>
<dictionary shared="false">
@ -175,17 +182,17 @@
<array len="4" shared="false">
<dictionary shared="false">
<string> "distance" </string>
<real> 4.173348 </real>
<real> 0.261354 </real>
<string> "x_rot" </string>
<real> 0.558294 </real>
<real> 0.458294 </real>
<string> "y_rot" </string>
<real> 1.049999 </real>
<real> -1.2 </real>
<string> "use_orthogonal" </string>
<bool> False </bool>
<string> "use_environment" </string>
<bool> False </bool>
<string> "pos" </string>
<vector3> 13.4293, 5.68289, 13.9717 </vector3>
<vector3> 13.4535, 5.75047, 13.8175 </vector3>
</dictionary>
<dictionary shared="false">
<string> "distance" </string>
@ -272,11 +279,12 @@
<int> 1 </int>
<int> 0 </int>
<real> 1.5 </real>
<color> 0.159092, 0.219774, 0.52093, 1 </color>
<color> 1, 1, 1, 1 </color>
<real> 0 </real>
<real> 0.08 </real>
<real> 0.5 </real>
<real> 60 </real>
<real> 1 </real>
<resource name=""></resource> <int> 2 </int>
<real> 40 </real>
<real> 0.410558 </real>
@ -339,7 +347,7 @@
<transform> 0.0160676, 0, -0.999871, 0, 1, 0, 0.999871, 0, 0.0160676, 8.50167, 4.15811, 15.9334 </transform>
</array>
<string> "nodes" </string>
<int_array len="547"> -1, -1, 1, 0, -1, 1, 2, 0, 0, 0, 0, 3, 3, -1, 11, 4, 1, 5, 2, 6, 2, 7, 3, 8, 4, 9, 5, 10, 5, 11, 5, 12, 6, 13, 7, 2, 8, 0, 0, 0, 14, 14, -1, 18, 15, 9, 16, 10, 17, 5, 18, 11, 19, 12, 20, 13, 21, 14, 22, 14, 23, 5, 24, 15, 25, 16, 26, 17, 27, 18, 28, 11, 29, 19, 30, 20, 31, 21, 32, 3, 0, 0, 0, 34, 33, -1, 1, 33, 22, 0, 0, 0, 36, 35, -1, 1, 2, 23, 0, 4, 0, 38, 37, 24, 1, 15, 25, 0, 4, 0, 38, 39, 24, 1, 15, 26, 0, 4, 0, 38, 40, 24, 1, 15, 27, 0, 4, 0, 38, 41, 24, 1, 15, 28, 0, 4, 0, 38, 42, 24, 1, 15, 29, 0, 4, 0, 38, 43, 24, 1, 15, 30, 0, 4, 0, 38, 44, 24, 1, 15, 31, 0, 4, 0, 38, 45, 24, 1, 15, 32, 0, 4, 0, 38, 46, 24, 1, 15, 33, 0, 4, 0, 38, 47, 24, 1, 15, 34, 0, 4, 0, 38, 48, 24, 1, 15, 35, 0, 4, 0, 38, 49, 24, 1, 15, 36, 0, 4, 0, 38, 50, 24, 1, 15, 37, 0, 4, 0, 38, 51, 24, 1, 15, 38, 0, 4, 0, 38, 52, 24, 1, 15, 39, 0, 4, 0, 38, 53, 24, 1, 15, 40, 0, 4, 0, 38, 54, 24, 1, 15, 41, 0, 4, 0, 38, 55, 24, 1, 15, 42, 0, 4, 0, 38, 56, 24, 1, 15, 43, 0, 4, 0, 38, 57, 24, 1, 15, 44, 0, 4, 0, 38, 58, 24, 1, 15, 45, 0, 4, 0, 38, 59, 24, 1, 15, 46, 0, 4, 0, 38, 60, 24, 1, 15, 47, 0, 4, 0, 38, 61, 24, 1, 15, 48, 0, 4, 0, 38, 62, 24, 1, 15, 49, 0, 4, 0, 38, 63, 24, 1, 15, 50, 0, 4, 0, 38, 64, 24, 1, 15, 51, 0, 4, 0, 38, 65, 24, 1, 15, 52, 0, 4, 0, 38, 66, 24, 1, 15, 53, 0, 4, 0, 38, 67, 24, 1, 15, 54, 0, 4, 0, 38, 68, 24, 1, 15, 55, 0, 4, 0, 38, 69, 24, 1, 15, 56, 0, 4, 0, 38, 70, 24, 1, 15, 57, 0, 4, 0, 38, 71, 24, 1, 15, 58, 0, 4, 0, 38, 72, 24, 1, 15, 59, 0, 4, 0, 38, 73, 24, 1, 15, 60, 0, 4, 0, 38, 74, 24, 1, 15, 61, 0, 4, 0, 38, 75, 24, 1, 15, 62, 0, 4, 0, 38, 76, 24, 1, 15, 63, 0, 4, 0, 38, 77, 24, 1, 15, 64, 0, 4, 0, 38, 78, 24, 1, 15, 65, 0, 4, 0, 38, 79, 24, 1, 15, 66, 0, 4, 0, 38, 80, 24, 1, 15, 67, 0, 4, 0, 38, 81, 24, 1, 15, 68, 0, 0, 0, 36, 82, -1, 0, 0, 49, 0, 84, 83, 69, 1, 15, 70, 0, 49, 0, 84, 85, 69, 1, 15, 71, 0, 49, 0, 84, 86, 69, 1, 15, 72, 0, 49, 0, 84, 87, 69, 1, 15, 73, 0, 0, 0, 84, 88, 74, 1, 15, 75, 0 </int_array>
<int_array len="569"> -1, -1, 1, 0, -1, 3, 2, 0, 3, 1, 4, 2, 0, 0, 0, 5, 5, -1, 13, 2, 0, 3, 1, 6, 3, 7, 4, 8, 4, 9, 5, 10, 6, 11, 7, 12, 7, 13, 7, 14, 8, 15, 9, 4, 10, 0, 0, 0, 16, 16, -1, 21, 2, 0, 3, 1, 17, 11, 18, 12, 19, 7, 20, 13, 21, 14, 22, 15, 23, 15, 24, 7, 25, 16, 26, 17, 27, 18, 28, 19, 29, 20, 30, 21, 31, 13, 32, 22, 33, 23, 34, 24, 35, 5, 0, 0, 0, 37, 36, -1, 3, 2, 0, 3, 1, 36, 25, 0, 0, 0, 39, 38, -1, 2, 2, 0, 4, 26, 0, 4, 0, 41, 40, 27, 1, 17, 28, 0, 4, 0, 41, 42, 27, 1, 17, 29, 0, 4, 0, 41, 43, 27, 1, 17, 30, 0, 4, 0, 41, 44, 27, 1, 17, 31, 0, 4, 0, 41, 45, 27, 1, 17, 32, 0, 4, 0, 41, 46, 27, 1, 17, 33, 0, 4, 0, 41, 47, 27, 1, 17, 34, 0, 4, 0, 41, 48, 27, 1, 17, 35, 0, 4, 0, 41, 49, 27, 1, 17, 36, 0, 4, 0, 41, 50, 27, 1, 17, 37, 0, 4, 0, 41, 51, 27, 1, 17, 38, 0, 4, 0, 41, 52, 27, 1, 17, 39, 0, 4, 0, 41, 53, 27, 1, 17, 40, 0, 4, 0, 41, 54, 27, 1, 17, 41, 0, 4, 0, 41, 55, 27, 1, 17, 42, 0, 4, 0, 41, 56, 27, 1, 17, 43, 0, 4, 0, 41, 57, 27, 1, 17, 44, 0, 4, 0, 41, 58, 27, 1, 17, 45, 0, 4, 0, 41, 59, 27, 1, 17, 46, 0, 4, 0, 41, 60, 27, 1, 17, 47, 0, 4, 0, 41, 61, 27, 1, 17, 48, 0, 4, 0, 41, 62, 27, 1, 17, 49, 0, 4, 0, 41, 63, 27, 1, 17, 50, 0, 4, 0, 41, 64, 27, 1, 17, 51, 0, 4, 0, 41, 65, 27, 1, 17, 52, 0, 4, 0, 41, 66, 27, 1, 17, 53, 0, 4, 0, 41, 67, 27, 1, 17, 54, 0, 4, 0, 41, 68, 27, 1, 17, 55, 0, 4, 0, 41, 69, 27, 1, 17, 56, 0, 4, 0, 41, 70, 27, 1, 17, 57, 0, 4, 0, 41, 71, 27, 1, 17, 58, 0, 4, 0, 41, 72, 27, 1, 17, 59, 0, 4, 0, 41, 73, 27, 1, 17, 60, 0, 4, 0, 41, 74, 27, 1, 17, 61, 0, 4, 0, 41, 75, 27, 1, 17, 62, 0, 4, 0, 41, 76, 27, 1, 17, 63, 0, 4, 0, 41, 77, 27, 1, 17, 64, 0, 4, 0, 41, 78, 27, 1, 17, 65, 0, 4, 0, 41, 79, 27, 1, 17, 66, 0, 4, 0, 41, 80, 27, 1, 17, 67, 0, 4, 0, 41, 81, 27, 1, 17, 68, 0, 4, 0, 41, 82, 27, 1, 17, 69, 0, 4, 0, 41, 83, 27, 1, 17, 70, 0, 4, 0, 41, 84, 27, 1, 17, 71, 0, 0, 0, 39, 85, -1, 1, 2, 0, 0, 49, 0, 87, 86, 72, 1, 17, 73, 0, 49, 0, 87, 88, 72, 1, 17, 74, 0, 49, 0, 87, 89, 72, 1, 17, 75, 0, 49, 0, 87, 90, 72, 1, 17, 76, 0, 0, 0, 87, 91, 77, 1, 17, 78, 0 </int_array>
<string> "conns" </string>
<int_array len="0"> </int_array>
</dictionary>

Binary file not shown.

View File

@ -891,6 +891,7 @@ RID RasterizerGLES1::shader_create(VS::ShaderMode p_mode) {
shader->has_alpha=false;
shader->fragment_line=0;
shader->vertex_line=0;
shader->light_line=0;
RID rid = shader_owner.make_rid(shader);
shader_set_mode(rid,p_mode);
// _shader_make_dirty(shader);
@ -921,19 +922,22 @@ VS::ShaderMode RasterizerGLES1::shader_get_mode(RID p_shader) const {
void RasterizerGLES1::shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,int p_vertex_ofs,int p_fragment_ofs) {
void RasterizerGLES1::shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,const String& p_light,int p_vertex_ofs,int p_fragment_ofs,int p_light_ofs) {
Shader *shader=shader_owner.get(p_shader);
ERR_FAIL_COND(!shader);
#ifdef DEBUG_ENABLED
if (shader->vertex_code==p_vertex && shader->fragment_code==p_fragment)
if (shader->vertex_code==p_vertex && shader->fragment_code==p_fragment && shader->light_code==p_light)
return;
#endif
shader->fragment_code=p_fragment;
shader->vertex_code=p_vertex;
shader->light_code=p_light;
shader->fragment_line=p_fragment_ofs;
shader->vertex_line=p_vertex_ofs;
shader->light_line=p_light_ofs;
}
@ -953,6 +957,13 @@ String RasterizerGLES1::shader_get_fragment_code(RID p_shader) const {
}
String RasterizerGLES1::shader_get_light_code(RID p_shader) const {
Shader *shader=shader_owner.get(p_shader);
ERR_FAIL_COND_V(!shader,String());
return shader->light_code;
}
void RasterizerGLES1::shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const {
@ -1099,39 +1110,21 @@ bool RasterizerGLES1::material_get_flag(RID p_material,VS::MaterialFlag p_flag)
}
void RasterizerGLES1::material_set_hint(RID p_material, VS::MaterialHint p_hint,bool p_enabled) {
void RasterizerGLES1::material_set_depth_draw_mode(RID p_material, VS::MaterialDepthDrawMode p_mode) {
Material *material = material_owner.get(p_material);
ERR_FAIL_COND(!material);
ERR_FAIL_INDEX(p_hint,VS::MATERIAL_HINT_MAX);
material->hints[p_hint]=p_enabled;
material->depth_draw_mode=p_mode;
}
bool RasterizerGLES1::material_get_hint(RID p_material,VS::MaterialHint p_hint) const {
VS::MaterialDepthDrawMode RasterizerGLES1::material_get_depth_draw_mode(RID p_material) const{
Material *material = material_owner.get(p_material);
ERR_FAIL_COND_V(!material,false);
ERR_FAIL_INDEX_V(p_hint,VS::MATERIAL_HINT_MAX,false);
return material->hints[p_hint];
ERR_FAIL_COND_V(!material,VS::MATERIAL_DEPTH_DRAW_ALWAYS);
return material->depth_draw_mode;
}
void RasterizerGLES1::material_set_shade_model(RID p_material, VS::MaterialShadeModel p_model) {
Material *material = material_owner.get(p_material);
ERR_FAIL_COND(!material);
material->shade_model=p_model;
};
VS::MaterialShadeModel RasterizerGLES1::material_get_shade_model(RID p_material) const {
Material *material = material_owner.get(p_material);
ERR_FAIL_COND_V(!material,VS::MATERIAL_SHADE_MODEL_LAMBERT);
return material->shade_model;
};
void RasterizerGLES1::material_set_blend_mode(RID p_material,VS::MaterialBlendMode p_mode) {
@ -1223,20 +1216,6 @@ RID RasterizerGLES1::fixed_material_get_texture(RID p_material,VS::FixedMaterial
return m->textures[p_parameter];
}
void RasterizerGLES1::fixed_material_set_detail_blend_mode(RID p_material,VS::MaterialBlendMode p_mode) {
Material *m=material_owner.get( p_material );
ERR_FAIL_COND(!m);
m->detail_blend_mode = p_mode;
}
VS::MaterialBlendMode RasterizerGLES1::fixed_material_get_detail_blend_mode(RID p_material) const {
Material *m=material_owner.get( p_material );
ERR_FAIL_COND_V(!m, VS::MATERIAL_BLEND_MODE_MIX);
return m->detail_blend_mode;
}
void RasterizerGLES1::fixed_material_set_texcoord_mode(RID p_material,VS::FixedMaterialParam p_parameter, VS::FixedMaterialTexCoordMode p_mode) {
@ -3395,7 +3374,7 @@ void RasterizerGLES1::_setup_material(const Geometry *p_geometry,const Material
}
bool current_depth_write=!p_material->hints[VS::MATERIAL_HINT_NO_DEPTH_DRAW];
bool current_depth_write=p_material->depth_draw_mode!=VS::MATERIAL_DEPTH_DRAW_ALWAYS; //broken
bool current_depth_test=!p_material->flags[VS::MATERIAL_FLAG_ONTOP];
@ -3460,7 +3439,7 @@ void RasterizerGLES1::_setup_light(LightInstance* p_instance, int p_idx) {
glLightfv(glid , GL_DIFFUSE, diffuse_sdark);
Color amb_color = ld->colors[VS::LIGHT_COLOR_AMBIENT];
Color amb_color = Color(0,0,0);
GLfloat amb_stexsize[4]={
amb_color.r,
amb_color.g,

View File

@ -132,10 +132,12 @@ class RasterizerGLES1 : public Rasterizer {
String vertex_code;
String fragment_code;
String light_code;
VS::ShaderMode mode;
Map<StringName,Variant> params;
int fragment_line;
int vertex_line;
int light_line;
bool valid;
bool has_alpha;
bool use_world_transform;
@ -149,15 +151,14 @@ class RasterizerGLES1 : public Rasterizer {
bool fixed_flags[VS::FIXED_MATERIAL_FLAG_MAX];
bool flags[VS::MATERIAL_FLAG_MAX];
bool hints[VS::MATERIAL_HINT_MAX];
Variant parameters[VisualServer::FIXED_MATERIAL_PARAM_MAX];
RID textures[VisualServer::FIXED_MATERIAL_PARAM_MAX];
VS::MaterialShadeModel shade_model;
VS::MaterialDepthDrawMode depth_draw_mode;
Transform uv_transform;
VS::FixedMaterialTexCoordMode texcoord_mode[VisualServer::FIXED_MATERIAL_PARAM_MAX];
VS::MaterialBlendMode detail_blend_mode;
VS::MaterialBlendMode blend_mode;
float line_width;
@ -179,8 +180,6 @@ class RasterizerGLES1 : public Rasterizer {
for(int i=0;i<VS::MATERIAL_FLAG_MAX;i++)
flags[i]=false;
flags[VS::MATERIAL_FLAG_VISIBLE]=true;
for(int i=0;i<VS::MATERIAL_HINT_MAX;i++)
hints[i]=false;
parameters[VS::FIXED_MATERIAL_PARAM_DIFFUSE] = Color(0.8, 0.8, 0.8);
parameters[VS::FIXED_MATERIAL_PARAM_SPECULAR_EXP] = 12;
@ -188,7 +187,7 @@ class RasterizerGLES1 : public Rasterizer {
for (int i=0; i<VisualServer::FIXED_MATERIAL_PARAM_MAX; i++) {
texcoord_mode[i] = VS::FIXED_MATERIAL_TEXCOORD_UV;
};
detail_blend_mode = VS::MATERIAL_BLEND_MODE_MIX;
depth_draw_mode=VS::MATERIAL_DEPTH_DRAW_OPAQUE_ONLY;
line_width=1;
has_alpha=false;
blend_mode=VS::MATERIAL_BLEND_MODE_MIX;
@ -433,7 +432,7 @@ class RasterizerGLES1 : public Rasterizer {
vars[VS::LIGHT_PARAM_ENERGY]=1.0;
vars[VS::LIGHT_PARAM_RADIUS]=1.0;
vars[VS::LIGHT_PARAM_SHADOW_Z_OFFSET]=0.05;
colors[VS::LIGHT_COLOR_AMBIENT]=Color(0,0,0);
colors[VS::LIGHT_COLOR_DIFFUSE]=Color(1,1,1);
colors[VS::LIGHT_COLOR_SPECULAR]=Color(1,1,1);
shadow_enabled=false;
@ -468,7 +467,7 @@ class RasterizerGLES1 : public Rasterizer {
fx_param[VS::ENV_FX_PARAM_DOF_BLUR_BEGIN]=100.0;
fx_param[VS::ENV_FX_PARAM_DOF_BLUR_RANGE]=10.0;
fx_param[VS::ENV_FX_PARAM_HDR_EXPOSURE]=0.4;
fx_param[VS::ENV_FX_PARAM_HDR_SCALAR]=1.0;
fx_param[VS::ENV_FX_PARAM_HDR_WHITE]=1.0;
fx_param[VS::ENV_FX_PARAM_HDR_GLOW_TRESHOLD]=0.95;
fx_param[VS::ENV_FX_PARAM_HDR_GLOW_SCALE]=0.2;
fx_param[VS::ENV_FX_PARAM_HDR_MIN_LUMINANCE]=0.4;
@ -862,9 +861,10 @@ public:
virtual void shader_set_mode(RID p_shader,VS::ShaderMode p_mode);
virtual VS::ShaderMode shader_get_mode(RID p_shader) const;
virtual void shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,int p_vertex_ofs=0,int p_fragment_ofs=0);
virtual void shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,const String& p_light,int p_vertex_ofs=0,int p_fragment_ofs=0,int p_light_ofs=0);
virtual String shader_get_fragment_code(RID p_shader) const;
virtual String shader_get_vertex_code(RID p_shader) const;
virtual String shader_get_light_code(RID p_shader) const;
virtual void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const;
@ -881,11 +881,8 @@ public:
virtual void material_set_flag(RID p_material, VS::MaterialFlag p_flag,bool p_enabled);
virtual bool material_get_flag(RID p_material,VS::MaterialFlag p_flag) const;
virtual void material_set_hint(RID p_material, VS::MaterialHint p_hint,bool p_enabled);
virtual bool material_get_hint(RID p_material,VS::MaterialHint p_hint) const;
virtual void material_set_shade_model(RID p_material, VS::MaterialShadeModel p_model);
virtual VS::MaterialShadeModel material_get_shade_model(RID p_material) const;
virtual void material_set_depth_draw_mode(RID p_material, VS::MaterialDepthDrawMode p_mode);
virtual VS::MaterialDepthDrawMode material_get_depth_draw_mode(RID p_material) const;
virtual void material_set_blend_mode(RID p_material,VS::MaterialBlendMode p_mode);
virtual VS::MaterialBlendMode material_get_blend_mode(RID p_material) const;
@ -906,9 +903,6 @@ public:
virtual void fixed_material_set_texture(RID p_material,VS::FixedMaterialParam p_parameter, RID p_texture);
virtual RID fixed_material_get_texture(RID p_material,VS::FixedMaterialParam p_parameter) const;
virtual void fixed_material_set_detail_blend_mode(RID p_material,VS::MaterialBlendMode p_mode);
virtual VS::MaterialBlendMode fixed_material_get_detail_blend_mode(RID p_material) const;
virtual void fixed_material_set_texcoord_mode(RID p_material,VS::FixedMaterialParam p_parameter, VS::FixedMaterialTexCoordMode p_mode);
virtual VS::FixedMaterialTexCoordMode fixed_material_get_texcoord_mode(RID p_material,VS::FixedMaterialParam p_parameter) const;

View File

@ -1132,20 +1132,22 @@ VS::ShaderMode RasterizerGLES2::shader_get_mode(RID p_shader) const {
}
void RasterizerGLES2::shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,const String& p_light,int p_vertex_ofs,int p_fragment_ofs,int p_light_ofs) {
void RasterizerGLES2::shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,int p_vertex_ofs,int p_fragment_ofs) {
Shader *shader=shader_owner.get(p_shader);
ERR_FAIL_COND(!shader);
#ifdef DEBUG_ENABLED
if (shader->vertex_code==p_vertex && shader->fragment_code==p_fragment)
if (shader->vertex_code==p_vertex && shader->fragment_code==p_fragment && shader->light_code==p_light)
return;
#endif
shader->fragment_code=p_fragment;
shader->vertex_code=p_vertex;
shader->light_code=p_light;
shader->fragment_line=p_fragment_ofs;
shader->vertex_line=p_vertex_ofs;
shader->light_line=p_light_ofs;
_shader_make_dirty(shader);
}
@ -1166,6 +1168,14 @@ String RasterizerGLES2::shader_get_fragment_code(RID p_shader) const {
}
String RasterizerGLES2::shader_get_light_code(RID p_shader) const {
Shader *shader=shader_owner.get(p_shader);
ERR_FAIL_COND_V(!shader,String());
return shader->light_code;
}
void RasterizerGLES2::_shader_make_dirty(Shader* p_shader) {
if (p_shader->dirty_list.in_list())
@ -1334,38 +1344,22 @@ bool RasterizerGLES2::material_get_flag(RID p_material,VS::MaterialFlag p_flag)
}
void RasterizerGLES2::material_set_hint(RID p_material, VS::MaterialHint p_hint,bool p_enabled) {
void RasterizerGLES2::material_set_depth_draw_mode(RID p_material, VS::MaterialDepthDrawMode p_mode) {
Material *material = material_owner.get(p_material);
ERR_FAIL_COND(!material);
ERR_FAIL_INDEX(p_hint,VS::MATERIAL_HINT_MAX);
material->hints[p_hint]=p_enabled;
material->depth_draw_mode=p_mode;
}
bool RasterizerGLES2::material_get_hint(RID p_material,VS::MaterialHint p_hint) const {
VS::MaterialDepthDrawMode RasterizerGLES2::material_get_depth_draw_mode(RID p_material) const {
Material *material = material_owner.get(p_material);
ERR_FAIL_COND_V(!material,false);
ERR_FAIL_INDEX_V(p_hint,VS::MATERIAL_HINT_MAX,false);
return material->hints[p_hint];
ERR_FAIL_COND_V(!material,VS::MATERIAL_DEPTH_DRAW_ALWAYS);
return material->depth_draw_mode;
}
void RasterizerGLES2::material_set_shade_model(RID p_material, VS::MaterialShadeModel p_model) {
Material *material = material_owner.get(p_material);
ERR_FAIL_COND(!material);
material->shade_model=p_model;
};
VS::MaterialShadeModel RasterizerGLES2::material_get_shade_model(RID p_material) const {
Material *material = material_owner.get(p_material);
ERR_FAIL_COND_V(!material,VS::MATERIAL_SHADE_MODEL_LAMBERT);
return material->shade_model;
};
void RasterizerGLES2::material_set_blend_mode(RID p_material,VS::MaterialBlendMode p_mode) {
@ -3455,14 +3449,21 @@ RID RasterizerGLES2::viewport_data_create() {
glGenFramebuffers(1, &vd->lum_fbo);
glBindFramebuffer(GL_FRAMEBUFFER, vd->lum_fbo);
GLuint format_luminance = use_fp16_fb?_GL_RG_EXT:GL_RGBA;
GLuint format_luminance_type = use_fp16_fb?(full_float_fb_supported?GL_FLOAT:_GL_HALF_FLOAT_OES):GL_UNSIGNED_BYTE;
GLuint format_luminance_components = use_fp16_fb?_GL_RG_EXT:GL_RGBA;
glGenTextures(1, &vd->lum_color);
glBindTexture(GL_TEXTURE_2D, vd->lum_color);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0,
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0,
// GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexImage2D(GL_TEXTURE_2D, 0, format_luminance, 1, 1, 0,
format_luminance_components, format_luminance_type, NULL);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, vd->lum_color, 0);
@ -3934,10 +3935,12 @@ void RasterizerGLES2::_update_shader( Shader* p_shader) const {
String vertex_code;
String vertex_globals;
ShaderCompilerGLES2::Flags flags;
ShaderCompilerGLES2::Flags vertex_flags;
ShaderCompilerGLES2::Flags fragment_flags;
ShaderCompilerGLES2::Flags light_flags;
if (p_shader->mode==VS::SHADER_MATERIAL) {
Error err = shader_precompiler.compile(p_shader->vertex_code,ShaderLanguage::SHADER_MATERIAL_VERTEX,vertex_code,vertex_globals,flags,&p_shader->uniforms);
Error err = shader_precompiler.compile(p_shader->vertex_code,ShaderLanguage::SHADER_MATERIAL_VERTEX,vertex_code,vertex_globals,vertex_flags,&p_shader->uniforms);
if (err) {
return; //invalid
}
@ -3950,11 +3953,26 @@ void RasterizerGLES2::_update_shader( Shader* p_shader) const {
String fragment_code;
String fragment_globals;
Error err = shader_precompiler.compile(p_shader->fragment_code,(p_shader->mode==VS::SHADER_MATERIAL?ShaderLanguage::SHADER_MATERIAL_FRAGMENT:ShaderLanguage::SHADER_POST_PROCESS),fragment_code,fragment_globals,flags,&p_shader->uniforms);
Error err = shader_precompiler.compile(p_shader->fragment_code,(p_shader->mode==VS::SHADER_MATERIAL?ShaderLanguage::SHADER_MATERIAL_FRAGMENT:ShaderLanguage::SHADER_POST_PROCESS),fragment_code,fragment_globals,fragment_flags,&p_shader->uniforms);
if (err) {
return; //invalid
}
String light_code;
String light_globals;
if (p_shader->mode==VS::SHADER_MATERIAL) {
Error err = shader_precompiler.compile(p_shader->light_code,(ShaderLanguage::SHADER_MATERIAL_LIGHT),light_code,light_globals,light_flags,&p_shader->uniforms);
if (err) {
return; //invalid
}
}
fragment_globals+=light_globals; //both fragment anyway
//print_line("compiled fragment: "+fragment_code);
// ("compiled fragment globals: "+fragment_globals);
@ -3975,40 +3993,43 @@ void RasterizerGLES2::_update_shader( Shader* p_shader) const {
if (p_shader->mode==VS::SHADER_MATERIAL) {
//print_line("setting code to id.. "+itos(p_shader->custom_code_id));
Vector<const char*> enablers;
if (flags.use_color_interp)
if (fragment_flags.use_color_interp)
enablers.push_back("#define ENABLE_COLOR_INTERP\n");
if (flags.use_uv_interp)
if (fragment_flags.use_uv_interp)
enablers.push_back("#define ENABLE_UV_INTERP\n");
if (flags.use_uv2_interp)
if (fragment_flags.use_uv2_interp)
enablers.push_back("#define ENABLE_UV2_INTERP\n");
if (flags.use_tangent_interp)
if (fragment_flags.use_tangent_interp)
enablers.push_back("#define ENABLE_TANGENT_INTERP\n");
if (flags.use_var1_interp)
if (fragment_flags.use_var1_interp)
enablers.push_back("#define ENABLE_VAR1_INTERP\n");
if (flags.use_var2_interp)
if (fragment_flags.use_var2_interp)
enablers.push_back("#define ENABLE_VAR2_INTERP\n");
if (flags.uses_texscreen) {
if (fragment_flags.uses_texscreen) {
enablers.push_back("#define ENABLE_TEXSCREEN\n");
}
if (flags.uses_screen_uv) {
if (fragment_flags.uses_screen_uv) {
enablers.push_back("#define ENABLE_SCREEN_UV\n");
}
if (flags.uses_discard) {
if (fragment_flags.uses_discard) {
enablers.push_back("#define ENABLE_DISCARD\n");
}
if (light_flags.uses_light) {
enablers.push_back("#define USE_LIGHT_SHADER_CODE\n");
}
material_shader.set_custom_shader_code(p_shader->custom_code_id,vertex_code, vertex_globals,fragment_code, fragment_globals,uniform_names,enablers);
material_shader.set_custom_shader_code(p_shader->custom_code_id,vertex_code, vertex_globals,fragment_code, light_code, fragment_globals,uniform_names,enablers);
} else {
//postprocess_shader.set_custom_shader_code(p_shader->custom_code_id,vertex_code, vertex_globals,fragment_code, fragment_globals,uniform_names);
}
p_shader->valid=true;
p_shader->has_alpha=flags.uses_alpha || flags.uses_texscreen;
p_shader->writes_vertex=flags.vertex_code_writes_vertex;
p_shader->uses_discard=flags.uses_discard;
p_shader->has_texscreen=flags.uses_texscreen;
p_shader->has_screen_uv=flags.uses_screen_uv;
p_shader->can_zpass=!flags.uses_discard && !flags.vertex_code_writes_vertex;
p_shader->has_alpha=fragment_flags.uses_alpha || fragment_flags.uses_texscreen;
p_shader->writes_vertex=vertex_flags.vertex_code_writes_vertex;
p_shader->uses_discard=fragment_flags.uses_discard;
p_shader->has_texscreen=fragment_flags.uses_texscreen;
p_shader->has_screen_uv=fragment_flags.uses_screen_uv;
p_shader->can_zpass=!fragment_flags.uses_discard && !vertex_flags.vertex_code_writes_vertex;
p_shader->version++;
}
@ -4073,10 +4094,10 @@ void RasterizerGLES2::_add_geometry( const Geometry* p_geometry, const InstanceD
if (shadow) {
if (has_blend_alpha || (has_base_alpha && !m->hints[VS::MATERIAL_HINT_OPAQUE_PRE_PASS]))
if (has_blend_alpha || (has_base_alpha && m->depth_draw_mode!=VS::MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA))
return; //bye
if (m->shader_cache && !m->shader_cache->writes_vertex && !m->shader_cache->uses_discard && !m->hints[VS::MATERIAL_HINT_OPAQUE_PRE_PASS]) {
if (m->shader_cache && !m->shader_cache->writes_vertex && !m->shader_cache->uses_discard && m->depth_draw_mode!=VS::MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA) {
//shader does not use discard and does not write a vertex position, use generic material
m = shadow_mat_ptr;
if (m->last_pass!=frame) {
@ -4159,7 +4180,7 @@ void RasterizerGLES2::_add_geometry( const Geometry* p_geometry, const InstanceD
e->light_type=0xFF; // no lights!
e->light=0xFFFF;
if (!shadow && !has_blend_alpha && has_alpha && m->hints[VS::MATERIAL_HINT_OPAQUE_PRE_PASS]) {
if (!shadow && !has_blend_alpha && has_alpha && m->depth_draw_mode==VS::MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA) {
//if nothing exists, add this element as opaque too
RenderList::Element *oe = opaque_render_list.add_element();
@ -4411,7 +4432,7 @@ bool RasterizerGLES2::_setup_material(const Geometry *p_geometry,const Material
material_shader.set_conditional(MaterialShaderGLES2::USE_SHADOW_PCF_HQ,shadow_filter==SHADOW_FILTER_PCF13);
material_shader.set_conditional(MaterialShaderGLES2::USE_SHADOW_ESM,shadow_filter==SHADOW_FILTER_ESM);
if (p_opaque_pass && p_material->hints[VS::MATERIAL_HINT_OPAQUE_PRE_PASS] && p_material->shader_cache && p_material->shader_cache->has_alpha) {
if (p_opaque_pass && p_material->depth_draw_mode==VS::MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA && p_material->shader_cache && p_material->shader_cache->has_alpha) {
material_shader.set_conditional(MaterialShaderGLES2::ENABLE_CLIP_ALPHA,true);
} else {
@ -4423,7 +4444,8 @@ bool RasterizerGLES2::_setup_material(const Geometry *p_geometry,const Material
if (!shadow) {
bool depth_test=!p_material->flags[VS::MATERIAL_FLAG_ONTOP];
bool depth_write=!p_material->hints[VS::MATERIAL_HINT_NO_DEPTH_DRAW] && (p_opaque_pass || !p_material->hints[VS::MATERIAL_HINT_NO_DEPTH_DRAW_FOR_ALPHA]);
bool depth_write=p_material->depth_draw_mode!=VS::MATERIAL_DEPTH_DRAW_NEVER && (p_opaque_pass || p_material->depth_draw_mode==VS::MATERIAL_DEPTH_DRAW_ALWAYS);
//bool depth_write=!p_material->hints[VS::MATERIAL_HINT_NO_DEPTH_DRAW] && (p_opaque_pass || !p_material->hints[VS::MATERIAL_HINT_NO_DEPTH_DRAW_FOR_ALPHA]);
if (current_depth_mask!=depth_write) {
current_depth_mask=depth_write;
@ -4594,7 +4616,6 @@ void RasterizerGLES2::_setup_light(uint16_t p_light) {
VL_LIGHT_DIR,
VL_LIGHT_ATTENUATION,
VL_LIGHT_SPOT_ATTENUATION,
VL_LIGHT_AMBIENT,
VL_LIGHT_DIFFUSE,
VL_LIGHT_SPECULAR,
VL_LIGHT_MAX
@ -4605,7 +4626,6 @@ void RasterizerGLES2::_setup_light(uint16_t p_light) {
MaterialShaderGLES2::LIGHT_DIRECTION,
MaterialShaderGLES2::LIGHT_ATTENUATION,
MaterialShaderGLES2::LIGHT_SPOT_ATTENUATION,
MaterialShaderGLES2::LIGHT_AMBIENT,
MaterialShaderGLES2::LIGHT_DIFFUSE,
MaterialShaderGLES2::LIGHT_SPECULAR,
};
@ -4617,12 +4637,10 @@ void RasterizerGLES2::_setup_light(uint16_t p_light) {
LightInstance *li=light_instances[p_light];
Light *l=li->base;
Color col_ambient=_convert_color(l->colors[VS::LIGHT_COLOR_AMBIENT]);
Color col_diffuse=_convert_color(l->colors[VS::LIGHT_COLOR_DIFFUSE]);
Color col_specular=_convert_color(l->colors[VS::LIGHT_COLOR_SPECULAR]);
for(int j=0;j<3;j++) {
light_data[VL_LIGHT_AMBIENT][j]=col_ambient[j];
light_data[VL_LIGHT_DIFFUSE][j]=col_diffuse[j];
light_data[VL_LIGHT_SPECULAR][j]=col_specular[j];
}
@ -5761,6 +5779,17 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
//material_shader.set_uniform(MaterialShaderGLES2::SKELETON_MATRICES,6);
material_shader.set_uniform(MaterialShaderGLES2::SKELTEX_PIXEL_SIZE,skeleton->pixel_size);
}
if (!shadow) {
if (!additive && current_env && current_env->fx_enabled[VS::ENV_FX_AMBIENT_LIGHT]) {
Color ambcolor = current_env->fx_param[VS::ENV_FX_PARAM_AMBIENT_LIGHT_COLOR];
float ambnrg = current_env->fx_param[VS::ENV_FX_PARAM_AMBIENT_LIGHT_ENERGY];
material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_LIGHT,Vector3(ambcolor.r*ambnrg,ambcolor.g*ambnrg,ambcolor.b*ambnrg));
} else {
material_shader.set_uniform(MaterialShaderGLES2::AMBIENT_LIGHT,Vector3());
}
}
_rinfo.shader_change_count++;
}
@ -5908,6 +5937,8 @@ void RasterizerGLES2::_process_glow_bloom() {
glBindTexture(GL_TEXTURE_2D, current_vd->lum_color );
glUniform1i(copy_shader.get_uniform_location(CopyShaderGLES2::HDR_SOURCE),2);
copy_shader.set_uniform(CopyShaderGLES2::TONEMAP_EXPOSURE,float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_EXPOSURE]));
copy_shader.set_uniform(CopyShaderGLES2::TONEMAP_WHITE,float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_WHITE]));
// copy_shader.set_uniform(CopyShaderGLES2::TONEMAP_WHITE,1.0);
copy_shader.set_uniform(CopyShaderGLES2::HDR_GLOW_TRESHOLD,float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_GLOW_TRESHOLD]));
copy_shader.set_uniform(CopyShaderGLES2::HDR_GLOW_SCALE,float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_GLOW_SCALE]));
@ -5987,7 +6018,7 @@ void RasterizerGLES2::_process_hdr() {
_copy_screen_quad();
copy_shader.set_conditional(CopyShaderGLES2::USE_HDR_COPY,false);
int passes = current_env->fx_param[VS::ENV_FX_PARAM_GLOW_BLUR_PASSES];
// int passes = current_env->fx_param[VS::ENV_FX_PARAM_GLOW_BLUR_PASSES];
copy_shader.set_conditional(CopyShaderGLES2::USE_HDR_REDUCE,true);
copy_shader.bind();
@ -6351,6 +6382,28 @@ void RasterizerGLES2::end_scene() {
glDepthMask(false);
if (current_env && current_env->fx_enabled[VS::ENV_FX_HDR]) {
int hdr_tm = current_env->fx_param[VS::ENV_FX_PARAM_HDR_TONEMAPPER];
switch(hdr_tm) {
case VS::ENV_FX_HDR_TONE_MAPPER_LINEAR: {
} break;
case VS::ENV_FX_HDR_TONE_MAPPER_LOG: {
copy_shader.set_conditional(CopyShaderGLES2::USE_LOG_TONEMAPPER,true);
} break;
case VS::ENV_FX_HDR_TONE_MAPPER_REINHARDT: {
copy_shader.set_conditional(CopyShaderGLES2::USE_REINHARDT_TONEMAPPER,true);
} break;
case VS::ENV_FX_HDR_TONE_MAPPER_REINHARDT_AUTOWHITE: {
copy_shader.set_conditional(CopyShaderGLES2::USE_REINHARDT_TONEMAPPER,true);
copy_shader.set_conditional(CopyShaderGLES2::USE_AUTOWHITE,true);
} break;
}
_process_hdr();
}
if (current_env && current_env->fx_enabled[VS::ENV_FX_GLOW]) {
@ -6400,6 +6453,7 @@ void RasterizerGLES2::end_scene() {
glBindTexture(GL_TEXTURE_2D, current_vd->lum_color );
glUniform1i(copy_shader.get_uniform_location(CopyShaderGLES2::HDR_SOURCE),2);
copy_shader.set_uniform(CopyShaderGLES2::TONEMAP_EXPOSURE,float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_EXPOSURE]));
copy_shader.set_uniform(CopyShaderGLES2::TONEMAP_WHITE,float(current_env->fx_param[VS::ENV_FX_PARAM_HDR_WHITE]));
}
@ -6430,6 +6484,9 @@ void RasterizerGLES2::end_scene() {
copy_shader.set_conditional(CopyShaderGLES2::USE_FXAA,false);
copy_shader.set_conditional(CopyShaderGLES2::USE_GLOW_SCREEN,false);
copy_shader.set_conditional(CopyShaderGLES2::USE_GLOW_SOFTLIGHT,false);
copy_shader.set_conditional(CopyShaderGLES2::USE_REINHARDT_TONEMAPPER,false);
copy_shader.set_conditional(CopyShaderGLES2::USE_AUTOWHITE,false);
copy_shader.set_conditional(CopyShaderGLES2::USE_LOG_TONEMAPPER,false);
material_shader.set_conditional(MaterialShaderGLES2::USE_8BIT_HDR,false);
@ -6444,6 +6501,7 @@ void RasterizerGLES2::end_scene() {
if (GLOBAL_DEF("rasterizer/debug_shadow_maps",false)) {
_debug_shadows();
}
// _debug_luminances();
}
@ -6813,7 +6871,7 @@ void RasterizerGLES2::_debug_draw_shadows_type(Vector<ShadowBuffer>& p_shadows,P
void RasterizerGLES2::_debug_luminances() {
canvas_shader.set_conditional(CanvasShaderGLES2::DEBUG_ENCODED_32,true);
canvas_shader.set_conditional(CanvasShaderGLES2::DEBUG_ENCODED_32,!use_fp16_fb);
canvas_begin();
glDisable(GL_BLEND);
canvas_shader.bind();
@ -6821,10 +6879,17 @@ void RasterizerGLES2::_debug_luminances() {
Size2 debug_size(128,128);
Size2 ofs;
for (int i=0;i<framebuffer.luminance.size();i++) {
_debug_draw_shadow(framebuffer.luminance[i].color, Rect2( ofs, debug_size ));
ofs.x+=debug_size.x;
for (int i=0;i<=framebuffer.luminance.size();i++) {
if (i==framebuffer.luminance.size()) {
if (!current_vd)
break;
_debug_draw_shadow(current_vd->lum_color, Rect2( ofs, debug_size ));
} else {
_debug_draw_shadow(framebuffer.luminance[i].color, Rect2( ofs, debug_size ));
}
ofs.x+=debug_size.x/2;
if ( (ofs.x+debug_size.x) > viewport.width ) {
ofs.x=0;
@ -7936,9 +8001,14 @@ void RasterizerGLES2::_update_framebuffer() {
GLuint format_rgba = GL_RGBA;
GLuint format_rgb = use_fp16_fb?_GL_RGB16F_EXT:GL_RGB;
GLuint format_type = use_fp16_fb?_GL_HALF_FLOAT_OES:GL_UNSIGNED_BYTE;
GLuint format_luminance = use_fp16_fb?_GL_RED_EXT:GL_RGBA;
/*GLuint format_luminance = use_fp16_fb?GL_RGB16F:GL_RGBA;
GLuint format_luminance_type = use_fp16_fb?(use_fu_GL_HALF_FLOAT_OES):GL_UNSIGNED_BYTE;
GLuint format_luminance_components = use_fp16_fb?GL_RGB:GL_RGBA;*/
GLuint format_luminance = use_fp16_fb?_GL_RG_EXT:GL_RGBA;
GLuint format_luminance_type = use_fp16_fb?(full_float_fb_supported?GL_FLOAT:_GL_HALF_FLOAT_OES):GL_UNSIGNED_BYTE;
GLuint format_luminance_components = use_fp16_fb?_GL_RED_EXT:GL_RGBA;
GLuint format_luminance_components = use_fp16_fb?_GL_RG_EXT:GL_RGBA;
@ -8082,8 +8152,8 @@ void RasterizerGLES2::_update_framebuffer() {
glGenTextures(1, &lb.color);
glBindTexture(GL_TEXTURE_2D, lb.color);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, format_luminance, lb.size, lb.size, 0,

View File

@ -163,8 +163,10 @@ class RasterizerGLES2 : public Rasterizer {
String vertex_code;
String fragment_code;
String light_code;
int vertex_line;
int fragment_line;
int light_line;
VS::ShaderMode mode;
uint32_t custom_code_id;
@ -193,6 +195,7 @@ class RasterizerGLES2 : public Rasterizer {
version=1;
vertex_line=0;
fragment_line=0;
light_line=0;
can_zpass=true;
has_texscreen=false;
has_screen_uv=false;
@ -211,10 +214,9 @@ class RasterizerGLES2 : public Rasterizer {
struct Material {
bool flags[VS::MATERIAL_FLAG_MAX];
bool hints[VS::MATERIAL_HINT_MAX];
VS::MaterialShadeModel shade_model;
VS::MaterialBlendMode blend_mode;
VS::MaterialDepthDrawMode depth_draw_mode;
float line_width;
bool has_alpha;
@ -241,12 +243,10 @@ class RasterizerGLES2 : public Rasterizer {
for(int i=0;i<VS::MATERIAL_FLAG_MAX;i++)
flags[i]=false;
flags[VS::MATERIAL_FLAG_VISIBLE]=true;
for(int i=0;i<VS::MATERIAL_HINT_MAX;i++)
hints[i]=false;
hints[VS::MATERIAL_HINT_NO_DEPTH_DRAW_FOR_ALPHA]=true;
line_width=1;
has_alpha=false;
depth_draw_mode=VS::MATERIAL_DEPTH_DRAW_OPAQUE_ONLY;
blend_mode=VS::MATERIAL_BLEND_MODE_MIX;
last_pass = 0;
shader_version=0;
@ -590,7 +590,6 @@ class RasterizerGLES2 : public Rasterizer {
vars[VS::LIGHT_PARAM_SHADOW_Z_SLOPE_SCALE]=1.4;
vars[VS::LIGHT_PARAM_SHADOW_ESM_MULTIPLIER]=60.0;
vars[VS::LIGHT_PARAM_SHADOW_BLUR_PASSES]=1;
colors[VS::LIGHT_COLOR_AMBIENT]=Color(0,0,0);
colors[VS::LIGHT_COLOR_DIFFUSE]=Color(1,1,1);
colors[VS::LIGHT_COLOR_SPECULAR]=Color(1,1,1);
shadow_enabled=false;
@ -635,8 +634,9 @@ class RasterizerGLES2 : public Rasterizer {
fx_param[VS::ENV_FX_PARAM_DOF_BLUR_PASSES]=1;
fx_param[VS::ENV_FX_PARAM_DOF_BLUR_BEGIN]=100.0;
fx_param[VS::ENV_FX_PARAM_DOF_BLUR_RANGE]=10.0;
fx_param[VS::ENV_FX_PARAM_HDR_TONEMAPPER]=VS::ENV_FX_HDR_TONE_MAPPER_LINEAR;
fx_param[VS::ENV_FX_PARAM_HDR_EXPOSURE]=0.4;
fx_param[VS::ENV_FX_PARAM_HDR_SCALAR]=1.0;
fx_param[VS::ENV_FX_PARAM_HDR_WHITE]=1.0;
fx_param[VS::ENV_FX_PARAM_HDR_GLOW_TRESHOLD]=0.95;
fx_param[VS::ENV_FX_PARAM_HDR_GLOW_SCALE]=0.2;
fx_param[VS::ENV_FX_PARAM_HDR_MIN_LUMINANCE]=0.4;
@ -1172,9 +1172,11 @@ public:
virtual void shader_set_mode(RID p_shader,VS::ShaderMode p_mode);
virtual VS::ShaderMode shader_get_mode(RID p_shader) const;
virtual void shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,int p_vertex_ofs=0,int p_fragment_ofs=0);
virtual void shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,const String& p_light,int p_vertex_ofs=0,int p_fragment_ofs=0,int p_light_ofs=0);
virtual String shader_get_fragment_code(RID p_shader) const;
virtual String shader_get_vertex_code(RID p_shader) const;
virtual String shader_get_light_code(RID p_shader) const;
virtual void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const;
@ -1192,11 +1194,8 @@ public:
virtual void material_set_flag(RID p_material, VS::MaterialFlag p_flag,bool p_enabled);
virtual bool material_get_flag(RID p_material,VS::MaterialFlag p_flag) const;
virtual void material_set_hint(RID p_material, VS::MaterialHint p_hint,bool p_enabled);
virtual bool material_get_hint(RID p_material,VS::MaterialHint p_hint) const;
virtual void material_set_shade_model(RID p_material, VS::MaterialShadeModel p_model);
virtual VS::MaterialShadeModel material_get_shade_model(RID p_material) const;
virtual void material_set_depth_draw_mode(RID p_material, VS::MaterialDepthDrawMode p_mode);
virtual VS::MaterialDepthDrawMode material_get_depth_draw_mode(RID p_material) const;
virtual void material_set_blend_mode(RID p_material,VS::MaterialBlendMode p_mode);
virtual VS::MaterialBlendMode material_get_blend_mode(RID p_material) const;

View File

@ -181,6 +181,13 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
flags->use_tangent_interp=true;
}
}
if (type==ShaderLanguage::SHADER_MATERIAL_LIGHT) {
if (vnode->name==vname_light) {
uses_light=true;
}
}
code=replace_string(vnode->name);
@ -410,7 +417,7 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
}
void ShaderCompilerGLES2::compile_node(SL::ProgramNode *p_program) {
Error ShaderCompilerGLES2::compile_node(SL::ProgramNode *p_program) {
// feed the local replace table and global code
global_code="";
@ -423,8 +430,15 @@ void ShaderCompilerGLES2::compile_node(SL::ProgramNode *p_program) {
for(Map<StringName,SL::Uniform>::Element *E=p_program->uniforms.front();E;E=E->next()) {
String uline="uniform "+_typestr(E->get().type)+" _"+E->key().operator String()+";"ENDL;
global_code+=uline;
if (uniforms) {
//if (uniforms->has(E->key())) {
// //repeated uniform, error
// ERR_EXPLAIN("Uniform already exists from other shader: "+String(E->key()));
// ERR_FAIL_COND_V(uniforms->has(E->key()),ERR_ALREADY_EXISTS);
//
// }
SL::Uniform u = E->get();
u.order+=ubase;
uniforms->insert(E->key(),u);
@ -474,12 +488,14 @@ void ShaderCompilerGLES2::compile_node(SL::ProgramNode *p_program) {
print_line(code);
code=code.replace("\n","");
#endif
return OK;
}
void ShaderCompilerGLES2::create_glsl_120_code(void *p_str,SL::ProgramNode *p_program) {
Error ShaderCompilerGLES2::create_glsl_120_code(void *p_str,SL::ProgramNode *p_program) {
ShaderCompilerGLES2 *compiler=(ShaderCompilerGLES2*)p_str;
compiler->compile_node(p_program);
return compiler->compile_node(p_program);
}
@ -505,6 +521,7 @@ Error ShaderCompilerGLES2::compile(const String& p_code, ShaderLanguage::ShaderT
uses_alpha=false;
uses_discard=false;
uses_screen_uv=false;
uses_light=false;
vertex_code_writes_vertex=false;
uniforms=r_uniforms;
flags=&r_flags;
@ -533,6 +550,7 @@ Error ShaderCompilerGLES2::compile(const String& p_code, ShaderLanguage::ShaderT
r_flags.vertex_code_writes_vertex=vertex_code_writes_vertex;
r_flags.uses_discard=uses_discard;
r_flags.uses_screen_uv=uses_screen_uv;
r_flags.uses_light=uses_light;
r_code_line=code;
r_globals_line=global_code;
return OK;
@ -577,6 +595,7 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
replace_table["clamp"]= "clamp";
replace_table["mix" ]= "mix";
replace_table["step" ]= "step";
replace_table["smoothstep" ]= "smoothstep";
replace_table["length"]= "length";
replace_table["distance"]= "distance";
replace_table["dot" ]= "dot";
@ -628,6 +647,7 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
mode_replace_table[1]["DIFFUSE_ALPHA"]="diffuse";
mode_replace_table[1]["SPECULAR"]="specular";
mode_replace_table[1]["EMISSION"]="emission";
mode_replace_table[1]["SHADE_PARAM"]="shade_param";
mode_replace_table[1]["SPEC_EXP"]="specular_exp";
mode_replace_table[1]["GLOW"]="glow";
mode_replace_table[1]["DISCARD"]="discard_";
@ -638,6 +658,26 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
//mode_replace_table[1]["SCREEN_TEXEL_SIZE"]="SCREEN_TEXEL_SIZE";
mode_replace_table[1]["TIME"]="time";
//////////////
mode_replace_table[2]["NORMAL"]="normal";
//mode_replace_table[2]["POSITION"]="IN_POSITION";
mode_replace_table[2]["LIGHT_DIR"]="light_dir";
mode_replace_table[2]["LIGHT_DIFFUSE"]="light_diffuse";
mode_replace_table[2]["LIGHT_SPECULAR"]="light_specular";
mode_replace_table[2]["EYE_VEC"]="eye_vec";
mode_replace_table[2]["DIFFUSE"]="mdiffuse";
mode_replace_table[2]["SPECULAR"]="specular";
mode_replace_table[2]["SPECULAR_EXP"]="specular_exp";
mode_replace_table[2]["SHADE_PARAM"]="shade_param";
mode_replace_table[2]["LIGHT"]="light";
mode_replace_table[2]["POINT_COORD"]="gl_PointCoord";
mode_replace_table[2]["TIME"]="time";
//mode_replace_table[2]["SCREEN_POS"]="SCREEN_POS";
//mode_replace_table[2]["SCREEN_TEXEL_SIZE"]="SCREEN_TEXEL_SIZE";
out_vertex_name="VERTEX";
vname_discard="DISCARD";
@ -651,5 +691,6 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
vname_var1_interp="VAR1";
vname_var2_interp="VAR2";
vname_vertex="VERTEX";
vname_light="LIGHT";
}

View File

@ -39,10 +39,11 @@ private:
ShaderLanguage::ProgramNode *program_node;
String dump_node_code(ShaderLanguage::Node *p_node,int p_level,bool p_assign_left=false);
void compile_node(ShaderLanguage::ProgramNode *p_program);
static void create_glsl_120_code(void *p_str,ShaderLanguage::ProgramNode *p_program);
Error compile_node(ShaderLanguage::ProgramNode *p_program);
static Error create_glsl_120_code(void *p_str,ShaderLanguage::ProgramNode *p_program);
bool uses_light;
bool uses_texscreen;
bool uses_texpos;
bool uses_alpha;
@ -62,6 +63,7 @@ private:
StringName vname_var1_interp;
StringName vname_var2_interp;
StringName vname_vertex;
StringName vname_light;
Map<StringName,ShaderLanguage::Uniform> *uniforms;
@ -73,7 +75,7 @@ private:
String replace_string(const StringName& p_string);
Map<StringName,StringName> mode_replace_table[2];
Map<StringName,StringName> mode_replace_table[3];
Map<StringName,StringName> replace_table;
public:
@ -92,6 +94,7 @@ public:
bool use_tangent_interp;
bool use_var1_interp;
bool use_var2_interp;
bool uses_light;
};
Error compile(const String& p_code, ShaderLanguage::ShaderType p_type, String& r_code_line, String& r_globals_line, Flags& r_flags, Map<StringName,ShaderLanguage::Uniform> *r_uniforms=NULL);

View File

@ -285,6 +285,7 @@ ShaderGLES2::Version* ShaderGLES2::get_current_version() {
//keep them around during the function
CharString code_string;
CharString code_string2;
CharString code_globals;
@ -437,6 +438,14 @@ ShaderGLES2::Version* ShaderGLES2::get_current_version() {
}
strings.push_back(fragment_code2.get_data());
if (cc) {
code_string2=cc->light.ascii();
strings.push_back(code_string2.get_data());
}
strings.push_back(fragment_code3.get_data());
#ifdef DEBUG_SHADER
DEBUG_PRINT("\nFragment Code:\n\n"+String(code_string.get_data()));
for(int i=0;i<strings.size();i++) {
@ -630,6 +639,7 @@ void ShaderGLES2::setup(const char** p_conditional_defines, int p_conditional_co
{
String globals_tag="\nFRAGMENT_SHADER_GLOBALS";
String code_tag="\nFRAGMENT_SHADER_CODE";
String light_code_tag="\nLIGHT_SHADER_CODE";
String code = fragment_code;
int cpos = code.find(globals_tag);
if (cpos==-1) {
@ -645,7 +655,16 @@ void ShaderGLES2::setup(const char** p_conditional_defines, int p_conditional_co
} else {
fragment_code1=code.substr(0,cpos).ascii();
fragment_code2=code.substr(cpos+code_tag.length(),code.length()).ascii();
String code2 = code.substr(cpos+code_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();
fragment_code3 = code2.substr(cpos+light_code_tag.length(),code2.length()).ascii();
}
}
}
}
@ -696,7 +715,7 @@ uint32_t ShaderGLES2::create_custom_shader() {
return last_custom_code++;
}
void ShaderGLES2::set_custom_shader_code(uint32_t p_code_id, const String& p_vertex, const String& p_vertex_globals,const String& p_fragment, const String& p_fragment_globals,const Vector<StringName>& p_uniforms,const Vector<const char*> &p_custom_defines) {
void ShaderGLES2::set_custom_shader_code(uint32_t p_code_id, const String& p_vertex, const String& p_vertex_globals,const String& p_fragment,const String& p_light, const String& p_fragment_globals,const Vector<StringName>& p_uniforms,const Vector<const char*> &p_custom_defines) {
ERR_FAIL_COND(!custom_code_map.has(p_code_id));
CustomCode *cc=&custom_code_map[p_code_id];
@ -705,6 +724,7 @@ void ShaderGLES2::set_custom_shader_code(uint32_t p_code_id, const String& p_ver
cc->vertex_globals=p_vertex_globals;
cc->fragment=p_fragment;
cc->fragment_globals=p_fragment_globals;
cc->light=p_light;
cc->custom_uniforms=p_uniforms;
cc->custom_defines=p_custom_defines;
cc->version++;

View File

@ -98,6 +98,7 @@ private:
String vertex_globals;
String fragment;
String fragment_globals;
String light;
uint32_t version;
Vector<StringName> custom_uniforms;
Vector<const char*> custom_defines;
@ -157,6 +158,7 @@ private:
CharString fragment_code0;
CharString fragment_code1;
CharString fragment_code2;
CharString fragment_code3;
CharString vertex_code0;
CharString vertex_code1;
@ -292,7 +294,7 @@ public:
void clear_caches();
uint32_t create_custom_shader();
void set_custom_shader_code(uint32_t p_id,const String& p_vertex, const String& p_vertex_globals,const String& p_fragment, const String& p_fragment_globals,const Vector<StringName>& p_uniforms,const Vector<const char*> &p_custom_defines);
void set_custom_shader_code(uint32_t p_id,const String& p_vertex, const String& p_vertex_globals,const String& p_fragment,const String& p_p_light,const String& p_fragment_globals,const Vector<StringName>& p_uniforms,const Vector<const char*> &p_custom_defines);
void set_custom_shader(uint32_t p_id);
void free_custom_shader(uint32_t p_id);

View File

@ -78,7 +78,7 @@ uniform highp float hdr_glow_scale;
uniform sampler2D hdr_source;
uniform highp float tonemap_exposure;
uniform highp float tonemap_white;
#endif
#ifdef USE_BCS
@ -318,6 +318,7 @@ void main() {
#ifdef USE_HDR
highp float white_mult = 1.0;
#ifdef USE_8BIT_HDR
highp vec4 _mult = vec4(1.0 / (256.0 * 256.0 * 256.0),1.0 / (256.0 * 256.0),1.0 / 256.0,1);
@ -325,11 +326,37 @@ void main() {
color.rgb*=LUM_RANGE;
hdr_lum*=LUM_RANGE; //restore to full range
#else
highp float hdr_lum = texture2D( hdr_source, vec2(0.0) ).r;
highp vec2 lv = texture2D( hdr_source, vec2(0.0) ).rg;
highp float hdr_lum = lv.r;
#ifdef USE_AUTOWHITE
white_mult=lv.g;
#endif
#endif
#ifdef USE_REINHARDT_TONEMAPPER
float src_lum = dot(color.rgb,vec3(0.3, 0.58, 0.12));
float lp = tonemap_exposure/hdr_lum*src_lum;
float white = tonemap_white;
#ifdef USE_AUTOWHITE
white_mult = (white_mult + 1.0 * white_mult);
white_mult*=white_mult;
white*=white_mult;
#endif
lp = ( lp * ( 1.0 + ( lp / ( white) ) ) ) / ( 1.0 + lp );
color.rgb*=lp;
#else
#ifdef USE_LOG_TONEMAPPER
color.rgb = tonemap_exposure * log(color.rgb+1.0)/log(hdr_lum+1.0);
#else
highp float tone_scale = tonemap_exposure / hdr_lum; //only linear supported
color.rgb*=tone_scale;
#endif
#endif
#endif
@ -393,7 +420,11 @@ void main() {
#ifdef USE_HDR_COPY
//highp float lum = dot(color.rgb,highp vec3(1.0/3.0,1.0/3.0,1.0/3.0));
highp float lum = max(color.r,max(color.g,color.b));
//highp float lum = max(color.r,max(color.g,color.b));
highp float lum = dot(color.rgb,vec3(0.3, 0.58, 0.12));
//lum=log(lum+0.0001); //everyone does it
#ifdef USE_8BIT_HDR
highp vec4 comp = fract(lum * vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0));
comp -= comp.xxyz * vec4(0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);
@ -422,21 +453,33 @@ void main() {
#else
highp float lum_accum = color.r;
lum_accum += texture2D( source, uv_interp+vec2(-pixel_size.x,-pixel_size.y) ).r;
lum_accum += texture2D( source, uv_interp+vec2(0.0,-pixel_size.y) ).r;
lum_accum += texture2D( source, uv_interp+vec2(pixel_size.x,-pixel_size.y) ).r;
lum_accum += texture2D( source, uv_interp+vec2(-pixel_size.x,0.0) ).r;
lum_accum += texture2D( source, uv_interp+vec2(pixel_size.x,0.0) ).r;
lum_accum += texture2D( source, uv_interp+vec2(-pixel_size.x,pixel_size.y) ).r;
lum_accum += texture2D( source, uv_interp+vec2(0.0,pixel_size.y) ).r;
lum_accum += texture2D( source, uv_interp+vec2(pixel_size.x,pixel_size.y) ).r;
highp float lum_max = color.g;
#define LUM_REDUCE(m_uv) \
{\
vec2 val = texture2D( source, uv_interp+m_uv ).rg;\
lum_accum+=val.x;\
lum_max=max(val.y,lum_max);\
}
LUM_REDUCE( vec2(-pixel_size.x,-pixel_size.y) );
LUM_REDUCE( vec2(0.0,-pixel_size.y) );
LUM_REDUCE( vec2(pixel_size.x,-pixel_size.y) );
LUM_REDUCE( vec2(-pixel_size.x,0.0) );
LUM_REDUCE( vec2(pixel_size.x,0.0) );
LUM_REDUCE( vec2(-pixel_size.x,pixel_size.y) );
LUM_REDUCE( vec2(0.0,pixel_size.y) );
LUM_REDUCE( vec2(pixel_size.x,pixel_size.y) );
lum_accum/=9.0;
#endif
#ifdef USE_HDR_STORE
#ifdef USE_8BIT_HDR
//lum_accum=exp(lum_accum);
#ifdef USE_8BIT_HDR
highp float vd_lum = dot(texture2D( source_vd_lum, vec2(0.0) ), _multcv );
lum_accum = clamp( vd_lum + (lum_accum-vd_lum)*hdr_time_delta*hdr_exp_adj_speed,min_luminance*(1.0/LUM_RANGE),max_luminance*(1.0/LUM_RANGE));
#else
@ -450,6 +493,10 @@ void main() {
highp vec4 comp = fract(lum_accum * vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0));
comp -= comp.xxyz * vec4(0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);
color=comp;
#else
#ifdef USE_AUTOWHITE
color.r=lum_accum;
color.g=lum_max;
#else
color.rgb=vec3(lum_accum);
#endif
@ -457,6 +504,10 @@ void main() {
#endif
#endif
#ifdef USE_RGBE
color.rgb = pow(color.rgb,color.a*255.0-(8.0+128.0));

View File

@ -115,7 +115,6 @@ uniform vec3 light_pos;
uniform vec3 light_direction;
uniform vec3 light_attenuation;
uniform vec3 light_spot_attenuation;
uniform vec3 light_ambient;
uniform vec3 light_diffuse;
uniform vec3 light_specular;
@ -132,6 +131,7 @@ varying vec3 specular_interp;
uniform float time;
uniform float instance_id;
uniform vec3 ambient_light;
#if !defined(USE_DEPTH_SHADOWS) && defined(USE_SHADOW_PASS)
@ -404,7 +404,7 @@ VERTEX_SHADER_CODE
float NdotL = max(0.0,dot( normal_interp, light_dir ));
vec3 half_vec = normalize(light_dir + eye_vec);
float eye_light = max(dot(normal_interp, half_vec),0.0);
diffuse_interp.rgb=light_diffuse * NdotL * attenuation;// + light_ambient;
diffuse_interp.rgb=light_diffuse * NdotL * attenuation;
diffuse_interp.a=attenuation;
if (NdotL > 0.0) {
specular_interp=light_specular * pow( eye_light, vertex_specular_exp ) * attenuation;
@ -510,28 +510,16 @@ uniform vec3 light_pos;
uniform vec3 light_direction;
uniform vec3 light_attenuation;
uniform vec3 light_spot_attenuation;
uniform vec3 light_ambient;
uniform vec3 light_diffuse;
uniform vec3 light_specular;
uniform vec3 ambient_light;
#ifdef USE_FRAGMENT_LIGHTING
vec3 process_shade(in vec3 normal, in vec3 light_dir, in vec3 eye_vec, in vec3 diffuse, in vec3 specular, in float specular_exp, in float attenuation) {
float NdotL = max(0.0,dot( normal, light_dir ));
vec3 half_vec = normalize(light_dir + eye_vec);
float eye_light = max(dot(normal, half_vec),0.0);
vec3 ret = light_ambient *diffuse + light_diffuse * diffuse * NdotL * attenuation;
if (NdotL > 0.0) {
ret+=light_specular * specular * pow( eye_light, specular_exp ) * attenuation;
}
return ret;
}
# ifdef USE_DEPTH_SHADOWS
# else
# endif
@ -770,9 +758,12 @@ void main() {
bool discard_=false;
#endif
{
FRAGMENT_SHADER_CODE
}
#if defined(ENABLE_DISCARD)
if (discard_) {
@ -1009,9 +1000,8 @@ FRAGMENT_SHADER_CODE
#ifdef LIGHT_TYPE_DIRECTIONAL
vec3 light_dir = -light_direction;
float light_attenuation = light_attenuation.r;
float attenuation = light_attenuation.r;
diffuse.rgb=process_shade(normal,light_dir,eye_vec,diffuse.rgb,specular,specular_exp,shadow_attenuation)*light_attenuation;
#endif
@ -1023,7 +1013,6 @@ FRAGMENT_SHADER_CODE
light_dir=normalize(light_dir);
float attenuation = pow( max(1.0 - dist/radius, 0.0), light_attenuation.b ) * light_attenuation.r;
diffuse.rgb=process_shade(normal,light_dir,eye_vec,diffuse.rgb,specular,specular_exp,shadow_attenuation)*attenuation;
#endif
@ -1040,10 +1029,39 @@ FRAGMENT_SHADER_CODE
float rim = (1.0 - scos) / (1.0 - spot_cutoff);
attenuation *= 1.0 - pow( rim, light_spot_attenuation.g);
diffuse.rgb=process_shade(normal,light_dir,eye_vec,diffuse.rgb,specular,specular_exp,shadow_attenuation)*attenuation;
#endif
# if defined(LIGHT_TYPE_DIRECTIONAL) || defined(LIGHT_TYPE_OMNI) || defined (LIGHT_TYPE_SPOT)
{
vec3 mdiffuse = diffuse.rgb;
vec3 light;
#if defined(USE_LIGHT_SHADER_CODE)
//light is written by the light shader
{
LIGHT_SHADER_CODE
}
#else
//traditional lambert + blinn
float NdotL = max(0.0,dot( normal, light_dir ));
vec3 half_vec = normalize(light_dir + eye_vec);
float eye_light = max(dot(normal, half_vec),0.0);
light = light_diffuse * mdiffuse * NdotL;
if (NdotL > 0.0) {
light+=specular * light_specular * pow( eye_light, specular_exp );
}
#endif
diffuse.rgb = ambient_light *diffuse.rgb + light * attenuation * shadow_attenuation;
}
# endif
# if !defined(LIGHT_TYPE_DIRECTIONAL) && !defined(LIGHT_TYPE_OMNI) && !defined (LIGHT_TYPE_SPOT)
//none
@ -1062,7 +1080,7 @@ FRAGMENT_SHADER_CODE
#ifdef USE_VERTEX_LIGHTING
vec3 ambient = light_ambient*diffuse.rgb;
vec3 ambient = ambient_light*diffuse.rgb;
# if defined(LIGHT_TYPE_OMNI) || defined (LIGHT_TYPE_SPOT)
ambient*=diffuse_interp.a; //attenuation affects ambient too
# endif

View File

@ -211,6 +211,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
while (I) {
I->get()=unescape_cmdline(I->get().strip_escapes());
// print_line("CMD: "+I->get());
I=I->next();
}
@ -223,6 +224,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
String game_path=".";
String debug_mode;
String debug_host;
String main_pack;
int rtm=-1;
String remotefs;
@ -237,9 +239,9 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
I=args.front();
packed_data = PackedData::get_singleton();
if (!packed_data)
packed_data = memnew(PackedData);
packed_data = PackedData::get_singleton();
if (!packed_data)
packed_data = memnew(PackedData);
#ifdef MINIZIP_ENABLED
packed_data->add_pack_source(ZipArchive::get_singleton());
@ -425,6 +427,17 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
goto error;
};
} else if (I->get() == "-main_pack") {
if (I->next()) {
main_pack=I->next()->get();
N = I->next()->next();
} else {
goto error;
};
} else if (I->get()=="-debug" || I->get()=="-d") {
debug_mode="local";
} else if (I->get()=="-editor_scene") {
@ -541,7 +554,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
#endif
if (globals->setup(game_path)!=OK) {
if (globals->setup(game_path,main_pack)!=OK) {
#ifdef TOOLS_ENABLED
editor=false;

View File

@ -65,7 +65,7 @@ bool GDScriptLanguage::validate(const String& p_script, int &r_line_error,int &r
GDParser parser;
Error err = parser.parse(p_script,p_path.get_base_dir());
Error err = parser.parse(p_script,p_path.get_base_dir(),true);
if (err) {
r_line_error=parser.get_error_line();
r_col_error=parser.get_error_column();

View File

@ -29,6 +29,7 @@
#include "gd_parser.h"
#include "print_string.h"
#include "io/resource_loader.h"
#include "os/file_access.h"
/* TODO:
*Property reduce constant expressions
@ -224,12 +225,23 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
String path = tokenizer->get_token_constant();
if (!path.is_abs_path() && base_path!="")
path=base_path+"/"+path;
path = path.replace("///","//");
path = path.replace("///","//");
Ref<Resource> res = ResourceLoader::load(path);
if (!res.is_valid()) {
_set_error("Can't preload resource at path: "+path);
return NULL;
Ref<Resource> res;
if (!validating) {
//this can be too slow for just validating code
res = ResourceLoader::load(path);
if (!res.is_valid()) {
_set_error("Can't preload resource at path: "+path);
return NULL;
}
} else {
if (!FileAccess::exists(path)) {
_set_error("Can't preload resource at path: "+path);
return NULL;
}
}
tokenizer->advance();
@ -2468,12 +2480,13 @@ Error GDParser::parse_bytecode(const Vector<uint8_t> &p_bytecode,const String& p
}
Error GDParser::parse(const String& p_code,const String& p_base_path) {
Error GDParser::parse(const String& p_code,const String& p_base_path,bool p_just_validate) {
GDTokenizerText *tt = memnew( GDTokenizerText );
tt->set_code(p_code);
validating=p_just_validate;
tokenizer=tt;
Error ret = _parse(p_base_path);
memdelete(tt);
@ -2498,6 +2511,7 @@ void GDParser::clear() {
head=NULL;
list=NULL;
validating=false;
error_set=false;
tab_level.clear();
tab_level.push_back(0);

View File

@ -356,6 +356,7 @@ private:
template<class T>
T* alloc_node();
bool validating;
int parenthesis;
bool error_set;
String error;
@ -392,7 +393,7 @@ public:
String get_error() const;
int get_error_line() const;
int get_error_column() const;
Error parse(const String& p_code,const String& p_base_path="");
Error parse(const String& p_code, const String& p_base_path="", bool p_just_validate=false);
Error parse_bytecode(const Vector<uint8_t> &p_bytecode,const String& p_base_path="");
const Node *get_parse_tree() const;

View File

@ -258,7 +258,11 @@ bool EditorExportPlatformAndroid::_set(const StringName& p_name, const Variant&
String n=p_name;
if (n=="version/code")
if (n=="custom_package/debug")
custom_debug_package=p_value;
else if (n=="custom_package/release")
custom_release_package=p_value;
else if (n=="version/code")
version_code=p_value;
else if (n=="version/name")
version_name=p_value;
@ -317,8 +321,11 @@ bool EditorExportPlatformAndroid::_set(const StringName& p_name, const Variant&
bool EditorExportPlatformAndroid::_get(const StringName& p_name,Variant &r_ret) const{
String n=p_name;
if (n=="version/code")
if (n=="custom_package/debug")
r_ret=custom_debug_package;
else if (n=="custom_package/release")
r_ret=custom_release_package;
else if (n=="version/code")
r_ret=version_code;
else if (n=="version/name")
r_ret=version_name;
@ -389,7 +396,7 @@ void EditorExportPlatformAndroid::_get_property_list( List<PropertyInfo> *p_list
p_list->push_back( PropertyInfo( Variant::STRING, "keystore/release_user" ) );
p_list->push_back( PropertyInfo( Variant::BOOL, "apk_expansion/enable" ) );
p_list->push_back( PropertyInfo( Variant::STRING, "apk_expansion/SALT" ) );
p_list->push_back( PropertyInfo( Variant::STRING, "apk_expansion/pubic_key" ) );
p_list->push_back( PropertyInfo( Variant::STRING, "apk_expansion/public_key",PROPERTY_HINT_MULTILINE_TEXT ) );
const char **perms = android_perms;
while(*perms) {
@ -1095,6 +1102,12 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
ep.step("Adding Files..",1);
Error err=OK;
Vector<String> cl = cmdline.strip_edges().split(" ");
for(int i=0;i<cl.size();i++) {
if (cl[i].strip_edges().length()==0) {
cl.remove(i);
i--;
}
}
if (p_dumb) {
@ -1123,12 +1136,12 @@ Error EditorExportPlatformAndroid::export_project(const String& p_path, bool p_d
}
err = save_pack(pf);
memdelete(pf);
cl.push_back("-main_pack");
cl.push_back(apkfname);
cl.push_back("-main_pack_md5");
cl.push_back("-use_apk_expansion");
cl.push_back("-apk_expansion_md5");
cl.push_back(FileAccess::get_md5(fullpath));
cl.push_back("-main_pack_cfg");
cl.push_back(apk_expansion_salt+","+apk_expansion_pkey);
cl.push_back("-apk_expansion_key");
cl.push_back(apk_expansion_pkey.strip_edges());
} else {
@ -1562,10 +1575,10 @@ bool EditorExportPlatformAndroid::can_export(String *r_error) const {
if (apk_expansion) {
if (apk_expansion_salt=="") {
valid=false;
err+="Invalid SALT for apk expansion.\n";
}
//if (apk_expansion_salt=="") {
// valid=false;
// err+="Invalid SALT for apk expansion.\n";
//}
if (apk_expansion_pkey=="") {
valid=false;
err+="Invalid public key for apk expansion.\n";

View File

@ -63,6 +63,10 @@ import com.android.godot.input.*;
import java.io.InputStream;
import javax.microedition.khronos.opengles.GL10;
import java.security.MessageDigest;
import java.io.File;
import java.io.FileInputStream;
import java.util.LinkedList;
public class Godot extends Activity implements SensorEventListener
{
@ -138,7 +142,11 @@ public class Godot extends Activity implements SensorEventListener
*/
private String[] command_line;
public GodotView mView;
private boolean godot_initialized=false;
private SensorManager mSensorManager;
private Sensor mAccelerometer;
@ -190,9 +198,9 @@ public class Godot extends Activity implements SensorEventListener
// GodotEditText layout
GodotEditText edittext = new GodotEditText(this);
edittext.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
edittext.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
// ...add to FrameLayout
layout.addView(edittext);
layout.addView(edittext);
mView = new GodotView(getApplication(),io,use_gl2, this);
layout.addView(mView,new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
@ -216,46 +224,89 @@ public class Godot extends Activity implements SensorEventListener
private String[] getCommandLine() {
InputStream is;
try {
is = getAssets().open("_cl_");
byte[] len = new byte[4];
int r = is.read(len);
if (r<4) {
System.out.printf("**ERROR** Wrong cmdline length.\n");
Log.d("GODOT", "**ERROR** Wrong cmdline length.\n");
return new String[0];
}
int argc=((int)(len[3]&0xFF)<<24) | ((int)(len[2]&0xFF)<<16) | ((int)(len[1]&0xFF)<<8) | ((int)(len[0]&0xFF));
String[] cmdline = new String[argc];
InputStream is;
try {
is = getAssets().open("/_cl_");
byte[] len = new byte[4];
int r = is.read(len);
if (r<4) {
System.out.printf("**ERROR** Wrong cmdline length.\n");
return new String[0];
for(int i=0;i<argc;i++) {
r = is.read(len);
if (r<4) {
Log.d("GODOT", "**ERROR** Wrong cmdline param lenght.\n");
return new String[0];
}
int strlen=((int)(len[3]&0xFF)<<24) | ((int)(len[2]&0xFF)<<16) | ((int)(len[1]&0xFF)<<8) | ((int)(len[0]&0xFF));
if (strlen>65535) {
Log.d("GODOT", "**ERROR** Wrong command len\n");
return new String[0];
}
byte[] arg = new byte[strlen];
r = is.read(arg);
if (r==strlen) {
cmdline[i]=new String(arg,"UTF-8");
}
}
int argc=((int)(len[3])<<24) | ((int)(len[2])<<16) | ((int)(len[1])<<8) | ((int)(len[0]));
String[] cmdline = new String[argc];
for(int i=0;i<argc;i++) {
r = is.read(len);
if (r<4) {
System.out.printf("**ERROR** Wrong cmdline param lenght.\n");
return new String[0];
}
int strlen=((int)(len[3])<<24) | ((int)(len[2])<<16) | ((int)(len[1])<<8) | ((int)(len[0]));
if (strlen>65535) {
System.out.printf("**ERROR** Wrong command len\n");
return new String[0];
}
byte[] arg = new byte[strlen];
r = is.read(arg);
if (r!=strlen) {
cmdline[i]=new String(arg,"UTF-8");
}
}
return cmdline;
} catch (Exception e) {
e.printStackTrace();
System.out.printf("**ERROR** No commandline.\n");
Log.d("GODOT", "**ERROR** Exception " + e.getClass().getName() + ":" + e.getMessage());
return new String[0];
}
}
String expansion_pack_path;
private void initializeGodot() {
if (expansion_pack_path!=null) {
String[] new_cmdline;
int cll=0;
if (command_line!=null) {
new_cmdline = new String[ command_line.length + 2 ];
cll=command_line.length;
for(int i=0;i<command_line.length;i++) {
new_cmdline[i]=command_line[i];
}
} else {
new_cmdline = new String[ 2 ];
}
new_cmdline[cll]="-main_pack";
new_cmdline[cll+1]=expansion_pack_path;
command_line=new_cmdline;
}
io = new GodotIO(this);
io.unique_id = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
GodotLib.io=io;
GodotLib.initialize(this,io.needsReloadHooks(),command_line);
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
result_callback = null;
mPaymentsManager = PaymentsManager.createManager(this).initService();
godot_initialized=true;
}
@Override protected void onCreate(Bundle icicle) {
System.out.printf("** GODOT ACTIVITY CREATED HERE ***\n");
@ -267,20 +318,112 @@ public class Godot extends Activity implements SensorEventListener
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//check for apk expansion API
if (true) {
command_line = getCommandLine();
boolean use_apk_expansion=false;
String main_pack_md5=null;
String main_pack_key=null;
List<String> new_args = new LinkedList<String>();
io = new GodotIO(this);
io.unique_id = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
GodotLib.io=io;
GodotLib.initialize(this,io.needsReloadHooks(),getCommandLine());
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
for(int i=0;i<command_line.length;i++) {
result_callback = null;
mPaymentsManager = PaymentsManager.createManager(this).initService();
boolean has_extra = i< command_line.length -1;
if (command_line[i].equals("-use_apk_expansion")) {
use_apk_expansion=true;
} else if (has_extra && command_line[i].equals("-apk_expansion_md5")) {
main_pack_md5=command_line[i+1];
i++;
} else if (has_extra && command_line[i].equals("-apk_expansion_key")) {
main_pack_key=command_line[i+1];
i++;
} else if (command_line[i].trim().length()!=0){
new_args.add(command_line[i]);
}
}
if (new_args.isEmpty())
command_line=null;
else
command_line = new_args.toArray(new String[new_args.size()]);
if (use_apk_expansion && main_pack_md5!=null && main_pack_key!=null) {
//check that environment is ok!
if (!Environment.getExternalStorageState().equals( Environment.MEDIA_MOUNTED )) {
Log.d("GODOT", "**ERROR! No media mounted!");
//show popup and die
}
// Build the full path to the app's expansion files
try {
expansion_pack_path = Environment.getExternalStorageDirectory().toString() + "/Android/obb/"+this.getPackageName();
expansion_pack_path+="/"+"main."+getPackageManager().getPackageInfo(getPackageName(), 0).versionCode+"."+this.getPackageName()+".obb";
} catch (Exception e) {
e.printStackTrace();
}
File f = new File(expansion_pack_path);
boolean pack_valid = true;
Log.d("GODOT","**PACK** - Path "+expansion_pack_path);
if (!f.exists()) {
pack_valid=false;
Log.d("GODOT","**PACK** - File does not exist");
} else {
try {
InputStream fis = new FileInputStream(expansion_pack_path);
// Create MD5 Hash
byte[] buffer = new byte[16384];
MessageDigest complete = MessageDigest.getInstance("MD5");
int numRead;
do {
numRead = fis.read(buffer);
if (numRead > 0) {
complete.update(buffer, 0, numRead);
}
} while (numRead != -1);
fis.close();
byte[] messageDigest = complete.digest();
// Create Hex String
StringBuffer hexString = new StringBuffer();
for (int i=0; i<messageDigest.length; i++)
hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
String md5str = hexString.toString();
Log.d("GODOT","**PACK** - My MD5: "+hexString+" - APK md5: "+main_pack_md5);
if (!hexString.equals(main_pack_md5)) {
pack_valid=false;
}
} catch (Exception e) {
e.printStackTrace();
Log.d("GODOT","**PACK FAIL**");
pack_valid=false;
}
}
if (!pack_valid) {
}
}
}
initializeGodot();
// instanceSingleton( new GodotFacebook(this) );
@ -299,6 +442,8 @@ public class Godot extends Activity implements SensorEventListener
@Override protected void onPause() {
super.onPause();
if (!godot_initialized)
return;
mView.onPause();
mSensorManager.unregisterListener(this);
GodotLib.focusout();
@ -310,6 +455,9 @@ public class Godot extends Activity implements SensorEventListener
@Override protected void onResume() {
super.onResume();
if (!godot_initialized)
return;
mView.onResume();
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
GodotLib.focusin();

View File

@ -0,0 +1,27 @@
package com.android.godot;
import com.google.android.vending.expansion.downloader.DownloaderClientMarshaller;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager.NameNotFoundException;
/**
* You should start your derived downloader class when this receiver gets the message
* from the alarm service using the provided service helper function within the
* DownloaderClientMarshaller. This class must be then registered in your AndroidManifest.xml
* file with a section like this:
* <receiver android:name=".GodotDownloaderAlarmReceiver"/>
*/
public class GodotDownloaderAlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
try {
DownloaderClientMarshaller.startDownloadServiceIfRequired(context, intent, GodotDownloaderService.class);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,47 @@
package com.android.godot;
import com.google.android.vending.expansion.downloader.impl.DownloaderService;
/**
* This class demonstrates the minimal client implementation of the
* DownloaderService from the Downloader library.
*/
public class GodotDownloaderService extends DownloaderService {
// stuff for LVL -- MODIFY FOR YOUR APPLICATION!
private static final String BASE64_PUBLIC_KEY = "REPLACE THIS WITH YOUR PUBLIC KEY";
// used by the preference obfuscater
private static final byte[] SALT = new byte[] {
1, 43, -12, -1, 54, 98,
-100, -12, 43, 2, -8, -4, 9, 5, -106, -108, -33, 45, -1, 84
};
/**
* This public key comes from your Android Market publisher account, and it
* used by the LVL to validate responses from Market on your behalf.
*/
@Override
public String getPublicKey() {
return BASE64_PUBLIC_KEY;
}
/**
* This is used by the preference obfuscater to make sure that your
* obfuscated preferences are different than the ones used by other
* applications.
*/
@Override
public byte[] getSALT() {
return SALT;
}
/**
* Fill this in with the class name for your alarm receiver. We do this
* because receivers must be unique across all of Android (it's a good idea
* to make sure that your receiver is in your unique package)
*/
@Override
public String getAlarmReceiverClassName() {
return GodotDownloaderAlarmReceiver.class.getName();
}
}

View File

@ -747,8 +747,34 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env,
}
const char ** cmdline=NULL;
int cmdlen=0;
bool use_apk_expansion=false;
if (p_cmdline) {
int cmdlen = env->GetArrayLength(p_cmdline);
if (cmdlen) {
cmdline = (const char**)malloc((env->GetArrayLength(p_cmdline)+1)*sizeof(const char*));
cmdline[cmdlen]=NULL;
os_android = new OS_Android(_gfx_init_func,env,_open_uri,_get_data_dir,_get_locale, _get_model,_show_vk, _hide_vk,_set_screen_orient,_get_unique_id, _play_video, _is_video_playing, _pause_video, _stop_video);
for (int i=0; i<cmdlen; i++) {
jstring string = (jstring) env->GetObjectArrayElement(p_cmdline, i);
const char *rawString = env->GetStringUTFChars(string, 0);
if (!rawString) {
__android_log_print(ANDROID_LOG_INFO,"godot","cmdline arg %i is null\n",i);
} else {
// __android_log_print(ANDROID_LOG_INFO,"godot","cmdline arg %i is: %s\n",i,rawString);
if (strcmp(rawString,"-main_pack")==0)
use_apk_expansion=true;
}
cmdline[i]=rawString;
}
}
}
os_android = new OS_Android(_gfx_init_func,env,_open_uri,_get_data_dir,_get_locale, _get_model,_show_vk, _hide_vk,_set_screen_orient,_get_unique_id, _play_video, _is_video_playing, _pause_video, _stop_video,use_apk_expansion);
os_android->set_need_reload_hooks(p_need_reload_hook);
char wd[500];
@ -759,16 +785,6 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_initialize(JNIEnv * env,
__android_log_print(ANDROID_LOG_INFO,"godot","**SETUP");
const char ** cmdline=NULL;
int cmdlen = env->GetArrayLength(p_cmdline);
cmdline = (const char**)malloc((env->GetArrayLength(p_cmdline)+1)*sizeof(const char*));
cmdline[cmdlen]=NULL;
for (int i=0; i<cmdlen; i++) {
jstring string = (jstring) env->GetObjectArrayElement(p_cmdline, i);
const char *rawString = env->GetStringUTFChars(string, 0);
cmdline[i]=rawString;
}
#if 0
char *args[]={"-test","render",NULL};
@ -833,6 +849,7 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_quit(JNIEnv * env, jobjec
input_mutex->lock();
quit_request=true;
print_line("BACK PRESSED");
input_mutex->unlock();
}
@ -1289,7 +1306,10 @@ JNIEXPORT void JNICALL Java_com_android_godot_GodotLib_key(JNIEnv * env, jobject
} else if (val == 61453) {
ievent.key.scancode = KEY_ENTER;
ievent.key.unicode = KEY_ENTER;
}
} else if (p_scancode==4) {
quit_request=true;
}
input_mutex->lock();
key_events.push_back(ievent);
@ -1390,7 +1410,7 @@ static Variant::Type get_jni_type(const String& p_type) {
static const char* get_jni_sig(const String& p_type) {
print_line("getting sig for " + p_type);
static struct {
const char *name;
const char *sig;

View File

@ -87,11 +87,17 @@ void OS_Android::initialize_core() {
#else
FileAccess::make_default<FileAccessBufferedFA<FileAccessJAndroid> >(FileAccess::ACCESS_RESOURCES);
if (use_apk_expansion)
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_RESOURCES);
else
FileAccess::make_default<FileAccessBufferedFA<FileAccessJAndroid> >(FileAccess::ACCESS_RESOURCES);
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_USERDATA);
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_FILESYSTEM);
//FileAccessBufferedFA<FileAccessUnix>::make_default();
DirAccess::make_default<DirAccessJAndroid>(DirAccess::ACCESS_RESOURCES);
if (use_apk_expansion)
DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_RESOURCES);
else
DirAccess::make_default<DirAccessJAndroid>(DirAccess::ACCESS_RESOURCES);
DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_USERDATA);
DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_FILESYSTEM);
@ -698,9 +704,10 @@ void OS_Android::native_video_stop() {
video_stop_func();
}
OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func) {
OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func,bool p_use_apk_expansion) {
use_apk_expansion=p_use_apk_expansion;
default_videomode.width=800;
default_videomode.height=600;
default_videomode.fullscreen=true;
@ -720,10 +727,10 @@ OS_Android::OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFu
get_model_func=p_get_model_func;
get_unique_id_func=p_get_unique_id;
video_play_func = p_video_play_func;
video_is_playing_func = p_video_is_playing_func;
video_pause_func = p_video_pause_func;
video_stop_func = p_video_stop_func;
video_play_func = p_video_play_func;
video_is_playing_func = p_video_is_playing_func;
video_pause_func = p_video_pause_func;
video_stop_func = p_video_stop_func;
show_virtual_keyboard_func = p_show_vk;
hide_virtual_keyboard_func = p_hide_vk;

View File

@ -88,6 +88,7 @@ private:
bool use_gl2;
bool use_reload_hooks;
bool use_apk_expansion;
Rasterizer *rasterizer;
VisualServer *visual_server;
@ -213,7 +214,7 @@ public:
virtual void native_video_pause();
virtual void native_video_stop();
OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func);
OS_Android(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func,GetLocaleFunc p_get_locale_func,GetModelFunc p_get_model_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient,GetUniqueIDFunc p_get_unique_id, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func,bool p_use_apk_expansion);
~OS_Android();
};

View File

@ -344,7 +344,7 @@ RES Camera::_get_gizmo_geometry() const {
mat->set_line_width(4);
mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
mat->set_flag(Material::FLAG_UNSHADED,true);
mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
//mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
surface_tool->begin(Mesh::PRIMITIVE_LINES);
surface_tool->set_material(mat);

View File

@ -548,7 +548,7 @@ RES FollowCamera::_get_gizmo_geometry() const {
mat->set_line_width(4);
mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
mat->set_flag(Material::FLAG_UNSHADED,true);
mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
// mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
surface_tool->begin(Mesh::PRIMITIVE_LINES);
surface_tool->set_material(mat);

View File

@ -165,7 +165,7 @@ RES Light::_get_gizmo_geometry() const {
mat_area->set_parameter( FixedMaterial::PARAM_EMISSION,Color(0.7,0.7,0.7) );
mat_area->set_blend_mode( Material::BLEND_MODE_ADD );
mat_area->set_flag(Material::FLAG_DOUBLE_SIDED,true);
mat_area->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
// mat_area->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
Ref<FixedMaterial> mat_light( memnew( FixedMaterial ));
@ -474,7 +474,6 @@ void Light::_bind_methods() {
}*/
ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "colors/ambient"), _SCS("set_color"), _SCS("get_color"),COLOR_AMBIENT);
ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "colors/diffuse"), _SCS("set_color"), _SCS("get_color"),COLOR_DIFFUSE);
ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "colors/specular"), _SCS("set_color"), _SCS("get_color"),COLOR_SPECULAR);
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "shadow/shadow"), _SCS("set_project_shadows"), _SCS("has_project_shadows"));
@ -495,7 +494,7 @@ void Light::_bind_methods() {
BIND_CONSTANT( PARAM_SHADOW_DARKENING );
BIND_CONSTANT( PARAM_SHADOW_Z_OFFSET );
BIND_CONSTANT( COLOR_AMBIENT );
BIND_CONSTANT( COLOR_DIFFUSE );
BIND_CONSTANT( COLOR_SPECULAR );
@ -518,7 +517,7 @@ Light::Light(VisualServer::LightType p_type) {
set_parameter(PARAM_SHADOW_ESM_MULTIPLIER,60);
set_parameter(PARAM_SHADOW_BLUR_PASSES,1);
set_color( COLOR_AMBIENT, Color(0,0,0));
set_color( COLOR_DIFFUSE, Color(1,1,1));
set_color( COLOR_SPECULAR, Color(1,1,1));

View File

@ -61,7 +61,6 @@ public:
enum LightColor {
COLOR_AMBIENT=VisualServer::LIGHT_COLOR_AMBIENT,
COLOR_DIFFUSE=VisualServer::LIGHT_COLOR_DIFFUSE,
COLOR_SPECULAR=VisualServer::LIGHT_COLOR_SPECULAR
};

View File

@ -324,7 +324,7 @@ RES Particles::_get_gizmo_geometry() const {
mat->set_parameter( FixedMaterial::PARAM_EMISSION,Color(0.5,0.7,0.8) );
mat->set_blend_mode( Material::BLEND_MODE_ADD );
mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
// mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
surface_tool->begin(Mesh::PRIMITIVE_TRIANGLES);

View File

@ -106,7 +106,7 @@ RES Portal::_get_gizmo_geometry() const {
mat->set_line_width(4);
mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
mat->set_flag(Material::FLAG_UNSHADED,true);
mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
// mat->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER,true);
surface_tool->begin(Mesh::PRIMITIVE_LINES);
surface_tool->set_material(mat);

View File

@ -99,7 +99,7 @@ RES Room::_get_gizmo_geometry() const {
mat->set_line_width(4);
mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
mat->set_flag(Material::FLAG_UNSHADED,true);
mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
// mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
surface_tool->begin(Mesh::PRIMITIVE_LINES);
surface_tool->set_material(mat);

View File

@ -445,7 +445,7 @@ RES Skeleton::_get_gizmo_geometry() const {
mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
mat->set_flag(Material::FLAG_UNSHADED,true);
mat->set_flag(Material::FLAG_ONTOP,true);
mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
// mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
surface_tool->begin(Mesh::PRIMITIVE_LINES);
surface_tool->set_material(mat);

View File

@ -98,7 +98,7 @@ RES SpatialPlayer::_get_gizmo_geometry() const {
mat->set_parameter( FixedMaterial::PARAM_EMISSION,Color(0.5,0.7,0.8) );
mat->set_blend_mode( Material::BLEND_MODE_ADD );
mat->set_flag(Material::FLAG_DOUBLE_SIDED,true);
mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
// mat->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
surface_tool->begin(Mesh::PRIMITIVE_TRIANGLES);

View File

@ -101,6 +101,11 @@ void Environment::_bind_methods() {
ObjectTypeDB::bind_method(_MD("fx_set_param","param","value"),&Environment::fx_set_param);
ObjectTypeDB::bind_method(_MD("fx_get_param","param"),&Environment::fx_get_param);
ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"ambient_light/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_AMBIENT_LIGHT);
ADD_PROPERTYI( PropertyInfo(Variant::COLOR,"ambient_light/color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_AMBIENT_LIGHT_COLOR);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"ambient_light/energy",PROPERTY_HINT_RANGE,"0,64,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_AMBIENT_LIGHT_ENERGY);
ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"fxaa/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_FXAA);
ADD_PROPERTY( PropertyInfo(Variant::INT,"background/mode",PROPERTY_HINT_ENUM,"Keep,Default Color,Color,Texture,Cubemap,Texture RGBE,Cubemap RGBE"),_SCS("set_background"),_SCS("get_background"));
@ -123,8 +128,9 @@ void Environment::_bind_methods() {
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"dof_blur/begin",PROPERTY_HINT_RANGE,"0,4096,0.1"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_DOF_BLUR_BEGIN);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"dof_blur/range",PROPERTY_HINT_RANGE,"0,4096,0.1"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_DOF_BLUR_RANGE);
ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"hdr/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_HDR);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/tonemapper",PROPERTY_HINT_ENUM,"Linear,Log,Reinhardt,ReinhardtAutoWhite"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_TONEMAPPER);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/exposure",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_EXPOSURE);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/scalar",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_SCALAR);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/white",PROPERTY_HINT_RANGE,"0.01,16,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_WHITE);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/glow_treshold",PROPERTY_HINT_RANGE,"0.00,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_GLOW_TRESHOLD);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/glow_scale",PROPERTY_HINT_RANGE,"0.00,16,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_GLOW_SCALE);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/min_luminance",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_MIN_LUMINANCE);
@ -153,7 +159,7 @@ void Environment::_bind_methods() {
FX_PARAM_DOF_BLUR_BEGIN=VS::ENV_FX_PARAM_DOF_BLUR_BEGIN,
FX_PARAM_DOF_BLUR_END=VS::ENV_FX_PARAM_DOF_BLUR_END,
FX_PARAM_HDR_EXPOSURE=VS::ENV_FX_PARAM_HDR_EXPOSURE,
FX_PARAM_HDR_SCALAR=VS::ENV_FX_PARAM_HDR_SCALAR,
FX_PARAM_HDR_WHITE=VS::ENV_FX_PARAM_HDR_WHITE,
FX_PARAM_HDR_GLOW_TRESHOLD=VS::ENV_FX_PARAM_HDR_GLOW_TRESHOLD,
FX_PARAM_HDR_GLOW_SCALE=VS::ENV_FX_PARAM_HDR_GLOW_SCALE,
FX_PARAM_HDR_MIN_LUMINANCE=VS::ENV_FX_PARAM_HDR_MIN_LUMINANCE,
@ -188,6 +194,7 @@ void Environment::_bind_methods() {
BIND_CONSTANT( BG_PARAM_MAX );
BIND_CONSTANT( FX_AMBIENT_LIGHT );
BIND_CONSTANT( FX_FXAA );
BIND_CONSTANT( FX_GLOW );
BIND_CONSTANT( FX_DOF_BLUR );
@ -202,6 +209,13 @@ void Environment::_bind_methods() {
BIND_CONSTANT( FX_BLUR_BLEND_MODE_SCREEN );
BIND_CONSTANT( FX_BLUR_BLEND_MODE_SOFTLIGHT );
BIND_CONSTANT( FX_HDR_TONE_MAPPER_LINEAR );
BIND_CONSTANT( FX_HDR_TONE_MAPPER_LOG );
BIND_CONSTANT( FX_HDR_TONE_MAPPER_REINHARDT );
BIND_CONSTANT( FX_HDR_TONE_MAPPER_REINHARDT_AUTOWHITE );
BIND_CONSTANT( FX_PARAM_AMBIENT_LIGHT_COLOR );
BIND_CONSTANT( FX_PARAM_AMBIENT_LIGHT_ENERGY );
BIND_CONSTANT( FX_PARAM_GLOW_BLUR_PASSES );
BIND_CONSTANT( FX_PARAM_GLOW_BLUR_SCALE );
BIND_CONSTANT( FX_PARAM_GLOW_BLUR_STRENGTH );
@ -211,8 +225,9 @@ void Environment::_bind_methods() {
BIND_CONSTANT( FX_PARAM_DOF_BLUR_PASSES );
BIND_CONSTANT( FX_PARAM_DOF_BLUR_BEGIN );
BIND_CONSTANT( FX_PARAM_DOF_BLUR_RANGE );
BIND_CONSTANT( FX_PARAM_HDR_TONEMAPPER);
BIND_CONSTANT( FX_PARAM_HDR_EXPOSURE );
BIND_CONSTANT( FX_PARAM_HDR_SCALAR );
BIND_CONSTANT( FX_PARAM_HDR_WHITE );
BIND_CONSTANT( FX_PARAM_HDR_GLOW_TRESHOLD );
BIND_CONSTANT( FX_PARAM_HDR_GLOW_SCALE );
BIND_CONSTANT( FX_PARAM_HDR_MIN_LUMINANCE );
@ -245,6 +260,8 @@ Environment::Environment() {
for(int i=0;i<FX_MAX;i++)
set_enable_fx(Fx(i),false);
fx_set_param(FX_PARAM_AMBIENT_LIGHT_COLOR,Color(0,0,0));
fx_set_param(FX_PARAM_AMBIENT_LIGHT_ENERGY,1.0);
fx_set_param(FX_PARAM_GLOW_BLUR_PASSES,1);
fx_set_param(FX_PARAM_GLOW_BLUR_SCALE,1);
fx_set_param(FX_PARAM_GLOW_BLUR_STRENGTH,1);
@ -253,8 +270,9 @@ Environment::Environment() {
fx_set_param(FX_PARAM_DOF_BLUR_PASSES,1);
fx_set_param(FX_PARAM_DOF_BLUR_BEGIN,100.0);
fx_set_param(FX_PARAM_DOF_BLUR_RANGE,10.0);
fx_set_param(FX_PARAM_HDR_TONEMAPPER,FX_HDR_TONE_MAPPER_LINEAR);
fx_set_param(FX_PARAM_HDR_EXPOSURE,0.4);
fx_set_param(FX_PARAM_HDR_SCALAR,1.0);
fx_set_param(FX_PARAM_HDR_WHITE,1.0);
fx_set_param(FX_PARAM_HDR_GLOW_TRESHOLD,0.95);
fx_set_param(FX_PARAM_HDR_GLOW_SCALE,0.2);
fx_set_param(FX_PARAM_HDR_MIN_LUMINANCE,0.4);

View File

@ -61,6 +61,7 @@ public:
};
enum Fx {
FX_AMBIENT_LIGHT=VS::ENV_FX_AMBIENT_LIGHT,
FX_FXAA=VS::ENV_FX_FXAA,
FX_GLOW=VS::ENV_FX_GLOW,
FX_DOF_BLUR=VS::ENV_FX_DOF_BLUR,
@ -77,7 +78,16 @@ public:
FX_BLUR_BLEND_MODE_SOFTLIGHT,
};
enum FxHDRToneMapper {
FX_HDR_TONE_MAPPER_LINEAR,
FX_HDR_TONE_MAPPER_LOG,
FX_HDR_TONE_MAPPER_REINHARDT,
FX_HDR_TONE_MAPPER_REINHARDT_AUTOWHITE,
};
enum FxParam {
FX_PARAM_AMBIENT_LIGHT_COLOR=VS::ENV_FX_PARAM_AMBIENT_LIGHT_COLOR,
FX_PARAM_AMBIENT_LIGHT_ENERGY=VS::ENV_FX_PARAM_AMBIENT_LIGHT_ENERGY,
FX_PARAM_GLOW_BLUR_PASSES=VS::ENV_FX_PARAM_GLOW_BLUR_PASSES,
FX_PARAM_GLOW_BLUR_SCALE=VS::ENV_FX_PARAM_GLOW_BLUR_SCALE,
FX_PARAM_GLOW_BLUR_STRENGTH=VS::ENV_FX_PARAM_GLOW_BLUR_STRENGTH,
@ -88,7 +98,8 @@ public:
FX_PARAM_DOF_BLUR_BEGIN=VS::ENV_FX_PARAM_DOF_BLUR_BEGIN,
FX_PARAM_DOF_BLUR_RANGE=VS::ENV_FX_PARAM_DOF_BLUR_RANGE,
FX_PARAM_HDR_EXPOSURE=VS::ENV_FX_PARAM_HDR_EXPOSURE,
FX_PARAM_HDR_SCALAR=VS::ENV_FX_PARAM_HDR_SCALAR,
FX_PARAM_HDR_TONEMAPPER=VS::ENV_FX_PARAM_HDR_TONEMAPPER,
FX_PARAM_HDR_WHITE=VS::ENV_FX_PARAM_HDR_WHITE,
FX_PARAM_HDR_GLOW_TRESHOLD=VS::ENV_FX_PARAM_HDR_GLOW_TRESHOLD,
FX_PARAM_HDR_GLOW_SCALE=VS::ENV_FX_PARAM_HDR_GLOW_SCALE,
FX_PARAM_HDR_MIN_LUMINANCE=VS::ENV_FX_PARAM_HDR_MIN_LUMINANCE,

View File

@ -36,17 +36,9 @@ static const char*_flag_names[Material::FLAG_MAX]={
"invert_faces",
"unshaded",
"on_top",
"wireframe",
"billboard_sw",
"lightmap_on_uv2"
};
static const char*_hint_names[Material::HINT_MAX]={
"decal",
"opaque_pre_zpass",
"no_shadow",
"no_depth_draw",
"no_alpha_depth_draw",
};
static const Material::Flag _flag_indices[Material::FLAG_MAX]={
Material::FLAG_VISIBLE,
@ -54,15 +46,7 @@ static const Material::Flag _flag_indices[Material::FLAG_MAX]={
Material::FLAG_INVERT_FACES,
Material::FLAG_UNSHADED,
Material::FLAG_ONTOP,
Material::FLAG_WIREFRAME,
Material::FLAG_BILLBOARD_TOGGLE
};
static const Material::Hint _hint_indices[Material::HINT_MAX]={
Material::HINT_DECAL,
Material::HINT_OPAQUE_PRE_PASS,
Material::HINT_NO_SHADOW,
Material::HINT_NO_DEPTH_DRAW,
Material::FLAG_LIGHTMAP_ON_UV2
};
@ -80,20 +64,6 @@ void Material::set_flag(Flag p_flag,bool p_enabled) {
}
void Material::set_hint(Hint p_hint,bool p_enabled) {
ERR_FAIL_INDEX(p_hint,HINT_MAX);
hints[p_hint]=p_enabled;
VisualServer::get_singleton()->material_set_hint(material,(VS::MaterialHint)p_hint,p_enabled);
_change_notify();
}
bool Material::get_hint(Hint p_hint) const {
ERR_FAIL_INDEX_V(p_hint,HINT_MAX,false);
return hints[p_hint];
}
void Material::set_blend_mode(BlendMode p_blend_mode) {
ERR_FAIL_INDEX(p_blend_mode,3);
@ -108,17 +78,15 @@ Material::BlendMode Material::get_blend_mode() const {
}
void Material::set_shade_model(ShadeModel p_model) {
ERR_FAIL_INDEX(p_model,8);
shade_model=p_model;
VisualServer::get_singleton()->material_set_shade_model(material,(VS::MaterialShadeModel)p_model);
void Material::set_depth_draw_mode(DepthDrawMode p_depth_draw_mode) {
depth_draw_mode=p_depth_draw_mode;
VisualServer::get_singleton()->material_set_depth_draw_mode(material,(VS::MaterialDepthDrawMode)p_depth_draw_mode);
}
Material::ShadeModel Material::get_shade_model() const {
Material::DepthDrawMode Material::get_depth_draw_mode() const {
return shade_model;
return depth_draw_mode;
}
bool Material::get_flag(Flag p_flag) const {
@ -144,49 +112,32 @@ void Material::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_flag","flag","enable"),&Material::set_flag);
ObjectTypeDB::bind_method(_MD("get_flag","flag"),&Material::get_flag);
ObjectTypeDB::bind_method(_MD("set_hint","hint","enable"),&Material::set_hint);
ObjectTypeDB::bind_method(_MD("get_hint","hint"),&Material::get_hint);
ObjectTypeDB::bind_method(_MD("set_blend_mode","mode"),&Material::set_blend_mode);
ObjectTypeDB::bind_method(_MD("get_blend_mode"),&Material::get_blend_mode);
ObjectTypeDB::bind_method(_MD("set_shade_model","model"),&Material::set_shade_model);
ObjectTypeDB::bind_method(_MD("get_shade_model"),&Material::get_shade_model);
ObjectTypeDB::bind_method(_MD("set_line_width","width"),&Material::set_line_width);
ObjectTypeDB::bind_method(_MD("get_line_width"),&Material::get_line_width);
ObjectTypeDB::bind_method(_MD("set_depth_draw_mode","mode"),&Material::set_depth_draw_mode);
ObjectTypeDB::bind_method(_MD("get_depth_draw_mode"),&Material::get_depth_draw_mode);
for(int i=0;i<FLAG_MAX;i++)
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, String()+"flags/"+_flag_names[i] ),_SCS("set_flag"),_SCS("get_flag"),_flag_indices[i]);
for(int i=0;i<HINT_MAX;i++)
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, String()+"hints/"+_hint_names[i] ),_SCS("set_hint"),_SCS("get_hint"),_hint_indices[i]);
ADD_PROPERTY( PropertyInfo( Variant::INT, "params/blend_mode",PROPERTY_HINT_ENUM,"Mix,Add,Sub,PMAlpha" ), _SCS("set_blend_mode"),_SCS("get_blend_mode"));
ADD_PROPERTY( PropertyInfo( Variant::INT, "params/depth_draw",PROPERTY_HINT_ENUM,"Always,Opaque Only,Pre-Pass Alpha,Never" ), _SCS("set_depth_draw_mode"),_SCS("get_depth_draw_mode"));
ADD_PROPERTY( PropertyInfo( Variant::REAL, "params/line_width",PROPERTY_HINT_RANGE,"0.1,32.0,0.1" ), _SCS("set_line_width"),_SCS("get_line_width"));
BIND_CONSTANT( FLAG_VISIBLE );
BIND_CONSTANT( FLAG_DOUBLE_SIDED );
BIND_CONSTANT( FLAG_INVERT_FACES );
BIND_CONSTANT( FLAG_UNSHADED );
BIND_CONSTANT( FLAG_ONTOP );
BIND_CONSTANT( FLAG_WIREFRAME );
BIND_CONSTANT( FLAG_BILLBOARD_TOGGLE );
BIND_CONSTANT( FLAG_MAX );
BIND_CONSTANT( HINT_DECAL );
BIND_CONSTANT( HINT_OPAQUE_PRE_PASS );
BIND_CONSTANT( HINT_NO_SHADOW );
BIND_CONSTANT( HINT_NO_DEPTH_DRAW );
BIND_CONSTANT( HINT_NO_DEPTH_DRAW_FOR_ALPHA );
BIND_CONSTANT( HINT_MAX );
BIND_CONSTANT( SHADE_MODEL_LAMBERT );
BIND_CONSTANT( SHADE_MODEL_LAMBERT_WRAP );
BIND_CONSTANT( SHADE_MODEL_FRESNEL );
BIND_CONSTANT( SHADE_MODEL_TOON );
BIND_CONSTANT( SHADE_MODEL_CUSTOM_0 );
BIND_CONSTANT( SHADE_MODEL_CUSTOM_1 );
BIND_CONSTANT( SHADE_MODEL_CUSTOM_2 );
BIND_CONSTANT( SHADE_MODEL_CUSTOM_3 );
BIND_CONSTANT( DEPTH_DRAW_ALWAYS );
BIND_CONSTANT( DEPTH_DRAW_OPAQUE_ONLY );
BIND_CONSTANT( DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA );
BIND_CONSTANT( DEPTH_DRAW_NEVER );
BIND_CONSTANT( BLEND_MODE_MIX );
BIND_CONSTANT( BLEND_MODE_ADD );
@ -205,15 +156,11 @@ Material::Material(const RID& p_material) {
flags[FLAG_INVERT_FACES]=false;
flags[FLAG_UNSHADED]=false;
flags[FLAG_ONTOP]=false;
flags[FLAG_WIREFRAME]=false;
flags[FLAG_BILLBOARD_TOGGLE]=false;
for(int i=0;i<HINT_MAX;i++)
hints[i]=false;
hints[HINT_NO_DEPTH_DRAW_FOR_ALPHA]=true;
depth_draw_mode=DEPTH_DRAW_OPAQUE_ONLY;
blend_mode=BLEND_MODE_MIX;
shade_model = SHADE_MODEL_LAMBERT;
}
Material::~Material() {
@ -340,6 +287,17 @@ FixedMaterial::TexCoordMode FixedMaterial::get_texcoord_mode(Parameter p_paramet
return texture_texcoord[p_parameter];
}
void FixedMaterial::set_light_shader(LightShader p_shader) {
light_shader=p_shader;
VS::get_singleton()->fixed_material_set_light_shader(material,VS::FixedMaterialLightShader(p_shader));
}
FixedMaterial::LightShader FixedMaterial::get_light_shader() const {
return light_shader;
}
void FixedMaterial::set_uv_transform(const Transform& p_transform) {
@ -356,16 +314,6 @@ Transform FixedMaterial::get_uv_transform() const {
void FixedMaterial::set_detail_blend_mode(BlendMode p_mode) {
detail_blend_mode=p_mode;
VS::get_singleton()->fixed_material_set_detail_blend_mode(material,(VS::MaterialBlendMode)p_mode);
}
Material::BlendMode FixedMaterial::get_detail_blend_mode() const {
return detail_blend_mode;
}
void FixedMaterial::set_fixed_flag(FixedFlag p_flag, bool p_value) {
ERR_FAIL_INDEX(p_flag,4);
@ -412,12 +360,12 @@ void FixedMaterial::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_uv_transform","transform"),&FixedMaterial::set_uv_transform);
ObjectTypeDB::bind_method(_MD("get_uv_transform"),&FixedMaterial::get_uv_transform);
ObjectTypeDB::bind_method(_MD("set_light_shader","shader"),&FixedMaterial::set_light_shader);
ObjectTypeDB::bind_method(_MD("get_light_shader"),&FixedMaterial::get_light_shader);
ObjectTypeDB::bind_method(_MD("set_point_size","size"),&FixedMaterial::set_point_size);
ObjectTypeDB::bind_method(_MD("get_point_size"),&FixedMaterial::get_point_size);
ObjectTypeDB::bind_method(_MD("set_detail_blend_mode","mode"),&FixedMaterial::set_detail_blend_mode);
ObjectTypeDB::bind_method(_MD("get_detail_blend_mode"),&FixedMaterial::get_detail_blend_mode);
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/use_alpha" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_ALPHA);
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/use_color_array" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_COLOR_ARRAY);
@ -427,11 +375,10 @@ void FixedMaterial::_bind_methods() {
ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "params/specular", PROPERTY_HINT_COLOR_NO_ALPHA ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPECULAR );
ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "params/emission", PROPERTY_HINT_COLOR_NO_ALPHA ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_EMISSION );
ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/specular_exp", PROPERTY_HINT_RANGE,"1,64,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPECULAR_EXP );
ADD_PROPERTY( PropertyInfo( Variant::REAL, "params/detail_blend", PROPERTY_HINT_ENUM,"Mix,Add,Sub,Mul" ), _SCS("set_detail_blend_mode"), _SCS("get_detail_blend_mode") );
ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/detail_mix", PROPERTY_HINT_RANGE,"0,1,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_DETAIL );
ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/normal_depth", PROPERTY_HINT_RANGE,"-4,4,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_NORMAL );
ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/shade_param", PROPERTY_HINT_RANGE,"0,1,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADE_PARAM );
ADD_PROPERTY( PropertyInfo( Variant::INT, "params/shader", PROPERTY_HINT_ENUM,"Lambert,Wrap,Velvet,Toon" ), _SCS("set_light_shader"), _SCS("get_light_shader") );
ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/shader_param", PROPERTY_HINT_RANGE,"0,1,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SHADE_PARAM );
ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/glow", PROPERTY_HINT_RANGE,"0,8,0.01" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_GLOW );
ADD_PROPERTY( PropertyInfo( Variant::REAL, "params/point_size", PROPERTY_HINT_RANGE,"0,1024,1" ), _SCS("set_point_size"), _SCS("get_point_size"));
ADD_PROPERTY( PropertyInfo( Variant::TRANSFORM, "uv_xform"), _SCS("set_uv_transform"), _SCS("get_uv_transform") );
@ -479,7 +426,7 @@ FixedMaterial::FixedMaterial() : Material(VS::get_singleton()->fixed_material_cr
param[PARAM_SHADE_PARAM]=0.5;
param[PARAM_DETAIL]=1.0;
detail_blend_mode=BLEND_MODE_MIX;
fixed_flags[FLAG_USE_ALPHA]=false;
fixed_flags[FLAG_USE_COLOR_ARRAY]=false;
@ -490,6 +437,8 @@ FixedMaterial::FixedMaterial() : Material(VS::get_singleton()->fixed_material_cr
texture_texcoord[i]=TEXCOORD_UV;
}
light_shader=LIGHT_SHADER_LAMBERT;
point_size=1.0;
}
@ -633,7 +582,7 @@ ParticleSystemMaterial::ParticleSystemMaterial() :Material(VisualServer::get_sin
set_flag(FLAG_DOUBLE_SIDED,true);
set_flag(FLAG_UNSHADED,true);
set_hint(HINT_NO_DEPTH_DRAW,true);
set_depth_draw_mode(DEPTH_DRAW_NEVER);
VisualServer::get_singleton()->fixed_material_set_flag(material,VS::FIXED_MATERIAL_FLAG_USE_ALPHA,true);
VisualServer::get_singleton()->fixed_material_set_flag(material,VS::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,true);
}
@ -680,7 +629,8 @@ void UnshadedMaterial::set_use_alpha(bool p_use_alpha) {
alpha=p_use_alpha;
VS::get_singleton()->fixed_material_set_flag(material,VS::FIXED_MATERIAL_FLAG_USE_ALPHA,p_use_alpha);
set_hint(HINT_NO_DEPTH_DRAW,p_use_alpha);
//set_depth_draw_mode();
//set_hint(HINT,p_use_alpha);
}

View File

@ -53,23 +53,10 @@ public:
FLAG_INVERT_FACES = VS::MATERIAL_FLAG_INVERT_FACES,
FLAG_UNSHADED = VS::MATERIAL_FLAG_UNSHADED,
FLAG_ONTOP = VS::MATERIAL_FLAG_ONTOP,
FLAG_WIREFRAME = VS::MATERIAL_FLAG_WIREFRAME,
FLAG_BILLBOARD_TOGGLE = VS::MATERIAL_FLAG_BILLBOARD,
FLAG_LIGHTMAP_ON_UV2 = VS::MATERIAL_FLAG_LIGHTMAP_ON_UV2,
FLAG_MAX = VS::MATERIAL_FLAG_MAX
};
enum ShadeModel {
SHADE_MODEL_LAMBERT,
SHADE_MODEL_LAMBERT_WRAP,
SHADE_MODEL_FRESNEL,
SHADE_MODEL_TOON,
SHADE_MODEL_CUSTOM_0,
SHADE_MODEL_CUSTOM_1,
SHADE_MODEL_CUSTOM_2,
SHADE_MODEL_CUSTOM_3
};
enum BlendMode {
BLEND_MODE_MIX = VS::MATERIAL_BLEND_MODE_MIX,
BLEND_MODE_MUL = VS::MATERIAL_BLEND_MODE_MUL,
@ -79,23 +66,20 @@ public:
};
enum Hint {
HINT_DECAL=VS::MATERIAL_HINT_DECAL,
HINT_OPAQUE_PRE_PASS=VS::MATERIAL_HINT_OPAQUE_PRE_PASS,
HINT_NO_SHADOW=VS::MATERIAL_HINT_NO_SHADOW,
HINT_NO_DEPTH_DRAW=VS::MATERIAL_HINT_NO_DEPTH_DRAW,
HINT_NO_DEPTH_DRAW_FOR_ALPHA=VS::MATERIAL_HINT_NO_DEPTH_DRAW_FOR_ALPHA,
HINT_MAX=VS::MATERIAL_HINT_MAX
enum DepthDrawMode {
DEPTH_DRAW_ALWAYS = VS::MATERIAL_DEPTH_DRAW_ALWAYS,
DEPTH_DRAW_OPAQUE_ONLY = VS::MATERIAL_DEPTH_DRAW_OPAQUE_ONLY,
DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA = VS::MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA,
DEPTH_DRAW_NEVER = VS::MATERIAL_DEPTH_DRAW_NEVER
};
private:
BlendMode blend_mode;
bool flags[VS::MATERIAL_FLAG_MAX];
bool hints[VS::MATERIAL_HINT_MAX];
ShadeModel shade_model;
float line_width;
DepthDrawMode depth_draw_mode;
protected:
RID material;
@ -105,18 +89,15 @@ public:
void set_flag(Flag p_flag,bool p_enabled);
bool get_flag(Flag p_flag) const;
void set_hint(Hint p_hint,bool p_enabled);
bool get_hint(Hint p_hint) const;
void set_blend_mode(BlendMode p_blend_mode);
BlendMode get_blend_mode() const;
void set_depth_draw_mode(DepthDrawMode p_depth_draw_mode);
DepthDrawMode get_depth_draw_mode() const;
void set_line_width(float p_width);
float get_line_width() const;
void set_shade_model(ShadeModel p_model);
ShadeModel get_shade_model() const;
virtual RID get_rid() const;
Material(const RID& p_rid=RID());
@ -124,8 +105,8 @@ public:
};
VARIANT_ENUM_CAST( Material::Flag );
VARIANT_ENUM_CAST( Material::Hint );
VARIANT_ENUM_CAST( Material::ShadeModel);
VARIANT_ENUM_CAST( Material::DepthDrawMode );
VARIANT_ENUM_CAST( Material::BlendMode );
@ -163,6 +144,14 @@ public:
FLAG_DISCARD_ALPHA=VS::FIXED_MATERIAL_FLAG_DISCARD_ALPHA
};
enum LightShader {
LIGHT_SHADER_LAMBERT=VS::FIXED_MATERIAL_LIGHT_SHADER_LAMBERT,
LIGHT_SHADER_WRAP=VS::FIXED_MATERIAL_LIGHT_SHADER_WRAP,
LIGHT_SHADER_VELVET=VS::FIXED_MATERIAL_LIGHT_SHADER_VELVET,
LIGHT_SHADER_TOON=VS::FIXED_MATERIAL_LIGHT_SHADER_TOON
};
private:
@ -173,10 +162,10 @@ private:
int tex;
};
BlendMode detail_blend_mode;
Variant param[PARAM_MAX];
Ref<Texture> texture_param[PARAM_MAX];
TexCoordMode texture_texcoord[PARAM_MAX];
LightShader light_shader;
bool fixed_flags[3];
float point_size;
@ -203,15 +192,15 @@ public:
void set_texcoord_mode(Parameter p_parameter, TexCoordMode p_mode);
TexCoordMode get_texcoord_mode(Parameter p_parameter) const;
void set_light_shader(LightShader p_shader);
LightShader get_light_shader() const;
void set_uv_transform(const Transform& p_transform);
Transform get_uv_transform() const;
void set_point_size(float p_transform);
float get_point_size() const;
void set_detail_blend_mode(BlendMode p_mode);
BlendMode get_detail_blend_mode() const;
FixedMaterial();
~FixedMaterial();
@ -222,6 +211,7 @@ public:
VARIANT_ENUM_CAST( FixedMaterial::Parameter );
VARIANT_ENUM_CAST( FixedMaterial::TexCoordMode );
VARIANT_ENUM_CAST( FixedMaterial::FixedFlag );
VARIANT_ENUM_CAST( FixedMaterial::LightShader );
class ShaderMaterial : public Material {

View File

@ -41,6 +41,7 @@ void PolygonPathFinder::setup(const Vector<Vector2>& p_points, const Vector<int>
for(int i=0;i<p_points.size();i++) {
points[i].pos=p_points[i];
points[i].penalty=0;
outside_point.x = i==0?p_points[0].x:(MAX( p_points[i].x, outside_point.x ));
outside_point.y = i==0?p_points[0].y:(MAX( p_points[i].y, outside_point.y ));
@ -115,13 +116,62 @@ void PolygonPathFinder::setup(const Vector<Vector2>& p_points, const Vector<int>
Vector<Vector2> PolygonPathFinder::find_path(const Vector2& p_from, const Vector2& p_to) {
Vector<Vector2> path;
if (!_is_point_inside(p_from)) {
printf("p_from outside\n");
return path;
Vector2 from=p_from;
Vector2 to=p_to;
Edge ignore_from_edge(-1,-1);
Edge ignore_to_edge(-1,-1);
if (!_is_point_inside(from)) {
float closest_dist=1e20;
Vector2 closest_point;
for (Set<Edge>::Element *E=edges.front();E;E=E->next()) {
const Edge& e=E->get();
Vector2 seg[2]={
points[e.points[0]].pos,
points[e.points[1]].pos
};
Vector2 closest = Geometry::get_closest_point_to_segment_2d(from,seg);
float d = from.distance_squared_to(closest);
if (d<closest_dist) {
ignore_from_edge=E->get();
closest_dist=d;
}
}
from=closest_point;
};
if (!_is_point_inside(p_to)) {
printf("p_to outside\n");
return path;
if (!_is_point_inside(to)) {
float closest_dist=1e20;
Vector2 closest_point;
for (Set<Edge>::Element *E=edges.front();E;E=E->next()) {
const Edge& e=E->get();
Vector2 seg[2]={
points[e.points[0]].pos,
points[e.points[1]].pos
};
Vector2 closest = Geometry::get_closest_point_to_segment_2d(to,seg);
float d = to.distance_squared_to(closest);
if (d<closest_dist) {
ignore_to_edge=E->get();
closest_dist=d;
}
}
to=closest_point;
};
//test direct connection
@ -132,11 +182,16 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2& p_from, const Vector
for (Set<Edge>::Element *E=edges.front();E;E=E->next()) {
const Edge& e=E->get();
if (e.points[0]==ignore_from_edge.points[0] && e.points[1]==ignore_from_edge.points[1])
continue;
if (e.points[0]==ignore_to_edge.points[0] && e.points[1]==ignore_to_edge.points[1])
continue;
Vector2 a = points[e.points[0]].pos;
Vector2 b = points[e.points[1]].pos;
if (Geometry::segment_intersects_segment_2d(a,b,p_from,p_to,NULL)) {
if (Geometry::segment_intersects_segment_2d(a,b,from,to,NULL)) {
can_see_eachother=false;
break;
}
@ -145,8 +200,8 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2& p_from, const Vector
if (can_see_eachother) {
path.push_back(p_from);
path.push_back(p_to);
path.push_back(from);
path.push_back(to);
return path;
}
}
@ -155,12 +210,15 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2& p_from, const Vector
int aidx = points.size()-2;
int bidx = points.size()-1;
points[aidx].pos=p_from;
points[bidx].pos=p_to;
points[aidx].pos=from;
points[bidx].pos=to;
points[aidx].distance=0;
points[bidx].distance=0;
points[aidx].prev=-1;
points[bidx].prev=-1;
points[aidx].penalty=0;
points[bidx].penalty=0;
for(int i=0;i<points.size()-2;i++) {
@ -171,6 +229,18 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2& p_from, const Vector
points[i].prev=-1;
points[i].distance=0;
if (!_is_point_inside(from*0.5+points[i].pos*0.5)) {
valid_a=false;
}
if (!_is_point_inside(to*0.5+points[i].pos*0.5)) {
valid_b=false;
}
for (Set<Edge>::Element *E=edges.front();E;E=E->next()) {
const Edge& e=E->get();
@ -178,28 +248,45 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2& p_from, const Vector
if (e.points[0]==i || e.points[1]==i)
continue;
Vector2 a = points[e.points[0]].pos;
Vector2 b = points[e.points[1]].pos;
if (valid_a) {
if (Geometry::segment_intersects_segment_2d(a,b,p_from,points[i].pos,NULL)) {
valid_a=false;
if (e.points[0]!=ignore_from_edge.points[1] &&
e.points[1]!=ignore_from_edge.points[1] &&
e.points[0]!=ignore_from_edge.points[0] &&
e.points[1]!=ignore_from_edge.points[0]) {
if (Geometry::segment_intersects_segment_2d(a,b,from,points[i].pos,NULL)) {
valid_a=false;
}
}
}
if (valid_b) {
if (Geometry::segment_intersects_segment_2d(a,b,p_to,points[i].pos,NULL)) {
valid_b=false;
if (e.points[0]!=ignore_to_edge.points[1] &&
e.points[1]!=ignore_to_edge.points[1] &&
e.points[0]!=ignore_to_edge.points[0] &&
e.points[1]!=ignore_to_edge.points[0]) {
if (Geometry::segment_intersects_segment_2d(a,b,to,points[i].pos,NULL)) {
valid_b=false;
}
}
}
if (!valid_a && !valid_b)
break;
}
if (valid_a) {
points[i].connections.insert(aidx);
points[aidx].connections.insert(i);
@ -220,7 +307,7 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2& p_from, const Vector
for(Set<int>::Element *E=points[aidx].connections.front();E;E=E->next()) {
open_list.insert(E->get());
points[E->get()].distance=p_from.distance_to(points[E->get()].pos);
points[E->get()].distance=from.distance_to(points[E->get()].pos);
points[E->get()].prev=aidx;
}
@ -244,7 +331,9 @@ Vector<Vector2> PolygonPathFinder::find_path(const Vector2& p_from, const Vector
const Point& p =points[E->get()];
float cost = p.distance;
cost+=p.pos.distance_to(p_to);
cost+=p.pos.distance_to(to);
cost+=p.penalty;
if (cost<least_cost) {
least_cost_point=E->get();
@ -352,6 +441,17 @@ void PolygonPathFinder::_set_data(const Dictionary& p_data) {
}
if (p_data.has("penalties")) {
DVector<float> penalties=p_data["penalties"];
if (penalties.size()==pc) {
DVector<float>::Read pr = penalties.read();
for(int i=0;i<pc;i++) {
points[i].penalty=pr[i];
}
}
}
DVector<int> segs=p_data["segments"];
int sc=segs.size();
ERR_FAIL_COND(sc&1);
@ -374,10 +474,15 @@ Dictionary PolygonPathFinder::_get_data() const{
p.resize(points.size()-2);
connections.resize(points.size()-2);
ind.resize(edges.size()*2);
DVector<float> penalties;
penalties.resize(points.size()-2);
{
DVector<Vector2>::Write wp=p.write();
DVector<float>::Write pw=penalties.write();
for(int i=0;i<points.size()-2;i++) {
wp[i]=points[i].pos;
pw[i]=points[i].penalty;
DVector<int> c;
c.resize(points[i].connections.size());
{
@ -403,6 +508,7 @@ Dictionary PolygonPathFinder::_get_data() const{
d["bounds"]=bounds;
d["points"]=p;
d["penalties"]=penalties;
d["connections"]=connections;
d["segments"]=ind;
@ -458,6 +564,19 @@ Rect2 PolygonPathFinder::get_bounds() const {
return bounds;
}
void PolygonPathFinder::set_point_penalty(int p_point,float p_penalty) {
ERR_FAIL_INDEX(p_point,points.size()-2);
points[p_point].penalty=p_penalty;
}
float PolygonPathFinder::get_point_penalty(int p_point) const {
ERR_FAIL_INDEX_V(p_point,points.size()-2,0);
return points[p_point].penalty;
}
void PolygonPathFinder::_bind_methods() {
@ -466,6 +585,9 @@ void PolygonPathFinder::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_intersections","from","to"),&PolygonPathFinder::get_intersections);
ObjectTypeDB::bind_method(_MD("get_closest_point","point"),&PolygonPathFinder::get_closest_point);
ObjectTypeDB::bind_method(_MD("is_point_inside","point"),&PolygonPathFinder::is_point_inside);
ObjectTypeDB::bind_method(_MD("set_point_penalty","idx","penalty"),&PolygonPathFinder::set_point_penalty);
ObjectTypeDB::bind_method(_MD("get_point_penalty","idx"),&PolygonPathFinder::get_point_penalty);
ObjectTypeDB::bind_method(_MD("get_bounds"),&PolygonPathFinder::get_bounds);
ObjectTypeDB::bind_method(_MD("_set_data"),&PolygonPathFinder::_set_data);
ObjectTypeDB::bind_method(_MD("_get_data"),&PolygonPathFinder::_get_data);

View File

@ -11,6 +11,7 @@ class PolygonPathFinder : public Resource {
Vector2 pos;
Set<int> connections;
float distance;
float penalty;
int prev;
};
@ -55,9 +56,12 @@ public:
void setup(const Vector<Vector2>& p_points, const Vector<int>& p_connections);
Vector<Vector2> find_path(const Vector2& p_from, const Vector2& p_to);
void set_point_penalty(int p_point,float p_penalty);
float get_point_penalty(int p_point) const;
bool is_point_inside(const Vector2& p_point) const;
Vector2 get_closest_point(const Vector2& p_point) const;
Vector<Vector2> get_intersections(const Vector2& p_from, const Vector2& p_to) const;
Vector<Vector2> get_intersections(const Vector2& p_from, const Vector2& p_to) const;
Rect2 get_bounds() const;

View File

@ -45,9 +45,9 @@ Shader::Mode Shader::get_mode() const {
return (Mode)VisualServer::get_singleton()->shader_get_mode(shader);
}
void Shader::set_code( const String& p_vertex, const String& p_fragment, int p_vertex_ofs,int p_fragment_ofs) {
void Shader::set_code( const String& p_vertex, const String& p_fragment, const String& p_light,int p_fragment_ofs,int p_light_ofs) {
VisualServer::get_singleton()->shader_set_code(shader,p_vertex,p_fragment,p_vertex_ofs,p_fragment_ofs);
VisualServer::get_singleton()->shader_set_code(shader,p_vertex,p_fragment,p_light,0,p_fragment_ofs,p_light_ofs);
params_cache_dirty=true;
emit_signal(SceneStringNames::get_singleton()->changed);
}
@ -64,6 +64,11 @@ String Shader::get_fragment_code() const {
}
String Shader::get_light_code() const {
return VisualServer::get_singleton()->shader_get_light_code(shader);
}
bool Shader::has_param(const StringName& p_param) const {
@ -106,12 +111,15 @@ Dictionary Shader::_get_code() {
String fs = VisualServer::get_singleton()->shader_get_fragment_code(shader);
String vs = VisualServer::get_singleton()->shader_get_vertex_code(shader);
String ls = VisualServer::get_singleton()->shader_get_light_code(shader);
Dictionary c;
c["fragment"]=fs;
c["fragment_ofs"]=0;
c["vertex"]=vs;
c["vertex_ofs"]=0;
c["light"]=ls;
c["light_ofs"]=0;
return c;
}
@ -119,8 +127,11 @@ void Shader::_set_code(const Dictionary& p_string) {
ERR_FAIL_COND(!p_string.has("fragment"));
ERR_FAIL_COND(!p_string.has("vertex"));
String light;
if (p_string.has("light"))
light=p_string["light"];
set_code(p_string["vertex"],p_string["fragment"]);
set_code(p_string["vertex"],p_string["fragment"],light);
}
void Shader::_bind_methods() {
@ -128,9 +139,10 @@ void Shader::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_mode","mode"),&Shader::set_mode);
ObjectTypeDB::bind_method(_MD("get_mode"),&Shader::get_mode);
ObjectTypeDB::bind_method(_MD("set_code","vcode","fcode","vofs","fofs"),&Shader::set_code,DEFVAL(0),DEFVAL(0));
ObjectTypeDB::bind_method(_MD("set_code","vcode","fcode","lcode","fofs","lofs"),&Shader::set_code,DEFVAL(0),DEFVAL(0));
ObjectTypeDB::bind_method(_MD("get_vertex_code"),&Shader::get_vertex_code);
ObjectTypeDB::bind_method(_MD("get_fragment_code"),&Shader::get_fragment_code);
ObjectTypeDB::bind_method(_MD("get_light_code"),&Shader::get_light_code);
ObjectTypeDB::bind_method(_MD("has_param","name"),&Shader::has_param);
@ -169,6 +181,7 @@ RES ResourceFormatLoaderShader::load(const String &p_path,const String& p_origin
String fragment_code;
String vertex_code;
String light_code;
int mode=-1;
@ -377,7 +390,7 @@ RES ResourceFormatLoaderShader::load(const String &p_path,const String& p_origin
}
}
shader->set_code(vertex_code,fragment_code);
shader->set_code(vertex_code,fragment_code,light_code);
f->close();
memdelete(f);

View File

@ -64,9 +64,10 @@ public:
void set_mode(Mode p_mode);
Mode get_mode() const;
void set_code( const String& p_vertex, const String& p_fragment, int p_vertex_ofs=0,int p_fragment_ofs=0);
void set_code( const String& p_vertex, const String& p_fragment, const String& p_light,int p_fragment_ofs=0,int p_light_ofs=0);
String get_vertex_code() const;
String get_fragment_code() const;
String get_light_code() const;
void get_param_list(List<PropertyInfo> *p_params) const;
bool has_param(const StringName& p_param) const;

View File

@ -134,23 +134,8 @@ RID Rasterizer::_create_shader(const FixedMaterialShaderKey& p_key) {
dcode+="uniform texture fmp_detail_tex;\n";
dcode+="uniform float fmp_detail;\n";
dcode+="color detail=tex( fmp_detail_tex,"+_TEXUVSTR(VS::FIXED_MATERIAL_PARAM_DETAIL)+");\n";
switch(p_key.detail_blend) {
case VS::MATERIAL_BLEND_MODE_MIX:
dcode+="diffuse=vec4(mix(diffuse.rgb,detail.rgb,detail.a*fmp_detail),diffuse.a);\n";
break;
case VS::MATERIAL_BLEND_MODE_ADD:
dcode+="diffuse=vec4(diffuse.rgb+detail.rgb*fmp_detail,diffuse.a);\n";
break;
case VS::MATERIAL_BLEND_MODE_SUB:
dcode+="diffuse=vec4(diffuse.rgb+detail.rgb*fmp_detail,diffuse.a);\n";
break;
case VS::MATERIAL_BLEND_MODE_MUL:
dcode+="diffuse=diffuse*mix(vec4(1,1,1,1),detail,fmp_detail);\n";
break;
}
//aways mix
dcode+="diffuse=vec4(mix(diffuse.rgb,detail.rgb,detail.a*fmp_detail),diffuse.a);\n";
code+=dcode;
}
@ -223,6 +208,22 @@ RID Rasterizer::_create_shader(const FixedMaterialShaderKey& p_key) {
code+="GLOW=glow;\n";
if (p_key.texture_mask&(1<<VS::FIXED_MATERIAL_PARAM_SHADE_PARAM)) {
String scode;
scode+="uniform texture fmp_shade_param_tex;\n";
scode+="SHADE_PARAM=tex( fmp_shade_param_tex,"+_TEXUVSTR(VS::FIXED_MATERIAL_PARAM_SHADE_PARAM)+").r;\n";
code+=scode;
} else {
String scode;
scode+="uniform float fmp_shade_param;\n";
scode+="SHADE_PARAM=fmp_shade_param;\n";
code+=scode;
}
//print_line("**FRAGMENT SHADER GENERATED code: \n"+code);
String vcode;
@ -235,12 +236,58 @@ RID Rasterizer::_create_shader(const FixedMaterialShaderKey& p_key) {
// vcode+="POINT_SIZE=10.0;\n";
}
String lcode;
switch(p_key.light_shader) {
case VS::FIXED_MATERIAL_LIGHT_SHADER_LAMBERT: {
//do nothing
} break;
case VS::FIXED_MATERIAL_LIGHT_SHADER_WRAP: {
lcode+="float NdotL = max(0.0,((dot( NORMAL, LIGHT_DIR )+SHADE_PARAM)/(1.0+SHADE_PARAM)));";
lcode+="vec3 half_vec = normalize(LIGHT_DIR + EYE_VEC);";
lcode+="float eye_light = max(dot(NORMAL, half_vec),0.0);";
lcode+="LIGHT = LIGHT_DIFFUSE * DIFFUSE * NdotL;";
lcode+="if (NdotL > 0.0) {";
lcode+="\tLIGHT+=LIGHT_SPECULAR * SPECULAR * pow( eye_light, SPECULAR_EXP );";
lcode+="};";
} break;
case VS::FIXED_MATERIAL_LIGHT_SHADER_VELVET: {
lcode+="float NdotL = max(0.0,dot( NORMAL, LIGHT_DIR ));";
lcode+="vec3 half_vec = normalize(LIGHT_DIR + EYE_VEC);";
lcode+="float eye_light = max(dot(NORMAL, half_vec),0.0);";
lcode+="LIGHT = LIGHT_DIFFUSE * DIFFUSE * NdotL;";
lcode+="float rim = (1.0-abs(dot(NORMAL,vec3(0,0,1))))*SHADE_PARAM;";
lcode+="LIGHT += LIGHT_DIFFUSE * DIFFUSE * rim;";
lcode+="if (NdotL > 0.0) {";
lcode+="\tLIGHT+=LIGHT_SPECULAR * SPECULAR * pow( eye_light, SPECULAR_EXP );";
lcode+="};";
} break;
case VS::FIXED_MATERIAL_LIGHT_SHADER_TOON: {
lcode+="float NdotL = dot( NORMAL, LIGHT_DIR );";
lcode+="vec3 light_ref = reflect( LIGHT_DIR, NORMAL );";
lcode+="float eye_light = clamp( dot( light_ref, vec3(0,0,0)-EYE_VEC), 0.0, 1.0 );";
lcode+="float NdotL_diffuse = smoothstep( max( SHADE_PARAM-0.05, 0.0-1.0), min( SHADE_PARAM+0.05, 1.0), NdotL );";
lcode+="float spec_radius=clamp((1.0-(SPECULAR_EXP/64.0)),0.0,1.0);";
lcode+="float NdotL_specular = smoothstep( max( spec_radius-0.05, 0.0), min( spec_radius+0.05, 1.0), eye_light )*max(NdotL,0);";
lcode+="LIGHT = NdotL_diffuse * LIGHT_DIFFUSE*DIFFUSE + NdotL_specular * LIGHT_SPECULAR*SPECULAR;";
} break;
}
//print_line("**VERTEX SHADER GENERATED code: \n"+vcode);
double tf = (OS::get_singleton()->get_ticks_usec()-t)/1000.0;
// print_line("generate: "+rtos(tf));
shader_set_code(fms.shader,vcode,code,0,0);
shader_set_code(fms.shader,vcode,code,lcode,0,0);
fixed_material_shaders[p_key]=fms;
return fms.shader;
@ -389,28 +436,6 @@ RID Rasterizer::fixed_material_get_texture(RID p_material,VS::FixedMaterialParam
return fm.texture[p_parameter];
}
void Rasterizer::fixed_material_set_detail_blend_mode(RID p_material,VS::MaterialBlendMode p_mode){
Map<RID,FixedMaterial*>::Element *E = fixed_materials.find(p_material);
ERR_FAIL_COND(!E);
FixedMaterial &fm=*E->get();
fm.get_key();
ERR_FAIL_INDEX(p_mode,4);
fm.detail_blend=p_mode;
if (!fm.dirty_list.in_list())
fixed_material_dirty_list.add( &fm.dirty_list );
}
VS::MaterialBlendMode Rasterizer::fixed_material_get_detail_blend_mode(RID p_material) const{
const Map<RID,FixedMaterial*>::Element *E = fixed_materials.find(p_material);
ERR_FAIL_COND_V(!E,VS::MATERIAL_BLEND_MODE_MIX);
const FixedMaterial &fm=*E->get();
return fm.detail_blend;
}
void Rasterizer::fixed_material_set_texcoord_mode(RID p_material,VS::FixedMaterialParam p_parameter, VS::FixedMaterialTexCoordMode p_mode) {
@ -462,6 +487,28 @@ Transform Rasterizer::fixed_material_get_uv_transform(RID p_material) const {
return fm.uv_xform;
}
void Rasterizer::fixed_material_set_light_shader(RID p_material,VS::FixedMaterialLightShader p_shader) {
Map<RID,FixedMaterial*>::Element *E = fixed_materials.find(p_material);
ERR_FAIL_COND(!E);
FixedMaterial &fm=*E->get();
fm.light_shader=p_shader;
if (!fm.dirty_list.in_list())
fixed_material_dirty_list.add( &fm.dirty_list );
}
VS::FixedMaterialLightShader Rasterizer::fixed_material_get_light_shader(RID p_material) const {
const Map<RID,FixedMaterial*>::Element *E = fixed_materials.find(p_material);
ERR_FAIL_COND_V(!E,VS::FIXED_MATERIAL_LIGHT_SHADER_LAMBERT);
const FixedMaterial &fm=*E->get();
return fm.light_shader;
}
void Rasterizer::fixed_material_set_point_size(RID p_material,float p_size) {
Map<RID,FixedMaterial*>::Element *E = fixed_materials.find(p_material);

View File

@ -51,7 +51,7 @@ protected:
struct {
uint16_t texcoord_mask;
uint8_t texture_mask;
uint8_t detail_blend:2;
uint8_t light_shader:2;
bool use_alpha:1;
bool use_color_array:1;
bool use_pointsize:1;
@ -85,7 +85,7 @@ protected:
bool use_pointsize;
float point_size;
Transform uv_xform;
VS::MaterialBlendMode detail_blend;
VS::FixedMaterialLightShader light_shader;
RID texture[VS::FIXED_MATERIAL_PARAM_MAX];
Variant param[VS::FIXED_MATERIAL_PARAM_MAX];
VS::FixedMaterialTexCoordMode texture_tc[VS::FIXED_MATERIAL_PARAM_MAX];
@ -103,7 +103,7 @@ protected:
k.use_color_array=use_color_array;
k.use_pointsize=use_pointsize;
k.discard_alpha=discard_alpha;
k.detail_blend=detail_blend;
k.light_shader=light_shader;
k.valid=true;
for(int i=0;i<VS::FIXED_MATERIAL_PARAM_MAX;i++) {
if (texture[i].is_valid()) {
@ -124,7 +124,7 @@ protected:
use_pointsize=false;
discard_alpha=false;
point_size=1.0;
detail_blend=VS::MATERIAL_BLEND_MODE_MIX;
light_shader=VS::FIXED_MATERIAL_LIGHT_SHADER_LAMBERT;
for(int i=0;i<VS::FIXED_MATERIAL_PARAM_MAX;i++) {
texture_tc[i]=VS::FIXED_MATERIAL_TEXCOORD_UV;
}
@ -192,9 +192,10 @@ public:
virtual void shader_set_mode(RID p_shader,VS::ShaderMode p_mode)=0;
virtual VS::ShaderMode shader_get_mode(RID p_shader) const=0;
virtual void shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,int p_vertex_ofs=0,int p_fragment_ofs=0)=0;
virtual void shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,const String& p_light,int p_vertex_ofs=0,int p_fragment_ofs=0,int p_light_ofs=0)=0;
virtual String shader_get_fragment_code(RID p_shader) const=0;
virtual String shader_get_vertex_code(RID p_shader) const=0;
virtual String shader_get_light_code(RID p_shader) const=0;
virtual void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const=0;
@ -211,11 +212,8 @@ public:
virtual void material_set_flag(RID p_material, VS::MaterialFlag p_flag,bool p_enabled)=0;
virtual bool material_get_flag(RID p_material,VS::MaterialFlag p_flag) const=0;
virtual void material_set_hint(RID p_material, VS::MaterialHint p_hint,bool p_enabled)=0;
virtual bool material_get_hint(RID p_material,VS::MaterialHint p_hint) const=0;
virtual void material_set_shade_model(RID p_material, VS::MaterialShadeModel p_model)=0;
virtual VS::MaterialShadeModel material_get_shade_model(RID p_material) const=0;
virtual void material_set_depth_draw_mode(RID p_material, VS::MaterialDepthDrawMode p_mode)=0;
virtual VS::MaterialDepthDrawMode material_get_depth_draw_mode(RID p_material) const=0;
virtual void material_set_blend_mode(RID p_material,VS::MaterialBlendMode p_mode)=0;
virtual VS::MaterialBlendMode material_get_blend_mode(RID p_material) const=0;
@ -237,15 +235,15 @@ public:
virtual void fixed_material_set_texture(RID p_material,VS::FixedMaterialParam p_parameter, RID p_texture);
virtual RID fixed_material_get_texture(RID p_material,VS::FixedMaterialParam p_parameter) const;
virtual void fixed_material_set_detail_blend_mode(RID p_material,VS::MaterialBlendMode p_mode);
virtual VS::MaterialBlendMode fixed_material_get_detail_blend_mode(RID p_material) const;
virtual void fixed_material_set_texcoord_mode(RID p_material,VS::FixedMaterialParam p_parameter, VS::FixedMaterialTexCoordMode p_mode);
virtual VS::FixedMaterialTexCoordMode fixed_material_get_texcoord_mode(RID p_material,VS::FixedMaterialParam p_parameter) const;
virtual void fixed_material_set_uv_transform(RID p_material,const Transform& p_transform);
virtual Transform fixed_material_get_uv_transform(RID p_material) const;
virtual void fixed_material_set_light_shader(RID p_material,VS::FixedMaterialLightShader p_shader);
virtual VS::FixedMaterialLightShader fixed_material_get_light_shader(RID p_material) const;
virtual void fixed_material_set_point_size(RID p_material,float p_size);
virtual float fixed_material_get_point_size(RID p_material) const;

View File

@ -151,6 +151,7 @@ RID RasterizerDummy::shader_create(VS::ShaderMode p_mode) {
shader->mode=p_mode;
shader->fragment_line=0;
shader->vertex_line=0;
shader->light_line=0;
RID rid = shader_owner.make_rid(shader);
return rid;
@ -174,16 +175,17 @@ VS::ShaderMode RasterizerDummy::shader_get_mode(RID p_shader) const {
return shader->mode;
}
void RasterizerDummy::shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,const String& p_light,int p_vertex_ofs,int p_fragment_ofs,int p_light_ofs) {
void RasterizerDummy::shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,int p_vertex_ofs,int p_fragment_ofs) {
Shader *shader=shader_owner.get(p_shader);
ERR_FAIL_COND(!shader);
shader->fragment_code=p_fragment;
shader->vertex_code=p_vertex;
shader->light_code=p_light;
shader->fragment_line=p_fragment_ofs;
shader->vertex_line=p_vertex_ofs;
shader->light_line=p_vertex_ofs;
}
@ -204,6 +206,14 @@ String RasterizerDummy::shader_get_fragment_code(RID p_shader) const {
}
String RasterizerDummy::shader_get_light_code(RID p_shader) const {
Shader *shader=shader_owner.get(p_shader);
ERR_FAIL_COND_V(!shader,String());
return shader->light_code;
}
void RasterizerDummy::shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const {
Shader *shader=shader_owner.get(p_shader);
@ -274,39 +284,21 @@ bool RasterizerDummy::material_get_flag(RID p_material,VS::MaterialFlag p_flag)
}
void RasterizerDummy::material_set_hint(RID p_material, VS::MaterialHint p_hint,bool p_enabled) {
void RasterizerDummy::material_set_depth_draw_mode(RID p_material, VS::MaterialDepthDrawMode p_mode) {
Material *material = material_owner.get(p_material);
ERR_FAIL_COND(!material);
ERR_FAIL_INDEX(p_hint,VS::MATERIAL_HINT_MAX);
material->hints[p_hint]=p_enabled;
material->depth_draw_mode=p_mode;
}
bool RasterizerDummy::material_get_hint(RID p_material,VS::MaterialHint p_hint) const {
VS::MaterialDepthDrawMode RasterizerDummy::material_get_depth_draw_mode(RID p_material) const{
Material *material = material_owner.get(p_material);
ERR_FAIL_COND_V(!material,false);
ERR_FAIL_INDEX_V(p_hint,VS::MATERIAL_HINT_MAX,false);
return material->hints[p_hint];
ERR_FAIL_COND_V(!material,VS::MATERIAL_DEPTH_DRAW_ALWAYS);
return material->depth_draw_mode;
}
void RasterizerDummy::material_set_shade_model(RID p_material, VS::MaterialShadeModel p_model) {
Material *material = material_owner.get(p_material);
ERR_FAIL_COND(!material);
material->shade_model=p_model;
};
VS::MaterialShadeModel RasterizerDummy::material_get_shade_model(RID p_material) const {
Material *material = material_owner.get(p_material);
ERR_FAIL_COND_V(!material,VS::MATERIAL_SHADE_MODEL_LAMBERT);
return material->shade_model;
};
void RasterizerDummy::material_set_blend_mode(RID p_material,VS::MaterialBlendMode p_mode) {

View File

@ -71,10 +71,12 @@ class RasterizerDummy : public Rasterizer {
String vertex_code;
String fragment_code;
String light_code;
VS::ShaderMode mode;
Map<StringName,Variant> params;
int fragment_line;
int vertex_line;
int light_line;
bool valid;
bool has_alpha;
bool use_world_transform;
@ -87,9 +89,8 @@ class RasterizerDummy : public Rasterizer {
struct Material {
bool flags[VS::MATERIAL_FLAG_MAX];
bool hints[VS::MATERIAL_HINT_MAX];
VS::MaterialShadeModel shade_model;
VS::MaterialDepthDrawMode depth_draw_mode;
VS::MaterialBlendMode blend_mode;
@ -107,9 +108,8 @@ class RasterizerDummy : public Rasterizer {
for(int i=0;i<VS::MATERIAL_FLAG_MAX;i++)
flags[i]=false;
flags[VS::MATERIAL_FLAG_VISIBLE]=true;
for(int i=0;i<VS::MATERIAL_HINT_MAX;i++)
hints[i]=false;
depth_draw_mode=VS::MATERIAL_DEPTH_DRAW_OPAQUE_ONLY;
line_width=1;
blend_mode=VS::MATERIAL_BLEND_MODE_MIX;
point_size = 1.0;
@ -296,7 +296,7 @@ class RasterizerDummy : public Rasterizer {
vars[VS::LIGHT_PARAM_ENERGY]=1.0;
vars[VS::LIGHT_PARAM_RADIUS]=1.0;
vars[VS::LIGHT_PARAM_SHADOW_Z_OFFSET]=0.05;
colors[VS::LIGHT_COLOR_AMBIENT]=Color(0,0,0);
colors[VS::LIGHT_COLOR_DIFFUSE]=Color(1,1,1);
colors[VS::LIGHT_COLOR_SPECULAR]=Color(1,1,1);
shadow_enabled=false;
@ -331,7 +331,7 @@ class RasterizerDummy : public Rasterizer {
fx_param[VS::ENV_FX_PARAM_DOF_BLUR_BEGIN]=100.0;
fx_param[VS::ENV_FX_PARAM_DOF_BLUR_RANGE]=10.0;
fx_param[VS::ENV_FX_PARAM_HDR_EXPOSURE]=0.4;
fx_param[VS::ENV_FX_PARAM_HDR_SCALAR]=1.0;
fx_param[VS::ENV_FX_PARAM_HDR_WHITE]=1.0;
fx_param[VS::ENV_FX_PARAM_HDR_GLOW_TRESHOLD]=0.95;
fx_param[VS::ENV_FX_PARAM_HDR_GLOW_SCALE]=0.2;
fx_param[VS::ENV_FX_PARAM_HDR_MIN_LUMINANCE]=0.4;
@ -415,9 +415,10 @@ public:
virtual void shader_set_mode(RID p_shader,VS::ShaderMode p_mode);
virtual VS::ShaderMode shader_get_mode(RID p_shader) const;
virtual void shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,int p_vertex_ofs=0,int p_fragment_ofs=0);
virtual void shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,const String& p_light,int p_vertex_ofs=0,int p_fragment_ofs=0,int p_light_ofs=0);
virtual String shader_get_fragment_code(RID p_shader) const;
virtual String shader_get_vertex_code(RID p_shader) const;
virtual String shader_get_light_code(RID p_shader) const;
virtual void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const;
@ -434,11 +435,8 @@ public:
virtual void material_set_flag(RID p_material, VS::MaterialFlag p_flag,bool p_enabled);
virtual bool material_get_flag(RID p_material,VS::MaterialFlag p_flag) const;
virtual void material_set_hint(RID p_material, VS::MaterialHint p_hint,bool p_enabled);
virtual bool material_get_hint(RID p_material,VS::MaterialHint p_hint) const;
virtual void material_set_shade_model(RID p_material, VS::MaterialShadeModel p_model);
virtual VS::MaterialShadeModel material_get_shade_model(RID p_material) const;
virtual void material_set_depth_draw_mode(RID p_material, VS::MaterialDepthDrawMode p_mode);
virtual VS::MaterialDepthDrawMode material_get_depth_draw_mode(RID p_material) const;
virtual void material_set_blend_mode(RID p_material,VS::MaterialBlendMode p_mode);
virtual VS::MaterialBlendMode material_get_blend_mode(RID p_material) const;

View File

@ -859,7 +859,20 @@ const ShaderLanguage::IntrinsicFuncDef ShaderLanguage::intrinsic_func_defs[]={
{"mix",TYPE_VEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_FLOAT,TYPE_VOID}},
{"mix",TYPE_VEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
{"step",TYPE_FLOAT,{TYPE_FLOAT,TYPE_FLOAT,TYPE_VOID}},
{"step",TYPE_VEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
{"step",TYPE_VEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
{"step",TYPE_VEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
{"step",TYPE_VEC2,{TYPE_FLOAT,TYPE_VEC2,TYPE_VOID}},
{"step",TYPE_VEC3,{TYPE_FLOAT,TYPE_VEC3,TYPE_VOID}},
{"step",TYPE_VEC4,{TYPE_FLOAT,TYPE_VEC4,TYPE_VOID}},
{"smoothstep",TYPE_FLOAT,{TYPE_FLOAT,TYPE_FLOAT,TYPE_FLOAT,TYPE_VOID}},
{"smoothstep",TYPE_VEC2,{TYPE_VEC2,TYPE_VEC2,TYPE_VEC2,TYPE_VOID}},
{"smoothstep",TYPE_VEC3,{TYPE_VEC3,TYPE_VEC3,TYPE_VEC3,TYPE_VOID}},
{"smoothstep",TYPE_VEC4,{TYPE_VEC4,TYPE_VEC4,TYPE_VEC4,TYPE_VOID}},
{"smoothstep",TYPE_VEC2,{TYPE_FLOAT,TYPE_FLOAT,TYPE_VEC2,TYPE_VOID}},
{"smoothstep",TYPE_VEC3,{TYPE_FLOAT,TYPE_FLOAT,TYPE_VEC3,TYPE_VOID}},
{"smoothstep",TYPE_VEC4,{TYPE_FLOAT,TYPE_FLOAT,TYPE_VEC4,TYPE_VOID}},
//intrinsics - geometric
{"length",TYPE_FLOAT,{TYPE_VEC2,TYPE_VOID}},
{"length",TYPE_FLOAT,{TYPE_VEC3,TYPE_VOID}},
@ -1045,6 +1058,27 @@ const ShaderLanguage::BuiltinsDef ShaderLanguage::fragment_builtins_defs[]={
{ NULL, TYPE_VOID}
};
const ShaderLanguage::BuiltinsDef ShaderLanguage::light_builtins_defs[]={
{ "NORMAL", TYPE_VEC3},
{ "LIGHT_DIR", TYPE_VEC3},
{ "LIGHT_DIFFUSE", TYPE_VEC3},
{ "LIGHT_SPECULAR", TYPE_VEC3},
{ "EYE_VEC", TYPE_VEC3},
{ "DIFFUSE", TYPE_VEC3},
{ "SPECULAR", TYPE_VEC3},
{ "SPECULAR_EXP", TYPE_FLOAT},
{ "SHADE_PARAM", TYPE_FLOAT},
{ "LIGHT", TYPE_VEC3},
{ "POINT_COORD", TYPE_VEC2},
// { "SCREEN_POS", TYPE_VEC2},
// { "SCREEN_TEXEL_SIZE", TYPE_VEC2},
{ "TIME", TYPE_FLOAT},
{ NULL, TYPE_VOID}
};
const ShaderLanguage::BuiltinsDef ShaderLanguage::postprocess_fragment_builtins_defs[]={
{ "IN_COLOR", TYPE_VEC3},
@ -2286,6 +2320,13 @@ Error ShaderLanguage::parse(const Vector<Token>& p_tokens,ShaderType p_type,Comp
idx++;
}
} break;
case SHADER_MATERIAL_LIGHT: {
int idx=0;
while (light_builtins_defs[idx].name) {
parser.program->builtin_variables[light_builtins_defs[idx].name]=light_builtins_defs[idx].type;
idx++;
}
} break;
case SHADER_POST_PROCESS: {
int idx=0;
while (postprocess_fragment_builtins_defs[idx].name) {
@ -2306,8 +2347,9 @@ Error ShaderLanguage::parse(const Vector<Token>& p_tokens,ShaderType p_type,Comp
t = OS::get_singleton()->get_ticks_usec();
if (p_compile_func)
p_compile_func(p_userdata,parser.program);
if (p_compile_func) {
err = p_compile_func(p_userdata,parser.program);
}
tf = (OS::get_singleton()->get_ticks_usec()-t)/1000.0;
//print_line("compile time: "+rtos(tf));
@ -2318,7 +2360,7 @@ Error ShaderLanguage::parse(const Vector<Token>& p_tokens,ShaderType p_type,Comp
memdelete( parser.nodegc.front()->get() );
parser.nodegc.pop_front();
}
return OK;
return err;
}
Error ShaderLanguage::compile(const String& p_code,ShaderType p_type,CompileFunc p_compile_func,void *p_userdata,String *r_error,int *r_err_line,int *r_err_column) {
@ -2372,6 +2414,13 @@ void ShaderLanguage::get_keyword_list(ShaderType p_type, List<String> *p_keyword
idx++;
}
} break;
case SHADER_MATERIAL_LIGHT: {
idx=0;
while (light_builtins_defs[idx].name) {
p_keywords->push_back(light_builtins_defs[idx].name);
idx++;
}
} break;
case SHADER_POST_PROCESS: {
idx=0;
while (postprocess_fragment_builtins_defs[idx].name) {

View File

@ -46,6 +46,7 @@ public:
enum ShaderType {
SHADER_MATERIAL_VERTEX,
SHADER_MATERIAL_FRAGMENT,
SHADER_MATERIAL_LIGHT,
SHADER_POST_PROCESS,
};
@ -215,7 +216,7 @@ public:
ProgramNode() { type=TYPE_PROGRAM; }
};
typedef void (*CompileFunc)(void*,ProgramNode*);
typedef Error (*CompileFunc)(void*,ProgramNode*);
struct VarInfo {
@ -360,6 +361,7 @@ private:
static const BuiltinsDef vertex_builtins_defs[];
static const BuiltinsDef fragment_builtins_defs[];
static const BuiltinsDef light_builtins_defs[];
static const BuiltinsDef postprocess_fragment_builtins_defs[];
static DataType get_token_datatype(TokenType p_type);

View File

@ -130,10 +130,10 @@ VisualServer::ShaderMode VisualServerRaster::shader_get_mode(RID p_shader) const
}
void VisualServerRaster::shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,int p_vertex_ofs,int p_fragment_ofs) {
void VisualServerRaster::shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,const String& p_light,int p_vertex_ofs,int p_fragment_ofs,int p_light_ofs) {
VS_CHANGED;
rasterizer->shader_set_code(p_shader,p_vertex,p_fragment,p_vertex_ofs,p_fragment_ofs);
rasterizer->shader_set_code(p_shader,p_vertex,p_fragment,p_light,p_vertex_ofs,p_fragment_ofs,p_light_ofs);
}
String VisualServerRaster::shader_get_vertex_code(RID p_shader) const{
@ -146,6 +146,11 @@ String VisualServerRaster::shader_get_fragment_code(RID p_shader) const{
return rasterizer->shader_get_fragment_code(p_shader);
}
String VisualServerRaster::shader_get_light_code(RID p_shader) const{
return rasterizer->shader_get_fragment_code(p_shader);
}
void VisualServerRaster::shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const {
return rasterizer->shader_get_param_list(p_shader,p_param_list);
@ -187,27 +192,16 @@ void VisualServerRaster::material_set_flag(RID p_material, MaterialFlag p_flag,b
rasterizer->material_set_flag(p_material,p_flag,p_enabled);
}
void VisualServerRaster::material_set_hint(RID p_material, MaterialHint p_hint,bool p_enabled) {
void VisualServerRaster::material_set_depth_draw_mode(RID p_material, MaterialDepthDrawMode p_mode) {
VS_CHANGED;
rasterizer->material_set_hint(p_material,p_hint,p_enabled);
}
bool VisualServerRaster::material_get_hint(RID p_material,MaterialHint p_hint) const {
return rasterizer->material_get_hint(p_material,p_hint);
rasterizer->material_set_depth_draw_mode(p_material,p_mode);
}
void VisualServerRaster::material_set_shade_model(RID p_material, MaterialShadeModel p_model) {
VS_CHANGED;
rasterizer->material_set_shade_model(p_material,p_model);
}
VisualServer::MaterialShadeModel VisualServerRaster::material_get_shade_model(RID p_material) const {
return rasterizer->material_get_shade_model(p_material);
VS::MaterialDepthDrawMode VisualServerRaster::material_get_depth_draw_mode(RID p_material) const {
return rasterizer->material_get_depth_draw_mode(p_material);
}
@ -273,17 +267,6 @@ RID VisualServerRaster::fixed_material_get_texture(RID p_material,FixedMaterialP
}
void VisualServerRaster::fixed_material_set_detail_blend_mode(RID p_material,MaterialBlendMode p_mode) {
VS_CHANGED;
rasterizer->fixed_material_set_detail_blend_mode(p_material,p_mode);
}
VS::MaterialBlendMode VisualServerRaster::fixed_material_get_detail_blend_mode(RID p_material) const {
return rasterizer->fixed_material_get_detail_blend_mode(p_material);
}
void VisualServerRaster::fixed_material_set_texcoord_mode(RID p_material,FixedMaterialParam p_parameter, FixedMaterialTexCoordMode p_mode) {
@ -318,6 +301,18 @@ Transform VisualServerRaster::fixed_material_get_uv_transform(RID p_material) co
return rasterizer->fixed_material_get_uv_transform(p_material);
}
void VisualServerRaster::fixed_material_set_light_shader(RID p_material,FixedMaterialLightShader p_shader) {
VS_CHANGED;
rasterizer->fixed_material_set_light_shader(p_material,p_shader);
}
VisualServerRaster::FixedMaterialLightShader VisualServerRaster::fixed_material_get_light_shader(RID p_material) const{
return rasterizer->fixed_material_get_light_shader(p_material);
}
/* MESH API */

View File

@ -691,9 +691,10 @@ public:
virtual void shader_set_mode(RID p_shader,ShaderMode p_mode);
virtual ShaderMode shader_get_mode(RID p_shader) const;
virtual void shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,int p_vertex_ofs=0,int p_fragment_ofs=0);
virtual void shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,const String& p_light,int p_vertex_ofs=0,int p_fragment_ofs=0,int p_light_ofs=0);
virtual String shader_get_vertex_code(RID p_shader) const;
virtual String shader_get_fragment_code(RID p_shader) const;
virtual String shader_get_light_code(RID p_shader) const;
virtual void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const;
@ -710,11 +711,8 @@ public:
virtual void material_set_flag(RID p_material, MaterialFlag p_flag,bool p_enabled);
virtual bool material_get_flag(RID p_material,MaterialFlag p_flag) const;
virtual void material_set_hint(RID p_material, MaterialHint p_hint,bool p_enabled);
virtual bool material_get_hint(RID p_material,MaterialHint p_hint) const;
virtual void material_set_shade_model(RID p_material, MaterialShadeModel p_model);
virtual MaterialShadeModel material_get_shade_model(RID p_material) const;
virtual void material_set_depth_draw_mode(RID p_material, MaterialDepthDrawMode p_mode);
virtual MaterialDepthDrawMode material_get_depth_draw_mode(RID p_material) const;
virtual void material_set_blend_mode(RID p_material,MaterialBlendMode p_mode);
virtual MaterialBlendMode material_get_blend_mode(RID p_material) const;
@ -736,16 +734,16 @@ public:
virtual void fixed_material_set_texture(RID p_material,FixedMaterialParam p_parameter, RID p_texture);
virtual RID fixed_material_get_texture(RID p_material,FixedMaterialParam p_parameter) const;
virtual void fixed_material_set_detail_blend_mode(RID p_material,MaterialBlendMode p_mode);
virtual MaterialBlendMode fixed_material_get_detail_blend_mode(RID p_material) const;
virtual void fixed_material_set_texcoord_mode(RID p_material,FixedMaterialParam p_parameter, FixedMaterialTexCoordMode p_mode);
virtual FixedMaterialTexCoordMode fixed_material_get_texcoord_mode(RID p_material,FixedMaterialParam p_parameter) const;
virtual void fixed_material_set_uv_transform(RID p_material,const Transform& p_transform);
virtual Transform fixed_material_get_uv_transform(RID p_material) const;
virtual void fixed_material_set_light_shader(RID p_material,FixedMaterialLightShader p_shader);
virtual FixedMaterialLightShader fixed_material_get_light_shader(RID p_material) const;
virtual void fixed_material_set_point_size(RID p_material,float p_size);
virtual float fixed_material_get_point_size(RID p_material) const;

View File

@ -647,9 +647,10 @@ public:
FUNC1R(RID,shader_create,ShaderMode);
FUNC2(shader_set_mode,RID,ShaderMode);
FUNC1RC(ShaderMode,shader_get_mode,RID);
FUNC5(shader_set_code,RID,const String&,const String&,int,int);
FUNC7(shader_set_code,RID,const String&,const String&,const String&,int,int,int);
FUNC1RC(String,shader_get_vertex_code,RID);
FUNC1RC(String,shader_get_fragment_code,RID);
FUNC1RC(String,shader_get_light_code,RID);
FUNC2SC(shader_get_param_list,RID,List<PropertyInfo>*);
/*virtual void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) {
@ -675,11 +676,8 @@ public:
FUNC3(material_set_flag,RID,MaterialFlag,bool);
FUNC2RC(bool,material_get_flag,RID,MaterialFlag);
FUNC3(material_set_hint,RID,MaterialHint,bool);
FUNC2RC(bool,material_get_hint,RID,MaterialHint);
FUNC2(material_set_shade_model,RID,MaterialShadeModel);
FUNC1RC(MaterialShadeModel,material_get_shade_model,RID);
FUNC2(material_set_depth_draw_mode,RID,MaterialDepthDrawMode);
FUNC1RC(MaterialDepthDrawMode,material_get_depth_draw_mode,RID);
FUNC2(material_set_blend_mode,RID,MaterialBlendMode);
FUNC1RC(MaterialBlendMode,material_get_blend_mode,RID);
@ -701,13 +699,14 @@ public:
FUNC3(fixed_material_set_texture,RID ,FixedMaterialParam, RID );
FUNC2RC(RID, fixed_material_get_texture,RID,FixedMaterialParam);
FUNC2(fixed_material_set_detail_blend_mode,RID ,MaterialBlendMode );
FUNC1RC(MaterialBlendMode, fixed_material_get_detail_blend_mode,RID);
FUNC3(fixed_material_set_texcoord_mode,RID,FixedMaterialParam, FixedMaterialTexCoordMode );
FUNC2RC(FixedMaterialTexCoordMode, fixed_material_get_texcoord_mode,RID,FixedMaterialParam);
FUNC2(fixed_material_set_light_shader,RID,FixedMaterialLightShader);
FUNC1RC(FixedMaterialLightShader, fixed_material_get_light_shader,RID);
FUNC2(fixed_material_set_uv_transform,RID,const Transform&);
FUNC1RC(Transform, fixed_material_get_uv_transform,RID);

View File

@ -298,7 +298,7 @@ RID VisualServer::material_2d_get(bool p_shaded, bool p_transparent, bool p_cut_
fixed_material_set_flag(material_2d[version],FIXED_MATERIAL_FLAG_DISCARD_ALPHA,p_cut_alpha);
material_set_flag(material_2d[version],MATERIAL_FLAG_UNSHADED,!p_shaded);
material_set_flag(material_2d[version],MATERIAL_FLAG_DOUBLE_SIDED,true);
material_set_hint(material_2d[version],MATERIAL_HINT_OPAQUE_PRE_PASS,p_opaque_prepass);
material_set_depth_draw_mode(material_2d[version],p_opaque_prepass?MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA:MATERIAL_DEPTH_DRAW_OPAQUE_ONLY);
fixed_material_set_texture(material_2d[version],FIXED_MATERIAL_PARAM_DIFFUSE,get_white_texture());
//material cut alpha?
return material_2d[version];
@ -568,8 +568,6 @@ void VisualServer::_bind_methods() {
BIND_CONSTANT( MATERIAL_FLAG_INVERT_FACES );
BIND_CONSTANT( MATERIAL_FLAG_UNSHADED );
BIND_CONSTANT( MATERIAL_FLAG_ONTOP );
BIND_CONSTANT( MATERIAL_FLAG_WIREFRAME );
BIND_CONSTANT( MATERIAL_FLAG_BILLBOARD );
BIND_CONSTANT( MATERIAL_FLAG_MAX );
BIND_CONSTANT( MATERIAL_BLEND_MODE_MIX );
@ -642,7 +640,7 @@ void VisualServer::_bind_methods() {
BIND_CONSTANT( LIGHT_OMNI );
BIND_CONSTANT( LIGHT_SPOT );
BIND_CONSTANT( LIGHT_COLOR_AMBIENT );
BIND_CONSTANT( LIGHT_COLOR_DIFFUSE );
BIND_CONSTANT( LIGHT_COLOR_SPECULAR );

View File

@ -142,9 +142,10 @@ public:
virtual void shader_set_mode(RID p_shader,ShaderMode p_mode)=0;
virtual ShaderMode shader_get_mode(RID p_shader) const=0;
virtual void shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,int p_vertex_ofs=0,int p_fragment_ofs=0)=0;
virtual void shader_set_code(RID p_shader, const String& p_vertex, const String& p_fragment,const String& p_light, int p_vertex_ofs=0,int p_fragment_ofs=0,int p_light_ofs=0)=0;
virtual String shader_get_fragment_code(RID p_shader) const=0;
virtual String shader_get_vertex_code(RID p_shader) const=0;
virtual String shader_get_light_code(RID p_shader) const=0;
virtual void shader_get_param_list(RID p_shader, List<PropertyInfo> *p_param_list) const=0;
@ -164,39 +165,22 @@ public:
MATERIAL_FLAG_INVERT_FACES, ///< Invert front/back of the object
MATERIAL_FLAG_UNSHADED,
MATERIAL_FLAG_ONTOP,
MATERIAL_FLAG_WIREFRAME,
MATERIAL_FLAG_BILLBOARD,
MATERIAL_FLAG_LIGHTMAP_ON_UV2,
MATERIAL_FLAG_MAX,
};
virtual void material_set_flag(RID p_material, MaterialFlag p_flag,bool p_enabled)=0;
virtual bool material_get_flag(RID p_material,MaterialFlag p_flag) const=0;
enum MaterialShadeModel {
MATERIAL_SHADE_MODEL_LAMBERT,
MATERIAL_SHADE_MODEL_LAMBERT_WRAP,
MATERIAL_SHADE_MODEL_TOON
enum MaterialDepthDrawMode {
MATERIAL_DEPTH_DRAW_ALWAYS,
MATERIAL_DEPTH_DRAW_OPAQUE_ONLY,
MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA,
MATERIAL_DEPTH_DRAW_NEVER
};
/* FIXED MATERIAL */
virtual void material_set_shade_model(RID p_material, MaterialShadeModel p_model)=0;
virtual MaterialShadeModel material_get_shade_model(RID p_material) const=0;
enum MaterialHint {
MATERIAL_HINT_DECAL,
MATERIAL_HINT_OPAQUE_PRE_PASS,
MATERIAL_HINT_NO_SHADOW,
MATERIAL_HINT_NO_DEPTH_DRAW,
MATERIAL_HINT_NO_DEPTH_DRAW_FOR_ALPHA,
MATERIAL_HINT_MAX
};
virtual void material_set_hint(RID p_material, MaterialHint p_hint,bool p_enabled)=0;
virtual bool material_get_hint(RID p_material,MaterialHint p_hint) const=0;
virtual void material_set_depth_draw_mode(RID p_material, MaterialDepthDrawMode p_mode)=0;
virtual MaterialDepthDrawMode material_get_depth_draw_mode(RID p_material) const=0;
enum MaterialBlendMode {
MATERIAL_BLEND_MODE_MIX, //default
@ -258,8 +242,19 @@ public:
virtual void fixed_material_set_texture(RID p_material,FixedMaterialParam p_parameter, RID p_texture)=0;
virtual RID fixed_material_get_texture(RID p_material,FixedMaterialParam p_parameter) const=0;
virtual void fixed_material_set_detail_blend_mode(RID p_material,MaterialBlendMode p_mode)=0;
virtual MaterialBlendMode fixed_material_get_detail_blend_mode(RID p_material) const=0;
enum FixedMaterialLightShader {
FIXED_MATERIAL_LIGHT_SHADER_LAMBERT,
FIXED_MATERIAL_LIGHT_SHADER_WRAP,
FIXED_MATERIAL_LIGHT_SHADER_VELVET,
FIXED_MATERIAL_LIGHT_SHADER_TOON,
};
virtual void fixed_material_set_light_shader(RID p_material,FixedMaterialLightShader p_shader)=0;
virtual FixedMaterialLightShader fixed_material_get_light_shader(RID p_material) const=0;
virtual void fixed_material_set_texcoord_mode(RID p_material,FixedMaterialParam p_parameter, FixedMaterialTexCoordMode p_mode)=0;
virtual FixedMaterialTexCoordMode fixed_material_get_texcoord_mode(RID p_material,FixedMaterialParam p_parameter) const=0;
@ -464,9 +459,7 @@ public:
LIGHT_SPOT
};
enum LightColor {
LIGHT_COLOR_AMBIENT,
enum LightColor {
LIGHT_COLOR_DIFFUSE,
LIGHT_COLOR_SPECULAR
};
@ -724,6 +717,7 @@ public:
virtual Variant environment_get_background_param(RID p_env,EnvironmentBGParam p_param) const=0;
enum EnvironmentFx {
ENV_FX_AMBIENT_LIGHT,
ENV_FX_FXAA,
ENV_FX_GLOW,
ENV_FX_DOF_BLUR,
@ -745,7 +739,16 @@ public:
ENV_FX_BLUR_BLEND_MODE_SOFTLIGHT,
};
enum EnvironmentFxHDRToneMapper {
ENV_FX_HDR_TONE_MAPPER_LINEAR,
ENV_FX_HDR_TONE_MAPPER_LOG,
ENV_FX_HDR_TONE_MAPPER_REINHARDT,
ENV_FX_HDR_TONE_MAPPER_REINHARDT_AUTOWHITE,
};
enum EnvironmentFxParam {
ENV_FX_PARAM_AMBIENT_LIGHT_COLOR,
ENV_FX_PARAM_AMBIENT_LIGHT_ENERGY,
ENV_FX_PARAM_GLOW_BLUR_PASSES,
ENV_FX_PARAM_GLOW_BLUR_SCALE,
ENV_FX_PARAM_GLOW_BLUR_STRENGTH,
@ -755,8 +758,9 @@ public:
ENV_FX_PARAM_DOF_BLUR_PASSES,
ENV_FX_PARAM_DOF_BLUR_BEGIN,
ENV_FX_PARAM_DOF_BLUR_RANGE,
ENV_FX_PARAM_HDR_TONEMAPPER,
ENV_FX_PARAM_HDR_EXPOSURE,
ENV_FX_PARAM_HDR_SCALAR,
ENV_FX_PARAM_HDR_WHITE,
ENV_FX_PARAM_HDR_GLOW_TRESHOLD,
ENV_FX_PARAM_HDR_GLOW_SCALE,
ENV_FX_PARAM_HDR_MIN_LUMINANCE,

View File

@ -734,6 +734,7 @@ void EditorNode::_save_scene(String p_file) {
flg|=ResourceSaver::FLAG_COMPRESS;
if (EditorSettings::get_singleton()->get("on_save/save_paths_as_relative"))
flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
flg|=ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS;
err = ResourceSaver::save(p_file,sdata,flg);

View File

@ -199,7 +199,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
return OK;
//well, it's an ambient light..
Light *l = memnew( DirectionalLight );
l->set_color(Light::COLOR_AMBIENT,ld.color);
// l->set_color(Light::COLOR_AMBIENT,ld.color);
l->set_color(Light::COLOR_DIFFUSE,Color(0,0,0));
l->set_color(Light::COLOR_SPECULAR,Color(0,0,0));
node = l;
@ -208,8 +208,8 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
//well, it's an ambient light..
Light *l = memnew( DirectionalLight );
if (found_ambient) //use it here
l->set_color(Light::COLOR_AMBIENT,ambient);
//if (found_ambient) //use it here
// l->set_color(Light::COLOR_AMBIENT,ambient);
l->set_color(Light::COLOR_DIFFUSE,ld.color);
l->set_color(Light::COLOR_SPECULAR,Color(1,1,1));
@ -661,7 +661,7 @@ Error ColladaImport::_create_mesh_surfaces(Ref<Mesh>& p_mesh,const Map<String,Co
const Collada::MeshData::Source *color_src=NULL;
int color_ofs=0;
if (false && p.sources.has("COLOR")) {
if (p.sources.has("COLOR")) {
String color_source_id = p.sources["COLOR"].source;
color_ofs = p.sources["COLOR"].offset;

View File

@ -173,7 +173,7 @@ public:
static const char *anim_flag_names[]={
"Detect Loop",
"Detect Loop (-loop,-cycle)",
"Keep Value Tracks",
"Optimize",
NULL
@ -680,7 +680,7 @@ EditorSceneImportDialog::EditorSceneImportDialog(EditorNode *p_editor, EditorSce
import_choose->connect("pressed", this,"_browse");
hbc = memnew( HBoxContainer );
vbc->add_margin_child("Target Scene:",hbc);
vbc->add_margin_child("Target Path:",hbc);
save_path = memnew( LineEdit );
save_path->set_h_size_flags(SIZE_EXPAND_FILL);
@ -1024,7 +1024,7 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
if (fm.is_valid()) {
fm->set_flag(Material::FLAG_UNSHADED,true);
fm->set_flag(Material::FLAG_DOUBLE_SIDED,true);
fm->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
fm->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
fm->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA,true);
}
}
@ -1129,7 +1129,7 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh>
if (fm.is_valid()) {
fm->set_flag(Material::FLAG_UNSHADED,true);
fm->set_flag(Material::FLAG_DOUBLE_SIDED,true);
fm->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
fm->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
fm->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA,true);
}
}
@ -1501,6 +1501,37 @@ void EditorSceneImportPlugin::_merge_existing_node(Node *p_node,Node *p_imported
room_node->set_room( room_imported->get_room() );
} else if (p_node->get_type()=="Skeleton") {
//for paths, overwrite path
Skeleton *skeleton_imported =imported_node->cast_to<Skeleton>();
Skeleton *skeleton_node =p_node->cast_to<Skeleton>();
//use imported bones, obviously
skeleton_node->clear_bones();
for(int i=0;i<skeleton_imported->get_bone_count();i++) {
skeleton_node->add_bone(skeleton_imported->get_bone_name(i));
skeleton_node->set_bone_parent(i,skeleton_imported->get_bone_parent(i));
skeleton_node->set_bone_rest(i,skeleton_imported->get_bone_rest(i));
skeleton_node->set_bone_pose(i,skeleton_imported->get_bone_pose(i));
}
} else if (p_node->get_type()=="AnimationPlayer") {
//for paths, overwrite path
AnimationPlayer *aplayer_imported =imported_node->cast_to<AnimationPlayer>();
AnimationPlayer *aplayer_node =p_node->cast_to<AnimationPlayer>();
//use imported bones, obviously
List<StringName> anims;
aplayer_imported->get_animation_list(&anims);
//use imported animations, could merge some stuff though
for (List<StringName>::Element *E=anims.front();E;E=E->next()) {
aplayer_node->add_animation(E->get(),aplayer_imported->get_animation(E->get()));
}
} else if (p_node->get_type()=="CollisionShape") {
//for paths, overwrite path
@ -1877,14 +1908,14 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c
if (merge) {
print_line("MERGING?????");
progress.step("Merging..",103);
FileAccess *fa = FileAccess::create(FileAccess::ACCESS_RESOURCES);
print_line("OPEN IN FS: "+p_dest_path);
if (fa->file_exists(p_dest_path)) {
print_line("TRY REALLY TO MERGE?");
//try to merge
Ref<PackedScene> s = ResourceLoader::load(p_dest_path);
@ -1915,7 +1946,7 @@ Error EditorSceneImportPlugin::import2(Node *scene, const String& p_dest_path, c
packer->set_import_metadata(from);
print_line("SAVING TO: "+p_dest_path);
err = ResourceSaver::save(p_dest_path,packer);
err = ResourceSaver::save(p_dest_path,packer,ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
//EditorFileSystem::get_singleton()->update_resource(packer);

View File

@ -57,7 +57,9 @@ void ShaderTextEditor::set_edited_shader(const Ref<Shader>& p_shader,ShaderLangu
_load_theme_settings();
if (p_type==ShaderLanguage::SHADER_MATERIAL_VERTEX)
if (p_type==ShaderLanguage::SHADER_MATERIAL_LIGHT)
get_text_edit()->set_text(shader->get_light_code());
else if (p_type==ShaderLanguage::SHADER_MATERIAL_VERTEX)
get_text_edit()->set_text(shader->get_vertex_code());
else
get_text_edit()->set_text(shader->get_fragment_code());
@ -129,7 +131,9 @@ void ShaderTextEditor::_validate_script() {
int line,col;
String code;
if (type==ShaderLanguage::SHADER_MATERIAL_VERTEX)
if (type==ShaderLanguage::SHADER_MATERIAL_LIGHT)
code=get_text_edit()->get_text();
else if (type==ShaderLanguage::SHADER_MATERIAL_VERTEX)
code=get_text_edit()->get_text();
else
code=get_text_edit()->get_text();
@ -364,6 +368,7 @@ void ShaderEditor::_params_changed() {
fragment_editor->_validate_script();
vertex_editor->_validate_script();
light_editor->_validate_script();
}
@ -400,6 +405,7 @@ void ShaderEditor::edit(const Ref<Shader>& p_shader) {
if (shader->get_mode()==Shader::MODE_MATERIAL) {
fragment_editor->set_edited_shader(p_shader,ShaderLanguage::SHADER_MATERIAL_FRAGMENT);
light_editor->set_edited_shader(shader,ShaderLanguage::SHADER_MATERIAL_LIGHT);
settings_menu->get_popup()->set_item_checked( settings_menu->get_popup()->get_item_index(SHADER_MATERIAL_MODE), true);
settings_menu->get_popup()->set_item_checked( settings_menu->get_popup()->get_item_index(SHADER_POST_PROCESS_MODE), false);
} else {
@ -431,7 +437,7 @@ void ShaderEditor::apply_shaders() {
if (shader.is_valid())
shader->set_code(vertex_editor->get_text_edit()->get_text(),fragment_editor->get_text_edit()->get_text(),0,0);
shader->set_code(vertex_editor->get_text_edit()->get_text(),fragment_editor->get_text_edit()->get_text(),light_editor->get_text_edit()->get_text(),0,0);
}
void ShaderEditor::_close_callback() {
@ -514,11 +520,16 @@ ShaderEditor::ShaderEditor() {
tab_container->add_child(fragment_editor);
fragment_editor->set_name("Fragment");
light_editor = memnew( ShaderTextEditor );
tab_container->add_child(light_editor);
light_editor->set_name("Lighting");
tab_container->set_current_tab(1);
vertex_editor->connect("script_changed", this,"apply_shaders");
fragment_editor->connect("script_changed", this,"apply_shaders");
light_editor->connect("script_changed", this,"apply_shaders");
}

View File

@ -99,6 +99,7 @@ class ShaderEditor : public Control {
ShaderTextEditor *vertex_editor;
ShaderTextEditor *fragment_editor;
ShaderTextEditor *light_editor;
void _tab_changed(int p_which);
void _menu_option(int p_optin);

View File

@ -158,7 +158,7 @@ void ResourcesDock::save_resource(const String& p_path,const Ref<Resource>& p_re
flg|=ResourceSaver::FLAG_RELATIVE_PATHS;
String path = Globals::get_singleton()->localize_path(p_path);
Error err = ResourceSaver::save(path,p_resource,flg);
Error err = ResourceSaver::save(path,p_resource,flg|ResourceSaver::FLAG_REPLACE_SUBRESOURCE_PATHS);
if (err!=OK) {
accept->set_text("Error saving resource!");

View File

@ -2232,7 +2232,7 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
light_material_omni_icon = Ref<FixedMaterial>( memnew( FixedMaterial ));
light_material_omni_icon->set_flag(Material::FLAG_UNSHADED, true);
light_material_omni_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true);
light_material_omni_icon->set_hint(Material::HINT_NO_DEPTH_DRAW, true);
light_material_omni_icon->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
light_material_omni_icon->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
light_material_omni_icon->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1,0.9));
light_material_omni_icon->set_texture(FixedMaterial::PARAM_DIFFUSE,SpatialEditor::get_singleton()->get_icon("GizmoLight","EditorIcons"));
@ -2241,7 +2241,7 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
light_material_directional_icon = Ref<FixedMaterial>( memnew( FixedMaterial ));
light_material_directional_icon->set_flag(Material::FLAG_UNSHADED, true);
light_material_directional_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true);
light_material_directional_icon->set_hint(Material::HINT_NO_DEPTH_DRAW, true);
light_material_directional_icon->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
light_material_directional_icon->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
light_material_directional_icon->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1,0.9));
light_material_directional_icon->set_texture(FixedMaterial::PARAM_DIFFUSE,SpatialEditor::get_singleton()->get_icon("GizmoDirectionalLight","EditorIcons"));
@ -2253,7 +2253,7 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
skeleton_material->set_flag(Material::FLAG_DOUBLE_SIDED,true);
skeleton_material->set_flag(Material::FLAG_UNSHADED,true);
skeleton_material->set_flag(Material::FLAG_ONTOP,true);
skeleton_material->set_hint(Material::HINT_NO_DEPTH_DRAW,true);
skeleton_material->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
//position 3D Shared mesh
@ -2293,7 +2293,7 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
sample_player_icon = Ref<FixedMaterial>( memnew( FixedMaterial ));
sample_player_icon->set_flag(Material::FLAG_UNSHADED, true);
sample_player_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true);
sample_player_icon->set_hint(Material::HINT_NO_DEPTH_DRAW, true);
sample_player_icon->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
sample_player_icon->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
sample_player_icon->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1,0.9));
sample_player_icon->set_texture(FixedMaterial::PARAM_DIFFUSE,SpatialEditor::get_singleton()->get_icon("GizmoSpatialSamplePlayer","EditorIcons"));
@ -2307,7 +2307,7 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
stream_player_icon = Ref<FixedMaterial>( memnew( FixedMaterial ));
stream_player_icon->set_flag(Material::FLAG_UNSHADED, true);
stream_player_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true);
stream_player_icon->set_hint(Material::HINT_NO_DEPTH_DRAW, true);
stream_player_icon->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
stream_player_icon->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
stream_player_icon->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1,0.9));
stream_player_icon->set_texture(FixedMaterial::PARAM_DIFFUSE,SpatialEditor::get_singleton()->get_icon("GizmoSpatialStreamPlayer","EditorIcons"));
@ -2315,7 +2315,7 @@ SpatialEditorGizmos::SpatialEditorGizmos() {
visibility_notifier_icon = Ref<FixedMaterial>( memnew( FixedMaterial ));
visibility_notifier_icon->set_flag(Material::FLAG_UNSHADED, true);
visibility_notifier_icon->set_flag(Material::FLAG_DOUBLE_SIDED, true);
visibility_notifier_icon->set_hint(Material::HINT_NO_DEPTH_DRAW, true);
visibility_notifier_icon->set_depth_draw_mode(Material::DEPTH_DRAW_NEVER);
visibility_notifier_icon->set_fixed_flag(FixedMaterial::FLAG_USE_ALPHA, true);
visibility_notifier_icon->set_parameter(FixedMaterial::PARAM_DIFFUSE,Color(1,1,1,0.9));
visibility_notifier_icon->set_texture(FixedMaterial::PARAM_DIFFUSE,SpatialEditor::get_singleton()->get_icon("Visible","EditorIcons"));