summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/baked_light.cpp571
-rw-r--r--scene/resources/baked_light.h162
-rw-r--r--scene/resources/bit_mask.cpp7
-rw-r--r--scene/resources/default_theme/color_picker_hue.pngbin0 -> 132 bytes
-rw-r--r--scene/resources/default_theme/color_picker_main.pngbin0 -> 310 bytes
-rw-r--r--scene/resources/default_theme/color_picker_sample.pngbin0 -> 194 bytes
-rw-r--r--scene/resources/default_theme/default_theme.cpp18
-rw-r--r--scene/resources/default_theme/theme_data.h15
-rw-r--r--scene/resources/dynamic_font.cpp2
-rw-r--r--scene/resources/dynamic_font_stb.cpp2
-rw-r--r--scene/resources/environment.cpp1180
-rw-r--r--scene/resources/environment.h346
-rw-r--r--scene/resources/material.cpp1260
-rw-r--r--scene/resources/material.h424
-rw-r--r--scene/resources/mesh.cpp136
-rw-r--r--scene/resources/mesh.h23
-rw-r--r--scene/resources/mesh_data_tool.cpp2
-rw-r--r--scene/resources/multimesh.cpp63
-rw-r--r--scene/resources/multimesh.h32
-rw-r--r--scene/resources/room.cpp38
-rw-r--r--scene/resources/room.h8
-rw-r--r--scene/resources/shader.cpp338
-rw-r--r--scene/resources/shader.h31
-rw-r--r--scene/resources/shader_graph.cpp7
-rw-r--r--scene/resources/shader_graph.h4
-rw-r--r--scene/resources/shape.cpp2
-rw-r--r--scene/resources/sky_box.cpp158
-rw-r--r--scene/resources/sky_box.h71
-rw-r--r--scene/resources/style_box.cpp126
-rw-r--r--scene/resources/style_box.h30
-rw-r--r--scene/resources/surface_tool.cpp40
-rw-r--r--scene/resources/texture.cpp18
-rw-r--r--scene/resources/texture.h2
33 files changed, 2925 insertions, 2191 deletions
diff --git a/scene/resources/baked_light.cpp b/scene/resources/baked_light.cpp
index bcfcbb2170..616c12e8d7 100644
--- a/scene/resources/baked_light.cpp
+++ b/scene/resources/baked_light.cpp
@@ -29,574 +29,3 @@
#include "baked_light.h"
#include "servers/visual_server.h"
-void BakedLight::set_mode(Mode p_mode) {
-
- mode=p_mode;
- VS::get_singleton()->baked_light_set_mode(baked_light,(VS::BakedLightMode(p_mode)));
-
-}
-
-BakedLight::Mode BakedLight::get_mode() const{
-
- return mode;
-}
-
-void BakedLight::set_octree(const DVector<uint8_t>& p_octree) {
-
- VS::get_singleton()->baked_light_set_octree(baked_light,p_octree);
-}
-
-DVector<uint8_t> BakedLight::get_octree() const {
-
- return VS::get_singleton()->baked_light_get_octree(baked_light);
-}
-
-void BakedLight::set_light(const DVector<uint8_t>& p_light) {
-
- VS::get_singleton()->baked_light_set_light(baked_light,p_light);
-}
-
-DVector<uint8_t> BakedLight::get_light() const {
-
- return VS::get_singleton()->baked_light_get_light(baked_light);
-}
-
-
-void BakedLight::set_sampler_octree(const DVector<int>& p_sampler_octree) {
-
- VS::get_singleton()->baked_light_set_sampler_octree(baked_light,p_sampler_octree);
-}
-
-DVector<int> BakedLight::get_sampler_octree() const {
-
- return VS::get_singleton()->baked_light_get_sampler_octree(baked_light);
-}
-
-
-
-
-
-void BakedLight::add_lightmap(const Ref<Texture> &p_texture,Size2 p_gen_size) {
-
- LightMap lm;
- lm.texture=p_texture;
- lm.gen_size=p_gen_size;
- lightmaps.push_back(lm);
- _update_lightmaps();
- _change_notify();
-}
-
-void BakedLight::set_lightmap_gen_size(int p_idx,const Size2& p_size){
-
- ERR_FAIL_INDEX(p_idx,lightmaps.size());
- lightmaps[p_idx].gen_size=p_size;
- _update_lightmaps();
-}
-Size2 BakedLight::get_lightmap_gen_size(int p_idx) const{
-
- ERR_FAIL_INDEX_V(p_idx,lightmaps.size(),Size2());
- return lightmaps[p_idx].gen_size;
-
-}
-void BakedLight::set_lightmap_texture(int p_idx,const Ref<Texture> &p_texture){
-
- ERR_FAIL_INDEX(p_idx,lightmaps.size());
- lightmaps[p_idx].texture=p_texture;
- _update_lightmaps();
-
-}
-Ref<Texture> BakedLight::get_lightmap_texture(int p_idx) const{
-
- ERR_FAIL_INDEX_V(p_idx,lightmaps.size(),Ref<Texture>());
- return lightmaps[p_idx].texture;
-
-}
-void BakedLight::erase_lightmap(int p_idx){
-
- ERR_FAIL_INDEX(p_idx,lightmaps.size());
- lightmaps.remove(p_idx);
- _update_lightmaps();
- _change_notify();
-
-}
-int BakedLight::get_lightmaps_count() const{
-
- return lightmaps.size();
-}
-void BakedLight::clear_lightmaps(){
-
- lightmaps.clear();
- _update_lightmaps();
- _change_notify();
-}
-
-
-
-void BakedLight::_update_lightmaps() {
-
- VS::get_singleton()->baked_light_clear_lightmaps(baked_light);
- for(int i=0;i<lightmaps.size();i++) {
-
- RID tid;
- if (lightmaps[i].texture.is_valid())
- tid=lightmaps[i].texture->get_rid();
- VS::get_singleton()->baked_light_add_lightmap(baked_light,tid,i);
- }
-}
-
-
-
-RID BakedLight::get_rid() const {
-
- return baked_light;
-}
-
-Array BakedLight::_get_lightmap_data() const {
-
- Array ret;
- ret.resize(lightmaps.size()*2);
-
- int idx=0;
- for(int i=0;i<lightmaps.size();i++) {
-
- ret[idx++]=Size2(lightmaps[i].gen_size);
- ret[idx++]=lightmaps[i].texture;
- }
- return ret;
-
-}
-
-void BakedLight::_set_lightmap_data(Array p_array){
-
- lightmaps.clear();
- for(int i=0;i<p_array.size();i+=2) {
-
- Size2 size = p_array[i];
- Ref<Texture> tex = p_array[i+1];
-// ERR_CONTINUE(tex.is_null());
- LightMap lm;
- lm.gen_size=size;
- lm.texture=tex;
- lightmaps.push_back(lm);
- }
- _update_lightmaps();
-}
-
-
-void BakedLight::set_cell_subdivision(int p_subdiv) {
-
- cell_subdiv=p_subdiv;
-}
-
-int BakedLight::get_cell_subdivision() const{
-
- return cell_subdiv;
-}
-
-void BakedLight::set_initial_lattice_subdiv(int p_size){
-
- lattice_subdiv=p_size;
-}
-int BakedLight::get_initial_lattice_subdiv() const{
-
- return lattice_subdiv;
-}
-
-void BakedLight::set_plot_size(float p_size){
-
- plot_size=p_size;
-}
-float BakedLight::get_plot_size() const{
-
- return plot_size;
-}
-
-void BakedLight::set_bounces(int p_size){
-
- bounces=p_size;
-}
-int BakedLight::get_bounces() const{
-
- return bounces;
-}
-
-void BakedLight::set_cell_extra_margin(float p_margin) {
- cell_extra_margin=p_margin;
-}
-
-float BakedLight::get_cell_extra_margin() const {
-
- return cell_extra_margin;
-}
-
-void BakedLight::set_edge_damp(float p_margin) {
- edge_damp=p_margin;
-}
-
-float BakedLight::get_edge_damp() const {
-
- return edge_damp;
-}
-
-
-void BakedLight::set_normal_damp(float p_margin) {
- normal_damp=p_margin;
-}
-
-float BakedLight::get_normal_damp() const {
-
- return normal_damp;
-}
-
-void BakedLight::set_tint(float p_margin) {
- tint=p_margin;
-}
-
-float BakedLight::get_tint() const {
-
- return tint;
-}
-
-void BakedLight::set_saturation(float p_margin) {
- saturation=p_margin;
-}
-
-float BakedLight::get_saturation() const {
-
- return saturation;
-}
-
-void BakedLight::set_ao_radius(float p_ao_radius) {
- ao_radius=p_ao_radius;
-}
-
-float BakedLight::get_ao_radius() const {
- return ao_radius;
-}
-
-void BakedLight::set_ao_strength(float p_ao_strength) {
-
- ao_strength=p_ao_strength;
-}
-
-float BakedLight::get_ao_strength() const {
-
- return ao_strength;
-}
-
-void BakedLight::set_realtime_color_enabled(const bool p_realtime_color_enabled) {
-
- VS::get_singleton()->baked_light_set_realtime_color_enabled(baked_light, p_realtime_color_enabled);
-}
-
-bool BakedLight::get_realtime_color_enabled() const {
-
- return VS::get_singleton()->baked_light_get_realtime_color_enabled(baked_light);
-}
-
-
-void BakedLight::set_realtime_color(const Color &p_realtime_color) {
-
- VS::get_singleton()->baked_light_set_realtime_color(baked_light, p_realtime_color);
-}
-
-Color BakedLight::get_realtime_color() const {
-
- return VS::get_singleton()->baked_light_get_realtime_color(baked_light);
-}
-
-void BakedLight::set_realtime_energy(const float p_realtime_energy) {
-
- VS::get_singleton()->baked_light_set_realtime_energy(baked_light, p_realtime_energy);
-}
-
-float BakedLight::get_realtime_energy() const {
-
- return VS::get_singleton()->baked_light_get_realtime_energy(baked_light);
-}
-
-
-
-void BakedLight::set_energy_multiplier(float p_multiplier){
-
- energy_multiply=p_multiplier;
-}
-float BakedLight::get_energy_multiplier() const{
-
- return energy_multiply;
-}
-
-void BakedLight::set_gamma_adjust(float p_adjust){
-
- gamma_adjust=p_adjust;
-}
-float BakedLight::get_gamma_adjust() const{
-
- return gamma_adjust;
-}
-
-void BakedLight::set_bake_flag(BakeFlags p_flags,bool p_enable){
-
- flags[p_flags]=p_enable;
-}
-bool BakedLight::get_bake_flag(BakeFlags p_flags) const{
-
- return flags[p_flags];
-}
-
-void BakedLight::set_format(Format p_format) {
-
- format=p_format;
- VS::get_singleton()->baked_light_set_lightmap_multiplier(baked_light,format==FORMAT_HDR8?8.0:1.0);
-}
-
-BakedLight::Format BakedLight::get_format() const{
-
- return format;
-}
-
-void BakedLight::set_transfer_lightmaps_only_to_uv2(bool p_enable) {
-
- transfer_only_uv2=p_enable;
-}
-
-bool BakedLight::get_transfer_lightmaps_only_to_uv2() const{
-
- return transfer_only_uv2;
-}
-
-
-bool BakedLight::_set(const StringName& p_name, const Variant& p_value) {
-
- String n = p_name;
- if (!n.begins_with("lightmap"))
- return false;
- int idx = n.get_slicec('/',1).to_int();
- ERR_FAIL_COND_V(idx<0,false);
- ERR_FAIL_COND_V(idx>lightmaps.size(),false);
-
- String what = n.get_slicec('/',2);
- Ref<Texture> tex;
- Size2 gens;
-
- if (what=="texture")
- tex=p_value;
- else if (what=="gen_size")
- gens=p_value;
-
- if (idx==lightmaps.size()) {
- if (tex.is_valid() || gens!=Size2())
- add_lightmap(tex,gens);
- } else {
- if (tex.is_valid())
- set_lightmap_texture(idx,tex);
- else if (gens!=Size2())
- set_lightmap_gen_size(idx,gens);
- }
-
-
- return true;
-}
-
-bool BakedLight::_get(const StringName& p_name,Variant &r_ret) const{
-
- String n = p_name;
- if (!n.begins_with("lightmap"))
- return false;
- int idx = n.get_slicec('/',1).to_int();
- ERR_FAIL_COND_V(idx<0,false);
- ERR_FAIL_COND_V(idx>lightmaps.size(),false);
-
- String what = n.get_slicec('/',2);
-
- if (what=="texture") {
- if (idx==lightmaps.size())
- r_ret=Ref<Texture>();
- else
- r_ret=lightmaps[idx].texture;
-
- } else if (what=="gen_size") {
-
- if (idx==lightmaps.size())
- r_ret=Size2();
- else
- r_ret=Size2(lightmaps[idx].gen_size);
- } else
- return false;
-
- return true;
-
-
-}
-void BakedLight::_get_property_list( List<PropertyInfo> *p_list) const{
-
- for(int i=0;i<=lightmaps.size();i++) {
-
- p_list->push_back(PropertyInfo(Variant::VECTOR2,"lightmaps/"+itos(i)+"/gen_size",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_EDITOR));
- p_list->push_back(PropertyInfo(Variant::OBJECT,"lightmaps/"+itos(i)+"/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture",PROPERTY_USAGE_EDITOR));
- }
-}
-
-
-void BakedLight::_bind_methods(){
-
-
- ObjectTypeDB::bind_method(_MD("set_mode","mode"),&BakedLight::set_mode);
- ObjectTypeDB::bind_method(_MD("get_mode"),&BakedLight::get_mode);
-
- ObjectTypeDB::bind_method(_MD("set_octree","octree"),&BakedLight::set_octree);
- ObjectTypeDB::bind_method(_MD("get_octree"),&BakedLight::get_octree);
-
- ObjectTypeDB::bind_method(_MD("set_light","light"),&BakedLight::set_light);
- ObjectTypeDB::bind_method(_MD("get_light"),&BakedLight::get_light);
-
- ObjectTypeDB::bind_method(_MD("set_sampler_octree","sampler_octree"),&BakedLight::set_sampler_octree);
- ObjectTypeDB::bind_method(_MD("get_sampler_octree"),&BakedLight::get_sampler_octree);
-
-
- ObjectTypeDB::bind_method(_MD("add_lightmap","texture:Texture","gen_size"),&BakedLight::add_lightmap);
- ObjectTypeDB::bind_method(_MD("erase_lightmap","id"),&BakedLight::erase_lightmap);
- ObjectTypeDB::bind_method(_MD("clear_lightmaps"),&BakedLight::clear_lightmaps);
-
- ObjectTypeDB::bind_method(_MD("_set_lightmap_data","lightmap_data"),&BakedLight::_set_lightmap_data);
- ObjectTypeDB::bind_method(_MD("_get_lightmap_data"),&BakedLight::_get_lightmap_data);
-
- ObjectTypeDB::bind_method(_MD("set_cell_subdivision","cell_subdivision"),&BakedLight::set_cell_subdivision);
- ObjectTypeDB::bind_method(_MD("get_cell_subdivision"),&BakedLight::get_cell_subdivision);
-
- ObjectTypeDB::bind_method(_MD("set_initial_lattice_subdiv","cell_subdivision"),&BakedLight::set_initial_lattice_subdiv);
- ObjectTypeDB::bind_method(_MD("get_initial_lattice_subdiv","cell_subdivision"),&BakedLight::get_initial_lattice_subdiv);
-
- ObjectTypeDB::bind_method(_MD("set_plot_size","plot_size"),&BakedLight::set_plot_size);
- ObjectTypeDB::bind_method(_MD("get_plot_size"),&BakedLight::get_plot_size);
-
- ObjectTypeDB::bind_method(_MD("set_bounces","bounces"),&BakedLight::set_bounces);
- ObjectTypeDB::bind_method(_MD("get_bounces"),&BakedLight::get_bounces);
-
- ObjectTypeDB::bind_method(_MD("set_cell_extra_margin","cell_extra_margin"),&BakedLight::set_cell_extra_margin);
- ObjectTypeDB::bind_method(_MD("get_cell_extra_margin"),&BakedLight::get_cell_extra_margin);
-
- ObjectTypeDB::bind_method(_MD("set_edge_damp","edge_damp"),&BakedLight::set_edge_damp);
- ObjectTypeDB::bind_method(_MD("get_edge_damp"),&BakedLight::get_edge_damp);
-
- ObjectTypeDB::bind_method(_MD("set_normal_damp","normal_damp"),&BakedLight::set_normal_damp);
- ObjectTypeDB::bind_method(_MD("get_normal_damp"),&BakedLight::get_normal_damp);
-
- ObjectTypeDB::bind_method(_MD("set_tint","tint"),&BakedLight::set_tint);
- ObjectTypeDB::bind_method(_MD("get_tint"),&BakedLight::get_tint);
-
- ObjectTypeDB::bind_method(_MD("set_saturation","saturation"),&BakedLight::set_saturation);
- ObjectTypeDB::bind_method(_MD("get_saturation"),&BakedLight::get_saturation);
-
- ObjectTypeDB::bind_method(_MD("set_ao_radius","ao_radius"),&BakedLight::set_ao_radius);
- ObjectTypeDB::bind_method(_MD("get_ao_radius"),&BakedLight::get_ao_radius);
-
- ObjectTypeDB::bind_method(_MD("set_ao_strength","ao_strength"),&BakedLight::set_ao_strength);
- ObjectTypeDB::bind_method(_MD("get_ao_strength"),&BakedLight::get_ao_strength);
-
- ObjectTypeDB::bind_method(_MD("set_realtime_color_enabled", "enabled"), &BakedLight::set_realtime_color_enabled);
- ObjectTypeDB::bind_method(_MD("get_realtime_color_enabled"), &BakedLight::get_realtime_color_enabled);
-
- ObjectTypeDB::bind_method(_MD("set_realtime_color", "tint"), &BakedLight::set_realtime_color);
- ObjectTypeDB::bind_method(_MD("get_realtime_color"), &BakedLight::get_realtime_color);
-
- ObjectTypeDB::bind_method(_MD("set_realtime_energy", "energy"), &BakedLight::set_realtime_energy);
- ObjectTypeDB::bind_method(_MD("get_realtime_energy"), &BakedLight::get_realtime_energy);
-
- ObjectTypeDB::bind_method(_MD("set_format","format"),&BakedLight::set_format);
- ObjectTypeDB::bind_method(_MD("get_format"),&BakedLight::get_format);
-
- ObjectTypeDB::bind_method(_MD("set_transfer_lightmaps_only_to_uv2","enable"),&BakedLight::set_transfer_lightmaps_only_to_uv2);
- ObjectTypeDB::bind_method(_MD("get_transfer_lightmaps_only_to_uv2"),&BakedLight::get_transfer_lightmaps_only_to_uv2);
-
-
-
-
- ObjectTypeDB::bind_method(_MD("set_energy_multiplier","energy_multiplier"),&BakedLight::set_energy_multiplier);
- ObjectTypeDB::bind_method(_MD("get_energy_multiplier"),&BakedLight::get_energy_multiplier);
-
- ObjectTypeDB::bind_method(_MD("set_gamma_adjust","gamma_adjust"),&BakedLight::set_gamma_adjust);
- ObjectTypeDB::bind_method(_MD("get_gamma_adjust"),&BakedLight::get_gamma_adjust);
-
- ObjectTypeDB::bind_method(_MD("set_bake_flag","flag","enabled"),&BakedLight::set_bake_flag);
- ObjectTypeDB::bind_method(_MD("get_bake_flag","flag"),&BakedLight::get_bake_flag);
-
- ADD_PROPERTY( PropertyInfo(Variant::INT,"mode/mode",PROPERTY_HINT_ENUM,"Octree,Lightmaps"),_SCS("set_mode"),_SCS("get_mode"));
-
- ADD_PROPERTY( PropertyInfo(Variant::INT,"baking/format",PROPERTY_HINT_ENUM,"RGB,HDR8,HDR16"),_SCS("set_format"),_SCS("get_format"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"baking/cell_subdiv",PROPERTY_HINT_RANGE,"4,14,1"),_SCS("set_cell_subdivision"),_SCS("get_cell_subdivision"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"baking/lattice_subdiv",PROPERTY_HINT_RANGE,"1,5,1"),_SCS("set_initial_lattice_subdiv"),_SCS("get_initial_lattice_subdiv"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"baking/light_bounces",PROPERTY_HINT_RANGE,"0,3,1"),_SCS("set_bounces"),_SCS("get_bounces"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"baking/plot_size",PROPERTY_HINT_RANGE,"1.0,16.0,0.01"),_SCS("set_plot_size"),_SCS("get_plot_size"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"baking/energy_mult",PROPERTY_HINT_RANGE,"0.01,4096.0,0.01"),_SCS("set_energy_multiplier"),_SCS("get_energy_multiplier"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"baking/gamma_adjust",PROPERTY_HINT_EXP_EASING),_SCS("set_gamma_adjust"),_SCS("get_gamma_adjust"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"baking/saturation",PROPERTY_HINT_RANGE,"0,8,0.01"),_SCS("set_saturation"),_SCS("get_saturation"));
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"baking_flags/diffuse"),_SCS("set_bake_flag"),_SCS("get_bake_flag"),BAKE_DIFFUSE);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"baking_flags/specular"),_SCS("set_bake_flag"),_SCS("get_bake_flag"),BAKE_SPECULAR);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"baking_flags/translucent"),_SCS("set_bake_flag"),_SCS("get_bake_flag"),BAKE_TRANSLUCENT);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"baking_flags/conserve_energy"),_SCS("set_bake_flag"),_SCS("get_bake_flag"),BAKE_CONSERVE_ENERGY);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"baking_flags/linear_color"),_SCS("set_bake_flag"),_SCS("get_bake_flag"),BAKE_LINEAR_COLOR);
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"lightmap/use_only_uv2"),_SCS("set_transfer_lightmaps_only_to_uv2"),_SCS("get_transfer_lightmaps_only_to_uv2"));
-
- ADD_PROPERTY( PropertyInfo(Variant::RAW_ARRAY,"octree",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_octree"),_SCS("get_octree"));
- ADD_PROPERTY( PropertyInfo(Variant::RAW_ARRAY,"light",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_light"),_SCS("get_light"));
- ADD_PROPERTY( PropertyInfo(Variant::INT_ARRAY,"sampler_octree",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("set_sampler_octree"),_SCS("get_sampler_octree"));
- ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"lightmaps",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_lightmap_data"),_SCS("_get_lightmap_data"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"advanced/cell_margin",PROPERTY_HINT_RANGE,"0.01,0.8,0.01"),_SCS("set_cell_extra_margin"),_SCS("get_cell_extra_margin"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"advanced/edge_damp",PROPERTY_HINT_RANGE,"0.0,8.0,0.1"),_SCS("set_edge_damp"),_SCS("get_edge_damp"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"advanced/normal_damp",PROPERTY_HINT_RANGE,"0.0,1.0,0.01"),_SCS("set_normal_damp"),_SCS("get_normal_damp"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"advanced/light_tint",PROPERTY_HINT_RANGE,"0.0,1.0,0.01"),_SCS("set_tint"),_SCS("get_tint"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"advanced/ao_radius",PROPERTY_HINT_RANGE,"0.0,16.0,0.01"),_SCS("set_ao_radius"),_SCS("get_ao_radius"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"advanced/ao_strength",PROPERTY_HINT_RANGE,"0.0,1.0,0.01"),_SCS("set_ao_strength"),_SCS("get_ao_strength"));
-
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "realtime/enabled"), _SCS("set_realtime_color_enabled"), _SCS("get_realtime_color_enabled"));
- ADD_PROPERTY(PropertyInfo(Variant::COLOR, "realtime/color", PROPERTY_HINT_COLOR_NO_ALPHA), _SCS("set_realtime_color"), _SCS("get_realtime_color"));
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "realtime/energy", PROPERTY_HINT_RANGE, "0.01,4096.0,0.01"), _SCS("set_realtime_energy"), _SCS("get_realtime_energy"));
-
-
- BIND_CONSTANT( MODE_OCTREE );
- BIND_CONSTANT( MODE_LIGHTMAPS );
-
- BIND_CONSTANT( BAKE_DIFFUSE );
- BIND_CONSTANT( BAKE_SPECULAR );
- BIND_CONSTANT( BAKE_TRANSLUCENT );
- BIND_CONSTANT( BAKE_CONSERVE_ENERGY );
- BIND_CONSTANT( BAKE_MAX );
-
-
-}
-
-
-BakedLight::BakedLight() {
-
- cell_subdiv=8;
- lattice_subdiv=4;
- plot_size=2.5;
- bounces=1;
- energy_multiply=2.0;
- gamma_adjust=0.7;
- cell_extra_margin=0.05;
- edge_damp=0.0;
- normal_damp=0.0;
- saturation=1;
- tint=0.0;
- ao_radius=2.5;
- ao_strength=0.7;
- format=FORMAT_RGB;
- transfer_only_uv2=false;
-
-
- flags[BAKE_DIFFUSE]=true;
- flags[BAKE_SPECULAR]=false;
- flags[BAKE_TRANSLUCENT]=true;
- flags[BAKE_CONSERVE_ENERGY]=false;
- flags[BAKE_LINEAR_COLOR]=false;
-
- mode=MODE_OCTREE;
- baked_light=VS::get_singleton()->baked_light_create();
-}
-
-BakedLight::~BakedLight() {
-
- VS::get_singleton()->free(baked_light);
-}
diff --git a/scene/resources/baked_light.h b/scene/resources/baked_light.h
index adbe7cccad..0c69ce429e 100644
--- a/scene/resources/baked_light.h
+++ b/scene/resources/baked_light.h
@@ -32,168 +32,6 @@
#include "resource.h"
#include "scene/resources/texture.h"
-class BakedLight : public Resource {
- OBJ_TYPE( BakedLight, Resource);
-public:
- enum Mode {
-
- MODE_OCTREE,
- MODE_LIGHTMAPS
- };
-
- enum Format {
-
- FORMAT_RGB,
- FORMAT_HDR8,
- FORMAT_HDR16
- };
-
- enum BakeFlags {
- BAKE_DIFFUSE,
- BAKE_SPECULAR,
- BAKE_TRANSLUCENT,
- BAKE_CONSERVE_ENERGY,
- BAKE_LINEAR_COLOR,
- BAKE_MAX
- };
-
-private:
-
- RID baked_light;
- Mode mode;
- struct LightMap {
- Size2i gen_size;
- Ref<Texture> texture;
- };
-
-
- Vector< LightMap> lightmaps;
-
- //bake vars
- int cell_subdiv;
- int lattice_subdiv;
- float plot_size;
- float energy_multiply;
- float gamma_adjust;
- float cell_extra_margin;
- float edge_damp;
- float normal_damp;
- float tint;
- float ao_radius;
- float ao_strength;
- float saturation;
- int bounces;
- bool transfer_only_uv2;
- Format format;
- bool flags[BAKE_MAX];
-
-
-
- void _update_lightmaps();
-
- Array _get_lightmap_data() const;
- void _set_lightmap_data(Array p_array);
-
-protected:
-
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
-
- static void _bind_methods();
-
-public:
-
- void set_cell_subdivision(int p_subdiv);
- int get_cell_subdivision() const;
-
- void set_initial_lattice_subdiv(int p_size);
- int get_initial_lattice_subdiv() const;
-
- void set_plot_size(float p_size);
- float get_plot_size() const;
-
- void set_bounces(int p_size);
- int get_bounces() const;
-
- void set_energy_multiplier(float p_multiplier);
- float get_energy_multiplier() const;
-
- void set_gamma_adjust(float p_adjust);
- float get_gamma_adjust() const;
-
- void set_cell_extra_margin(float p_margin);
- float get_cell_extra_margin() const;
-
- void set_edge_damp(float p_margin);
- float get_edge_damp() const;
-
- void set_normal_damp(float p_margin);
- float get_normal_damp() const;
-
- void set_tint(float p_margin);
- float get_tint() const;
-
- void set_saturation(float p_saturation);
- float get_saturation() const;
-
- void set_ao_radius(float p_ao_radius);
- float get_ao_radius() const;
-
- void set_ao_strength(float p_ao_strength);
- float get_ao_strength() const;
-
- void set_realtime_color_enabled(const bool p_enabled);
- bool get_realtime_color_enabled() const;
-
- void set_realtime_color(const Color& p_realtime_color);
- Color get_realtime_color() const;
-
- void set_realtime_energy(const float p_realtime_energy);
- float get_realtime_energy() const;
-
- void set_bake_flag(BakeFlags p_flags,bool p_enable);
- bool get_bake_flag(BakeFlags p_flags) const;
-
- void set_format(Format p_margin);
- Format get_format() const;
-
- void set_transfer_lightmaps_only_to_uv2(bool p_enable);
- bool get_transfer_lightmaps_only_to_uv2() const;
-
- void set_mode(Mode p_mode);
- Mode get_mode() const;
-
- void set_octree(const DVector<uint8_t>& p_octree);
- DVector<uint8_t> get_octree() const;
-
- void set_light(const DVector<uint8_t>& p_light);
- DVector<uint8_t> get_light() const;
-
- void set_sampler_octree(const DVector<int>& p_sampler_octree);
- DVector<int> get_sampler_octree() const;
-
-
-
- void add_lightmap(const Ref<Texture> &p_texture,Size2 p_gen_size=Size2(256,256));
- void set_lightmap_gen_size(int p_idx,const Size2& p_size);
- Size2 get_lightmap_gen_size(int p_idx) const;
- void set_lightmap_texture(int p_idx,const Ref<Texture> &p_texture);
- Ref<Texture> get_lightmap_texture(int p_idx) const;
- void erase_lightmap(int p_idx);
- int get_lightmaps_count() const;
- void clear_lightmaps();
-
- virtual RID get_rid() const;
-
- BakedLight();
- ~BakedLight();
-};
-
-
-VARIANT_ENUM_CAST(BakedLight::Format);
-VARIANT_ENUM_CAST(BakedLight::Mode);
-VARIANT_ENUM_CAST(BakedLight::BakeFlags);
#endif // BAKED_LIGHT_H
diff --git a/scene/resources/bit_mask.cpp b/scene/resources/bit_mask.cpp
index b9b31ba32a..5763be2e08 100644
--- a/scene/resources/bit_mask.cpp
+++ b/scene/resources/bit_mask.cpp
@@ -45,8 +45,8 @@ void BitMap::create_from_image_alpha(const Image& p_image){
ERR_FAIL_COND(p_image.empty());
Image img=p_image;
- img.convert(Image::FORMAT_INTENSITY);
- ERR_FAIL_COND(img.get_format()!=Image::FORMAT_INTENSITY);
+ img.convert(Image::FORMAT_LA8);
+ ERR_FAIL_COND(img.get_format()!=Image::FORMAT_LA8);
create(Size2(img.get_width(),img.get_height()));
@@ -58,7 +58,7 @@ void BitMap::create_from_image_alpha(const Image& p_image){
int bbyte = i/8;
int bbit = i % 8;
- if (r[i])
+ if (r[i*2])
w[bbyte]|=(1<<bbit);
}
@@ -193,7 +193,6 @@ void BitMap::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY,"data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_data"),_SCS("_get_data"));
-
}
BitMap::BitMap() {
diff --git a/scene/resources/default_theme/color_picker_hue.png b/scene/resources/default_theme/color_picker_hue.png
new file mode 100644
index 0000000000..9bdd24f4fe
--- /dev/null
+++ b/scene/resources/default_theme/color_picker_hue.png
Binary files differ
diff --git a/scene/resources/default_theme/color_picker_main.png b/scene/resources/default_theme/color_picker_main.png
new file mode 100644
index 0000000000..0498628180
--- /dev/null
+++ b/scene/resources/default_theme/color_picker_main.png
Binary files differ
diff --git a/scene/resources/default_theme/color_picker_sample.png b/scene/resources/default_theme/color_picker_sample.png
new file mode 100644
index 0000000000..b145a3e384
--- /dev/null
+++ b/scene/resources/default_theme/color_picker_sample.png
Binary files differ
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index d90c66af38..4c6cf1c7c0 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -58,14 +58,14 @@ static Ref<StyleBoxTexture> make_stylebox(T p_src,float p_left, float p_top, flo
if (scale>1) {
Size2 orig_size = Size2(img.get_width(),img.get_height());
- img.convert(Image::FORMAT_RGBA);
+ img.convert(Image::FORMAT_RGBA8);
img.expand_x2_hq2x();
if (scale!=2.0) {
img.resize(orig_size.x*scale,orig_size.y*scale);
}
} else if (scale<1) {
Size2 orig_size = Size2(img.get_width(),img.get_height());
- img.convert(Image::FORMAT_RGBA);
+ img.convert(Image::FORMAT_RGBA8);
img.resize(orig_size.x*scale,orig_size.y*scale);
}
@@ -108,14 +108,14 @@ static Ref<Texture> make_icon(T p_src) {
if (scale>1) {
Size2 orig_size = Size2(img.get_width(),img.get_height());
- img.convert(Image::FORMAT_RGBA);
+ img.convert(Image::FORMAT_RGBA8);
img.expand_x2_hq2x();
if (scale!=2.0) {
img.resize(orig_size.x*scale,orig_size.y*scale);
}
} else if (scale<1) {
Size2 orig_size = Size2(img.get_width(),img.get_height());
- img.convert(Image::FORMAT_RGBA);
+ img.convert(Image::FORMAT_RGBA8);
img.resize(orig_size.x*scale,orig_size.y*scale);
}
texture->create_from_image( img,ImageTexture::FLAG_FILTER );
@@ -125,7 +125,7 @@ static Ref<Texture> make_icon(T p_src) {
static Ref<Shader> make_shader(const char*vertex_code,const char*fragment_code,const char*lighting_code) {
Ref<Shader> shader = (memnew( Shader(Shader::MODE_CANVAS_ITEM) ));
- shader->set_code(vertex_code, fragment_code, lighting_code);
+// shader->set_code(vertex_code, fragment_code, lighting_code);
return shader;
}
@@ -214,6 +214,8 @@ static Ref<StyleBox> make_empty_stylebox(float p_margin_left=-1, float p_margin_
return style;
}
+
+
void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref<Font> & large_font, Ref<Texture>& default_icon, Ref<StyleBox>& default_style, float p_scale) {
scale=p_scale;
@@ -833,10 +835,15 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref
t->set_icon("screen_picker","ColorPicker", make_icon( icon_color_pick_png ) );
t->set_icon("add_preset","ColorPicker", make_icon( icon_add_png ) );
+ t->set_icon("color_area", "ColorPicker", make_icon( color_picker_main_png));
+ t->set_icon("color_hue", "ColorPicker", make_icon( color_picker_hue_png));
+ t->set_icon("color_sample", "ColorPicker", make_icon( color_picker_sample_png));
t->set_shader("uv_editor", "ColorPicker", make_shader("", uv_editor_shader_code, ""));
t->set_shader("w_editor", "ColorPicker", make_shader("", w_editor_shader_code, ""));
+
+
// TooltipPanel
Ref<StyleBoxTexture> style_tt = make_stylebox( tooltip_bg_png,4,4,4,4);
@@ -962,7 +969,6 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref
t->set_icon( "logo","Icons", make_icon(logo_png) );
-
// Theme
default_icon= make_icon(error_icon_png) ;
diff --git a/scene/resources/default_theme/theme_data.h b/scene/resources/default_theme/theme_data.h
index 73c801483f..913ea9b5e9 100644
--- a/scene/resources/default_theme/theme_data.h
+++ b/scene/resources/default_theme/theme_data.h
@@ -69,6 +69,21 @@ static const unsigned char close_hl_png[]={
};
+static const unsigned char color_picker_hue_png[]={
+0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x1,0x0,0x8,0x2,0x0,0x0,0x0,0x35,0x30,0x61,0x19,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x9,0x18,0xc,0x24,0x18,0xa9,0xb3,0x2c,0xb7,0x0,0x0,0x0,0x23,0x49,0x44,0x41,0x54,0x68,0xde,0xed,0xc1,0x31,0x1,0x0,0x0,0x0,0xc2,0xa0,0xf5,0x4f,0x6d,0xd,0xf,0xa0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xbe,0xd,0x31,0x0,0x0,0x1,0x35,0x84,0x14,0xe2,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+};
+
+
+static const unsigned char color_picker_main_png[]={
+0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x1,0x0,0x0,0x0,0x1,0x0,0x8,0x2,0x0,0x0,0x0,0xd3,0x10,0x3f,0x31,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x9,0x18,0xc,0x23,0x22,0x20,0xfe,0x63,0xc2,0x0,0x0,0x0,0xd5,0x49,0x44,0x41,0x54,0x78,0xda,0xed,0xc1,0x31,0x1,0x0,0x0,0x0,0xc2,0xa0,0xf5,0x4f,0xed,0x65,0xb,0xa0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x1b,0x1,0x2d,0x0,0x1,0x9e,0xcb,0xc2,0xed,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+};
+
+
+static const unsigned char color_picker_sample_png[]={
+0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x14,0x8,0x2,0x0,0x0,0x0,0xed,0x20,0x74,0x8,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x9,0x18,0xc,0x27,0x37,0x29,0x4f,0x42,0x2d,0x0,0x0,0x0,0x61,0x49,0x44,0x41,0x54,0x68,0xde,0xed,0xd9,0xb1,0xd,0x0,0x21,0xc,0x3,0x40,0x40,0xbf,0x5f,0x66,0xcd,0x84,0xf9,0x96,0x19,0xf0,0x5d,0x87,0x5c,0x5b,0x9,0xca,0x9e,0x99,0x75,0xe9,0xee,0xfb,0x59,0x55,0x52,0xe9,0xc3,0xe9,0x59,0x10,0x4c,0x1,0x50,0x0,0x50,0x0,0x8,0xf4,0xf9,0x15,0x49,0x93,0x53,0x13,0x0,0x2b,0x10,0x28,0x0,0x28,0x0,0x64,0xd9,0x2e,0xc1,0xd2,0xe4,0xd4,0x4,0xc0,0xa,0x4,0xa,0x0,0xa,0x0,0x59,0x5c,0x82,0xa5,0xd1,0xa9,0x9,0x80,0x15,0x8,0x14,0x0,0x14,0x0,0xb2,0xfc,0x5b,0xb2,0x3c,0x5a,0x4,0xa1,0xf3,0x57,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
+};
+
+
static const unsigned char dosfont_png[]={
0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x80,0x0,0x0,0x0,0x80,0x1,0x0,0x0,0x0,0x0,0xeb,0x45,0x5c,0x66,0x0,0x0,0x0,0x4,0x67,0x41,0x4d,0x41,0x0,0x0,0xb1,0x8f,0xb,0xfc,0x61,0x5,0x0,0x0,0x0,0x20,0x63,0x48,0x52,0x4d,0x0,0x0,0x7a,0x26,0x0,0x0,0x80,0x84,0x0,0x0,0xfa,0x0,0x0,0x0,0x80,0xe8,0x0,0x0,0x75,0x30,0x0,0x0,0xea,0x60,0x0,0x0,0x3a,0x98,0x0,0x0,0x17,0x70,0x9c,0xba,0x51,0x3c,0x0,0x0,0x0,0x2,0x74,0x52,0x4e,0x53,0x0,0x0,0x76,0x93,0xcd,0x38,0x0,0x0,0x0,0x2,0x62,0x4b,0x47,0x44,0x0,0x1,0xdd,0x8a,0x13,0xa4,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x89,0x0,0x0,0xb,0x89,0x1,0x37,0xc9,0xcb,0xad,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x6,0x16,0x12,0x2b,0x5,0x39,0x1a,0x32,0x39,0x0,0x0,0x2,0x83,0x49,0x44,0x41,0x54,0x48,0xc7,0xed,0xd4,0xb1,0x6e,0xdb,0x30,0x10,0x0,0x50,0x22,0x3,0x27,0x22,0xc8,0x78,0x83,0x91,0xa9,0x1f,0xc0,0xa9,0x10,0xa,0x7e,0xc,0x11,0x14,0x87,0xc,0x1c,0x32,0x9,0x1a,0xe,0x46,0xa6,0xfc,0x43,0xff,0x86,0xb5,0x80,0x9b,0x88,0x8e,0x5d,0x64,0x18,0x9e,0xdc,0xd5,0x53,0x91,0xc1,0xa0,0x7a,0xa4,0xe4,0xd4,0x31,0xd2,0x25,0x70,0x97,0xa2,0x37,0x48,0xe6,0x33,0x45,0xdd,0x51,0x24,0x95,0x7a,0x23,0xe0,0x75,0x13,0xb,0xd8,0x93,0xbf,0x51,0x51,0xa3,0xac,0x99,0xc9,0x29,0x87,0x81,0x83,0xb2,0x0,0xc7,0xfe,0xee,0x43,0x58,0x85,0x95,0xb7,0xa6,0xb6,0xaf,0x7a,0xe9,0x93,0x63,0xc3,0xf2,0xc,0x96,0x3e,0xba,0x97,0x11,0x3,0xb5,0x46,0xc0,0x15,0x30,0x43,0x1,0xbd,0x6,0x81,0x71,0xa9,0xb2,0x82,0x9,0x92,0x3d,0xf6,0xb0,0xbd,0x5c,0xf2,0x53,0xf2,0x75,0xc,0x11,0x5f,0xc7,0xe0,0xc4,0xaa,0xb4,0x40,0x41,0xc4,0x69,0xd0,0x27,0x55,0x12,0x13,0x78,0x74,0xa7,0xb5,0xd8,0x3f,0x14,0x77,0x81,0x0,0x22,0x93,0x9b,0x4c,0x54,0x5b,0x72,0x6d,0x98,0x17,0xd1,0x33,0xb3,0x94,0xaa,0x3c,0x93,0xea,0xb4,0x76,0x31,0x6a,0x66,0x0,0xa9,0x59,0x1c,0x8c,0xe,0x33,0xc0,0x12,0x4c,0x29,0xc2,0xa5,0xc3,0xc1,0xd0,0xb2,0x64,0x6a,0x60,0xa3,0xc0,0xea,0xac,0x19,0x58,0x4b,0xa9,0x4a,0x17,0xf0,0xda,0x68,0xb6,0x5,0xec,0xb2,0xf6,0x88,0x33,0xc8,0x18,0x52,0xd5,0x5a,0x1,0xb3,0x61,0x1,0x53,0xdf,0x2,0x51,0x2d,0x33,0xdd,0x12,0x59,0xea,0x94,0x95,0x3c,0x80,0x2e,0x5e,0xf9,0xdb,0x71,0x73,0x70,0xcf,0x39,0x3b,0x76,0xb7,0xbb,0x7d,0xcf,0x74,0x50,0xd,0x62,0x40,0x44,0x6,0x83,0xfe,0xc7,0x8e,0x51,0x5,0x5c,0xe1,0xdd,0xdd,0xaa,0xc2,0xf8,0x53,0x80,0x31,0xe2,0xfd,0x7d,0x14,0x8,0x7e,0xcc,0x5,0x28,0x62,0xd7,0xc5,0xc,0xa6,0xf3,0xc3,0x46,0xa6,0x30,0xd7,0x1e,0x1b,0x2e,0xd0,0x7f,0x63,0x5f,0x1f,0xf1,0x32,0xc9,0x90,0x82,0xef,0xb9,0x82,0xc,0x5a,0x1,0xef,0x66,0x90,0xd7,0x7a,0x2c,0x80,0x13,0x94,0xc4,0xf6,0x9f,0xd8,0x75,0xbb,0x2c,0x89,0xed,0xff,0x42,0xe9,0xa7,0xfb,0xa4,0x84,0xec,0x13,0x45,0x7,0x1a,0xb9,0x97,0x18,0x65,0xab,0x4,0xf9,0x54,0x8c,0x3c,0x54,0xe8,0xed,0xa3,0x7c,0x7b,0x55,0xe0,0x8b,0x0,0xf6,0x4f,0x36,0xd6,0x3d,0xc3,0xe8,0x41,0xc0,0xa1,0xb1,0xdb,0x9,0xa8,0x29,0x0,0xe,0xec,0xc3,0x4,0xc1,0x8,0xc,0x0,0xd6,0x36,0xf3,0x23,0xba,0x80,0x3,0x6f,0x17,0x15,0xbe,0x4b,0xe5,0x8c,0x23,0xc2,0x57,0x7b,0x5d,0x61,0x53,0xc0,0x61,0xf,0xbd,0xd5,0x15,0x68,0x47,0x8e,0x0,0x7b,0x37,0xba,0xab,0xba,0x59,0xcc,0x79,0x3d,0xd7,0xaf,0x5a,0xe3,0x85,0x66,0x69,0xab,0x16,0x32,0x31,0x5b,0xd0,0xdb,0x66,0x2,0x2f,0x6f,0xe,0xb2,0x42,0xb5,0x87,0xdf,0xf0,0x59,0xae,0x6a,0x86,0xae,0x93,0x4c,0x7d,0x1b,0x9a,0x6b,0x84,0xdd,0x9a,0xd6,0xca,0xc8,0x89,0xc3,0xfb,0xd4,0x82,0xe,0x30,0xa2,0x2c,0x18,0xc2,0x98,0xb2,0x4f,0x8,0xba,0x83,0xa1,0x40,0x12,0x88,0x6f,0x43,0x38,0x82,0x1c,0x1f,0x15,0x70,0x82,0x96,0xa8,0xa5,0x3d,0xed,0x9c,0xde,0xb9,0x1,0xe9,0xb8,0x5f,0x4c,0x39,0xd2,0xa6,0xac,0xa6,0x48,0xe7,0xd0,0x95,0x53,0xb0,0xc4,0x7b,0x97,0xd4,0xcd,0x3c,0xdd,0xf0,0xd0,0x4e,0xbf,0xe6,0x65,0x24,0x5b,0x7b,0x7d,0xe,0xe5,0xd6,0xae,0xe9,0x90,0x64,0xfd,0x70,0x9e,0x21,0xb5,0x6c,0x5,0xa4,0xa2,0x87,0xe9,0xa3,0x25,0xf4,0x5,0x5c,0x39,0x61,0xa6,0x1e,0xbe,0x11,0x18,0x80,0xed,0xb,0x18,0x9b,0x70,0x70,0xec,0x5f,0x80,0x3f,0x26,0x27,0xb3,0xc9,0x33,0xc8,0x5c,0x2c,0x5a,0x59,0x1f,0xcb,0x2c,0x89,0x9d,0xae,0xf,0x7d,0xcc,0xdb,0x9c,0xdd,0xd5,0xed,0x7c,0x7f,0xbe,0xd0,0x52,0xf9,0x1f,0xff,0x76,0xfc,0x2,0x24,0x3a,0x65,0x42,0xf6,0x41,0x91,0x95,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x63,0x72,0x65,0x61,0x74,0x65,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xc9,0xad,0xc8,0x52,0x0,0x0,0x0,0x25,0x74,0x45,0x58,0x74,0x64,0x61,0x74,0x65,0x3a,0x6d,0x6f,0x64,0x69,0x66,0x79,0x0,0x32,0x30,0x31,0x36,0x2d,0x30,0x36,0x2d,0x32,0x32,0x54,0x32,0x30,0x3a,0x33,0x39,0x3a,0x32,0x36,0x2b,0x30,0x32,0x3a,0x30,0x30,0xb8,0xf0,0x70,0xee,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
};
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index 3361c1e41c..b661240fd3 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -573,7 +573,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
//blit to image and texture
{
- Image img(tex.texture_size,tex.texture_size,0,Image::FORMAT_GRAYSCALE_ALPHA,tex.imgdata);
+ Image img(tex.texture_size,tex.texture_size,0,Image::FORMAT_LA8,tex.imgdata);
if (tex.texture.is_null()) {
tex.texture.instance();
diff --git a/scene/resources/dynamic_font_stb.cpp b/scene/resources/dynamic_font_stb.cpp
index 456e6a5ee7..d1efc0f705 100644
--- a/scene/resources/dynamic_font_stb.cpp
+++ b/scene/resources/dynamic_font_stb.cpp
@@ -321,7 +321,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
//blit to image and texture
{
- Image img(tex.texture_size,tex.texture_size,0,Image::FORMAT_GRAYSCALE_ALPHA,tex.imgdata);
+ Image img(tex.texture_size,tex.texture_size,0,Image::FORMAT_LA8,tex.imgdata);
if (tex.texture.is_null()) {
tex.texture.instance();
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp
index a7b7d291d4..6e388e70ec 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -28,267 +28,1017 @@
/*************************************************************************/
#include "environment.h"
#include "texture.h"
-void Environment::set_background(BG p_bg) {
+#include "globals.h"
+#include "servers/visual_server.h"
+
+RID Environment::get_rid() const {
+
+ return environment;
+}
+
+
+void Environment::set_background(BGMode p_bg) {
- ERR_FAIL_INDEX(p_bg,BG_MAX);
bg_mode=p_bg;
VS::get_singleton()->environment_set_background(environment,VS::EnvironmentBG(p_bg));
+ _change_notify();
+}
+
+void Environment::set_skybox(const Ref<SkyBox> &p_skybox){
+
+ bg_skybox=p_skybox;
+
+ RID sb_rid;
+ if (bg_skybox.is_valid())
+ sb_rid=bg_skybox->get_rid();
+
+ VS::get_singleton()->environment_set_skybox(environment,sb_rid);
+}
+
+void Environment::set_skybox_scale(float p_scale) {
+
+ bg_skybox_scale=p_scale;
+ VS::get_singleton()->environment_set_skybox_scale(environment,p_scale);
+}
+
+void Environment::set_bg_color(const Color& p_color){
+
+ bg_color=p_color;
+ VS::get_singleton()->environment_set_bg_color(environment,p_color);
+}
+void Environment::set_bg_energy(float p_energy){
+
+ bg_energy=p_energy;
+ VS::get_singleton()->environment_set_bg_energy(environment,p_energy);
+}
+void Environment::set_canvas_max_layer(int p_max_layer){
+
+ bg_canvas_max_layer=p_max_layer;
+ VS::get_singleton()->environment_set_canvas_max_layer(environment,p_max_layer);
+}
+void Environment::set_ambient_light_color(const Color& p_color){
+
+ ambient_color=p_color;
+ VS::get_singleton()->environment_set_ambient_light(environment,ambient_color,ambient_energy,ambient_skybox_contribution);
+}
+void Environment::set_ambient_light_energy(float p_energy){
+
+ ambient_energy=p_energy;
+ VS::get_singleton()->environment_set_ambient_light(environment,ambient_color,ambient_energy,ambient_skybox_contribution);
}
+void Environment::set_ambient_light_skybox_contribution(float p_energy){
-Environment::BG Environment::get_background() const{
+ ambient_skybox_contribution=p_energy;
+ VS::get_singleton()->environment_set_ambient_light(environment,ambient_color,ambient_energy,ambient_skybox_contribution);
+}
+
+Environment::BGMode Environment::get_background() const{
return bg_mode;
}
+Ref<SkyBox> Environment::get_skybox() const{
-void Environment::set_background_param(BGParam p_param, const Variant& p_value){
+ return bg_skybox;
+}
- ERR_FAIL_INDEX(p_param,BG_PARAM_MAX);
- bg_param[p_param]=p_value;
- VS::get_singleton()->environment_set_background_param(environment,VS::EnvironmentBGParam(p_param),p_value);
+float Environment::get_skybox_scale() const {
+ return bg_skybox_scale;
}
-Variant Environment::get_background_param(BGParam p_param) const{
- ERR_FAIL_INDEX_V(p_param,BG_PARAM_MAX,Variant());
- return bg_param[p_param];
+Color Environment::get_bg_color() const{
+ return bg_color;
}
+float Environment::get_bg_energy() const{
-void Environment::set_enable_fx(Fx p_effect,bool p_enabled){
+ return bg_energy;
+}
+int Environment::get_canvas_max_layer() const{
- ERR_FAIL_INDEX(p_effect,FX_MAX);
- fx_enabled[p_effect]=p_enabled;
- VS::get_singleton()->environment_set_enable_fx(environment,VS::EnvironmentFx(p_effect),p_enabled);
+ return bg_canvas_max_layer;
+}
+Color Environment::get_ambient_light_color() const{
+ return ambient_color;
}
-bool Environment::is_fx_enabled(Fx p_effect) const{
+float Environment::get_ambient_light_energy() const{
- ERR_FAIL_INDEX_V(p_effect,FX_MAX,false);
- return fx_enabled[p_effect];
+ return ambient_energy;
+}
+float Environment::get_ambient_light_skybox_contribution() const{
+ return ambient_skybox_contribution;
}
-void Environment::fx_set_param(FxParam p_param,const Variant& p_value){
- ERR_FAIL_INDEX(p_param,FX_PARAM_MAX);
- fx_param[p_param]=p_value;
- VS::get_singleton()->environment_fx_set_param(environment,VS::EnvironmentFxParam(p_param),p_value);
+void Environment::set_tonemapper(ToneMapper p_tone_mapper) {
+
+ tone_mapper=p_tone_mapper;
+ VS::get_singleton()->environment_set_tonemap(environment,VS::EnvironmentToneMapper(tone_mapper),tonemap_exposure,tonemap_white,tonemap_auto_exposure,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_grey);
}
-Variant Environment::fx_get_param(FxParam p_param) const{
- ERR_FAIL_INDEX_V(p_param,FX_PARAM_MAX,Variant());
- return fx_param[p_param];
+Environment::ToneMapper Environment::get_tonemapper() const{
+ return tone_mapper;
}
-RID Environment::get_rid() const {
+void Environment::set_tonemap_exposure(float p_exposure){
+
+ tonemap_exposure=p_exposure;
+ VS::get_singleton()->environment_set_tonemap(environment,VS::EnvironmentToneMapper(tone_mapper),tonemap_exposure,tonemap_white,tonemap_auto_exposure,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_grey);
+}
+
+float Environment::get_tonemap_exposure() const{
+
+ return tonemap_exposure;
+}
+
+void Environment::set_tonemap_white(float p_white){
+
+ tonemap_white=p_white;
+ VS::get_singleton()->environment_set_tonemap(environment,VS::EnvironmentToneMapper(tone_mapper),tonemap_exposure,tonemap_white,tonemap_auto_exposure,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_grey);
+
+}
+float Environment::get_tonemap_white() const {
+
+ return tonemap_white;
+}
+
+void Environment::set_tonemap_auto_exposure(bool p_enabled) {
+
+ tonemap_auto_exposure=p_enabled;
+ VS::get_singleton()->environment_set_tonemap(environment,VS::EnvironmentToneMapper(tone_mapper),tonemap_exposure,tonemap_white,tonemap_auto_exposure,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_grey);
+
+}
+bool Environment::get_tonemap_auto_exposure() const {
+
+ return tonemap_auto_exposure;
+}
+
+void Environment::set_tonemap_auto_exposure_max(float p_auto_exposure_max) {
+
+ tonemap_auto_exposure_max=p_auto_exposure_max;
+ VS::get_singleton()->environment_set_tonemap(environment,VS::EnvironmentToneMapper(tone_mapper),tonemap_exposure,tonemap_white,tonemap_auto_exposure,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_grey);
+
+}
+float Environment::get_tonemap_auto_exposure_max() const {
+
+ return tonemap_auto_exposure_max;
+}
+
+void Environment::set_tonemap_auto_exposure_min(float p_auto_exposure_min) {
+
+ tonemap_auto_exposure_min=p_auto_exposure_min;
+ VS::get_singleton()->environment_set_tonemap(environment,VS::EnvironmentToneMapper(tone_mapper),tonemap_exposure,tonemap_white,tonemap_auto_exposure,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_grey);
+
+}
+float Environment::get_tonemap_auto_exposure_min() const {
+
+ return tonemap_auto_exposure_min;
+}
+
+void Environment::set_tonemap_auto_exposure_speed(float p_auto_exposure_speed) {
+
+ tonemap_auto_exposure_speed=p_auto_exposure_speed;
+ VS::get_singleton()->environment_set_tonemap(environment,VS::EnvironmentToneMapper(tone_mapper),tonemap_exposure,tonemap_white,tonemap_auto_exposure,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_grey);
+
+}
+float Environment::get_tonemap_auto_exposure_speed() const {
+
+ return tonemap_auto_exposure_speed;
+}
+
+void Environment::set_tonemap_auto_exposure_grey(float p_auto_exposure_grey) {
+
+ tonemap_auto_exposure_grey=p_auto_exposure_grey;
+ VS::get_singleton()->environment_set_tonemap(environment,VS::EnvironmentToneMapper(tone_mapper),tonemap_exposure,tonemap_white,tonemap_auto_exposure,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_grey);
+
+}
+float Environment::get_tonemap_auto_exposure_grey() const {
+
+ return tonemap_auto_exposure_grey;
+}
+
+void Environment::set_adjustment_enable(bool p_enable) {
+
+ adjustment_enabled=p_enable;
+ VS::get_singleton()->environment_set_adjustment(environment,adjustment_enabled,adjustment_brightness,adjustment_contrast,adjustment_saturation,adjustment_color_correction.is_valid()?adjustment_color_correction->get_rid():RID());
+}
+
+bool Environment::is_adjustment_enabled() const {
+
+ return adjustment_enabled;
+}
+
+
+void Environment::set_adjustment_brightness(float p_brightness) {
+
+ adjustment_brightness=p_brightness;
+ VS::get_singleton()->environment_set_adjustment(environment,adjustment_enabled,adjustment_brightness,adjustment_contrast,adjustment_saturation,adjustment_color_correction.is_valid()?adjustment_color_correction->get_rid():RID());
+
+}
+float Environment::get_adjustment_brightness() const {
+
+ return adjustment_brightness;
+}
+
+void Environment::set_adjustment_contrast(float p_contrast) {
+
+ adjustment_contrast=p_contrast;
+ VS::get_singleton()->environment_set_adjustment(environment,adjustment_enabled,adjustment_brightness,adjustment_contrast,adjustment_saturation,adjustment_color_correction.is_valid()?adjustment_color_correction->get_rid():RID());
+
+}
+float Environment::get_adjustment_contrast() const {
+
+ return adjustment_contrast;
+}
+
+void Environment::set_adjustment_saturation(float p_saturation) {
+
+ adjustment_saturation=p_saturation;
+ VS::get_singleton()->environment_set_adjustment(environment,adjustment_enabled,adjustment_brightness,adjustment_contrast,adjustment_saturation,adjustment_color_correction.is_valid()?adjustment_color_correction->get_rid():RID());
+
+}
+float Environment::get_adjustment_saturation() const {
+
+ return adjustment_saturation;
+}
+
+void Environment::set_adjustment_color_correction(const Ref<Texture>& p_ramp) {
+
+ adjustment_color_correction=p_ramp;
+ VS::get_singleton()->environment_set_adjustment(environment,adjustment_enabled,adjustment_brightness,adjustment_contrast,adjustment_saturation,adjustment_color_correction.is_valid()?adjustment_color_correction->get_rid():RID());
- return environment;
}
+Ref<Texture> Environment::get_adjustment_color_correction() const {
+
+ return adjustment_color_correction;
+}
+
+
+void Environment::_validate_property(PropertyInfo& property) const {
+
+ if (property.name=="background/skybox" || property.name=="background/skybox_scale" || property.name=="ambient_light/skybox_contribution") {
+ if (bg_mode!=BG_SKYBOX) {
+ property.usage=PROPERTY_USAGE_NOEDITOR;
+ }
+ }
+
+ if (property.name=="background/color") {
+ if (bg_mode!=BG_COLOR) {
+ property.usage=PROPERTY_USAGE_NOEDITOR;
+ }
+ }
+
+ if (property.name=="background/canvas_max_layer") {
+ if (bg_mode!=BG_CANVAS) {
+ property.usage=PROPERTY_USAGE_NOEDITOR;
+ }
+ }
+
+}
+
+void Environment::set_ssr_enabled(bool p_enable) {
+
+ ssr_enabled=p_enable;
+ VS::get_singleton()->environment_set_ssr(environment,ssr_enabled,ssr_max_steps,ssr_accel,ssr_fade,ssr_depth_tolerance,ssr_smooth,ssr_roughness);
+}
+
+bool Environment::is_ssr_enabled() const{
+
+ return ssr_enabled;
+}
+
+void Environment::set_ssr_max_steps(int p_steps){
+
+ ssr_max_steps=p_steps;
+ VS::get_singleton()->environment_set_ssr(environment,ssr_enabled,ssr_max_steps,ssr_accel,ssr_fade,ssr_depth_tolerance,ssr_smooth,ssr_roughness);
+
+}
+int Environment::get_ssr_max_steps() const {
+
+ return ssr_max_steps;
+}
+
+void Environment::set_ssr_accel(float p_accel) {
+
+ ssr_accel=p_accel;
+ VS::get_singleton()->environment_set_ssr(environment,ssr_enabled,ssr_max_steps,ssr_accel,ssr_fade,ssr_depth_tolerance,ssr_smooth,ssr_roughness);
+
+}
+float Environment::get_ssr_accel() const {
+
+ return ssr_accel;
+}
+
+void Environment::set_ssr_fade(float p_fade) {
+
+ ssr_fade=p_fade;
+ VS::get_singleton()->environment_set_ssr(environment,ssr_enabled,ssr_max_steps,ssr_accel,ssr_fade,ssr_depth_tolerance,ssr_smooth,ssr_roughness);
+
+}
+float Environment::get_ssr_fade() const {
+
+ return ssr_fade;
+}
+
+void Environment::set_ssr_depth_tolerance(float p_depth_tolerance) {
+
+ ssr_depth_tolerance=p_depth_tolerance;
+ VS::get_singleton()->environment_set_ssr(environment,ssr_enabled,ssr_max_steps,ssr_accel,ssr_fade,ssr_depth_tolerance,ssr_smooth,ssr_roughness);
+
+}
+float Environment::get_ssr_depth_tolerance() const {
+
+ return ssr_depth_tolerance;
+}
+
+void Environment::set_ssr_smooth(bool p_enable) {
+
+ ssr_smooth=p_enable;
+ VS::get_singleton()->environment_set_ssr(environment,ssr_enabled,ssr_max_steps,ssr_accel,ssr_fade,ssr_depth_tolerance,ssr_smooth,ssr_roughness);
+
+}
+bool Environment::is_ssr_smooth() const {
+
+ return ssr_smooth;
+}
+
+void Environment::set_ssr_rough(bool p_enable) {
+
+ ssr_roughness=p_enable;
+ VS::get_singleton()->environment_set_ssr(environment,ssr_enabled,ssr_max_steps,ssr_accel,ssr_fade,ssr_depth_tolerance,ssr_smooth,ssr_roughness);
+
+}
+bool Environment::is_ssr_rough() const {
+
+ return ssr_roughness;
+}
+
+void Environment::set_ssao_enabled(bool p_enable) {
+
+ ssao_enabled=p_enable;
+ VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur);
+
+}
+
+bool Environment::is_ssao_enabled() const{
+
+ return ssao_enabled;
+}
+
+void Environment::set_ssao_radius(float p_radius){
+
+ ssao_radius=p_radius;
+ VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur);
+}
+float Environment::get_ssao_radius() const{
+
+ return ssao_radius;
+}
+
+
+void Environment::set_ssao_intensity(float p_intensity){
+
+ ssao_intensity=p_intensity;
+ VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur);
+}
+
+float Environment::get_ssao_intensity() const{
+
+ return ssao_intensity;
+}
+
+void Environment::set_ssao_radius2(float p_radius){
+
+ ssao_radius2=p_radius;
+ VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur);
+}
+float Environment::get_ssao_radius2() const{
+
+ return ssao_radius2;
+}
+
+
+void Environment::set_ssao_intensity2(float p_intensity){
+
+ ssao_intensity2=p_intensity;
+ VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur);
+}
+float Environment::get_ssao_intensity2() const{
+
+ return ssao_intensity2;
+}
+
+void Environment::set_ssao_bias(float p_bias){
+
+ ssao_bias=p_bias;
+ VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur);
+}
+float Environment::get_ssao_bias() const{
+
+ return ssao_bias;
+}
+
+void Environment::set_ssao_direct_light_affect(float p_direct_light_affect){
+
+ ssao_direct_light_affect=p_direct_light_affect;
+ VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur);
+}
+float Environment::get_ssao_direct_light_affect() const{
+
+ return ssao_direct_light_affect;
+}
+
+
+void Environment::set_ssao_color(const Color& p_color) {
+
+ ssao_color=p_color;
+ VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur);
+}
+
+Color Environment::get_ssao_color() const {
+
+ return ssao_color;
+}
+
+void Environment::set_ssao_blur(bool p_enable) {
+
+ ssao_blur=p_enable;
+ VS::get_singleton()->environment_set_ssao(environment,ssao_enabled,ssao_radius,ssao_intensity,ssao_radius2,ssao_intensity2,ssao_bias,ssao_direct_light_affect,ssao_color,ssao_blur);
+}
+bool Environment::is_ssao_blur_enabled() const {
+
+ return ssao_blur;
+}
+
+void Environment::set_glow_enabled(bool p_enabled) {
+
+ glow_enabled=p_enabled;
+ VS::get_singleton()->environment_set_glow(environment,glow_enabled,glow_levels,glow_intensity,glow_strength,glow_bloom,VS::EnvironmentGlowBlendMode(glow_blend_mode),glow_hdr_bleed_treshold,glow_hdr_bleed_treshold,glow_bicubic_upscale);
+}
+
+bool Environment::is_glow_enabled() const{
+
+ return glow_enabled;
+}
+
+void Environment::set_glow_level(int p_level,bool p_enabled){
+
+ ERR_FAIL_INDEX(p_level,VS::MAX_GLOW_LEVELS);
+
+ if (p_enabled)
+ glow_levels|=(1<<p_level);
+ else
+ glow_levels&=~(1<<p_level);
+
+ VS::get_singleton()->environment_set_glow(environment,glow_enabled,glow_levels,glow_intensity,glow_strength,glow_bloom,VS::EnvironmentGlowBlendMode(glow_blend_mode),glow_hdr_bleed_treshold,glow_hdr_bleed_treshold,glow_bicubic_upscale);
+
+}
+bool Environment::is_glow_level_enabled(int p_level) const{
+
+ ERR_FAIL_INDEX_V(p_level,VS::MAX_GLOW_LEVELS,false);
+
+ return glow_levels&(1<<p_level);
+}
+
+void Environment::set_glow_intensity(float p_intensity){
+
+ glow_intensity=p_intensity;
+
+ VS::get_singleton()->environment_set_glow(environment,glow_enabled,glow_levels,glow_intensity,glow_strength,glow_bloom,VS::EnvironmentGlowBlendMode(glow_blend_mode),glow_hdr_bleed_treshold,glow_hdr_bleed_treshold,glow_bicubic_upscale);
+
+}
+float Environment::get_glow_intensity() const{
+
+ return glow_intensity;
+}
+
+void Environment::set_glow_strength(float p_strength){
+
+ glow_strength=p_strength;
+ VS::get_singleton()->environment_set_glow(environment,glow_enabled,glow_levels,glow_intensity,glow_strength,glow_bloom,VS::EnvironmentGlowBlendMode(glow_blend_mode),glow_hdr_bleed_treshold,glow_hdr_bleed_treshold,glow_bicubic_upscale);
+
+}
+float Environment::get_glow_strength() const{
+
+ return glow_strength;
+}
+
+void Environment::set_glow_bloom(float p_treshold){
+
+ glow_bloom=p_treshold;
+
+ VS::get_singleton()->environment_set_glow(environment,glow_enabled,glow_levels,glow_intensity,glow_strength,glow_bloom,VS::EnvironmentGlowBlendMode(glow_blend_mode),glow_hdr_bleed_treshold,glow_hdr_bleed_treshold,glow_bicubic_upscale);
+
+}
+float Environment::get_glow_bloom() const{
+
+ return glow_bloom;
+}
+
+void Environment::set_glow_blend_mode(GlowBlendMode p_mode){
+
+ glow_blend_mode=p_mode;
+
+ VS::get_singleton()->environment_set_glow(environment,glow_enabled,glow_levels,glow_intensity,glow_strength,glow_bloom,VS::EnvironmentGlowBlendMode(glow_blend_mode),glow_hdr_bleed_treshold,glow_hdr_bleed_treshold,glow_bicubic_upscale);
+
+}
+Environment::GlowBlendMode Environment::get_glow_blend_mode() const{
+
+ return glow_blend_mode;
+}
+
+void Environment::set_glow_hdr_bleed_treshold(float p_treshold){
+
+ glow_hdr_bleed_treshold=p_treshold;
+
+ VS::get_singleton()->environment_set_glow(environment,glow_enabled,glow_levels,glow_intensity,glow_strength,glow_bloom,VS::EnvironmentGlowBlendMode(glow_blend_mode),glow_hdr_bleed_treshold,glow_hdr_bleed_treshold,glow_bicubic_upscale);
+
+}
+float Environment::get_glow_hdr_bleed_treshold() const{
+
+ return glow_hdr_bleed_treshold;
+}
+
+void Environment::set_glow_hdr_bleed_scale(float p_scale){
+
+ glow_hdr_bleed_scale=p_scale;
+
+ VS::get_singleton()->environment_set_glow(environment,glow_enabled,glow_levels,glow_intensity,glow_strength,glow_bloom,VS::EnvironmentGlowBlendMode(glow_blend_mode),glow_hdr_bleed_treshold,glow_hdr_bleed_treshold,glow_bicubic_upscale);
+
+}
+float Environment::get_glow_hdr_bleed_scale() const{
+
+ return glow_hdr_bleed_scale;
+}
+
+void Environment::set_glow_bicubic_upscale(bool p_enable) {
+
+ glow_bicubic_upscale=p_enable;
+ VS::get_singleton()->environment_set_glow(environment,glow_enabled,glow_levels,glow_intensity,glow_strength,glow_bloom,VS::EnvironmentGlowBlendMode(glow_blend_mode),glow_hdr_bleed_treshold,glow_hdr_bleed_treshold,glow_bicubic_upscale);
+
+}
+
+bool Environment::is_glow_bicubic_upscale_enabled() const {
+
+ return glow_bicubic_upscale;
+}
+
+
+void Environment::set_dof_blur_far_enabled(bool p_enable) {
+
+ dof_blur_far_enabled=p_enable;
+ VS::get_singleton()->environment_set_dof_blur_far(environment,dof_blur_far_enabled,dof_blur_far_distance,dof_blur_far_transition,dof_blur_far_amount,VS::EnvironmentDOFBlurQuality(dof_blur_far_quality));
+}
+
+bool Environment::is_dof_blur_far_enabled() const{
+
+ return dof_blur_far_enabled;
+}
+
+void Environment::set_dof_blur_far_distance(float p_distance){
+
+ dof_blur_far_distance=p_distance;
+ VS::get_singleton()->environment_set_dof_blur_far(environment,dof_blur_far_enabled,dof_blur_far_distance,dof_blur_far_transition,dof_blur_far_amount,VS::EnvironmentDOFBlurQuality(dof_blur_far_quality));
+
+}
+float Environment::get_dof_blur_far_distance() const{
+
+ return dof_blur_far_distance;
+}
+
+void Environment::set_dof_blur_far_transition(float p_distance){
+
+ dof_blur_far_transition=p_distance;
+ VS::get_singleton()->environment_set_dof_blur_far(environment,dof_blur_far_enabled,dof_blur_far_distance,dof_blur_far_transition,dof_blur_far_amount,VS::EnvironmentDOFBlurQuality(dof_blur_far_quality));
+}
+float Environment::get_dof_blur_far_transition() const{
+
+ return dof_blur_far_transition;
+}
+
+void Environment::set_dof_blur_far_amount(float p_amount){
+
+ dof_blur_far_amount=p_amount;
+ VS::get_singleton()->environment_set_dof_blur_far(environment,dof_blur_far_enabled,dof_blur_far_distance,dof_blur_far_transition,dof_blur_far_amount,VS::EnvironmentDOFBlurQuality(dof_blur_far_quality));
+
+}
+float Environment::get_dof_blur_far_amount() const{
+
+ return dof_blur_far_amount;
+}
+
+void Environment::set_dof_blur_far_quality(DOFBlurQuality p_quality) {
+
+ dof_blur_far_quality=p_quality;
+ VS::get_singleton()->environment_set_dof_blur_far(environment,dof_blur_far_enabled,dof_blur_far_distance,dof_blur_far_transition,dof_blur_far_amount,VS::EnvironmentDOFBlurQuality(dof_blur_far_quality));
+}
+
+Environment::DOFBlurQuality Environment::get_dof_blur_far_quality() const {
+
+ return dof_blur_far_quality;
+}
+
+
+void Environment::set_dof_blur_near_enabled(bool p_enable) {
+
+ dof_blur_near_enabled=p_enable;
+ VS::get_singleton()->environment_set_dof_blur_near(environment,dof_blur_near_enabled,dof_blur_near_distance,dof_blur_near_transition,dof_blur_near_amount,VS::EnvironmentDOFBlurQuality(dof_blur_near_quality));
+}
+
+bool Environment::is_dof_blur_near_enabled() const{
+
+ return dof_blur_near_enabled;
+}
+
+void Environment::set_dof_blur_near_distance(float p_distance){
+
+ dof_blur_near_distance=p_distance;
+ VS::get_singleton()->environment_set_dof_blur_near(environment,dof_blur_near_enabled,dof_blur_near_distance,dof_blur_near_transition,dof_blur_near_amount,VS::EnvironmentDOFBlurQuality(dof_blur_near_quality));
+}
+
+float Environment::get_dof_blur_near_distance() const{
+
+ return dof_blur_near_distance;
+}
+
+void Environment::set_dof_blur_near_transition(float p_distance){
+
+ dof_blur_near_transition=p_distance;
+ VS::get_singleton()->environment_set_dof_blur_near(environment,dof_blur_near_enabled,dof_blur_near_distance,dof_blur_near_transition,dof_blur_near_amount,VS::EnvironmentDOFBlurQuality(dof_blur_near_quality));
+}
+
+float Environment::get_dof_blur_near_transition() const{
+
+ return dof_blur_near_transition;
+}
+
+void Environment::set_dof_blur_near_amount(float p_amount){
+
+ dof_blur_near_amount=p_amount;
+ VS::get_singleton()->environment_set_dof_blur_near(environment,dof_blur_near_enabled,dof_blur_near_distance,dof_blur_near_transition,dof_blur_near_amount,VS::EnvironmentDOFBlurQuality(dof_blur_near_quality));
+}
+
+float Environment::get_dof_blur_near_amount() const{
+
+ return dof_blur_near_amount;
+}
+
+void Environment::set_dof_blur_near_quality(DOFBlurQuality p_quality) {
+
+ dof_blur_near_quality=p_quality;
+ VS::get_singleton()->environment_set_dof_blur_near(environment,dof_blur_near_enabled,dof_blur_near_distance,dof_blur_near_transition,dof_blur_near_amount,VS::EnvironmentDOFBlurQuality(dof_blur_near_quality));
+}
+
+Environment::DOFBlurQuality Environment::get_dof_blur_near_quality() const {
+
+ return dof_blur_near_quality;
+}
+
void Environment::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_background","bgmode"),&Environment::set_background);
+ ObjectTypeDB::bind_method(_MD("set_background","mode"),&Environment::set_background);
+ ObjectTypeDB::bind_method(_MD("set_skybox","skybox:CubeMap"),&Environment::set_skybox);
+ ObjectTypeDB::bind_method(_MD("set_skybox_scale","scale"),&Environment::set_skybox_scale);
+ ObjectTypeDB::bind_method(_MD("set_bg_color","color"),&Environment::set_bg_color);
+ ObjectTypeDB::bind_method(_MD("set_bg_energy","energy"),&Environment::set_bg_energy);
+ ObjectTypeDB::bind_method(_MD("set_canvas_max_layer","layer"),&Environment::set_canvas_max_layer);
+ ObjectTypeDB::bind_method(_MD("set_ambient_light_color","color"),&Environment::set_ambient_light_color);
+ ObjectTypeDB::bind_method(_MD("set_ambient_light_energy","energy"),&Environment::set_ambient_light_energy);
+ ObjectTypeDB::bind_method(_MD("set_ambient_light_skybox_contribution","energy"),&Environment::set_ambient_light_skybox_contribution);
+
+
ObjectTypeDB::bind_method(_MD("get_background"),&Environment::get_background);
+ ObjectTypeDB::bind_method(_MD("get_skybox:CubeMap"),&Environment::get_skybox);
+ ObjectTypeDB::bind_method(_MD("get_skybox_scale"),&Environment::get_skybox_scale);
+ ObjectTypeDB::bind_method(_MD("get_bg_color"),&Environment::get_bg_color);
+ ObjectTypeDB::bind_method(_MD("get_bg_energy"),&Environment::get_bg_energy);
+ ObjectTypeDB::bind_method(_MD("get_canvas_max_layer"),&Environment::get_canvas_max_layer);
+ ObjectTypeDB::bind_method(_MD("get_ambient_light_color"),&Environment::get_ambient_light_color);
+ ObjectTypeDB::bind_method(_MD("get_ambient_light_energy"),&Environment::get_ambient_light_energy);
+ ObjectTypeDB::bind_method(_MD("get_ambient_light_skybox_contribution"),&Environment::get_ambient_light_skybox_contribution);
+
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"background/mode",PROPERTY_HINT_ENUM,"Clear Color,Custom Color,Skybox,Canvas,Keep"),_SCS("set_background"),_SCS("get_background") );
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"background/skybox",PROPERTY_HINT_RESOURCE_TYPE,"SkyBox"),_SCS("set_skybox"),_SCS("get_skybox") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"background/skybox_scale",PROPERTY_HINT_RANGE,"0,32,0.01"),_SCS("set_skybox_scale"),_SCS("get_skybox_scale") );
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"background/color"),_SCS("set_bg_color"),_SCS("get_bg_color") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"background/energy",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_bg_energy"),_SCS("get_bg_energy") );
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"background/canvas_max_layer",PROPERTY_HINT_RANGE,"-1000,1000,1"),_SCS("set_canvas_max_layer"),_SCS("get_canvas_max_layer") );
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"ambient_light/color"),_SCS("set_ambient_light_color"),_SCS("get_ambient_light_color") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_light/energy",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_ambient_light_energy"),_SCS("get_ambient_light_energy") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_light/skybox_contribution",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_ambient_light_skybox_contribution"),_SCS("get_ambient_light_skybox_contribution") );
+
+
+ ObjectTypeDB::bind_method(_MD("set_ssr_enabled","enabled"),&Environment::set_ssr_enabled);
+ ObjectTypeDB::bind_method(_MD("is_ssr_enabled"),&Environment::is_ssr_enabled);
+
+ ObjectTypeDB::bind_method(_MD("set_ssr_max_steps","max_steps"),&Environment::set_ssr_max_steps);
+ ObjectTypeDB::bind_method(_MD("get_ssr_max_steps"),&Environment::get_ssr_max_steps);
+
+ ObjectTypeDB::bind_method(_MD("set_ssr_accel","accel"),&Environment::set_ssr_accel);
+ ObjectTypeDB::bind_method(_MD("get_ssr_accel"),&Environment::get_ssr_accel);
+
+ ObjectTypeDB::bind_method(_MD("set_ssr_fade","fade"),&Environment::set_ssr_fade);
+ ObjectTypeDB::bind_method(_MD("get_ssr_fade"),&Environment::get_ssr_fade);
+
+ ObjectTypeDB::bind_method(_MD("set_ssr_depth_tolerance","depth_tolerance"),&Environment::set_ssr_depth_tolerance);
+ ObjectTypeDB::bind_method(_MD("get_ssr_depth_tolerance"),&Environment::get_ssr_depth_tolerance);
+
+ ObjectTypeDB::bind_method(_MD("set_ssr_smooth","smooth"),&Environment::set_ssr_smooth);
+ ObjectTypeDB::bind_method(_MD("is_ssr_smooth"),&Environment::is_ssr_smooth);
+
+ ObjectTypeDB::bind_method(_MD("set_ssr_rough","rough"),&Environment::set_ssr_rough);
+ ObjectTypeDB::bind_method(_MD("is_ssr_rough"),&Environment::is_ssr_rough);
+
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ss_reflections/enabled"),_SCS("set_ssr_enabled"),_SCS("is_ssr_enabled") );
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"ss_reflections/max_steps",PROPERTY_HINT_RANGE,"1,512,1"),_SCS("set_ssr_max_steps"),_SCS("get_ssr_max_steps") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ss_reflections/accel",PROPERTY_HINT_RANGE,"0,4,0.01"),_SCS("set_ssr_accel"),_SCS("get_ssr_accel") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ss_reflections/fade",PROPERTY_HINT_EXP_EASING),_SCS("set_ssr_fade"),_SCS("get_ssr_fade") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ss_reflections/depth_tolerance",PROPERTY_HINT_RANGE,"0.1,128,0.1"),_SCS("set_ssr_depth_tolerance"),_SCS("get_ssr_depth_tolerance") );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ss_reflections/accel_smooth"),_SCS("set_ssr_smooth"),_SCS("is_ssr_smooth") );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ss_reflections/roughness"),_SCS("set_ssr_rough"),_SCS("is_ssr_rough") );
+
+ ObjectTypeDB::bind_method(_MD("set_ssao_enabled","enabled"),&Environment::set_ssao_enabled);
+ ObjectTypeDB::bind_method(_MD("is_ssao_enabled"),&Environment::is_ssao_enabled);
+
+ ObjectTypeDB::bind_method(_MD("set_ssao_radius","radius"),&Environment::set_ssao_radius);
+ ObjectTypeDB::bind_method(_MD("get_ssao_radius"),&Environment::get_ssao_radius);
+
+ ObjectTypeDB::bind_method(_MD("set_ssao_intensity","intensity"),&Environment::set_ssao_intensity);
+ ObjectTypeDB::bind_method(_MD("get_ssao_intensity"),&Environment::get_ssao_intensity);
+
+ ObjectTypeDB::bind_method(_MD("set_ssao_radius2","radius"),&Environment::set_ssao_radius2);
+ ObjectTypeDB::bind_method(_MD("get_ssao_radius2"),&Environment::get_ssao_radius2);
+
+ ObjectTypeDB::bind_method(_MD("set_ssao_intensity2","intensity"),&Environment::set_ssao_intensity2);
+ ObjectTypeDB::bind_method(_MD("get_ssao_intensity2"),&Environment::get_ssao_intensity2);
+
+ ObjectTypeDB::bind_method(_MD("set_ssao_bias","bias"),&Environment::set_ssao_bias);
+ ObjectTypeDB::bind_method(_MD("get_ssao_bias"),&Environment::get_ssao_bias);
+
+ ObjectTypeDB::bind_method(_MD("set_ssao_direct_light_affect","amount"),&Environment::set_ssao_direct_light_affect);
+ ObjectTypeDB::bind_method(_MD("get_ssao_direct_light_affect"),&Environment::get_ssao_direct_light_affect);
+
+ ObjectTypeDB::bind_method(_MD("set_ssao_color","color"),&Environment::set_ssao_color);
+ ObjectTypeDB::bind_method(_MD("get_ssao_color"),&Environment::get_ssao_color);
+
+ ObjectTypeDB::bind_method(_MD("set_ssao_blur","enabled"),&Environment::set_ssao_blur);
+ ObjectTypeDB::bind_method(_MD("is_ssao_blur_enabled"),&Environment::is_ssao_blur_enabled);
+
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ambient_occlusion/enabled"),_SCS("set_ssao_enabled"),_SCS("is_ssao_enabled") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_occlusion/radius",PROPERTY_HINT_RANGE,"0.1,16,0.1"),_SCS("set_ssao_radius"),_SCS("get_ssao_radius") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_occlusion/intensity",PROPERTY_HINT_RANGE,"0.0,9,0.1"),_SCS("set_ssao_intensity"),_SCS("get_ssao_intensity") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_occlusion/radius2",PROPERTY_HINT_RANGE,"0.0,16,0.1"),_SCS("set_ssao_radius2"),_SCS("get_ssao_radius2") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_occlusion/intensity2",PROPERTY_HINT_RANGE,"0.0,9,0.1"),_SCS("set_ssao_intensity2"),_SCS("get_ssao_intensity2") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_occlusion/bias",PROPERTY_HINT_RANGE,"0.001,8,0.001"),_SCS("set_ssao_bias"),_SCS("get_ssao_bias") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"ambient_occlusion/light_affect",PROPERTY_HINT_RANGE,"0.00,1,0.01"),_SCS("set_ssao_direct_light_affect"),_SCS("get_ssao_direct_light_affect") );
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"ambient_occlusion/color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("set_ssao_color"),_SCS("get_ssao_color") );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"ambient_occlusion/blur"),_SCS("set_ssao_blur"),_SCS("is_ssao_blur_enabled") );
+
+ ObjectTypeDB::bind_method(_MD("set_dof_blur_far_enabled","enabled"),&Environment::set_dof_blur_far_enabled);
+ ObjectTypeDB::bind_method(_MD("is_dof_blur_far_enabled"),&Environment::is_dof_blur_far_enabled);
+
+ ObjectTypeDB::bind_method(_MD("set_dof_blur_far_distance","intensity"),&Environment::set_dof_blur_far_distance);
+ ObjectTypeDB::bind_method(_MD("get_dof_blur_far_distance"),&Environment::get_dof_blur_far_distance);
+
+ ObjectTypeDB::bind_method(_MD("set_dof_blur_far_transition","intensity"),&Environment::set_dof_blur_far_transition);
+ ObjectTypeDB::bind_method(_MD("get_dof_blur_far_transition"),&Environment::get_dof_blur_far_transition);
+
+ ObjectTypeDB::bind_method(_MD("set_dof_blur_far_amount","intensity"),&Environment::set_dof_blur_far_amount);
+ ObjectTypeDB::bind_method(_MD("get_dof_blur_far_amount"),&Environment::get_dof_blur_far_amount);
+
+ ObjectTypeDB::bind_method(_MD("set_dof_blur_far_quality","intensity"),&Environment::set_dof_blur_far_quality);
+ ObjectTypeDB::bind_method(_MD("get_dof_blur_far_quality"),&Environment::get_dof_blur_far_quality);
+
+ ObjectTypeDB::bind_method(_MD("set_dof_blur_near_enabled","enabled"),&Environment::set_dof_blur_near_enabled);
+ ObjectTypeDB::bind_method(_MD("is_dof_blur_near_enabled"),&Environment::is_dof_blur_near_enabled);
+
+ ObjectTypeDB::bind_method(_MD("set_dof_blur_near_distance","intensity"),&Environment::set_dof_blur_near_distance);
+ ObjectTypeDB::bind_method(_MD("get_dof_blur_near_distance"),&Environment::get_dof_blur_near_distance);
+
+ ObjectTypeDB::bind_method(_MD("set_dof_blur_near_transition","intensity"),&Environment::set_dof_blur_near_transition);
+ ObjectTypeDB::bind_method(_MD("get_dof_blur_near_transition"),&Environment::get_dof_blur_near_transition);
+
+ ObjectTypeDB::bind_method(_MD("set_dof_blur_near_amount","intensity"),&Environment::set_dof_blur_near_amount);
+ ObjectTypeDB::bind_method(_MD("get_dof_blur_near_amount"),&Environment::get_dof_blur_near_amount);
+
+ ObjectTypeDB::bind_method(_MD("set_dof_blur_near_quality","level"),&Environment::set_dof_blur_near_quality);
+ ObjectTypeDB::bind_method(_MD("get_dof_blur_near_quality"),&Environment::get_dof_blur_near_quality);
+
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"dof_blur_far/enabled"),_SCS("set_dof_blur_far_enabled"),_SCS("is_dof_blur_far_enabled") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_far/distance",PROPERTY_HINT_EXP_RANGE,"0.01,8192,0.01"),_SCS("set_dof_blur_far_distance"),_SCS("get_dof_blur_far_distance") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_far/transition",PROPERTY_HINT_EXP_RANGE,"0.01,8192,0.01"),_SCS("set_dof_blur_far_transition"),_SCS("get_dof_blur_far_transition") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_far/amount",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_dof_blur_far_amount"),_SCS("get_dof_blur_far_amount") );
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"dof_blur_far/quality",PROPERTY_HINT_ENUM,"Low,Medium,High"),_SCS("set_dof_blur_far_quality"),_SCS("get_dof_blur_far_quality") );
+
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"dof_blur_near/enabled"),_SCS("set_dof_blur_near_enabled"),_SCS("is_dof_blur_near_enabled") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_near/distance",PROPERTY_HINT_EXP_RANGE,"0.01,8192,0.01"),_SCS("set_dof_blur_near_distance"),_SCS("get_dof_blur_near_distance") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_near/transition",PROPERTY_HINT_EXP_RANGE,"0.01,8192,0.01"),_SCS("set_dof_blur_near_transition"),_SCS("get_dof_blur_near_transition") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"dof_blur_near/amount",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_dof_blur_near_amount"),_SCS("get_dof_blur_near_amount") );
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"dof_blur_near/quality",PROPERTY_HINT_ENUM,"Low,Medium,High"),_SCS("set_dof_blur_near_quality"),_SCS("get_dof_blur_near_quality") );
+
+
+ ObjectTypeDB::bind_method(_MD("set_glow_enabled","enabled"),&Environment::set_glow_enabled);
+ ObjectTypeDB::bind_method(_MD("is_glow_enabled"),&Environment::is_glow_enabled);
+
+ ObjectTypeDB::bind_method(_MD("set_glow_level","idx","enabled"),&Environment::set_glow_level);
+ ObjectTypeDB::bind_method(_MD("is_glow_level_enabled","idx"),&Environment::is_glow_level_enabled);
+
+ ObjectTypeDB::bind_method(_MD("set_glow_intensity","intensity"),&Environment::set_glow_intensity);
+ ObjectTypeDB::bind_method(_MD("get_glow_intensity"),&Environment::get_glow_intensity);
+
+ ObjectTypeDB::bind_method(_MD("set_glow_strength","strength"),&Environment::set_glow_strength);
+ ObjectTypeDB::bind_method(_MD("get_glow_strength"),&Environment::get_glow_strength);
+
+ ObjectTypeDB::bind_method(_MD("set_glow_bloom","amount"),&Environment::set_glow_bloom);
+ ObjectTypeDB::bind_method(_MD("get_glow_bloom"),&Environment::get_glow_bloom);
+
+ ObjectTypeDB::bind_method(_MD("set_glow_blend_mode","mode"),&Environment::set_glow_blend_mode);
+ ObjectTypeDB::bind_method(_MD("get_glow_blend_mode"),&Environment::get_glow_blend_mode);
+
+ ObjectTypeDB::bind_method(_MD("set_glow_hdr_bleed_treshold","treshold"),&Environment::set_glow_hdr_bleed_treshold);
+ ObjectTypeDB::bind_method(_MD("get_glow_hdr_bleed_treshold"),&Environment::get_glow_hdr_bleed_treshold);
+
+ ObjectTypeDB::bind_method(_MD("set_glow_hdr_bleed_scale","scale"),&Environment::set_glow_hdr_bleed_scale);
+ ObjectTypeDB::bind_method(_MD("get_glow_hdr_bleed_scale"),&Environment::get_glow_hdr_bleed_scale);
+
+ ObjectTypeDB::bind_method(_MD("set_glow_bicubic_upscale","enabled"),&Environment::set_glow_bicubic_upscale);
+ ObjectTypeDB::bind_method(_MD("is_glow_bicubic_upscale_enabled"),&Environment::is_glow_bicubic_upscale_enabled);
+
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"glow/enabled"),_SCS("set_glow_enabled"),_SCS("is_glow_enabled") );
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow/levels/1"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),0 );
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow/levels/2"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),1 );
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow/levels/3"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),2 );
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow/levels/4"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),3 );
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow/levels/5"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),4 );
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow/levels/6"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),5 );
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"glow/levels/7"),_SCS("set_glow_level"),_SCS("is_glow_level_enabled"),6 );
+
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"glow/intensity",PROPERTY_HINT_RANGE,"0.0,8.0,0.01"),_SCS("set_glow_intensity"),_SCS("get_glow_intensity") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"glow/strength",PROPERTY_HINT_RANGE,"0.0,2.0,0.01"),_SCS("set_glow_strength"),_SCS("get_glow_strength") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"glow/bloom",PROPERTY_HINT_RANGE,"0.0,1.0,0.01"),_SCS("set_glow_bloom"),_SCS("get_glow_bloom") );
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"glow/blend_mode",PROPERTY_HINT_ENUM,"Additive,Screen,Softlight,Replace"),_SCS("set_glow_blend_mode"),_SCS("get_glow_blend_mode") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"glow/hdr_treshold",PROPERTY_HINT_RANGE,"0.0,4.0,0.01"),_SCS("set_glow_hdr_bleed_treshold"),_SCS("get_glow_hdr_bleed_treshold") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"glow/hdr_scale",PROPERTY_HINT_RANGE,"0.0,4.0,0.01"),_SCS("set_glow_hdr_bleed_scale"),_SCS("get_glow_hdr_bleed_scale") );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"glow/bicubic_upscale"),_SCS("set_glow_bicubic_upscale"),_SCS("is_glow_bicubic_upscale_enabled") );
+
+
+ ObjectTypeDB::bind_method(_MD("set_tonemapper","mode"),&Environment::set_tonemapper);
+ ObjectTypeDB::bind_method(_MD("get_tonemapper"),&Environment::get_tonemapper);
+
+ ObjectTypeDB::bind_method(_MD("set_tonemap_exposure","exposure"),&Environment::set_tonemap_exposure);
+ ObjectTypeDB::bind_method(_MD("get_tonemap_exposure"),&Environment::get_tonemap_exposure);
+
+ ObjectTypeDB::bind_method(_MD("set_tonemap_white","white"),&Environment::set_tonemap_white);
+ ObjectTypeDB::bind_method(_MD("get_tonemap_white"),&Environment::get_tonemap_white);
+
+ ObjectTypeDB::bind_method(_MD("set_tonemap_auto_exposure","auto_exposure"),&Environment::set_tonemap_auto_exposure);
+ ObjectTypeDB::bind_method(_MD("get_tonemap_auto_exposure"),&Environment::get_tonemap_auto_exposure);
+
+ ObjectTypeDB::bind_method(_MD("set_tonemap_auto_exposure_max","exposure_max"),&Environment::set_tonemap_auto_exposure_max);
+ ObjectTypeDB::bind_method(_MD("get_tonemap_auto_exposure_max"),&Environment::get_tonemap_auto_exposure_max);
+
+ ObjectTypeDB::bind_method(_MD("set_tonemap_auto_exposure_min","exposure_min"),&Environment::set_tonemap_auto_exposure_min);
+ ObjectTypeDB::bind_method(_MD("get_tonemap_auto_exposure_min"),&Environment::get_tonemap_auto_exposure_min);
+
+ ObjectTypeDB::bind_method(_MD("set_tonemap_auto_exposure_speed","exposure_speed"),&Environment::set_tonemap_auto_exposure_speed);
+ ObjectTypeDB::bind_method(_MD("get_tonemap_auto_exposure_speed"),&Environment::get_tonemap_auto_exposure_speed);
+
+ ObjectTypeDB::bind_method(_MD("set_tonemap_auto_exposure_grey","exposure_grey"),&Environment::set_tonemap_auto_exposure_grey);
+ ObjectTypeDB::bind_method(_MD("get_tonemap_auto_exposure_grey"),&Environment::get_tonemap_auto_exposure_grey);
+
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"tonemap/mode",PROPERTY_HINT_ENUM,"Linear,Reindhart,Filmic,Aces"),_SCS("set_tonemapper"),_SCS("get_tonemapper") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"tonemap/exposure",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_tonemap_exposure"),_SCS("get_tonemap_exposure") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"tonemap/white",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_tonemap_white"),_SCS("get_tonemap_white") );
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"auto_exposure/enabled"),_SCS("set_tonemap_auto_exposure"),_SCS("get_tonemap_auto_exposure") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"auto_exposure/scale",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("set_tonemap_auto_exposure_grey"),_SCS("get_tonemap_auto_exposure_grey") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"auto_exposure/min_luma",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_tonemap_auto_exposure_min"),_SCS("get_tonemap_auto_exposure_min") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"auto_exposure/max_luma",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_tonemap_auto_exposure_max"),_SCS("get_tonemap_auto_exposure_max") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"auto_exposure/speed",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("set_tonemap_auto_exposure_speed"),_SCS("get_tonemap_auto_exposure_speed") );
+
+ ObjectTypeDB::bind_method(_MD("set_adjustment_enable","enabled"),&Environment::set_adjustment_enable);
+ ObjectTypeDB::bind_method(_MD("is_adjustment_enabled"),&Environment::is_adjustment_enabled);
+
+ ObjectTypeDB::bind_method(_MD("set_adjustment_brightness","brightness"),&Environment::set_adjustment_brightness);
+ ObjectTypeDB::bind_method(_MD("get_adjustment_brightness"),&Environment::get_adjustment_brightness);
+
+ ObjectTypeDB::bind_method(_MD("set_adjustment_contrast","contrast"),&Environment::set_adjustment_contrast);
+ ObjectTypeDB::bind_method(_MD("get_adjustment_contrast"),&Environment::get_adjustment_contrast);
+
+ ObjectTypeDB::bind_method(_MD("set_adjustment_saturation","saturation"),&Environment::set_adjustment_saturation);
+ ObjectTypeDB::bind_method(_MD("get_adjustment_saturation"),&Environment::get_adjustment_saturation);
+
+ ObjectTypeDB::bind_method(_MD("set_adjustment_color_correction","color_correction"),&Environment::set_adjustment_color_correction);
+ ObjectTypeDB::bind_method(_MD("get_adjustment_color_correction"),&Environment::get_adjustment_color_correction);
+
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"adjustment/enabled"),_SCS("set_adjustment_enable"),_SCS("is_adjustment_enabled") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"adjustment/brightness",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("set_adjustment_brightness"),_SCS("get_adjustment_brightness") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"adjustment/contrast",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("set_adjustment_contrast"),_SCS("get_adjustment_contrast") );
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"adjustment/saturation",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("set_adjustment_saturation"),_SCS("get_adjustment_saturation") );
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"adjustment/color_correction",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_adjustment_color_correction"),_SCS("get_adjustment_color_correction") );
+
+
+ GLOBAL_DEF("rendering/skybox/irradiance_cube_resolution",256);
+ GLOBAL_DEF("rendering/skybox/radiance_cube_resolution",64);
+
+ BIND_CONSTANT(BG_KEEP);
+ BIND_CONSTANT(BG_CLEAR_COLOR);
+ BIND_CONSTANT(BG_COLOR);
+ BIND_CONSTANT(BG_SKYBOX);
+ BIND_CONSTANT(BG_CANVAS);
+ BIND_CONSTANT(BG_MAX);
+ BIND_CONSTANT(GLOW_BLEND_MODE_ADDITIVE);
+ BIND_CONSTANT(GLOW_BLEND_MODE_SCREEN);
+ BIND_CONSTANT(GLOW_BLEND_MODE_SOFTLIGHT);
+ BIND_CONSTANT(GLOW_BLEND_MODE_REPLACE);
+ BIND_CONSTANT(TONE_MAPPER_LINEAR);
+ BIND_CONSTANT(TONE_MAPPER_REINHARDT);
+ BIND_CONSTANT(TONE_MAPPER_FILMIC);
+ BIND_CONSTANT(TONE_MAPPER_ACES);
+ BIND_CONSTANT(DOF_BLUR_QUALITY_LOW);
+ BIND_CONSTANT(DOF_BLUR_QUALITY_MEDIUM);
+ BIND_CONSTANT(DOF_BLUR_QUALITY_HIGH);
- ObjectTypeDB::bind_method(_MD("set_background_param","param","value"),&Environment::set_background_param);
- ObjectTypeDB::bind_method(_MD("get_background_param","param"),&Environment::get_background_param);
-
- ObjectTypeDB::bind_method(_MD("set_enable_fx","effect","enabled"),&Environment::set_enable_fx);
- ObjectTypeDB::bind_method(_MD("is_fx_enabled","effect"),&Environment::is_fx_enabled);
-
- 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,Canvas"),_SCS("set_background"),_SCS("get_background"));
- ADD_PROPERTYI( PropertyInfo(Variant::COLOR,"background/color"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_COLOR);
- ADD_PROPERTYI( PropertyInfo(Variant::OBJECT,"background/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_TEXTURE);
- ADD_PROPERTYI( PropertyInfo(Variant::OBJECT,"background/cubemap",PROPERTY_HINT_RESOURCE_TYPE,"CubeMap"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_CUBEMAP);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"background/energy",PROPERTY_HINT_RANGE,"0,128,0.01"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_ENERGY);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"background/scale",PROPERTY_HINT_RANGE,"0.001,16,0.001"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_SCALE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"background/glow",PROPERTY_HINT_RANGE,"0.00,8,0.01"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_GLOW);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"background/canvas_max_layer"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_CANVAS_MAX_LAYER);
-
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"glow/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_GLOW);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"glow/blur_passes",PROPERTY_HINT_RANGE,"1,4,1"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_PASSES);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"glow/blur_scale",PROPERTY_HINT_RANGE,"0.01,4,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_SCALE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"glow/blur_strength",PROPERTY_HINT_RANGE,"0.01,4,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_STRENGTH);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"glow/blur_blend_mode",PROPERTY_HINT_ENUM,"Additive,Screen,SoftLight"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_BLEND_MODE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"glow/bloom",PROPERTY_HINT_RANGE,"0,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLOOM);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"glow/bloom_treshold",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLOOM_TRESHOLD);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"dof_blur/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_DOF_BLUR);
- ADD_PROPERTYI( PropertyInfo(Variant::INT,"dof_blur/blur_passes",PROPERTY_HINT_RANGE,"1,4,1"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_DOF_BLUR_PASSES);
- 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/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);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/max_luminance",PROPERTY_HINT_RANGE,"0.01,64,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_MAX_LUMINANCE);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"hdr/exposure_adj_speed",PROPERTY_HINT_RANGE,"0.001,64,0.001"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"fog/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_FOG);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"fog/begin",PROPERTY_HINT_RANGE,"0.01,4096,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_FOG_BEGIN);
- ADD_PROPERTYI( PropertyInfo(Variant::COLOR,"fog/begin_color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_FOG_BEGIN_COLOR);
- ADD_PROPERTYI( PropertyInfo(Variant::COLOR,"fog/end_color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_FOG_END_COLOR);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"fog/attenuation",PROPERTY_HINT_EXP_EASING),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_FOG_ATTENUATION);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"fog/bg"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_FOG_BG);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"bcs/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_BCS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"bcs/brightness",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_BCS_BRIGHTNESS);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"bcs/contrast",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_BCS_CONTRAST);
- ADD_PROPERTYI( PropertyInfo(Variant::REAL,"bcs/saturation",PROPERTY_HINT_RANGE,"0.01,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_BCS_SATURATION);
- ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"srgb/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_SRGB);
-
-
-
-
-
-/*
- FX_PARAM_BLOOM_GLOW_BLUR_PASSES=VS::ENV_FX_PARAM_BLOOM_GLOW_BLUR_PASSES,
- FX_PARAM_BLOOM_AMOUNT=VS::ENV_FX_PARAM_BLOOM_AMOUNT,
- FX_PARAM_DOF_BLUR_PASSES=VS::ENV_FX_PARAM_DOF_BLUR_PASSES,
- 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_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,
- FX_PARAM_HDR_MAX_LUMINANCE=VS::ENV_FX_PARAM_HDR_MAX_LUMINANCE,
- FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED=VS::ENV_FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED,
- FX_PARAM_FOG_BEGIN=VS::ENV_FX_PARAM_FOG_BEGIN,
- FX_PARAM_FOG_ATTENUATION=VS::ENV_FX_PARAM_FOG_ATTENUATION,
- FX_PARAM_FOG_BEGIN_COLOR=VS::ENV_FX_PARAM_FOG_BEGIN_COLOR,
- FX_PARAM_FOG_END_COLOR=VS::ENV_FX_PARAM_FOG_END_COLOR,
- FX_PARAM_FOG_BG=VS::ENV_FX_PARAM_FOG_BG,
- FX_PARAM_GAMMA_VALUE=VS::ENV_FX_PARAM_GAMMA_VALUE,
- FX_PARAM_BRIGHTNESS_VALUE=VS::ENV_FX_PARAM_BRIGHTNESS_VALUE,
- FX_PARAM_CONTRAST_VALUE=VS::ENV_FX_PARAM_CONTRAST_VALUE,
- FX_PARAM_SATURATION_VALUE=VS::ENV_FX_PARAM_SATURATION_VALUE,
- FX_PARAM_MAX=VS::ENV_FX_PARAM_MAX
-*/
-
- BIND_CONSTANT( BG_KEEP );
- BIND_CONSTANT( BG_DEFAULT_COLOR );
- BIND_CONSTANT( BG_COLOR );
- BIND_CONSTANT( BG_TEXTURE );
- BIND_CONSTANT( BG_CUBEMAP );
- BIND_CONSTANT( BG_CANVAS );
- BIND_CONSTANT( BG_MAX );
-
- BIND_CONSTANT( BG_PARAM_CANVAS_MAX_LAYER );
- BIND_CONSTANT( BG_PARAM_COLOR );
- BIND_CONSTANT( BG_PARAM_TEXTURE );
- BIND_CONSTANT( BG_PARAM_CUBEMAP );
- BIND_CONSTANT( BG_PARAM_ENERGY );
- BIND_CONSTANT( BG_PARAM_GLOW );
- BIND_CONSTANT( BG_PARAM_MAX );
-
-
- BIND_CONSTANT( FX_AMBIENT_LIGHT );
- BIND_CONSTANT( FX_FXAA );
- BIND_CONSTANT( FX_GLOW );
- BIND_CONSTANT( FX_DOF_BLUR );
- BIND_CONSTANT( FX_HDR );
- BIND_CONSTANT( FX_FOG );
- BIND_CONSTANT( FX_BCS);
- BIND_CONSTANT( FX_SRGB );
- BIND_CONSTANT( FX_MAX );
-
-
- BIND_CONSTANT( FX_BLUR_BLEND_MODE_ADDITIVE );
- 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 );
- BIND_CONSTANT( FX_PARAM_GLOW_BLUR_BLEND_MODE );
- BIND_CONSTANT( FX_PARAM_GLOW_BLOOM);
- BIND_CONSTANT( FX_PARAM_GLOW_BLOOM_TRESHOLD);
- 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_WHITE );
- BIND_CONSTANT( FX_PARAM_HDR_GLOW_TRESHOLD );
- BIND_CONSTANT( FX_PARAM_HDR_GLOW_SCALE );
- BIND_CONSTANT( FX_PARAM_HDR_MIN_LUMINANCE );
- BIND_CONSTANT( FX_PARAM_HDR_MAX_LUMINANCE );
- BIND_CONSTANT( FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED );
- BIND_CONSTANT( FX_PARAM_FOG_BEGIN );
- BIND_CONSTANT( FX_PARAM_FOG_ATTENUATION );
- BIND_CONSTANT( FX_PARAM_FOG_BEGIN_COLOR );
- BIND_CONSTANT( FX_PARAM_FOG_END_COLOR );
- BIND_CONSTANT( FX_PARAM_FOG_BG );
- BIND_CONSTANT( FX_PARAM_BCS_BRIGHTNESS );
- BIND_CONSTANT( FX_PARAM_BCS_CONTRAST );
- BIND_CONSTANT( FX_PARAM_BCS_SATURATION );
- BIND_CONSTANT( FX_PARAM_MAX );
}
Environment::Environment() {
+ bg_mode=BG_CLEAR_COLOR;
+ bg_skybox_scale=1.0;
+ bg_energy=1.0;
+ bg_canvas_max_layer=0;
+ ambient_energy=1.0;
+ ambient_skybox_contribution=0;
+
+
+ tone_mapper=TONE_MAPPER_LINEAR;
+ tonemap_exposure=1.0;
+ tonemap_white=1.0;
+ tonemap_auto_exposure=false;
+ tonemap_auto_exposure_max=8;
+ tonemap_auto_exposure_min=0.05;
+ tonemap_auto_exposure_speed=0.5;
+ tonemap_auto_exposure_grey=0.4;
+
+ set_tonemapper(tone_mapper); //update
+
+ adjustment_enabled=false;
+ adjustment_contrast=1.0;
+ adjustment_saturation=1.0;
+ adjustment_brightness=1.0;
+
+ set_adjustment_enable(adjustment_enabled); //update
+
environment = VS::get_singleton()->environment_create();
- set_background(BG_DEFAULT_COLOR);
- set_background_param(BG_PARAM_COLOR,Color(0,0,0));
- set_background_param(BG_PARAM_TEXTURE,Ref<ImageTexture>());
- set_background_param(BG_PARAM_CUBEMAP,Ref<CubeMap>());
- set_background_param(BG_PARAM_ENERGY,1.0);
- set_background_param(BG_PARAM_SCALE,1.0);
- set_background_param(BG_PARAM_GLOW,0.0);
-
- 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);
- fx_set_param(FX_PARAM_GLOW_BLOOM,0.0);
- fx_set_param(FX_PARAM_GLOW_BLOOM_TRESHOLD,0.5);
- 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_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);
- fx_set_param(FX_PARAM_HDR_MAX_LUMINANCE,8.0);
- fx_set_param(FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED,0.5);
- fx_set_param(FX_PARAM_FOG_BEGIN,100.0);
- fx_set_param(FX_PARAM_FOG_ATTENUATION,1.0);
- fx_set_param(FX_PARAM_FOG_BEGIN_COLOR,Color(0,0,0));
- fx_set_param(FX_PARAM_FOG_END_COLOR,Color(0,0,0));
- fx_set_param(FX_PARAM_FOG_BG,true);
- fx_set_param(FX_PARAM_BCS_BRIGHTNESS,1.0);
- fx_set_param(FX_PARAM_BCS_CONTRAST,1.0);
- fx_set_param(FX_PARAM_BCS_SATURATION,1.0);
+ ssr_enabled=false;
+ ssr_max_steps=64;
+ ssr_accel=0.04;
+ ssr_fade=2.0;
+ ssr_depth_tolerance=0.2;
+ ssr_smooth=true;
+ ssr_roughness=true;
+
+ ssao_enabled=false;
+ ssao_radius=1;
+ ssao_intensity=1;
+ ssao_radius2=0;
+ ssao_intensity2=1;
+ ssao_bias=0.01;
+ ssao_direct_light_affect=false;
+ ssao_blur=true;
+
+ glow_enabled=false;
+ glow_levels=(1<<2)|(1<<4);
+ glow_intensity=0.8;
+ glow_strength=1.0;
+ glow_bloom=0.0;
+ glow_blend_mode=GLOW_BLEND_MODE_SOFTLIGHT;
+ glow_hdr_bleed_treshold=1.0;
+ glow_hdr_bleed_scale=2.0;
+ glow_bicubic_upscale=false;
+
+ dof_blur_far_enabled=false;
+ dof_blur_far_distance=10;
+ dof_blur_far_transition=5;
+ dof_blur_far_amount=0.1;
+ dof_blur_far_quality=DOF_BLUR_QUALITY_MEDIUM;
+
+ dof_blur_near_enabled=false;
+ dof_blur_near_distance=2;
+ dof_blur_near_transition=1;
+ dof_blur_near_amount=0.1;
+ dof_blur_near_quality=DOF_BLUR_QUALITY_MEDIUM;
}
+
Environment::~Environment() {
VS::get_singleton()->free(environment);
diff --git a/scene/resources/environment.h b/scene/resources/environment.h
index c00fa0ab51..8f2e4532a4 100644
--- a/scene/resources/environment.h
+++ b/scene/resources/environment.h
@@ -31,113 +31,288 @@
#include "resource.h"
#include "servers/visual_server.h"
+#include "scene/resources/texture.h"
+#include "scene/resources/sky_box.h"
class Environment : public Resource {
OBJ_TYPE(Environment,Resource);
public:
- enum BG {
+ enum BGMode {
- BG_KEEP=VS::ENV_BG_KEEP,
- BG_DEFAULT_COLOR=VS::ENV_BG_DEFAULT_COLOR,
- BG_COLOR=VS::ENV_BG_COLOR,
- BG_TEXTURE=VS::ENV_BG_TEXTURE,
- BG_CUBEMAP=VS::ENV_BG_CUBEMAP,
- BG_CANVAS=VS::ENV_BG_CANVAS,
- BG_MAX=VS::ENV_BG_MAX
+ BG_CLEAR_COLOR,
+ BG_COLOR,
+ BG_SKYBOX,
+ BG_CANVAS,
+ BG_KEEP,
+ BG_MAX
};
- enum BGParam {
- BG_PARAM_CANVAS_MAX_LAYER=VS::ENV_BG_PARAM_CANVAS_MAX_LAYER,
- BG_PARAM_COLOR=VS::ENV_BG_PARAM_COLOR,
- BG_PARAM_TEXTURE=VS::ENV_BG_PARAM_TEXTURE,
- BG_PARAM_CUBEMAP=VS::ENV_BG_PARAM_CUBEMAP,
- BG_PARAM_ENERGY=VS::ENV_BG_PARAM_ENERGY,
- BG_PARAM_SCALE=VS::ENV_BG_PARAM_SCALE,
- BG_PARAM_GLOW=VS::ENV_BG_PARAM_GLOW,
- BG_PARAM_MAX=VS::ENV_BG_PARAM_MAX
- };
- 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,
- FX_HDR=VS::ENV_FX_HDR,
- FX_FOG=VS::ENV_FX_FOG,
- FX_BCS=VS::ENV_FX_BCS,
- FX_SRGB=VS::ENV_FX_SRGB,
- FX_MAX=VS::ENV_FX_MAX,
+ enum ToneMapper {
+ TONE_MAPPER_LINEAR,
+ TONE_MAPPER_REINHARDT,
+ TONE_MAPPER_FILMIC,
+ TONE_MAPPER_ACES
};
- enum FxBlurBlendMode {
- FX_BLUR_BLEND_MODE_ADDITIVE,
- FX_BLUR_BLEND_MODE_SCREEN,
- FX_BLUR_BLEND_MODE_SOFTLIGHT,
+ enum GlowBlendMode {
+ GLOW_BLEND_MODE_ADDITIVE,
+ GLOW_BLEND_MODE_SCREEN,
+ GLOW_BLEND_MODE_SOFTLIGHT,
+ GLOW_BLEND_MODE_REPLACE,
};
- enum FxHDRToneMapper {
- FX_HDR_TONE_MAPPER_LINEAR,
- FX_HDR_TONE_MAPPER_LOG,
- FX_HDR_TONE_MAPPER_REINHARDT,
- FX_HDR_TONE_MAPPER_REINHARDT_AUTOWHITE,
+ enum DOFBlurQuality {
+ DOF_BLUR_QUALITY_LOW,
+ DOF_BLUR_QUALITY_MEDIUM,
+ DOF_BLUR_QUALITY_HIGH,
};
- 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,
- FX_PARAM_GLOW_BLUR_BLEND_MODE=VS::ENV_FX_PARAM_GLOW_BLUR_BLEND_MODE,
- FX_PARAM_GLOW_BLOOM=VS::ENV_FX_PARAM_GLOW_BLOOM,
- FX_PARAM_GLOW_BLOOM_TRESHOLD=VS::ENV_FX_PARAM_GLOW_BLOOM_TRESHOLD,
- FX_PARAM_DOF_BLUR_PASSES=VS::ENV_FX_PARAM_DOF_BLUR_PASSES,
- 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_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,
- FX_PARAM_HDR_MAX_LUMINANCE=VS::ENV_FX_PARAM_HDR_MAX_LUMINANCE,
- FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED=VS::ENV_FX_PARAM_HDR_EXPOSURE_ADJUST_SPEED,
- FX_PARAM_FOG_BEGIN=VS::ENV_FX_PARAM_FOG_BEGIN,
- FX_PARAM_FOG_BEGIN_COLOR=VS::ENV_FX_PARAM_FOG_BEGIN_COLOR,
- FX_PARAM_FOG_END_COLOR=VS::ENV_FX_PARAM_FOG_END_COLOR,
- FX_PARAM_FOG_ATTENUATION=VS::ENV_FX_PARAM_FOG_ATTENUATION,
- FX_PARAM_FOG_BG=VS::ENV_FX_PARAM_FOG_BG,
- FX_PARAM_BCS_BRIGHTNESS=VS::ENV_FX_PARAM_BCS_BRIGHTNESS,
- FX_PARAM_BCS_CONTRAST=VS::ENV_FX_PARAM_BCS_CONTRAST,
- FX_PARAM_BCS_SATURATION=VS::ENV_FX_PARAM_BCS_SATURATION,
- FX_PARAM_MAX=VS::ENV_FX_PARAM_MAX
- };
private:
-
- BG bg_mode;
- Variant bg_param[BG_PARAM_MAX];
- bool fx_enabled[FX_MAX];
- Variant fx_param[FX_PARAM_MAX];
RID environment;
+ BGMode bg_mode;
+ Ref<SkyBox> bg_skybox;
+ float bg_skybox_scale;
+ Color bg_color;
+ float bg_energy;
+ int bg_canvas_max_layer;
+ Color ambient_color;
+ float ambient_energy;
+ float ambient_skybox_contribution;
+
+ ToneMapper tone_mapper;
+ float tonemap_exposure;
+ float tonemap_white;
+ bool tonemap_auto_exposure;
+ float tonemap_auto_exposure_max;
+ float tonemap_auto_exposure_min;
+ float tonemap_auto_exposure_speed;
+ float tonemap_auto_exposure_grey;
+
+ bool adjustment_enabled;
+ float adjustment_contrast;
+ float adjustment_saturation;
+ float adjustment_brightness;
+ Ref<Texture> adjustment_color_correction;
+
+ bool ssr_enabled;
+ int ssr_max_steps;
+ float ssr_accel;
+ float ssr_fade;
+ float ssr_depth_tolerance;
+ bool ssr_smooth;
+ bool ssr_roughness;
+
+ bool ssao_enabled;
+ float ssao_radius;
+ float ssao_intensity;
+ float ssao_radius2;
+ float ssao_intensity2;
+ float ssao_bias;
+ float ssao_direct_light_affect;
+ Color ssao_color;
+ bool ssao_blur;
+
+ bool glow_enabled;
+ int glow_levels;
+ float glow_intensity;
+ float glow_strength;
+ float glow_bloom;
+ GlowBlendMode glow_blend_mode;
+ float glow_hdr_bleed_treshold;
+ float glow_hdr_bleed_scale;
+ bool glow_bicubic_upscale;
+
+ bool dof_blur_far_enabled;
+ float dof_blur_far_distance;
+ float dof_blur_far_transition;
+ float dof_blur_far_amount;
+ DOFBlurQuality dof_blur_far_quality;
+
+ bool dof_blur_near_enabled;
+ float dof_blur_near_distance;
+ float dof_blur_near_transition;
+ float dof_blur_near_amount;
+ DOFBlurQuality dof_blur_near_quality;
+
protected:
static void _bind_methods();
+ virtual void _validate_property(PropertyInfo& property) const;
+
public:
- void set_background(BG p_bg);
- BG get_background() const;
- void set_background_param(BGParam p_param, const Variant& p_value);
- Variant get_background_param(BGParam p_param) const;
- void set_enable_fx(Fx p_effect,bool p_enabled);
- bool is_fx_enabled(Fx p_effect) const;
+ void set_background(BGMode p_bg);
+ void set_skybox(const Ref<SkyBox>& p_skybox);
+ void set_skybox_scale(float p_scale);
+ void set_bg_color(const Color& p_color);
+ void set_bg_energy(float p_energy);
+ void set_canvas_max_layer(int p_max_layer);
+ void set_ambient_light_color(const Color& p_color);
+ void set_ambient_light_energy(float p_energy);
+ void set_ambient_light_skybox_contribution(float p_energy);
+
+ BGMode get_background() const;
+ Ref<SkyBox> get_skybox() const;
+ float get_skybox_scale() const;
+ Color get_bg_color() const;
+ float get_bg_energy() const;
+ int get_canvas_max_layer() const;
+ Color get_ambient_light_color() const;
+ float get_ambient_light_energy() const;
+ float get_ambient_light_skybox_contribution() const;
+
+
+ void set_tonemapper(ToneMapper p_tone_mapper);
+ ToneMapper get_tonemapper() const;
+
+ void set_tonemap_exposure(float p_exposure);
+ float get_tonemap_exposure() const;
+
+ void set_tonemap_white(float p_white);
+ float get_tonemap_white() const;
+
+ void set_tonemap_auto_exposure(bool p_enabled);
+ bool get_tonemap_auto_exposure() const;
+
+ void set_tonemap_auto_exposure_max(float p_auto_exposure_max);
+ float get_tonemap_auto_exposure_max() const;
+
+ void set_tonemap_auto_exposure_min(float p_auto_exposure_min);
+ float get_tonemap_auto_exposure_min() const;
+
+ void set_tonemap_auto_exposure_speed(float p_auto_exposure_speed);
+ float get_tonemap_auto_exposure_speed() const;
+
+ void set_tonemap_auto_exposure_grey(float p_auto_exposure_grey);
+ float get_tonemap_auto_exposure_grey() const;
+
+ void set_adjustment_enable(bool p_enable);
+ bool is_adjustment_enabled() const;
+
+ void set_adjustment_brightness(float p_brightness);
+ float get_adjustment_brightness() const;
+
+ void set_adjustment_contrast(float p_contrast);
+ float get_adjustment_contrast() const;
+
+ void set_adjustment_saturation(float p_saturation);
+ float get_adjustment_saturation() const;
+
+ void set_adjustment_color_correction(const Ref<Texture>& p_ramp);
+ Ref<Texture> get_adjustment_color_correction() const;
+
+ void set_ssr_enabled(bool p_enable);
+ bool is_ssr_enabled() const;
+
+ void set_ssr_max_steps(int p_steps);
+ int get_ssr_max_steps() const;
+
+ void set_ssr_accel(float p_accel);
+ float get_ssr_accel() const;
+
+ void set_ssr_fade(float p_transition);
+ float get_ssr_fade() const;
+
+ void set_ssr_depth_tolerance(float p_depth_tolerance);
+ float get_ssr_depth_tolerance() const;
+
+ void set_ssr_smooth(bool p_enable);
+ bool is_ssr_smooth() const;
+
+ void set_ssr_rough(bool p_enable);
+ bool is_ssr_rough() const;
+
+ void set_ssao_enabled(bool p_enable);
+ bool is_ssao_enabled() const;
+
+ void set_ssao_radius(float p_radius);
+ float get_ssao_radius() const;
+
+ void set_ssao_intensity(float p_intensity);
+ float get_ssao_intensity() const;
+
+ void set_ssao_radius2(float p_radius);
+ float get_ssao_radius2() const;
+
+ void set_ssao_intensity2(float p_intensity);
+ float get_ssao_intensity2() const;
+
+ void set_ssao_bias(float p_bias);
+ float get_ssao_bias() const;
+
+ void set_ssao_direct_light_affect(float p_direct_light_affect);
+ float get_ssao_direct_light_affect() const;
+
+ void set_ssao_color(const Color& p_color);
+ Color get_ssao_color() const;
+
+ void set_ssao_blur(bool p_enable);
+ bool is_ssao_blur_enabled() const;
+
+
+ void set_glow_enabled(bool p_enabled);
+ bool is_glow_enabled() const;
+
+ void set_glow_level(int p_level,bool p_enabled);
+ bool is_glow_level_enabled(int p_level) const;
+
+ void set_glow_intensity(float p_intensity);
+ float get_glow_intensity() const;
+
+ void set_glow_strength(float p_strength);
+ float get_glow_strength() const;
+
+ void set_glow_bloom(float p_treshold);
+ float get_glow_bloom() const;
+
+ void set_glow_blend_mode(GlowBlendMode p_mode);
+ GlowBlendMode get_glow_blend_mode() const;
+
+ void set_glow_hdr_bleed_treshold(float p_treshold);
+ float get_glow_hdr_bleed_treshold() const;
+
+ void set_glow_hdr_bleed_scale(float p_scale);
+ float get_glow_hdr_bleed_scale() const;
+
+ void set_glow_bicubic_upscale(bool p_enable);
+ bool is_glow_bicubic_upscale_enabled() const;
+
+ void set_dof_blur_far_enabled(bool p_enable);
+ bool is_dof_blur_far_enabled() const;
+
+ void set_dof_blur_far_distance(float p_distance);
+ float get_dof_blur_far_distance() const;
+
+ void set_dof_blur_far_transition(float p_distance);
+ float get_dof_blur_far_transition() const;
+
+ void set_dof_blur_far_amount(float p_amount);
+ float get_dof_blur_far_amount() const;
+
+ void set_dof_blur_far_quality(DOFBlurQuality p_quality);
+ DOFBlurQuality get_dof_blur_far_quality() const;
+
+ void set_dof_blur_near_enabled(bool p_enable);
+ bool is_dof_blur_near_enabled() const;
+
+ void set_dof_blur_near_distance(float p_distance);
+ float get_dof_blur_near_distance() const;
+
+ void set_dof_blur_near_transition(float p_distance);
+ float get_dof_blur_near_transition() const;
+
+ void set_dof_blur_near_amount(float p_amount);
+ float get_dof_blur_near_amount() const;
+
+ void set_dof_blur_near_quality(DOFBlurQuality p_quality);
+ DOFBlurQuality get_dof_blur_near_quality() const;
- void fx_set_param(FxParam p_param,const Variant& p_value);
- Variant fx_get_param(FxParam p_param) const;
virtual RID get_rid() const;
@@ -145,9 +320,12 @@ public:
~Environment();
};
-VARIANT_ENUM_CAST( Environment::BG );
-VARIANT_ENUM_CAST( Environment::BGParam );
-VARIANT_ENUM_CAST( Environment::Fx );
-VARIANT_ENUM_CAST( Environment::FxParam );
+
+
+
+VARIANT_ENUM_CAST(Environment::BGMode)
+VARIANT_ENUM_CAST(Environment::ToneMapper)
+VARIANT_ENUM_CAST(Environment::GlowBlendMode)
+VARIANT_ENUM_CAST(Environment::DOFBlurQuality)
#endif // ENVIRONMENT_H
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 2ecd2cc07b..a6136b2741 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -29,576 +29,1110 @@
#include "material.h"
#include "scene/scene_string_names.h"
+RID Material::get_rid() const {
-static const char*_flag_names[Material::FLAG_MAX]={
- "visible",
- "double_sided",
- "invert_faces",
- "unshaded",
- "on_top",
- "lightmap_on_uv2",
- "colarray_is_srgb"
-};
-
+ return material;
+}
-static const Material::Flag _flag_indices[Material::FLAG_MAX]={
- Material::FLAG_VISIBLE,
- Material::FLAG_DOUBLE_SIDED,
- Material::FLAG_INVERT_FACES,
- Material::FLAG_UNSHADED,
- Material::FLAG_ONTOP,
- Material::FLAG_LIGHTMAP_ON_UV2,
- Material::FLAG_COLOR_ARRAY_SRGB,
-};
+Material::Material() {
+ material=VisualServer::get_singleton()->material_create();
+}
-RID Material::get_rid() const {
+Material::~Material() {
- return material;
+ VisualServer::get_singleton()->free(material);
}
-void Material::set_flag(Flag p_flag,bool p_enabled) {
- ERR_FAIL_INDEX(p_flag,FLAG_MAX);
- flags[p_flag]=p_enabled;
- VisualServer::get_singleton()->material_set_flag(material,(VS::MaterialFlag)p_flag,p_enabled);
- _change_notify();
+/////////////////////////////////
+
+Mutex *FixedSpatialMaterial::material_mutex=NULL;
+SelfList<FixedSpatialMaterial>::List FixedSpatialMaterial::dirty_materials;
+Map<FixedSpatialMaterial::MaterialKey,FixedSpatialMaterial::ShaderData> FixedSpatialMaterial::shader_map;
+FixedSpatialMaterial::ShaderNames* FixedSpatialMaterial::shader_names=NULL;
+
+void FixedSpatialMaterial::init_shaders() {
+
+#ifndef NO_THREADS
+ material_mutex = Mutex::create();
+#endif
+
+ shader_names = memnew( ShaderNames );
+
+ shader_names->albedo="albedo";
+ shader_names->specular="specular";
+ shader_names->roughness="roughness";
+ shader_names->metalness="metalness";
+ shader_names->emission="emission";
+ shader_names->emission_energy="emission_energy";
+ shader_names->normal_scale="normal_scale";
+ shader_names->rim="rim";
+ shader_names->rim_tint="rim_tint";
+ shader_names->clearcoat="clearcoat";
+ shader_names->clearcoat_gloss="clearcoat_gloss";
+ shader_names->anisotropy="anisotropy_ratio";
+ shader_names->height_scale="height_scale";
+ shader_names->subsurface_scattering_strength="subsurface_scattering_strength";
+ shader_names->refraction="refraction";
+ shader_names->refraction_roughness="refraction_roughness";
+ shader_names->point_size="point_size";
+ shader_names->uv1_scale="uv1_scale";
+ shader_names->uv1_offset="uv1_offset";
+ shader_names->uv2_scale="uv2_scale";
+ shader_names->uv2_offset="uv2_offset";
+
+ shader_names->texture_names[TEXTURE_ALBEDO]="texture_albedo";
+ shader_names->texture_names[TEXTURE_SPECULAR]="texture_specular";
+ shader_names->texture_names[TEXTURE_EMISSION]="texture_emission";
+ shader_names->texture_names[TEXTURE_NORMAL]="texture_normal";
+ shader_names->texture_names[TEXTURE_RIM]="texture_rim";
+ shader_names->texture_names[TEXTURE_CLEARCOAT]="texture_clearcoat";
+ shader_names->texture_names[TEXTURE_FLOWMAP]="texture_flowmap";
+ shader_names->texture_names[TEXTURE_AMBIENT_OCCLUSION]="texture_ambient_occlusion";
+ shader_names->texture_names[TEXTURE_HEIGHT]="texture_height";
+ shader_names->texture_names[TEXTURE_SUBSURFACE_SCATTERING]="texture_subsurface_scattering";
+ shader_names->texture_names[TEXTURE_REFRACTION]="texture_refraction";
+ shader_names->texture_names[TEXTURE_REFRACTION_ROUGHNESS]="texture_refraction_roughness";
+ shader_names->texture_names[TEXTURE_DETAIL_MASK]="texture_detail_mask";
+ shader_names->texture_names[TEXTURE_DETAIL_ALBEDO]="texture_detail_albedo";
+ shader_names->texture_names[TEXTURE_DETAIL_NORMAL]="texture_detail_normal";
+
}
+void FixedSpatialMaterial::finish_shaders(){
-void Material::set_blend_mode(BlendMode p_blend_mode) {
+#ifndef NO_THREADS
+ memdelete( material_mutex );
+#endif
+
+ memdelete( shader_names );
- ERR_FAIL_INDEX(p_blend_mode,4);
- blend_mode=p_blend_mode;
- VisualServer::get_singleton()->material_set_blend_mode(material,(VS::MaterialBlendMode)p_blend_mode);
- _change_notify();
}
-Material::BlendMode Material::get_blend_mode() const {
- return blend_mode;
+
+void FixedSpatialMaterial::_update_shader() {
+
+ dirty_materials.remove( &element );
+
+ MaterialKey mk = _compute_key();
+ if (mk.key==current_key.key)
+ return; //no update required in the end
+
+ if (shader_map.has(current_key)) {
+ shader_map[current_key].users--;
+ if (shader_map[current_key].users==0) {
+ //deallocate shader, as it's no longer in use
+ VS::get_singleton()->free(shader_map[current_key].shader);
+ shader_map.erase(current_key);
+ }
+ }
+
+ current_key=mk;
+
+ if (shader_map.has(mk)) {
+
+ VS::get_singleton()->material_set_shader(_get_material(),shader_map[mk].shader);
+ shader_map[mk].users++;
+ return;
+ }
+
+ //must create a shader!
+
+ String code="render_mode ";
+ switch(blend_mode) {
+ case BLEND_MODE_MIX: code+="blend_mix"; break;
+ case BLEND_MODE_ADD: code+="blend_add"; break;
+ case BLEND_MODE_SUB: code+="blend_sub"; break;
+ case BLEND_MODE_MUL: code+="blend_mul"; break;
+ }
+
+ switch(depth_draw_mode) {
+ case DEPTH_DRAW_OPAQUE_ONLY: code+=",depth_draw_opaque"; break;
+ case DEPTH_DRAW_ALWAYS: code+=",depth_draw_always"; break;
+ case DEPTH_DRAW_DISABLED: code+=",depth_draw_never"; break;
+ case DEPTH_DRAW_ALPHA_OPAQUE_PREPASS: code+=",depth_draw_alpha_prepass"; break;
+ }
+
+ switch(cull_mode) {
+ case CULL_BACK: code+=",cull_back"; break;
+ case CULL_FRONT: code+=",cull_front"; break;
+ case CULL_DISABLED: code+=",cull_disabled"; break;
+
+ }
+
+ if (flags[FLAG_UNSHADED]) {
+ code+=",unshaded";
+ }
+ if (flags[FLAG_ONTOP]) {
+ code+=",ontop";
+ }
+
+ code+=";\n";
+
+
+ code+="uniform vec4 albedo : hint_color;\n";
+ code+="uniform sampler2D texture_albedo : hint_albedo;\n";
+ if (specular_mode==SPECULAR_MODE_SPECULAR) {
+ code+="uniform vec4 specular : hint_color;\n";
+ } else {
+ code+="uniform float metalness;\n";
+ }
+
+ code+="uniform float roughness : hint_range(0,1);\n";
+ code+="uniform float point_size : hint_range(0,128);\n";
+ code+="uniform sampler2D texture_specular : hint_white;\n";
+ code+="uniform vec2 uv1_scale;\n";
+ code+="uniform vec2 uv1_offset;\n";
+ code+="uniform vec2 uv2_scale;\n";
+ code+="uniform vec2 uv2_offset;\n";
+
+ if (features[FEATURE_EMISSION]) {
+
+ code+="uniform sampler2D texture_emission : hint_black_albedo;\n";
+ code+="uniform vec4 emission : hint_color;\n";
+ code+="uniform float emission_energy;\n";
+ }
+
+ if (features[FEATURE_NORMAL_MAPPING]) {
+ code+="uniform sampler2D texture_normal : hint_normal;\n";
+ code+="uniform float normal_scale : hint_range(-16,16);\n";
+ }
+ if (features[FEATURE_RIM]) {
+ code+="uniform float rim : hint_range(0,1);\n";
+ code+="uniform float rim_tint : hint_range(0,1);\n";
+ code+="uniform sampler2D texture_rim : hint_white;\n";
+ }
+ if (features[FEATURE_CLEARCOAT]) {
+ code+="uniform float clearcoat : hint_range(0,1);\n";
+ code+="uniform float clearcoat_gloss : hint_range(0,1);\n";
+ code+="uniform sampler2D texture_clearcoat : hint_white;\n";
+ }
+ if (features[FEATURE_ANISOTROPY]) {
+ code+="uniform float anisotropy_ratio : hint_range(0,256);\n";
+ code+="uniform sampler2D texture_flowmap : hint_aniso;\n";
+ }
+ if (features[FEATURE_AMBIENT_OCCLUSION]) {
+ code+="uniform sampler2D texture_ambient_occlusion : hint_white;\n";
+ }
+
+ if (features[FEATURE_DETAIL]) {
+ code+="uniform sampler2D texture_detail_albedo : hint_albedo;\n";
+ code+="uniform sampler2D texture_detail_normal : hint_normal;\n";
+ code+="uniform sampler2D texture_detail_mask : hint_white;\n";
+ }
+
+ if (features[FEATURE_SUBSURACE_SCATTERING]) {
+
+ code+="uniform float subsurface_scattering_strength : hint_range(0,1);\n";
+ code+="uniform sampler2D texture_subsurface_scattering : hint_white;\n";
+
+ }
+
+
+ code+="\n\n";
+
+ code+="void vertex() {\n";
+
+ if (flags[FLAG_SRGB_VERTEX_COLOR]) {
+
+ code+="\tCOLOR.rgb = mix( pow((COLOR.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), COLOR.rgb* (1.0 / 12.92), lessThan(COLOR.rgb,vec3(0.04045)) );\n";
+ }
+ if (flags[FLAG_USE_POINT_SIZE]) {
+
+ code+="\tPOINT_SIZE=point_size;\n";
+ }
+ code+="\tUV=UV*uv1_scale+uv1_offset;\n";
+ if (detail_uv==DETAIL_UV_2) {
+ code+="\tUV2=UV2*uv2_scale+uv2_offset;\n";
+ }
+
+ code+="}\n";
+ code+="\n\n";
+ code+="void fragment() {\n";
+
+ if (flags[FLAG_USE_POINT_SIZE]) {
+ code+="\tvec4 albedo_tex = texture(texture_albedo,POINT_COORD);\n";
+ } else {
+ code+="\tvec4 albedo_tex = texture(texture_albedo,UV);\n";
+ }
+
+ if (flags[FLAG_ALBEDO_FROM_VERTEX_COLOR]) {
+ code+="\talbedo_tex *= COLOR;\n";
+ }
+
+ code+="\tALBEDO = albedo.rgb * albedo_tex.rgb;\n";
+ if (features[FEATURE_TRANSPARENT]) {
+ code+="\tALPHA = albedo.a * albedo_tex.a;\n";
+ }
+
+ if (features[FEATURE_EMISSION]) {
+ code+="\tEMISSION = (emission.rgb+texture(texture_emission,UV).rgb)*emission_energy;\n";
+ }
+
+ if (features[FEATURE_NORMAL_MAPPING]) {
+ code+="\tNORMALMAP = texture(texture_normal,UV).rgb;\n";
+ code+="\tNORMALMAP_DEPTH = normal_scale;\n";
+ }
+
+ if (features[FEATURE_RIM]) {
+ code+="\tvec2 rim_tex = texture(texture_rim,UV).xw;\n";
+ code+="\tRIM = rim*rim_tex.x;";
+ code+="\tRIM_TINT = rim_tint*rim_tex.y;\n";
+ }
+
+ if (features[FEATURE_CLEARCOAT]) {
+ code+="\tvec2 clearcoat_tex = texture(texture_clearcoat,UV).xw;\n";
+ code+="\tCLEARCOAT = clearcoat*clearcoat_tex.x;";
+ code+="\tCLEARCOAT_GLOSS = clearcoat_gloss*clearcoat_tex.y;\n";
+ }
+
+ if (features[FEATURE_ANISOTROPY]) {
+ code+="\tvec4 anisotropy_tex = texture(texture_flowmap,UV);\n";
+ code+="\tANISOTROPY = anisotropy_ratio*anisotropy_tex.a;\n";
+ code+="\tANISOTROPY_FLOW = anisotropy_tex.rg*2.0-1.0;\n";
+ }
+
+ if (features[FEATURE_AMBIENT_OCCLUSION]) {
+ code+="\tAO = texture(texture_ambient_occlusion,UV).r;\n";
+ }
+
+ if (features[FEATURE_SUBSURACE_SCATTERING]) {
+
+ code+="\tfloat sss_tex = texture(texture_subsurface_scattering,UV).r;\n";
+ code+="\tSSS_STRENGTH=subsurface_scattering_strength*sss_tex;\n";
+ }
+
+ if (features[FEATURE_DETAIL]) {
+ String det_uv=detail_uv==DETAIL_UV_1?"UV":"UV2";
+ code+="\tvec4 detail_tex = texture(texture_detail_albedo,"+det_uv+");\n";
+ code+="\tvec4 detail_norm_tex = texture(texture_detail_normal,"+det_uv+");\n";
+ code+="\tvec4 detail_mask_tex = texture(texture_detail_mask,UV);\n";
+
+ switch(detail_blend_mode) {
+ case BLEND_MODE_MIX: {
+ code+="\tvec3 detail = mix(ALBEDO.rgb,detail_tex.rgb,detail_tex.a);\n";
+ } break;
+ case BLEND_MODE_ADD: {
+ code+="\tvec3 detail = mix(ALBEDO.rgb,ALBEDO.rgb+detail_tex.rgb,detail_tex.a);\n";
+ } break;
+ case BLEND_MODE_SUB: {
+ code+="\tvec3 detail = mix(ALBEDO.rgb,ALBEDO.rgb-detail_tex.rgb,detail_tex.a);\n";
+ } break;
+ case BLEND_MODE_MUL: {
+ code+="\tvec3 detail = mix(ALBEDO.rgb,ALBEDO.rgb*detail_tex.rgb,detail_tex.a);\n";
+ } break;
+
+ }
+
+ code+="\tvec3 detail_norm = mix(NORMALMAP,detail_norm_tex.rgb,detail_tex.a);\n";
+
+ code+="\tNORMALMAP = mix(NORMALMAP,detail_norm,detail_mask_tex.r);\n";
+ code+="\tALBEDO.rgb = mix(ALBEDO.rgb,detail,detail_mask_tex.r);\n";
+ }
+
+ if (specular_mode==SPECULAR_MODE_SPECULAR) {
+
+ code+="\tvec4 specular_tex = texture(texture_specular,UV);\n";
+ code+="\tSPECULAR = specular.rgb * specular_tex.rgb;\n";
+ code+="\tROUGHNESS = specular_tex.a * roughness;\n";
+ } else {
+ code+="\tvec4 specular_tex = texture(texture_specular,UV);\n";
+ code+="\tSPECULAR = vec3(metalness * specular_tex.r);\n";
+ code+="\tROUGHNESS = specular_tex.a * roughness;\n";
+ }
+
+ code+="}\n";
+
+ ShaderData shader_data;
+ shader_data.shader = VS::get_singleton()->shader_create(VS::SHADER_SPATIAL);
+ shader_data.users=1;
+
+ VS::get_singleton()->shader_set_code( shader_data.shader, code );
+
+ shader_map[mk]=shader_data;
+
+ VS::get_singleton()->material_set_shader(_get_material(),shader_data.shader);
+
}
+void FixedSpatialMaterial::flush_changes() {
-void Material::set_depth_draw_mode(DepthDrawMode p_depth_draw_mode) {
+ if (material_mutex)
+ material_mutex->lock();
- depth_draw_mode=p_depth_draw_mode;
- VisualServer::get_singleton()->material_set_depth_draw_mode(material,(VS::MaterialDepthDrawMode)p_depth_draw_mode);
+ while (dirty_materials.first()) {
+
+ dirty_materials.first()->self()->_update_shader();
+ }
+
+ if (material_mutex)
+ material_mutex->unlock();
}
-Material::DepthDrawMode Material::get_depth_draw_mode() const {
+void FixedSpatialMaterial::_queue_shader_change() {
+
+ if (material_mutex)
+ material_mutex->lock();
+
+ if (!element.in_list()) {
+ dirty_materials.add(&element);
+ }
+
+ if (material_mutex)
+ material_mutex->unlock();
+
- return depth_draw_mode;
}
-bool Material::get_flag(Flag p_flag) const {
+bool FixedSpatialMaterial::_is_shader_dirty() const {
- ERR_FAIL_INDEX_V(p_flag,FLAG_MAX,false);
- return flags[p_flag];
+ bool dirty=false;
+
+ if (material_mutex)
+ material_mutex->lock();
+
+ dirty=element.in_list();
+
+ if (material_mutex)
+ material_mutex->unlock();
+
+ return dirty;
}
+void FixedSpatialMaterial::set_albedo(const Color& p_albedo) {
-void Material::set_line_width(float p_width) {
+ albedo=p_albedo;
- line_width=p_width;
- VisualServer::get_singleton()->material_set_line_width(material,p_width);
- _change_notify("line_width");
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->albedo,p_albedo);
}
-float Material::get_line_width() const {
+Color FixedSpatialMaterial::get_albedo() const{
- return line_width;
+ return albedo;
}
+void FixedSpatialMaterial::set_specular_mode(SpecularMode p_mode) {
+ specular_mode=p_mode;
+ _change_notify();
+ _queue_shader_change();
+}
-void Material::_bind_methods() {
+FixedSpatialMaterial::SpecularMode FixedSpatialMaterial::get_specular_mode() const {
- 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_blend_mode","mode"),&Material::set_blend_mode);
- ObjectTypeDB::bind_method(_MD("get_blend_mode"),&Material::get_blend_mode);
- 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);
+ return specular_mode;
+}
+void FixedSpatialMaterial::set_specular(const Color& p_specular){
- 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]);
+ specular=p_specular;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->specular,p_specular);
- 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"));
+}
+Color FixedSpatialMaterial::get_specular() const{
- 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_LIGHTMAP_ON_UV2 );
- BIND_CONSTANT( FLAG_COLOR_ARRAY_SRGB );
- BIND_CONSTANT( FLAG_MAX );
+ return specular;
+}
- BIND_CONSTANT( DEPTH_DRAW_ALWAYS );
- BIND_CONSTANT( DEPTH_DRAW_OPAQUE_ONLY );
- BIND_CONSTANT( DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA );
- BIND_CONSTANT( DEPTH_DRAW_NEVER );
+void FixedSpatialMaterial::set_roughness(float p_roughness){
- BIND_CONSTANT( BLEND_MODE_MIX );
- BIND_CONSTANT( BLEND_MODE_ADD );
- BIND_CONSTANT( BLEND_MODE_SUB );
- BIND_CONSTANT( BLEND_MODE_MUL );
- BIND_CONSTANT( BLEND_MODE_PREMULT_ALPHA );
+ roughness=p_roughness;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->roughness,p_roughness);
}
-Material::Material(const RID& p_material) {
- material=p_material;
+float FixedSpatialMaterial::get_roughness() const{
- flags[FLAG_VISIBLE]=true;
- flags[FLAG_DOUBLE_SIDED]=false;
- flags[FLAG_INVERT_FACES]=false;
- flags[FLAG_UNSHADED]=false;
- flags[FLAG_ONTOP]=false;
- flags[FLAG_LIGHTMAP_ON_UV2]=true;
- flags[FLAG_COLOR_ARRAY_SRGB]=false;
+ return roughness;
+}
- depth_draw_mode=DEPTH_DRAW_OPAQUE_ONLY;
+void FixedSpatialMaterial::set_metalness(float p_metalness){
+
+ metalness=p_metalness;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->metalness,p_metalness);
+}
- blend_mode=BLEND_MODE_MIX;
+float FixedSpatialMaterial::get_metalness() const{
+
+ return metalness;
}
-Material::~Material() {
+void FixedSpatialMaterial::set_emission(const Color& p_emission){
+
+ emission=p_emission;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->emission,p_emission);
- VisualServer::get_singleton()->free(material);
}
+Color FixedSpatialMaterial::get_emission() const{
-static const char*_param_names[FixedMaterial::PARAM_MAX]={
- "diffuse",
- "detail",
- "specular",
- "emission",
- "specular_exp",
- "glow",
- "normal",
- "shade_param"
-};
-
-static const char*_full_param_names[FixedMaterial::PARAM_MAX]={
- "params/diffuse",
- "params/detail",
- "params/specular",
- "params/emission",
- "params/specular_exp",
- "params/glow",
- "params/normal",
- "params/shade_param"
-};
-
-/*
-static const char*_texture_param_names[FixedMaterial::PARAM_MAX]={
- "tex_diffuse",
- "tex_detail",
- "tex_specular",
- "tex_emission",
- "tex_specular_exp",
- "tex_glow",
- "tex_detail_mix",
- "tex_normal",
- "tex_shade_param"
-};
-*/
-static const FixedMaterial::Parameter _param_indices[FixedMaterial::PARAM_MAX]={
- FixedMaterial::PARAM_DIFFUSE,
- FixedMaterial::PARAM_DETAIL,
- FixedMaterial::PARAM_SPECULAR,
- FixedMaterial::PARAM_EMISSION,
- FixedMaterial::PARAM_SPECULAR_EXP,
- FixedMaterial::PARAM_GLOW,
- FixedMaterial::PARAM_NORMAL,
- FixedMaterial::PARAM_SHADE_PARAM,
-};
-
-
-
-
-void FixedMaterial::set_parameter(Parameter p_parameter, const Variant& p_value) {
-
- ERR_FAIL_INDEX(p_parameter,PARAM_MAX);
- if ((p_parameter==PARAM_DIFFUSE || p_parameter==PARAM_SPECULAR || p_parameter==PARAM_EMISSION)) {
-
- if (p_value.get_type()!=Variant::COLOR) {
- ERR_EXPLAIN(String(_param_names[p_parameter])+" expects Color");
- ERR_FAIL();
- }
- } else {
+ return emission;
+}
- if (!p_value.is_num()) {
- ERR_EXPLAIN(String(_param_names[p_parameter])+" expects scalar");
- ERR_FAIL();
- }
- }
- ERR_FAIL_COND( (p_parameter==PARAM_DIFFUSE || p_parameter==PARAM_SPECULAR || p_parameter==PARAM_EMISSION) && p_value.get_type()!=Variant::COLOR );
- ERR_FAIL_COND( p_parameter!=PARAM_SHADE_PARAM && p_parameter!=PARAM_DIFFUSE && p_parameter!=PARAM_DETAIL && p_parameter!=PARAM_SPECULAR && p_parameter!=PARAM_EMISSION && p_value.get_type()!=Variant::REAL && p_value.get_type()!=Variant::INT );
+void FixedSpatialMaterial::set_emission_energy(float p_emission_energy){
- param[p_parameter]=p_value;
+ emission_energy=p_emission_energy;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->emission_energy,p_emission_energy);
- VisualServer::get_singleton()->fixed_material_set_param(material,(VS::FixedMaterialParam)p_parameter,p_value);
+}
+float FixedSpatialMaterial::get_emission_energy() const{
- _change_notify(_full_param_names[p_parameter]);
+ return emission_energy;
}
-Variant FixedMaterial::get_parameter(Parameter p_parameter) const {
- ERR_FAIL_INDEX_V(p_parameter,PARAM_MAX,Variant());
- return param[p_parameter];
+void FixedSpatialMaterial::set_normal_scale(float p_normal_scale){
+
+ normal_scale=p_normal_scale;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->normal_scale,p_normal_scale);
+
}
+float FixedSpatialMaterial::get_normal_scale() const{
+ return normal_scale;
+}
+void FixedSpatialMaterial::set_rim(float p_rim){
-void FixedMaterial::set_texture(Parameter p_parameter, Ref<Texture> p_texture) {
+ rim=p_rim;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->rim,p_rim);
- ERR_FAIL_INDEX(p_parameter,PARAM_MAX);
- texture_param[p_parameter]=p_texture;
- VisualServer::get_singleton()->fixed_material_set_texture(material,(VS::FixedMaterialParam)p_parameter,p_texture.is_null()?RID():p_texture->get_rid());
+}
+float FixedSpatialMaterial::get_rim() const{
- _change_notify();
+ return rim;
}
-Ref<Texture> FixedMaterial::get_texture(Parameter p_parameter) const {
- ERR_FAIL_INDEX_V(p_parameter,PARAM_MAX,Ref<Texture>());
- return texture_param[p_parameter];
+void FixedSpatialMaterial::set_rim_tint(float p_rim_tint){
+
+ rim_tint=p_rim_tint;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->rim_tint,p_rim_tint);
+
}
+float FixedSpatialMaterial::get_rim_tint() const{
-void FixedMaterial::set_texcoord_mode(Parameter p_parameter, TexCoordMode p_mode) {
+ return rim_tint;
+}
- ERR_FAIL_INDEX(p_parameter,PARAM_MAX);
- ERR_FAIL_INDEX(p_mode,4);
+void FixedSpatialMaterial::set_clearcoat(float p_clearcoat){
- if (p_mode==texture_texcoord[p_parameter])
- return;
+ clearcoat=p_clearcoat;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->clearcoat,p_clearcoat);
- texture_texcoord[p_parameter]=p_mode;
+}
- VisualServer::get_singleton()->fixed_material_set_texcoord_mode(material,(VS::FixedMaterialParam)p_parameter,(VS::FixedMaterialTexCoordMode)p_mode);
+float FixedSpatialMaterial::get_clearcoat() const{
- _change_notify();
+ return clearcoat;
}
-FixedMaterial::TexCoordMode FixedMaterial::get_texcoord_mode(Parameter p_parameter) const {
+void FixedSpatialMaterial::set_clearcoat_gloss(float p_clearcoat_gloss){
+
+ clearcoat_gloss=p_clearcoat_gloss;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->clearcoat_gloss,p_clearcoat_gloss);
+
- ERR_FAIL_INDEX_V(p_parameter,PARAM_MAX,TEXCOORD_UV);
- return texture_texcoord[p_parameter];
}
-void FixedMaterial::set_light_shader(LightShader p_shader) {
+float FixedSpatialMaterial::get_clearcoat_gloss() const{
- light_shader=p_shader;
- VS::get_singleton()->fixed_material_set_light_shader(material,VS::FixedMaterialLightShader(p_shader));
+ return clearcoat_gloss;
}
-FixedMaterial::LightShader FixedMaterial::get_light_shader() const {
+void FixedSpatialMaterial::set_anisotropy(float p_anisotropy){
+
+ anisotropy=p_anisotropy;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->anisotropy,p_anisotropy);
+
+}
+float FixedSpatialMaterial::get_anisotropy() const{
- return light_shader;
+ return anisotropy;
}
+void FixedSpatialMaterial::set_height_scale(float p_height_scale){
+
+ height_scale=p_height_scale;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->height_scale,p_height_scale);
-void FixedMaterial::set_uv_transform(const Transform& p_transform) {
- uv_transform=p_transform;
- VisualServer::get_singleton()->fixed_material_set_uv_transform(material, p_transform );
- _change_notify();
}
-Transform FixedMaterial::get_uv_transform() const {
+float FixedSpatialMaterial::get_height_scale() const{
- return uv_transform;
+ return height_scale;
}
+void FixedSpatialMaterial::set_subsurface_scattering_strength(float p_subsurface_scattering_strength){
+ subsurface_scattering_strength=p_subsurface_scattering_strength;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->subsurface_scattering_strength,subsurface_scattering_strength);
-void FixedMaterial::set_fixed_flag(FixedFlag p_flag, bool p_value) {
- ERR_FAIL_INDEX(p_flag,5);
- fixed_flags[p_flag]=p_value;
- VisualServer::get_singleton()->fixed_material_set_flag(material,(VS::FixedMaterialFlags)p_flag,p_value);
+}
+
+float FixedSpatialMaterial::get_subsurface_scattering_strength() const{
+ return subsurface_scattering_strength;
}
-bool FixedMaterial::get_fixed_flag(FixedFlag p_flag) const {
- ERR_FAIL_INDEX_V(p_flag,5,false);
- return fixed_flags[p_flag];
+void FixedSpatialMaterial::set_refraction(float p_refraction){
+
+ refraction=p_refraction;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->refraction,refraction);
+
}
-void FixedMaterial::set_point_size(float p_size) {
+float FixedSpatialMaterial::get_refraction() const {
- ERR_FAIL_COND(p_size<0);
- point_size=p_size;
- VisualServer::get_singleton()->fixed_material_set_point_size(material,p_size);
+ return refraction;
}
-float FixedMaterial::get_point_size() const{
+void FixedSpatialMaterial::set_refraction_roughness(float p_refraction_roughness) {
+
+ refraction_roughness=p_refraction_roughness;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->refraction_roughness,refraction_roughness);
- return point_size;
}
+float FixedSpatialMaterial::get_refraction_roughness() const {
+ return refraction_roughness;
+}
-void FixedMaterial::_bind_methods() {
+void FixedSpatialMaterial::set_detail_uv(DetailUV p_detail_uv) {
+ if (detail_uv==p_detail_uv)
+ return;
- ObjectTypeDB::bind_method(_MD("set_parameter","param","value"),&FixedMaterial::set_parameter);
- ObjectTypeDB::bind_method(_MD("get_parameter","param"),&FixedMaterial::get_parameter);
+ detail_uv=p_detail_uv;
+ _queue_shader_change();
+}
+FixedSpatialMaterial::DetailUV FixedSpatialMaterial::get_detail_uv() const {
- ObjectTypeDB::bind_method(_MD("set_texture","param","texture:Texture"),&FixedMaterial::set_texture);
- ObjectTypeDB::bind_method(_MD("get_texture:Texture","param"),&FixedMaterial::get_texture);
+ return detail_uv;
+}
+void FixedSpatialMaterial::set_blend_mode(BlendMode p_mode) {
- ObjectTypeDB::bind_method(_MD("set_texcoord_mode","param","mode"),&FixedMaterial::set_texcoord_mode);
- ObjectTypeDB::bind_method(_MD("get_texcoord_mode","param"),&FixedMaterial::get_texcoord_mode);
+ if (blend_mode==p_mode)
+ return;
- ObjectTypeDB::bind_method(_MD("set_fixed_flag","flag","value"),&FixedMaterial::set_fixed_flag);
- ObjectTypeDB::bind_method(_MD("get_fixed_flag","flag"),&FixedMaterial::get_fixed_flag);
+ blend_mode=p_mode;
+ _queue_shader_change();
+}
+FixedSpatialMaterial::BlendMode FixedSpatialMaterial::get_blend_mode() const {
- ObjectTypeDB::bind_method(_MD("set_uv_transform","transform"),&FixedMaterial::set_uv_transform);
- ObjectTypeDB::bind_method(_MD("get_uv_transform"),&FixedMaterial::get_uv_transform);
+ return blend_mode;
+}
- ObjectTypeDB::bind_method(_MD("set_light_shader","shader"),&FixedMaterial::set_light_shader);
- ObjectTypeDB::bind_method(_MD("get_light_shader"),&FixedMaterial::get_light_shader);
+void FixedSpatialMaterial::set_detail_blend_mode(BlendMode p_mode) {
- ObjectTypeDB::bind_method(_MD("set_point_size","size"),&FixedMaterial::set_point_size);
- ObjectTypeDB::bind_method(_MD("get_point_size"),&FixedMaterial::get_point_size);
+ detail_blend_mode=p_mode;
+ _queue_shader_change();
+}
+FixedSpatialMaterial::BlendMode FixedSpatialMaterial::get_detail_blend_mode() const {
+ return 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);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/use_point_size" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_POINT_SIZE);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/discard_alpha" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_DISCARD_ALPHA);
- ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/use_xy_normalmap" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_XY_NORMALMAP);
- ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "params/diffuse" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_DIFFUSE);
- 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_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_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") );
+void FixedSpatialMaterial::set_depth_draw_mode(DepthDrawMode p_mode) {
- for(int i=0;i<PARAM_MAX;i++) {
- ADD_PROPERTYI( PropertyInfo( Variant::OBJECT, String()+"textures/"+_param_names[i],PROPERTY_HINT_RESOURCE_TYPE,"Texture" ), _SCS("set_texture"), _SCS("get_texture"), _param_indices[i]);
- ADD_PROPERTYI( PropertyInfo( Variant::INT, String()+"textures/"+_param_names[i]+"_tc",PROPERTY_HINT_ENUM,"UV,UV Xform,UV2,Sphere" ), _SCS("set_texcoord_mode"), _SCS("get_texcoord_mode"), _param_indices[i] );
- }
+ if (depth_draw_mode==p_mode)
+ return;
+ depth_draw_mode=p_mode;
+ _queue_shader_change();
+}
+FixedSpatialMaterial::DepthDrawMode FixedSpatialMaterial::get_depth_draw_mode() const {
- BIND_CONSTANT( PARAM_DIFFUSE );
- BIND_CONSTANT( PARAM_DETAIL );
- BIND_CONSTANT( PARAM_SPECULAR );
- BIND_CONSTANT( PARAM_EMISSION );
- BIND_CONSTANT( PARAM_SPECULAR_EXP );
- BIND_CONSTANT( PARAM_GLOW );
- BIND_CONSTANT( PARAM_NORMAL );
- BIND_CONSTANT( PARAM_SHADE_PARAM );
- BIND_CONSTANT( PARAM_MAX );
+ return depth_draw_mode;
+}
- BIND_CONSTANT( TEXCOORD_UV );
- BIND_CONSTANT( TEXCOORD_UV_TRANSFORM );
- BIND_CONSTANT( TEXCOORD_UV2 );
- BIND_CONSTANT( TEXCOORD_SPHERE );
+void FixedSpatialMaterial::set_cull_mode(CullMode p_mode) {
- BIND_CONSTANT( FLAG_USE_ALPHA );
- BIND_CONSTANT( FLAG_USE_COLOR_ARRAY );
- BIND_CONSTANT( FLAG_USE_POINT_SIZE );
- BIND_CONSTANT( FLAG_DISCARD_ALPHA );
+ if (cull_mode==p_mode)
+ return;
- BIND_CONSTANT( LIGHT_SHADER_LAMBERT );
- BIND_CONSTANT( LIGHT_SHADER_WRAP );
- BIND_CONSTANT( LIGHT_SHADER_VELVET );
- BIND_CONSTANT( LIGHT_SHADER_TOON );
+ cull_mode=p_mode;
+ _queue_shader_change();
+}
+FixedSpatialMaterial::CullMode FixedSpatialMaterial::get_cull_mode() const {
+ return cull_mode;
}
+void FixedSpatialMaterial::set_diffuse_mode(DiffuseMode p_mode) {
-FixedMaterial::FixedMaterial() : Material(VS::get_singleton()->fixed_material_create()) {
+ if (diffuse_mode==p_mode)
+ return;
+ diffuse_mode=p_mode;
+ _queue_shader_change();
+}
+FixedSpatialMaterial::DiffuseMode FixedSpatialMaterial::get_diffuse_mode() const {
+ return diffuse_mode;
+}
- param[PARAM_DIFFUSE]=Color(1,1,1);
- param[PARAM_SPECULAR]=Color(0.0,0.0,0.0);
- param[PARAM_EMISSION]=Color(0.0,0.0,0.0);
- param[PARAM_SPECULAR_EXP]=40;
- param[PARAM_GLOW]=0;
- param[PARAM_NORMAL]=1;
- param[PARAM_SHADE_PARAM]=0.5;
- param[PARAM_DETAIL]=1.0;
+void FixedSpatialMaterial::set_flag(Flags p_flag,bool p_enabled) {
- set_flag(FLAG_COLOR_ARRAY_SRGB,true);
+ ERR_FAIL_INDEX(p_flag,FLAG_MAX);
- fixed_flags[FLAG_USE_ALPHA]=false;
- fixed_flags[FLAG_USE_COLOR_ARRAY]=false;
- fixed_flags[FLAG_USE_POINT_SIZE]=false;
- fixed_flags[FLAG_USE_XY_NORMALMAP]=false;
- fixed_flags[FLAG_DISCARD_ALPHA]=false;
+ if (flags[p_flag]==p_enabled)
+ return;
+ flags[p_flag]=p_enabled;
+ _queue_shader_change();
+}
- for(int i=0;i<PARAM_MAX;i++) {
+bool FixedSpatialMaterial::get_flag(Flags p_flag) const {
- texture_texcoord[i]=TEXCOORD_UV;
- }
+ ERR_FAIL_INDEX_V(p_flag,FLAG_MAX,false);
+ return flags[p_flag];
+}
- light_shader=LIGHT_SHADER_LAMBERT;
+void FixedSpatialMaterial::set_feature(Feature p_feature,bool p_enabled) {
- point_size=1.0;
-}
+ ERR_FAIL_INDEX(p_feature,FEATURE_MAX);
+ if (features[p_feature]==p_enabled)
+ return;
+ features[p_feature]=p_enabled;
+ _change_notify();
+ _queue_shader_change();
-FixedMaterial::~FixedMaterial() {
}
+bool FixedSpatialMaterial::get_feature(Feature p_feature) const {
+ ERR_FAIL_INDEX_V(p_feature,FEATURE_MAX,false);
+ return features[p_feature];
+}
-bool ShaderMaterial::_set(const StringName& p_name, const Variant& p_value) {
- if (p_name==SceneStringNames::get_singleton()->shader_shader) {
- set_shader(p_value);
- return true;
- } else {
+void FixedSpatialMaterial::set_texture(TextureParam p_param, const Ref<Texture> &p_texture) {
- if (shader.is_valid()) {
+ ERR_FAIL_INDEX(p_param,TEXTURE_MAX);
+ textures[p_param]=p_texture;
+ RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->texture_names[p_param],rid);
+}
+Ref<Texture> FixedSpatialMaterial::get_texture(TextureParam p_param) const {
- StringName pr = shader->remap_param(p_name);
- if (!pr) {
- String n = p_name;
- if (n.find("param/")==0) { //backwards compatibility
- pr = n.substr(6,n.length());
- }
- }
- if (pr) {
- VisualServer::get_singleton()->material_set_param(material,pr,p_value);
- return true;
- }
- }
+ ERR_FAIL_INDEX_V(p_param,TEXTURE_MAX,Ref<Texture>());
+ return textures[p_param];
+}
+
+
+void FixedSpatialMaterial::_validate_feature(const String& text, Feature feature,PropertyInfo& property) const {
+ if (property.name.begins_with(text) && property.name!=text+"/enabled" && !features[feature]) {
+ property.usage=0;
}
- return false;
}
-bool ShaderMaterial::_get(const StringName& p_name,Variant &r_ret) const {
-
+void FixedSpatialMaterial::_validate_property(PropertyInfo& property) const {
+ _validate_feature("normal",FEATURE_NORMAL_MAPPING,property);
+ _validate_feature("emission",FEATURE_EMISSION,property);
+ _validate_feature("rim",FEATURE_RIM,property);
+ _validate_feature("clearcoat",FEATURE_CLEARCOAT,property);
+ _validate_feature("anisotropy",FEATURE_ANISOTROPY,property);
+ _validate_feature("ao",FEATURE_AMBIENT_OCCLUSION,property);
+ _validate_feature("height",FEATURE_HEIGHT_MAPPING,property);
+ _validate_feature("subsurf_scatter",FEATURE_SUBSURACE_SCATTERING,property);
+ _validate_feature("refraction",FEATURE_REFRACTION,property);
+ _validate_feature("detail",FEATURE_DETAIL,property);
+
+ if (property.name=="specular/color" && specular_mode==SPECULAR_MODE_METALLIC) {
+ property.usage=0;
+ }
+ if (property.name=="specular/metalness" && specular_mode==SPECULAR_MODE_SPECULAR) {
+ property.usage=0;
+ }
- if (p_name==SceneStringNames::get_singleton()->shader_shader) {
+}
- r_ret=get_shader();
- return true;
- } else {
+void FixedSpatialMaterial::set_line_width(float p_line_width) {
- if (shader.is_valid()) {
+ line_width=p_line_width;
+ VS::get_singleton()->material_set_line_width(_get_material(),line_width);
+}
- StringName pr = shader->remap_param(p_name);
- if (pr) {
- r_ret=VisualServer::get_singleton()->material_get_param(material,pr);
- return true;
- }
- }
+float FixedSpatialMaterial::get_line_width() const {
- }
+ return line_width;
+}
+void FixedSpatialMaterial::set_point_size(float p_point_size) {
- return false;
+ point_size=p_point_size;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->point_size,p_point_size);
}
+float FixedSpatialMaterial::get_point_size() const {
-void ShaderMaterial::_get_property_list( List<PropertyInfo> *p_list) const {
+ return point_size;
+}
- p_list->push_back( PropertyInfo( Variant::OBJECT, "shader/shader", PROPERTY_HINT_RESOURCE_TYPE,"MaterialShader,MaterialShaderGraph" ) );
- if (!shader.is_null()) {
+void FixedSpatialMaterial::set_uv1_scale(const Vector2& p_scale) {
- shader->get_param_list(p_list);
- }
+ uv1_scale=p_scale;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->uv1_scale,p_scale);
+}
+Vector2 FixedSpatialMaterial::get_uv1_scale() const{
+
+ return uv1_scale;
}
+void FixedSpatialMaterial::set_uv1_offset(const Vector2& p_offset){
-void ShaderMaterial::_shader_changed() {
+ uv1_offset=p_offset;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->uv1_offset,p_offset);
- _change_notify(); //also all may have changed then
}
+Vector2 FixedSpatialMaterial::get_uv1_offset() const{
-void ShaderMaterial::set_shader(const Ref<Shader>& p_shader) {
+ return uv1_offset;
+}
- ERR_FAIL_COND(p_shader.is_valid() && p_shader->get_mode()!=Shader::MODE_MATERIAL);
- if (shader.is_valid())
- shader->disconnect(SceneStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->_shader_changed);
- shader=p_shader;
- VS::get_singleton()->material_set_shader(material,shader.is_valid()?shader->get_rid():RID());
- if (shader.is_valid()) {
- shader->connect(SceneStringNames::get_singleton()->changed,this,SceneStringNames::get_singleton()->_shader_changed);
- }
- _change_notify();
+void FixedSpatialMaterial::set_uv2_scale(const Vector2& p_scale) {
+ uv2_scale=p_scale;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->uv2_scale,p_scale);
}
-Ref<Shader> ShaderMaterial::get_shader() const {
+Vector2 FixedSpatialMaterial::get_uv2_scale() const{
- return shader;
+ return uv2_scale;
}
+void FixedSpatialMaterial::set_uv2_offset(const Vector2& p_offset){
-void ShaderMaterial::set_shader_param(const StringName& p_param,const Variant& p_value) {
-
- VisualServer::get_singleton()->material_set_param(material,p_param,p_value);
+ uv2_offset=p_offset;
+ VS::get_singleton()->material_set_param(_get_material(),shader_names->uv2_offset,p_offset);
}
-Variant ShaderMaterial::get_shader_param(const StringName& p_param) const{
+Vector2 FixedSpatialMaterial::get_uv2_offset() const{
- return VisualServer::get_singleton()->material_get_param(material,p_param);
+ return uv2_offset;
}
+void FixedSpatialMaterial::_bind_methods() {
-void ShaderMaterial::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("set_albedo","albedo"),&FixedSpatialMaterial::set_albedo);
+ ObjectTypeDB::bind_method(_MD("get_albedo"),&FixedSpatialMaterial::get_albedo);
- ObjectTypeDB::bind_method(_MD("set_shader","shader:Shader"), &ShaderMaterial::set_shader );
- ObjectTypeDB::bind_method(_MD("get_shader:Shader"), &ShaderMaterial::get_shader );
+ ObjectTypeDB::bind_method(_MD("set_specular_mode","specular_mode"),&FixedSpatialMaterial::set_specular_mode);
+ ObjectTypeDB::bind_method(_MD("get_specular_mode"),&FixedSpatialMaterial::get_specular_mode);
- ObjectTypeDB::bind_method(_MD("set_shader_param","param","value:Variant"), &ShaderMaterial::set_shader_param);
- ObjectTypeDB::bind_method(_MD("get_shader_param:Variant","param"), &ShaderMaterial::get_shader_param);
+ ObjectTypeDB::bind_method(_MD("set_specular","specular"),&FixedSpatialMaterial::set_specular);
+ ObjectTypeDB::bind_method(_MD("get_specular"),&FixedSpatialMaterial::get_specular);
- ObjectTypeDB::bind_method(_MD("_shader_changed"), &ShaderMaterial::_shader_changed );
-}
+ ObjectTypeDB::bind_method(_MD("set_metalness","metalness"),&FixedSpatialMaterial::set_metalness);
+ ObjectTypeDB::bind_method(_MD("get_metalness"),&FixedSpatialMaterial::get_metalness);
+ ObjectTypeDB::bind_method(_MD("set_roughness","roughness"),&FixedSpatialMaterial::set_roughness);
+ ObjectTypeDB::bind_method(_MD("get_roughness"),&FixedSpatialMaterial::get_roughness);
-void ShaderMaterial::get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const {
+ ObjectTypeDB::bind_method(_MD("set_emission","emission"),&FixedSpatialMaterial::set_emission);
+ ObjectTypeDB::bind_method(_MD("get_emission"),&FixedSpatialMaterial::get_emission);
- String f = p_function.operator String();
- if ((f=="get_shader_param" || f=="set_shader_param") && p_idx==0) {
+ ObjectTypeDB::bind_method(_MD("set_emission_energy","emission_energy"),&FixedSpatialMaterial::set_emission_energy);
+ ObjectTypeDB::bind_method(_MD("get_emission_energy"),&FixedSpatialMaterial::get_emission_energy);
+
+ ObjectTypeDB::bind_method(_MD("set_normal_scale","normal_scale"),&FixedSpatialMaterial::set_normal_scale);
+ ObjectTypeDB::bind_method(_MD("get_normal_scale"),&FixedSpatialMaterial::get_normal_scale);
+
+ ObjectTypeDB::bind_method(_MD("set_rim","rim"),&FixedSpatialMaterial::set_rim);
+ ObjectTypeDB::bind_method(_MD("get_rim"),&FixedSpatialMaterial::get_rim);
+
+ ObjectTypeDB::bind_method(_MD("set_rim_tint","rim_tint"),&FixedSpatialMaterial::set_rim_tint);
+ ObjectTypeDB::bind_method(_MD("get_rim_tint"),&FixedSpatialMaterial::get_rim_tint);
+
+ ObjectTypeDB::bind_method(_MD("set_clearcoat","clearcoat"),&FixedSpatialMaterial::set_clearcoat);
+ ObjectTypeDB::bind_method(_MD("get_clearcoat"),&FixedSpatialMaterial::get_clearcoat);
+
+ ObjectTypeDB::bind_method(_MD("set_clearcoat_gloss","clearcoat_gloss"),&FixedSpatialMaterial::set_clearcoat_gloss);
+ ObjectTypeDB::bind_method(_MD("get_clearcoat_gloss"),&FixedSpatialMaterial::get_clearcoat_gloss);
+
+ ObjectTypeDB::bind_method(_MD("set_anisotropy","anisotropy"),&FixedSpatialMaterial::set_anisotropy);
+ ObjectTypeDB::bind_method(_MD("get_anisotropy"),&FixedSpatialMaterial::get_anisotropy);
+
+ ObjectTypeDB::bind_method(_MD("set_height_scale","height_scale"),&FixedSpatialMaterial::set_height_scale);
+ ObjectTypeDB::bind_method(_MD("get_height_scale"),&FixedSpatialMaterial::get_height_scale);
+
+ ObjectTypeDB::bind_method(_MD("set_subsurface_scattering_strength","strength"),&FixedSpatialMaterial::set_subsurface_scattering_strength);
+ ObjectTypeDB::bind_method(_MD("get_subsurface_scattering_strength"),&FixedSpatialMaterial::get_subsurface_scattering_strength);
+
+ ObjectTypeDB::bind_method(_MD("set_refraction","refraction"),&FixedSpatialMaterial::set_refraction);
+ ObjectTypeDB::bind_method(_MD("get_refraction"),&FixedSpatialMaterial::get_refraction);
+
+ ObjectTypeDB::bind_method(_MD("set_refraction_roughness","refraction_roughness"),&FixedSpatialMaterial::set_refraction_roughness);
+ ObjectTypeDB::bind_method(_MD("get_refraction_roughness"),&FixedSpatialMaterial::get_refraction_roughness);
+
+ ObjectTypeDB::bind_method(_MD("set_line_width","line_width"),&FixedSpatialMaterial::set_line_width);
+ ObjectTypeDB::bind_method(_MD("get_line_width"),&FixedSpatialMaterial::get_line_width);
+
+ ObjectTypeDB::bind_method(_MD("set_point_size","point_size"),&FixedSpatialMaterial::set_point_size);
+ ObjectTypeDB::bind_method(_MD("get_point_size"),&FixedSpatialMaterial::get_point_size);
+
+ ObjectTypeDB::bind_method(_MD("set_detail_uv","detail_uv"),&FixedSpatialMaterial::set_detail_uv);
+ ObjectTypeDB::bind_method(_MD("get_detail_uv"),&FixedSpatialMaterial::get_detail_uv);
+
+ ObjectTypeDB::bind_method(_MD("set_blend_mode","blend_mode"),&FixedSpatialMaterial::set_blend_mode);
+ ObjectTypeDB::bind_method(_MD("get_blend_mode"),&FixedSpatialMaterial::get_blend_mode);
+
+ ObjectTypeDB::bind_method(_MD("set_depth_draw_mode","depth_draw_mode"),&FixedSpatialMaterial::set_depth_draw_mode);
+ ObjectTypeDB::bind_method(_MD("get_depth_draw_mode"),&FixedSpatialMaterial::get_depth_draw_mode);
+
+ ObjectTypeDB::bind_method(_MD("set_cull_mode","cull_mode"),&FixedSpatialMaterial::set_cull_mode);
+ ObjectTypeDB::bind_method(_MD("get_cull_mode"),&FixedSpatialMaterial::get_cull_mode);
+
+ ObjectTypeDB::bind_method(_MD("set_diffuse_mode","diffuse_mode"),&FixedSpatialMaterial::set_diffuse_mode);
+ ObjectTypeDB::bind_method(_MD("get_diffuse_mode"),&FixedSpatialMaterial::get_diffuse_mode);
+
+ ObjectTypeDB::bind_method(_MD("set_flag","flag","enable"),&FixedSpatialMaterial::set_flag);
+ ObjectTypeDB::bind_method(_MD("get_flag"),&FixedSpatialMaterial::get_flag);
+
+ ObjectTypeDB::bind_method(_MD("set_feature","feature","enable"),&FixedSpatialMaterial::set_feature);
+ ObjectTypeDB::bind_method(_MD("get_feature","feature"),&FixedSpatialMaterial::get_feature);
+
+ ObjectTypeDB::bind_method(_MD("set_texture","param:Texture","texture"),&FixedSpatialMaterial::set_texture);
+ ObjectTypeDB::bind_method(_MD("get_texture:Texture","param:Texture"),&FixedSpatialMaterial::get_texture);
+
+ ObjectTypeDB::bind_method(_MD("set_detail_blend_mode","detail_blend_mode"),&FixedSpatialMaterial::set_detail_blend_mode);
+ ObjectTypeDB::bind_method(_MD("get_detail_blend_mode"),&FixedSpatialMaterial::get_detail_blend_mode);
+
+ ObjectTypeDB::bind_method(_MD("set_uv1_scale","scale"),&FixedSpatialMaterial::set_uv1_scale);
+ ObjectTypeDB::bind_method(_MD("get_uv1_scale"),&FixedSpatialMaterial::get_uv1_scale);
+
+ ObjectTypeDB::bind_method(_MD("set_uv1_offset","offset"),&FixedSpatialMaterial::set_uv1_offset);
+ ObjectTypeDB::bind_method(_MD("get_uv1_offset"),&FixedSpatialMaterial::get_uv1_offset);
+
+ ObjectTypeDB::bind_method(_MD("set_uv2_scale","scale"),&FixedSpatialMaterial::set_uv2_scale);
+ ObjectTypeDB::bind_method(_MD("get_uv2_scale"),&FixedSpatialMaterial::get_uv2_scale);
+
+ ObjectTypeDB::bind_method(_MD("set_uv2_offset","offset"),&FixedSpatialMaterial::set_uv2_offset);
+ ObjectTypeDB::bind_method(_MD("get_uv2_offset"),&FixedSpatialMaterial::get_uv2_offset);
+
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"flags/transparent"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_TRANSPARENT);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"flags/unshaded"),_SCS("set_flag"),_SCS("get_flag"),FLAG_UNSHADED);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"flags/on_top"),_SCS("set_flag"),_SCS("get_flag"),FLAG_ONTOP);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"flags/use_point_size"),_SCS("set_flag"),_SCS("get_flag"),FLAG_USE_POINT_SIZE);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"vertex_color/use_as_albedo"),_SCS("set_flag"),_SCS("get_flag"),FLAG_ALBEDO_FROM_VERTEX_COLOR);
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"vertex_color/is_srgb"),_SCS("set_flag"),_SCS("get_flag"),FLAG_SRGB_VERTEX_COLOR);
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"params/diffuse_mode",PROPERTY_HINT_ENUM,"Labert,Lambert Wrap,Oren Nayar,Burley"),_SCS("set_diffuse_mode"),_SCS("get_diffuse_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"params/blend_mode",PROPERTY_HINT_ENUM,"Mix,Add,Sub,Mul"),_SCS("set_blend_mode"),_SCS("get_blend_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"params/cull_mode",PROPERTY_HINT_ENUM,"Back,Front,Disabled"),_SCS("set_cull_mode"),_SCS("get_cull_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"params/depth_draw_mode",PROPERTY_HINT_ENUM,"Opaque Only,Always,Never,Opaque Pre-Pass"),_SCS("set_depth_draw_mode"),_SCS("get_depth_draw_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"params/line_width",PROPERTY_HINT_RANGE,"0.1,128,0.1"),_SCS("set_line_width"),_SCS("get_line_width"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"params/point_size",PROPERTY_HINT_RANGE,"0.1,128,0.1"),_SCS("set_point_size"),_SCS("get_point_size"));
+
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"albedo/color"),_SCS("set_albedo"),_SCS("get_albedo"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"albedo/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_ALBEDO);
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"specular/mode",PROPERTY_HINT_ENUM,"Metallic,Specular"),_SCS("set_specular_mode"),_SCS("get_specular_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"specular/color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("set_specular"),_SCS("get_specular"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"specular/metalness",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_metalness"),_SCS("get_metalness"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"specular/roughness",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_roughness"),_SCS("get_roughness"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"specular/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_SPECULAR);
+
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"emission/enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_EMISSION);
+ ADD_PROPERTY(PropertyInfo(Variant::COLOR,"emission/color",PROPERTY_HINT_COLOR_NO_ALPHA),_SCS("set_emission"),_SCS("get_emission"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"emission/energy",PROPERTY_HINT_RANGE,"0,16,0.01"),_SCS("set_emission_energy"),_SCS("get_emission_energy"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"emission/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_EMISSION);
+
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"normal/enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_NORMAL_MAPPING);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"normal/scale",PROPERTY_HINT_RANGE,"-16,16,0.01"),_SCS("set_normal_scale"),_SCS("get_normal_scale"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"normal/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_NORMAL);
+
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"rim/enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_RIM);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"rim/amount",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_rim"),_SCS("get_rim"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"rim/tint",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_rim_tint"),_SCS("get_rim_tint"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"rim/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_RIM);
+
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"clearcoat/enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_CLEARCOAT);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"clearcoat/amount",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_clearcoat"),_SCS("get_clearcoat"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"clearcoat/gloss",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_clearcoat_gloss"),_SCS("get_clearcoat_gloss"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"clearcoat/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_CLEARCOAT);
+
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"anisotropy/enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_ANISOTROPY);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"anisotropy/anisotropy",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_anisotropy"),_SCS("get_anisotropy"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"anisotropy/flowmap",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_FLOWMAP);
+
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"ao/enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_AMBIENT_OCCLUSION);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"ao/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_AMBIENT_OCCLUSION);
+
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"height/enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_HEIGHT_MAPPING);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"height/scale",PROPERTY_HINT_RANGE,"-16,16,0.01"),_SCS("set_height_scale"),_SCS("get_height_scale"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"height/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_HEIGHT);
+
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"subsurf_scatter/enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_SUBSURACE_SCATTERING);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"subsurf_scatter/strength",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_subsurface_scattering_strength"),_SCS("get_subsurface_scattering_strength"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"subsurf_scatter/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_SUBSURFACE_SCATTERING);
+
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"refraction/enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_REFRACTION);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"refraction/displacement",PROPERTY_HINT_RANGE,"-1,1,0.01"),_SCS("set_refraction"),_SCS("get_refraction"));
+ ADD_PROPERTY(PropertyInfo(Variant::REAL,"refraction/roughness",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_refraction_roughness"),_SCS("get_refraction_roughness"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"refraction/texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_REFRACTION);
+
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL,"detail/enabled"),_SCS("set_feature"),_SCS("get_feature"),FEATURE_DETAIL);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"detail/mask",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_DETAIL_MASK);
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"detail/blend_mode",PROPERTY_HINT_ENUM,"Mix,Add,Sub,Mul"),_SCS("set_detail_blend_mode"),_SCS("get_detail_blend_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"detail/uv_layer",PROPERTY_HINT_ENUM,"UV1,UV2"),_SCS("set_detail_uv"),_SCS("get_detail_uv"));
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"detail/albedo",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_DETAIL_ALBEDO);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT,"detail/normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"),TEXTURE_DETAIL_NORMAL);
+
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"uv1/scale"),_SCS("set_uv1_scale"),_SCS("get_uv1_scale"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"uv1/offset"),_SCS("set_uv1_offset"),_SCS("get_uv1_offset"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"uv2/scale"),_SCS("set_uv2_scale"),_SCS("get_uv2_scale"));
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"uv2/offset"),_SCS("set_uv2_offset"),_SCS("get_uv2_offset"));
+
+
+ BIND_CONSTANT( TEXTURE_ALBEDO );
+ BIND_CONSTANT( TEXTURE_SPECULAR );
+ BIND_CONSTANT( TEXTURE_EMISSION );
+ BIND_CONSTANT( TEXTURE_NORMAL );
+ BIND_CONSTANT( TEXTURE_RIM );
+ BIND_CONSTANT( TEXTURE_CLEARCOAT );
+ BIND_CONSTANT( TEXTURE_FLOWMAP );
+ BIND_CONSTANT( TEXTURE_AMBIENT_OCCLUSION );
+ BIND_CONSTANT( TEXTURE_HEIGHT );
+ BIND_CONSTANT( TEXTURE_SUBSURFACE_SCATTERING );
+ BIND_CONSTANT( TEXTURE_REFRACTION );
+ BIND_CONSTANT( TEXTURE_REFRACTION_ROUGHNESS );
+ BIND_CONSTANT( TEXTURE_DETAIL_MASK );
+ BIND_CONSTANT( TEXTURE_DETAIL_ALBEDO );
+ BIND_CONSTANT( TEXTURE_DETAIL_NORMAL );
+ BIND_CONSTANT( TEXTURE_MAX );
+
+
+ BIND_CONSTANT( DETAIL_UV_1 );
+ BIND_CONSTANT( DETAIL_UV_2 );
+
+ BIND_CONSTANT( FEATURE_TRANSPARENT );
+ BIND_CONSTANT( FEATURE_EMISSION );
+ BIND_CONSTANT( FEATURE_NORMAL_MAPPING );
+ BIND_CONSTANT( FEATURE_RIM );
+ BIND_CONSTANT( FEATURE_CLEARCOAT );
+ BIND_CONSTANT( FEATURE_ANISOTROPY );
+ BIND_CONSTANT( FEATURE_AMBIENT_OCCLUSION );
+ BIND_CONSTANT( FEATURE_HEIGHT_MAPPING );
+ BIND_CONSTANT( FEATURE_SUBSURACE_SCATTERING );
+ BIND_CONSTANT( FEATURE_REFRACTION );
+ BIND_CONSTANT( FEATURE_DETAIL );
+ BIND_CONSTANT( FEATURE_MAX );
+
+ BIND_CONSTANT( BLEND_MODE_MIX );
+ BIND_CONSTANT( BLEND_MODE_ADD );
+ BIND_CONSTANT( BLEND_MODE_SUB );
+ BIND_CONSTANT( BLEND_MODE_MUL );
+
+ BIND_CONSTANT( DEPTH_DRAW_OPAQUE_ONLY );
+ BIND_CONSTANT( DEPTH_DRAW_ALWAYS );
+ BIND_CONSTANT( DEPTH_DRAW_DISABLED );
+ BIND_CONSTANT( DEPTH_DRAW_ALPHA_OPAQUE_PREPASS );
+
+
+ BIND_CONSTANT( CULL_BACK );
+ BIND_CONSTANT( CULL_FRONT );
+ BIND_CONSTANT( CULL_DISABLED );
+
+ BIND_CONSTANT( FLAG_UNSHADED );
+ BIND_CONSTANT( FLAG_ONTOP );
+ BIND_CONSTANT( FLAG_ALBEDO_FROM_VERTEX_COLOR );
+ BIND_CONSTANT( FLAG_SRGB_VERTEX_COLOR )
+ BIND_CONSTANT( FLAG_USE_POINT_SIZE )
+ BIND_CONSTANT( FLAG_MAX );
+
+ BIND_CONSTANT( DIFFUSE_LAMBERT );
+ BIND_CONSTANT( DIFFUSE_LAMBERT_WRAP );
+ BIND_CONSTANT( DIFFUSE_OREN_NAYAR );
+ BIND_CONSTANT( DIFFUSE_BURLEY );
+
+ BIND_CONSTANT( SPECULAR_MODE_METALLIC );
+ BIND_CONSTANT( SPECULAR_MODE_SPECULAR );
- if (shader.is_valid()) {
- List<PropertyInfo> pl;
- shader->get_param_list(&pl);
- for (List<PropertyInfo>::Element *E=pl.front();E;E=E->next()) {
- r_options->push_back("\""+E->get().name.replace_first("shader_param/","")+"\"");
- }
- }
- }
- Material::get_argument_options(p_function,p_idx,r_options);
}
-ShaderMaterial::ShaderMaterial() :Material(VisualServer::get_singleton()->material_create()){
+FixedSpatialMaterial::FixedSpatialMaterial() : element(this) {
+
+ //initialize to right values
+ specular_mode=SPECULAR_MODE_METALLIC;
+ set_albedo(Color(0.7,0.7,0.7,1.0));
+ set_specular(Color(0.1,0.1,0.1));
+ set_roughness(0.0);
+ set_metalness(0.1);
+ set_emission(Color(0,0,0));
+ set_emission_energy(1.0);
+ set_normal_scale(1);
+ set_rim(1.0);
+ set_rim_tint(0.5);
+ set_clearcoat(1);
+ set_clearcoat_gloss(0.5);
+ set_anisotropy(0);
+ set_height_scale(1);
+ set_subsurface_scattering_strength(0);
+ set_refraction(0);
+ set_refraction_roughness(0);
+ set_line_width(1);
+ set_point_size(1);
+ set_uv1_offset(Vector2(0,0));
+ set_uv1_scale(Vector2(1,1));
+ set_uv2_offset(Vector2(0,0));
+ set_uv2_scale(Vector2(1,1));
+
+ detail_uv=DETAIL_UV_1;
+ blend_mode=BLEND_MODE_MIX;
+ detail_blend_mode=BLEND_MODE_MIX;
+ depth_draw_mode=DEPTH_DRAW_OPAQUE_ONLY;
+ cull_mode=CULL_BACK;
+ for(int i=0;i<FLAG_MAX;i++) {
+ flags[i]=0;
+ }
+ diffuse_mode=DIFFUSE_LAMBERT;
+
+ for(int i=0;i<FEATURE_MAX;i++) {
+ features[i]=false;
+ }
+ current_key.key=0;
+ current_key.invalid_key=1;
+ _queue_shader_change();
}
+FixedSpatialMaterial::~FixedSpatialMaterial() {
-/////////////////////////////////
+ if (material_mutex)
+ material_mutex->lock();
+
+ if (shader_map.has(current_key)) {
+ shader_map[current_key].users--;
+ if (shader_map[current_key].users==0) {
+ //deallocate shader, as it's no longer in use
+ VS::get_singleton()->free(shader_map[current_key].shader);
+ shader_map.erase(current_key);
+ }
+
+ VS::get_singleton()->material_set_shader(_get_material(),RID());
+ }
+
+
+ if (material_mutex)
+ material_mutex->unlock();
+
+}
diff --git a/scene/resources/material.h b/scene/resources/material.h
index fc1ea3d89a..c2659c4fc4 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -34,7 +34,7 @@
#include "scene/resources/shader.h"
#include "resource.h"
#include "servers/visual/shader_language.h"
-
+#include "self_list.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -45,209 +45,367 @@ class Material : public Resource {
RES_BASE_EXTENSION("mtl");
OBJ_SAVE_TYPE( Material );
-public:
+ RID material;
+protected:
- enum Flag {
- FLAG_VISIBLE = VS::MATERIAL_FLAG_VISIBLE,
- FLAG_DOUBLE_SIDED = VS::MATERIAL_FLAG_DOUBLE_SIDED,
- FLAG_INVERT_FACES = VS::MATERIAL_FLAG_INVERT_FACES,
- FLAG_UNSHADED = VS::MATERIAL_FLAG_UNSHADED,
- FLAG_ONTOP = VS::MATERIAL_FLAG_ONTOP,
- FLAG_LIGHTMAP_ON_UV2 = VS::MATERIAL_FLAG_LIGHTMAP_ON_UV2,
- FLAG_COLOR_ARRAY_SRGB = VS::MATERIAL_FLAG_COLOR_ARRAY_SRGB,
- FLAG_MAX = VS::MATERIAL_FLAG_MAX
- };
+ _FORCE_INLINE_ RID _get_material() const { return material; }
+public:
- enum BlendMode {
- BLEND_MODE_MIX = VS::MATERIAL_BLEND_MODE_MIX,
- BLEND_MODE_MUL = VS::MATERIAL_BLEND_MODE_MUL,
- BLEND_MODE_ADD = VS::MATERIAL_BLEND_MODE_ADD,
- BLEND_MODE_SUB = VS::MATERIAL_BLEND_MODE_SUB,
- BLEND_MODE_PREMULT_ALPHA = VS::MATERIAL_BLEND_MODE_PREMULT_ALPHA,
+ virtual RID get_rid() const;
+ Material();
+ virtual ~Material();
+};
- };
- 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
- };
+class FixedSpatialMaterial : public Material {
+ OBJ_TYPE(FixedSpatialMaterial,Material)
-private:
- BlendMode blend_mode;
- bool flags[VS::MATERIAL_FLAG_MAX];
- float line_width;
- DepthDrawMode depth_draw_mode;
-protected:
- RID material;
+public:
- static void _bind_methods();
+ enum TextureParam {
+ TEXTURE_ALBEDO,
+ TEXTURE_SPECULAR,
+ TEXTURE_EMISSION,
+ TEXTURE_NORMAL,
+ TEXTURE_RIM,
+ TEXTURE_CLEARCOAT,
+ TEXTURE_FLOWMAP,
+ TEXTURE_AMBIENT_OCCLUSION,
+ TEXTURE_HEIGHT,
+ TEXTURE_SUBSURFACE_SCATTERING,
+ TEXTURE_REFRACTION,
+ TEXTURE_REFRACTION_ROUGHNESS,
+ TEXTURE_DETAIL_MASK,
+ TEXTURE_DETAIL_ALBEDO,
+ TEXTURE_DETAIL_NORMAL,
+ TEXTURE_MAX
-public:
- void set_flag(Flag p_flag,bool p_enabled);
- bool get_flag(Flag p_flag) 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;
+ enum DetailUV {
+ DETAIL_UV_1,
+ DETAIL_UV_2
+ };
- virtual RID get_rid() const;
+ enum Feature {
+ FEATURE_TRANSPARENT,
+ FEATURE_EMISSION,
+ FEATURE_NORMAL_MAPPING,
+ FEATURE_RIM,
+ FEATURE_CLEARCOAT,
+ FEATURE_ANISOTROPY,
+ FEATURE_AMBIENT_OCCLUSION,
+ FEATURE_HEIGHT_MAPPING,
+ FEATURE_SUBSURACE_SCATTERING,
+ FEATURE_REFRACTION,
+ FEATURE_DETAIL,
+ FEATURE_MAX
+ };
- Material(const RID& p_rid=RID());
- virtual ~Material();
-};
-VARIANT_ENUM_CAST( Material::Flag );
-VARIANT_ENUM_CAST( Material::DepthDrawMode );
+ enum BlendMode {
+ BLEND_MODE_MIX,
+ BLEND_MODE_ADD,
+ BLEND_MODE_SUB,
+ BLEND_MODE_MUL,
+ };
-VARIANT_ENUM_CAST( Material::BlendMode );
+ enum DepthDrawMode {
+ DEPTH_DRAW_OPAQUE_ONLY,
+ DEPTH_DRAW_ALWAYS,
+ DEPTH_DRAW_DISABLED,
+ DEPTH_DRAW_ALPHA_OPAQUE_PREPASS
+ };
-class FixedMaterial : public Material {
+ enum CullMode {
+ CULL_BACK,
+ CULL_FRONT,
+ CULL_DISABLED
+ };
- OBJ_TYPE( FixedMaterial, Material );
- REVERSE_GET_PROPERTY_LIST
-public:
+ enum Flags {
+ FLAG_UNSHADED,
+ FLAG_ONTOP,
+ FLAG_ALBEDO_FROM_VERTEX_COLOR,
+ FLAG_SRGB_VERTEX_COLOR,
+ FLAG_USE_POINT_SIZE,
+ FLAG_MAX
+ };
- enum Parameter {
- PARAM_DIFFUSE=VS::FIXED_MATERIAL_PARAM_DIFFUSE,
- PARAM_DETAIL=VS::FIXED_MATERIAL_PARAM_DETAIL,
- PARAM_SPECULAR=VS::FIXED_MATERIAL_PARAM_SPECULAR,
- PARAM_EMISSION=VS::FIXED_MATERIAL_PARAM_EMISSION,
- PARAM_SPECULAR_EXP=VS::FIXED_MATERIAL_PARAM_SPECULAR_EXP,
- PARAM_GLOW=VS::FIXED_MATERIAL_PARAM_GLOW,
- PARAM_NORMAL=VS::FIXED_MATERIAL_PARAM_NORMAL,
- PARAM_SHADE_PARAM=VS::FIXED_MATERIAL_PARAM_SHADE_PARAM,
- PARAM_MAX=VS::FIXED_MATERIAL_PARAM_MAX
+ enum DiffuseMode {
+ DIFFUSE_LAMBERT,
+ DIFFUSE_LAMBERT_WRAP,
+ DIFFUSE_OREN_NAYAR,
+ DIFFUSE_BURLEY,
};
+ enum SpecularMode {
+ SPECULAR_MODE_METALLIC,
+ SPECULAR_MODE_SPECULAR,
+ };
- enum TexCoordMode {
+private:
+ union MaterialKey {
+
+ struct {
+ uint32_t feature_mask : 14;
+ uint32_t detail_uv : 1;
+ uint32_t blend_mode : 2;
+ uint32_t depth_draw_mode : 2;
+ uint32_t cull_mode : 2;
+ uint32_t flags : 5;
+ uint32_t detail_blend_mode : 2;
+ uint32_t diffuse_mode : 2;
+ uint32_t invalid_key : 1;
+ uint32_t specular_mode : 1;
+ };
+
+ uint32_t key;
+
+ bool operator<(const MaterialKey& p_key) const {
+ return key < p_key.key;
+ }
- TEXCOORD_UV=VS::FIXED_MATERIAL_TEXCOORD_UV,
- TEXCOORD_UV_TRANSFORM=VS::FIXED_MATERIAL_TEXCOORD_UV_TRANSFORM,
- TEXCOORD_UV2=VS::FIXED_MATERIAL_TEXCOORD_UV2,
- TEXCOORD_SPHERE=VS::FIXED_MATERIAL_TEXCOORD_SPHERE
};
- enum FixedFlag {
- FLAG_USE_ALPHA=VS::FIXED_MATERIAL_FLAG_USE_ALPHA,
- FLAG_USE_COLOR_ARRAY=VS::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,
- FLAG_USE_POINT_SIZE=VS::FIXED_MATERIAL_FLAG_USE_POINT_SIZE,
- FLAG_DISCARD_ALPHA=VS::FIXED_MATERIAL_FLAG_DISCARD_ALPHA,
- FLAG_USE_XY_NORMALMAP=VS::FIXED_MATERIAL_FLAG_USE_XY_NORMALMAP,
- FLAG_MAX=VS::FIXED_MATERIAL_FLAG_MAX
+ struct ShaderData {
+ RID shader;
+ int users;
};
- enum LightShader {
+ static Map<MaterialKey,ShaderData> shader_map;
+
+ MaterialKey current_key;
+
+ _FORCE_INLINE_ MaterialKey _compute_key() const {
+
+ MaterialKey mk;
+ mk.key=0;
+ for(int i=0;i<FEATURE_MAX;i++) {
+ if (features[i]) {
+ mk.feature_mask|=(1<<i);
+ }
+ }
+ mk.detail_uv=detail_uv;
+ mk.blend_mode=blend_mode;
+ mk.depth_draw_mode=depth_draw_mode;
+ mk.cull_mode=cull_mode;
+ for(int i=0;i<FLAG_MAX;i++) {
+ if (flags[i]) {
+ mk.flags|=(1<<i);
+ }
+ }
+ mk.detail_blend_mode=detail_blend_mode;
+ mk.diffuse_mode=diffuse_mode;
+ mk.specular_mode=specular_mode;
+
+ return mk;
+ }
+
+ struct ShaderNames {
+ StringName albedo;
+ StringName specular;
+ StringName metalness;
+ StringName roughness;
+ StringName emission;
+ StringName emission_energy;
+ StringName normal_scale;
+ StringName rim;
+ StringName rim_tint;
+ StringName clearcoat;
+ StringName clearcoat_gloss;
+ StringName anisotropy;
+ StringName height_scale;
+ StringName subsurface_scattering_strength;
+ StringName refraction;
+ StringName refraction_roughness;
+ StringName point_size;
+ StringName uv1_scale;
+ StringName uv1_offset;
+ StringName uv2_scale;
+ StringName uv2_offset;
+ StringName texture_names[TEXTURE_MAX];
- 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:
+ static Mutex *material_mutex;
+ static SelfList<FixedSpatialMaterial>::List dirty_materials;
+ static ShaderNames* shader_names;
+
+ SelfList<FixedSpatialMaterial> element;
+
+ void _update_shader();
+ _FORCE_INLINE_ void _queue_shader_change();
+ _FORCE_INLINE_ bool _is_shader_dirty() const;
+
+ Color albedo;
+ Color specular;
+ float metalness;
+ float roughness;
+ Color emission;
+ float emission_energy;
+ float normal_scale;
+ float rim;
+ float rim_tint;
+ float clearcoat;
+ float clearcoat_gloss;
+ float anisotropy;
+ float height_scale;
+ float subsurface_scattering_strength;
+ float refraction;
+ float refraction_roughness;
+ float line_width;
+ float point_size;
+ Vector2 uv1_scale;
+ Vector2 uv1_offset;
- struct Node {
+ Vector2 uv2_scale;
+ Vector2 uv2_offset;
- int param;
- int mult;
- int tex;
- };
+ DetailUV detail_uv;
- Variant param[PARAM_MAX];
- Ref<Texture> texture_param[PARAM_MAX];
- TexCoordMode texture_texcoord[PARAM_MAX];
- LightShader light_shader;
- bool fixed_flags[FLAG_MAX];
- float point_size;
+ BlendMode blend_mode;
+ BlendMode detail_blend_mode;
+ DepthDrawMode depth_draw_mode;
+ CullMode cull_mode;
+ bool flags[FLAG_MAX];
+ DiffuseMode diffuse_mode;
+ SpecularMode specular_mode;
+ bool features[FEATURE_MAX];
- Transform uv_transform;
+ Ref<Texture> textures[TEXTURE_MAX];
-protected:
+ _FORCE_INLINE_ void _validate_feature(const String& text, Feature feature,PropertyInfo& property) const;
+protected:
static void _bind_methods();
-
+ void _validate_property(PropertyInfo& property) const;
public:
- void set_fixed_flag(FixedFlag p_flag, bool p_value);
- bool get_fixed_flag(FixedFlag p_flag) const;
- void set_parameter(Parameter p_parameter, const Variant& p_value);
- Variant get_parameter(Parameter p_parameter) const;
+ void set_albedo(const Color& p_albedo);
+ Color get_albedo() const;
- void set_texture(Parameter p_parameter, Ref<Texture> p_texture);
- Ref<Texture> get_texture(Parameter p_parameter) const;
+ void set_specular_mode(SpecularMode p_mode);
+ SpecularMode get_specular_mode() const;
- void set_texcoord_mode(Parameter p_parameter, TexCoordMode p_mode);
- TexCoordMode get_texcoord_mode(Parameter p_parameter) const;
+ void set_specular(const Color& p_specular);
+ Color get_specular() const;
- void set_light_shader(LightShader p_shader);
- LightShader get_light_shader() const;
+ void set_metalness(float p_metalness);
+ float get_metalness() const;
- void set_uv_transform(const Transform& p_transform);
- Transform get_uv_transform() const;
+ void set_roughness(float p_roughness);
+ float get_roughness() const;
- void set_point_size(float p_transform);
- float get_point_size() const;
+ void set_emission(const Color& p_emission);
+ Color get_emission() const;
- FixedMaterial();
- ~FixedMaterial();
+ void set_emission_energy(float p_emission_energy);
+ float get_emission_energy() const;
-};
+ void set_normal_scale(float p_normal_scale);
+ float get_normal_scale() const;
+ void set_rim(float p_rim);
+ float get_rim() const;
+ void set_rim_tint(float p_rim_tint);
+ float get_rim_tint() const;
-VARIANT_ENUM_CAST( FixedMaterial::Parameter );
-VARIANT_ENUM_CAST( FixedMaterial::TexCoordMode );
-VARIANT_ENUM_CAST( FixedMaterial::FixedFlag );
-VARIANT_ENUM_CAST( FixedMaterial::LightShader );
+ void set_clearcoat(float p_clearcoat);
+ float get_clearcoat() const;
-class ShaderMaterial : public Material {
+ void set_clearcoat_gloss(float p_clearcoat_gloss);
+ float get_clearcoat_gloss() const;
- OBJ_TYPE( ShaderMaterial, Material );
+ void set_anisotropy(float p_anisotropy);
+ float get_anisotropy() const;
- Ref<Shader> shader;
+ void set_height_scale(float p_height_scale);
+ float get_height_scale() const;
+ void set_subsurface_scattering_strength(float p_strength);
+ float get_subsurface_scattering_strength() const;
+ void set_refraction(float p_refraction);
+ float get_refraction() const;
- void _shader_changed();
- static void _shader_parse(void*p_self,ShaderLanguage::ProgramNode*p_node);
+ void set_refraction_roughness(float p_refraction_roughness);
+ float get_refraction_roughness() const;
-protected:
+ void set_line_width(float p_line_width);
+ float get_line_width() const;
- bool _set(const StringName& p_name, const Variant& p_value);
- bool _get(const StringName& p_name,Variant &r_ret) const;
- void _get_property_list( List<PropertyInfo> *p_list) const;
+ void set_point_size(float p_point_size);
+ float get_point_size() const;
- static void _bind_methods();
+ void set_detail_uv(DetailUV p_detail_uv);
+ DetailUV get_detail_uv() const;
-public:
+ void set_blend_mode(BlendMode p_mode);
+ BlendMode get_blend_mode() const;
+
+ void set_detail_blend_mode(BlendMode p_mode);
+ BlendMode get_detail_blend_mode() const;
+
+ void set_depth_draw_mode(DepthDrawMode p_mode);
+ DepthDrawMode get_depth_draw_mode() const;
- void set_shader(const Ref<Shader>& p_shader);
- Ref<Shader> get_shader() const;
+ void set_cull_mode(CullMode p_mode);
+ CullMode get_cull_mode() const;
- void set_shader_param(const StringName& p_param,const Variant& p_value);
- Variant get_shader_param(const StringName& p_param) const;
+ void set_diffuse_mode(DiffuseMode p_mode);
+ DiffuseMode get_diffuse_mode() const;
- void get_argument_options(const StringName& p_function,int p_idx,List<String>*r_options) const;
+ void set_flag(Flags p_flag,bool p_enabled);
+ bool get_flag(Flags p_flag) const;
- ShaderMaterial();
+ void set_texture(TextureParam p_param,const Ref<Texture>& p_texture);
+ Ref<Texture> get_texture(TextureParam p_param) const;
+
+ void set_feature(Feature p_feature,bool p_enabled);
+ bool get_feature(Feature p_feature) const;
+
+ void set_uv1_scale(const Vector2& p_scale);
+ Vector2 get_uv1_scale() const;
+
+ void set_uv1_offset(const Vector2& p_offset);
+ Vector2 get_uv1_offset() const;
+
+ void set_uv2_scale(const Vector2& p_scale);
+ Vector2 get_uv2_scale() const;
+
+ void set_uv2_offset(const Vector2& p_offset);
+ Vector2 get_uv2_offset() const;
+
+ static void init_shaders();
+ static void finish_shaders();
+ static void flush_changes();
+
+ FixedSpatialMaterial();
+ virtual ~FixedSpatialMaterial();
};
+VARIANT_ENUM_CAST( FixedSpatialMaterial::TextureParam )
+VARIANT_ENUM_CAST( FixedSpatialMaterial::DetailUV )
+VARIANT_ENUM_CAST( FixedSpatialMaterial::Feature )
+VARIANT_ENUM_CAST( FixedSpatialMaterial::BlendMode )
+VARIANT_ENUM_CAST( FixedSpatialMaterial::DepthDrawMode )
+VARIANT_ENUM_CAST( FixedSpatialMaterial::CullMode )
+VARIANT_ENUM_CAST( FixedSpatialMaterial::Flags )
+VARIANT_ENUM_CAST( FixedSpatialMaterial::DiffuseMode )
+VARIANT_ENUM_CAST( FixedSpatialMaterial::SpecularMode )
+
//////////////////////
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index 4932b5f66f..58c2d08eec 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -122,22 +122,64 @@ bool Mesh::_set(const StringName& p_name, const Variant& p_value) {
if (idx==surfaces.size()) {
- if (what=="custom") {
- add_custom_surface(p_value);
- return true;
-
- }
-
//create
Dictionary d=p_value;
ERR_FAIL_COND_V(!d.has("primitive"),false);
- ERR_FAIL_COND_V(!d.has("arrays"),false);
- ERR_FAIL_COND_V(!d.has("morph_arrays"),false);
- bool alphasort = d.has("alphasort") && bool(d["alphasort"]);
+ if (d.has("arrays")) {
+ //old format
+ ERR_FAIL_COND_V(!d.has("morph_arrays"),false);
+ add_surface_from_arrays(PrimitiveType(int(d["primitive"])),d["arrays"],d["morph_arrays"]);
+
+ } else if (d.has("array_data")) {
+
+ DVector<uint8_t> array_data = d["array_data"];
+ DVector<uint8_t> array_index_data;
+ if (d.has("array_index_data"))
+ array_index_data=d["array_index_data"];
+
+ ERR_FAIL_COND_V(!d.has("format"),false);
+ uint32_t format = d["format"];
+
+ ERR_FAIL_COND_V(!d.has("primitive"),false);
+ uint32_t primitive = d["primitive"];
+
+ ERR_FAIL_COND_V(!d.has("vertex_count"),false);
+ int vertex_count = d["vertex_count"];
+
+ int index_count=0;
+ if (d.has("index_count"))
+ index_count=d["index_count"];
+
+ Vector< DVector<uint8_t> > morphs;
+
+ if (d.has("morph_data")) {
+ Array morph_data=d["morph_data"];
+ for(int i=0;i<morph_data.size();i++) {
+ DVector<uint8_t> morph = morph_data[i];
+ morphs.push_back(morph_data[i]);
+ }
+ }
+
+ ERR_FAIL_COND_V(!d.has("aabb"),false);
+ AABB aabb = d["aabb"];
+
+ Vector<AABB> bone_aabb;
+ if (d.has("bone_aabb")) {
+ Array baabb = d["bone_aabb"];
+ bone_aabb.resize(baabb.size());
+
+ for(int i=0;i<baabb.size();i++) {
+ bone_aabb[i]=baabb[i];
+ }
+ }
+
+ add_surface(format,PrimitiveType(primitive),array_data,vertex_count,array_index_data,index_count,aabb,morphs,bone_aabb);
+ } else {
+ ERR_FAIL_V(false);
+ }
- add_surface(PrimitiveType(int(d["primitive"])),d["arrays"],d["morph_arrays"],alphasort);
if (d.has("material")) {
surface_set_material(idx,d["material"]);
@@ -193,10 +235,31 @@ bool Mesh::_get(const StringName& p_name,Variant &r_ret) const {
ERR_FAIL_INDEX_V(idx,surfaces.size(),false);
Dictionary d;
- d["primitive"]=surface_get_primitive_type(idx);
- d["arrays"]=surface_get_arrays(idx);
- d["morph_arrays"]=surface_get_morph_arrays(idx);
- d["alphasort"]=surface_is_alpha_sorting_enabled(idx);
+
+ d["array_data"]=VS::get_singleton()->mesh_surface_get_array(mesh,idx);
+ d["vertex_count"]=VS::get_singleton()->mesh_surface_get_array_len(mesh,idx);
+ d["array_index_data"]=VS::get_singleton()->mesh_surface_get_index_array(mesh,idx);
+ d["index_count"]=VS::get_singleton()->mesh_surface_get_array_index_len(mesh,idx);
+ d["primitive"]=VS::get_singleton()->mesh_surface_get_primitive_type(mesh,idx);
+ d["format"]=VS::get_singleton()->mesh_surface_get_format(mesh,idx);
+ d["aabb"]=VS::get_singleton()->mesh_surface_get_aabb(mesh,idx);
+
+ Vector<AABB> skel_aabb = VS::get_singleton()->mesh_surface_get_skeleton_aabb(mesh,idx);
+ Array arr;
+ for(int i=0;i<skel_aabb.size();i++) {
+ arr[i]=skel_aabb[i];
+ }
+ d["skeleton_aabb"]=arr;
+
+ Vector< DVector<uint8_t> > morph_data = VS::get_singleton()->mesh_surface_get_blend_shapes(mesh,idx);
+
+ Array md;
+ for(int i=0;i<morph_data.size();i++) {
+ md.push_back(morph_data[i]);
+ }
+
+ d["morph_data"]=md;
+
Ref<Material> m = surface_get_material(idx);
if (m.is_valid())
d["material"]=m;
@@ -243,14 +306,24 @@ void Mesh::_recompute_aabb() {
}
-void Mesh::add_surface(PrimitiveType p_primitive,const Array& p_arrays,const Array& p_blend_shapes,bool p_alphasort) {
+void Mesh::add_surface(uint32_t p_format,PrimitiveType p_primitive,const DVector<uint8_t>& p_array,int p_vertex_count,const DVector<uint8_t>& p_index_array,int p_index_count,const AABB& p_aabb,const Vector<DVector<uint8_t> >& p_blend_shapes,const Vector<AABB>& p_bone_aabbs) {
+
+ Surface s;
+ s.aabb=p_aabb;
+ surfaces.push_back(s);
+
+ VisualServer::get_singleton()->mesh_add_surface(mesh,p_format,(VS::PrimitiveType)p_primitive,p_array,p_vertex_count,p_index_array,p_index_count,p_aabb,p_blend_shapes,p_bone_aabbs);
+
+}
+
+void Mesh::add_surface_from_arrays(PrimitiveType p_primitive,const Array& p_arrays,const Array& p_blend_shapes,uint32_t p_flags) {
ERR_FAIL_COND(p_arrays.size()!=ARRAY_MAX);
Surface s;
- VisualServer::get_singleton()->mesh_add_surface(mesh,(VisualServer::PrimitiveType)p_primitive, p_arrays,p_blend_shapes,p_alphasort);
+ VisualServer::get_singleton()->mesh_add_surface_from_arrays(mesh,(VisualServer::PrimitiveType)p_primitive, p_arrays,p_blend_shapes,p_flags);
surfaces.push_back(s);
@@ -274,7 +347,6 @@ void Mesh::add_surface(PrimitiveType p_primitive,const Array& p_arrays,const Arr
}
surfaces[surfaces.size()-1].aabb=aabb;
- surfaces[surfaces.size()-1].alphasort=p_alphasort;
_recompute_aabb();
@@ -289,29 +361,18 @@ void Mesh::add_surface(PrimitiveType p_primitive,const Array& p_arrays,const Arr
Array Mesh::surface_get_arrays(int p_surface) const {
ERR_FAIL_INDEX_V(p_surface,surfaces.size(),Array());
- return VisualServer::get_singleton()->mesh_get_surface_arrays(mesh,p_surface);
+ return VisualServer::get_singleton()->mesh_surface_get_arrays(mesh,p_surface);
}
Array Mesh::surface_get_morph_arrays(int p_surface) const {
ERR_FAIL_INDEX_V(p_surface,surfaces.size(),Array());
- return VisualServer::get_singleton()->mesh_get_surface_morph_arrays(mesh,p_surface);
+ return Array();
}
-void Mesh::add_custom_surface(const Variant& p_data) {
-
- Surface s;
- s.aabb=AABB();
- VisualServer::get_singleton()->mesh_add_custom_surface(mesh,p_data);
- surfaces.push_back(s);
-
- triangle_mesh=Ref<TriangleMesh>();
- _change_notify();
-}
-
int Mesh::get_surface_count() const {
@@ -418,11 +479,6 @@ Mesh::PrimitiveType Mesh::surface_get_primitive_type(int p_idx) const {
return (PrimitiveType)VisualServer::get_singleton()->mesh_surface_get_primitive_type( mesh, p_idx );
}
-bool Mesh::surface_is_alpha_sorting_enabled(int p_idx) const {
-
- ERR_FAIL_INDEX_V( p_idx, surfaces.size(), 0 );
- return surfaces[p_idx].alphasort;
-}
void Mesh::surface_set_material(int p_idx, const Ref<Material>& p_material) {
@@ -719,8 +775,10 @@ Ref<TriangleMesh> Mesh::generate_triangle_mesh() const {
DVector<int> indices = a[ARRAY_INDEX];
DVector<int>::Read ir = indices.read();
- for(int i=0;i<ic;i++)
- facesw[widx++]=vr[ ir[i] ];
+ for(int i=0;i<ic;i++) {
+ int index = ir[i];
+ facesw[widx++]=vr[ index ];
+ }
} else {
@@ -954,7 +1012,7 @@ Ref<Mesh> Mesh::create_outline(float p_margin) const {
Ref<Mesh> newmesh = memnew( Mesh );
- newmesh->add_surface(PRIMITIVE_TRIANGLES,arrays);
+ newmesh->add_surface_from_arrays(PRIMITIVE_TRIANGLES,arrays);
return newmesh;
}
@@ -968,7 +1026,7 @@ void Mesh::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_morph_target_mode","mode"),&Mesh::set_morph_target_mode);
ObjectTypeDB::bind_method(_MD("get_morph_target_mode"),&Mesh::get_morph_target_mode);
- ObjectTypeDB::bind_method(_MD("add_surface","primitive","arrays","morph_arrays","alphasort"),&Mesh::add_surface,DEFVAL(Array()),DEFVAL(false));
+ ObjectTypeDB::bind_method(_MD("add_surface_from_arrays","primitive","arrays","blend_shapes","compress_flags"),&Mesh::add_surface_from_arrays,DEFVAL(Array()),DEFVAL(ARRAY_COMPRESS_DEFAULT));
ObjectTypeDB::bind_method(_MD("get_surface_count"),&Mesh::get_surface_count);
ObjectTypeDB::bind_method(_MD("surface_remove","surf_idx"),&Mesh::surface_remove);
ObjectTypeDB::bind_method(_MD("surface_get_array_len","surf_idx"),&Mesh::surface_get_array_len);
diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h
index 61731b163e..399cd8921f 100644
--- a/scene/resources/mesh.h
+++ b/scene/resources/mesh.h
@@ -77,6 +77,22 @@ public:
ARRAY_FORMAT_WEIGHTS=1<<ARRAY_WEIGHTS,
ARRAY_FORMAT_INDEX=1<<ARRAY_INDEX,
+ ARRAY_COMPRESS_BASE=(ARRAY_INDEX+1),
+ ARRAY_COMPRESS_VERTEX=1<<(ARRAY_VERTEX+ARRAY_COMPRESS_BASE), // mandatory
+ ARRAY_COMPRESS_NORMAL=1<<(ARRAY_NORMAL+ARRAY_COMPRESS_BASE),
+ ARRAY_COMPRESS_TANGENT=1<<(ARRAY_TANGENT+ARRAY_COMPRESS_BASE),
+ ARRAY_COMPRESS_COLOR=1<<(ARRAY_COLOR+ARRAY_COMPRESS_BASE),
+ ARRAY_COMPRESS_TEX_UV=1<<(ARRAY_TEX_UV+ARRAY_COMPRESS_BASE),
+ ARRAY_COMPRESS_TEX_UV2=1<<(ARRAY_TEX_UV2+ARRAY_COMPRESS_BASE),
+ ARRAY_COMPRESS_BONES=1<<(ARRAY_BONES+ARRAY_COMPRESS_BASE),
+ ARRAY_COMPRESS_WEIGHTS=1<<(ARRAY_WEIGHTS+ARRAY_COMPRESS_BASE),
+ ARRAY_COMPRESS_INDEX=1<<(ARRAY_INDEX+ARRAY_COMPRESS_BASE),
+
+ ARRAY_FLAG_USE_2D_VERTICES=ARRAY_COMPRESS_INDEX<<1,
+ ARRAY_FLAG_USE_16_BIT_BONES=ARRAY_COMPRESS_INDEX<<2,
+
+ ARRAY_COMPRESS_DEFAULT=ARRAY_COMPRESS_VERTEX|ARRAY_COMPRESS_NORMAL|ARRAY_COMPRESS_TANGENT|ARRAY_COMPRESS_COLOR|ARRAY_COMPRESS_TEX_UV|ARRAY_COMPRESS_TEX_UV2|ARRAY_COMPRESS_WEIGHTS
+
};
enum PrimitiveType {
@@ -99,7 +115,6 @@ private:
struct Surface {
String name;
AABB aabb;
- bool alphasort;
Ref<Material> material;
};
Vector<Surface> surfaces;
@@ -123,12 +138,12 @@ protected:
public:
- void add_surface(PrimitiveType p_primitive,const Array& p_arrays,const Array& p_blend_shapes=Array(),bool p_alphasort=false);
+ void add_surface_from_arrays(PrimitiveType p_primitive, const Array& p_arrays, const Array& p_blend_shapes=Array(), uint32_t p_flags=ARRAY_COMPRESS_DEFAULT);
+ void add_surface(uint32_t p_format,PrimitiveType p_primitive,const DVector<uint8_t>& p_array,int p_vertex_count,const DVector<uint8_t>& p_index_array,int p_index_count,const AABB& p_aabb,const Vector<DVector<uint8_t> >& p_blend_shapes=Vector<DVector<uint8_t> >(),const Vector<AABB>& p_bone_aabbs=Vector<AABB>());
+
Array surface_get_arrays(int p_surface) const;
virtual Array surface_get_morph_arrays(int p_surface) const;
- void add_custom_surface(const Variant& p_data); //only recognized by driver
-
void add_morph_target(const StringName& p_name);
int get_morph_target_count() const;
StringName get_morph_target_name(int p_index) const;
diff --git a/scene/resources/mesh_data_tool.cpp b/scene/resources/mesh_data_tool.cpp
index df36390c0e..e06ff6fd52 100644
--- a/scene/resources/mesh_data_tool.cpp
+++ b/scene/resources/mesh_data_tool.cpp
@@ -328,7 +328,7 @@ Error MeshDataTool::commit_to_surface(const Ref<Mesh>& p_mesh) {
Ref<Mesh> ncmesh=p_mesh;
int sc = ncmesh->get_surface_count();
- ncmesh->add_surface(Mesh::PRIMITIVE_TRIANGLES,arr);
+ ncmesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES,arr);
ncmesh->surface_set_material(sc,material);
return OK;
diff --git a/scene/resources/multimesh.cpp b/scene/resources/multimesh.cpp
index 2554b17a98..b96ad155c0 100644
--- a/scene/resources/multimesh.cpp
+++ b/scene/resources/multimesh.cpp
@@ -141,7 +141,7 @@ Ref<Mesh> MultiMesh::get_mesh() const {
void MultiMesh::set_instance_count(int p_count) {
- VisualServer::get_singleton()->multimesh_set_instance_count(multimesh,p_count);
+ VisualServer::get_singleton()->multimesh_allocate(multimesh,p_count,VS::MultimeshTransformFormat(transform_format),VS::MultimeshColorFormat(color_format));
}
int MultiMesh::get_instance_count() const {
@@ -174,66 +174,58 @@ Color MultiMesh::get_instance_color(int p_instance) const {
}
-void MultiMesh::set_aabb(const AABB& p_aabb) {
- aabb=p_aabb;
- VisualServer::get_singleton()->multimesh_set_aabb(multimesh,p_aabb);
-
-
-}
AABB MultiMesh::get_aabb() const {
- return aabb;
+ return VisualServer::get_singleton()->multimesh_get_aabb(multimesh);
}
-void MultiMesh::generate_aabb() {
-
-
-
- ERR_EXPLAIN("Cannot generate AABB if mesh is null.");
- ERR_FAIL_COND(mesh.is_null());
- AABB base_aabb=mesh->get_aabb();
+RID MultiMesh::get_rid() const {
- aabb=AABB();
+ return multimesh;
- int instance_count = get_instance_count();
- for(int i=0;i<instance_count;i++) {
+}
- Transform xform = get_instance_transform(i);
- if(i==0)
- aabb=xform.xform(base_aabb);
- else
- aabb.merge_with(xform.xform(base_aabb));
+void MultiMesh::set_color_format(ColorFormat p_color_format) {
- }
+ color_format=p_color_format;
+}
- set_aabb(aabb);
+MultiMesh::ColorFormat MultiMesh::get_color_format() const{
+ return color_format;
}
-RID MultiMesh::get_rid() const {
+void MultiMesh::set_transform_format(TransformFormat p_transform_format){
- return multimesh;
+ transform_format=p_transform_format;
+}
+MultiMesh::TransformFormat MultiMesh::get_transform_format() const{
+ return transform_format;
}
+
void MultiMesh::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_mesh","mesh:Mesh"),&MultiMesh::set_mesh);
ObjectTypeDB::bind_method(_MD("get_mesh:Mesh"),&MultiMesh::get_mesh);
+ ObjectTypeDB::bind_method(_MD("set_color_format","format"),&MultiMesh::set_color_format);
+ ObjectTypeDB::bind_method(_MD("get_color_format"),&MultiMesh::get_color_format);
+ ObjectTypeDB::bind_method(_MD("set_transform_format","format"),&MultiMesh::set_transform_format);
+ ObjectTypeDB::bind_method(_MD("get_transform_format"),&MultiMesh::get_transform_format);
+
ObjectTypeDB::bind_method(_MD("set_instance_count","count"),&MultiMesh::set_instance_count);
ObjectTypeDB::bind_method(_MD("get_instance_count"),&MultiMesh::get_instance_count);
ObjectTypeDB::bind_method(_MD("set_instance_transform","instance","transform"),&MultiMesh::set_instance_transform);
ObjectTypeDB::bind_method(_MD("get_instance_transform","instance"),&MultiMesh::get_instance_transform);
ObjectTypeDB::bind_method(_MD("set_instance_color","instance","color"),&MultiMesh::set_instance_color);
ObjectTypeDB::bind_method(_MD("get_instance_color","instance"),&MultiMesh::get_instance_color);
- ObjectTypeDB::bind_method(_MD("set_aabb","visibility_aabb"),&MultiMesh::set_aabb);
ObjectTypeDB::bind_method(_MD("get_aabb"),&MultiMesh::get_aabb);
- ObjectTypeDB::bind_method(_MD("generate_aabb"),&MultiMesh::generate_aabb);
ObjectTypeDB::bind_method(_MD("_set_transform_array"),&MultiMesh::_set_transform_array);
ObjectTypeDB::bind_method(_MD("_get_transform_array"),&MultiMesh::_get_transform_array);
@@ -241,17 +233,28 @@ void MultiMesh::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_get_color_array"),&MultiMesh::_get_color_array);
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"color_format",PROPERTY_HINT_ENUM,"None,Byte,Float"), _SCS("set_color_format"), _SCS("get_color_format"));
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"transform_format",PROPERTY_HINT_ENUM,"2D,3D"), _SCS("set_transform_format"), _SCS("get_transform_format"));
ADD_PROPERTY(PropertyInfo(Variant::INT,"instance_count",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_instance_count"), _SCS("get_instance_count"));
ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"mesh",PROPERTY_HINT_RESOURCE_TYPE,"Mesh"), _SCS("set_mesh"), _SCS("get_mesh"));
- ADD_PROPERTY(PropertyInfo(Variant::_AABB,"aabb"), _SCS("set_aabb"), _SCS("get_aabb") );
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3_ARRAY,"transform_array",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_transform_array"), _SCS("_get_transform_array"));
ADD_PROPERTY(PropertyInfo(Variant::COLOR_ARRAY,"color_array",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_color_array"), _SCS("_get_color_array"));
+
+
+ BIND_CONSTANT( TRANSFORM_2D );
+ BIND_CONSTANT( TRANSFORM_3D );
+ BIND_CONSTANT( COLOR_NONE );
+ BIND_CONSTANT( COLOR_8BIT );
+ BIND_CONSTANT( COLOR_FLOAT );
+
}
MultiMesh::MultiMesh() {
multimesh = VisualServer::get_singleton()->multimesh_create();
+ color_format=COLOR_NONE;
+ transform_format=TRANSFORM_2D;
}
MultiMesh::~MultiMesh() {
diff --git a/scene/resources/multimesh.h b/scene/resources/multimesh.h
index 448b4b3413..85c8718aa7 100644
--- a/scene/resources/multimesh.h
+++ b/scene/resources/multimesh.h
@@ -30,16 +30,31 @@
#define MULTIMESH_H
#include "scene/resources/mesh.h"
-
+#include "servers/visual_server.h"
class MultiMesh : public Resource {
OBJ_TYPE( MultiMesh, Resource );
RES_BASE_EXTENSION("mmsh");
+public:
- AABB aabb;
+ enum TransformFormat {
+ TRANSFORM_2D = VS::MULTIMESH_TRANSFORM_2D,
+ TRANSFORM_3D = VS::MULTIMESH_TRANSFORM_3D
+ };
+
+ enum ColorFormat {
+ COLOR_NONE = VS::MULTIMESH_COLOR_NONE,
+ COLOR_8BIT = VS::MULTIMESH_COLOR_8BIT,
+ COLOR_FLOAT = VS::MULTIMESH_COLOR_FLOAT,
+ };
+private:
Ref<Mesh> mesh;
RID multimesh;
+ TransformFormat transform_format;
+ ColorFormat color_format;
+
+
protected:
static void _bind_methods();
@@ -55,6 +70,12 @@ public:
void set_mesh(const Ref<Mesh>& p_mesh);
Ref<Mesh> get_mesh() const;
+ void set_color_format(ColorFormat p_color_format);
+ ColorFormat get_color_format() const;
+
+ void set_transform_format(TransformFormat p_transform_format);
+ TransformFormat get_transform_format() const;
+
void set_instance_count(int p_count);
int get_instance_count() const;
@@ -64,11 +85,8 @@ public:
void set_instance_color(int p_instance, const Color& p_color);
Color get_instance_color(int p_instance) const;
- void set_aabb(const AABB& p_aabb);
virtual AABB get_aabb() const;
- void generate_aabb();
-
virtual RID get_rid() const;
MultiMesh();
@@ -76,4 +94,8 @@ public:
};
+
+VARIANT_ENUM_CAST( MultiMesh::TransformFormat );
+VARIANT_ENUM_CAST( MultiMesh::ColorFormat);
+
#endif // MULTI_MESH_H
diff --git a/scene/resources/room.cpp b/scene/resources/room.cpp
index dee2ea8ea2..dd833a3f2a 100644
--- a/scene/resources/room.cpp
+++ b/scene/resources/room.cpp
@@ -36,16 +36,6 @@ RID RoomBounds::get_rid() const {
return area;
}
-void RoomBounds::set_bounds( const BSP_Tree& p_bounds ) {
-
- VisualServer::get_singleton()->room_set_bounds(area,p_bounds);
- emit_signal("changed");
-}
-
-BSP_Tree RoomBounds::get_bounds() const {
-
- return VisualServer::get_singleton()->room_get_bounds(area);
-}
void RoomBounds::set_geometry_hint(const DVector<Face3>& p_geometry_hint) {
@@ -57,41 +47,15 @@ DVector<Face3> RoomBounds::get_geometry_hint() const {
return geometry_hint;
}
-void RoomBounds::_regenerate_bsp_cubic() {
-
- if (geometry_hint.size()) {
-
- float err=0;
- geometry_hint= Geometry::wrap_geometry( geometry_hint, &err ); ///< create a "wrap" that encloses the given geometry
- BSP_Tree new_bounds(geometry_hint,err);
- set_bounds(new_bounds);
- }
-
-}
-
-void RoomBounds::_regenerate_bsp() {
-
- if (geometry_hint.size()) {
-
- BSP_Tree new_bounds(geometry_hint,0);
- set_bounds(new_bounds);
- }
-}
void RoomBounds::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_bounds","bsp_tree"),&RoomBounds::set_bounds);
- ObjectTypeDB::bind_method(_MD("get_bounds"),&RoomBounds::get_bounds);
ObjectTypeDB::bind_method(_MD("set_geometry_hint","triangles"),&RoomBounds::set_geometry_hint);
ObjectTypeDB::bind_method(_MD("get_geometry_hint"),&RoomBounds::get_geometry_hint);
- ObjectTypeDB::bind_method(_MD("regenerate_bsp"),&RoomBounds::_regenerate_bsp);
- ObjectTypeDB::set_method_flags(get_type_static(),_SCS("regenerate_bsp"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ObjectTypeDB::bind_method(_MD("regenerate_bsp_cubic"),&RoomBounds::_regenerate_bsp_cubic);
- ObjectTypeDB::set_method_flags(get_type_static(),_SCS("regenerate_bsp_cubic"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
- ADD_PROPERTY( PropertyInfo( Variant::DICTIONARY, "bounds"), _SCS("set_bounds"),_SCS("get_bounds") );
+ //ADD_PROPERTY( PropertyInfo( Variant::DICTIONARY, "bounds"), _SCS("set_bounds"),_SCS("get_bounds") );
ADD_PROPERTY( PropertyInfo( Variant::VECTOR3_ARRAY, "geometry_hint"),_SCS("set_geometry_hint"),_SCS("get_geometry_hint") );
}
diff --git a/scene/resources/room.h b/scene/resources/room.h
index 5b0950ce34..6ecd7e846d 100644
--- a/scene/resources/room.h
+++ b/scene/resources/room.h
@@ -34,6 +34,7 @@
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
+
class RoomBounds : public Resource {
OBJ_TYPE( RoomBounds, Resource );
@@ -42,8 +43,7 @@ class RoomBounds : public Resource {
RID area;
DVector<Face3> geometry_hint;
- void _regenerate_bsp();
- void _regenerate_bsp_cubic();
+
protected:
static void _bind_methods();
@@ -52,8 +52,6 @@ public:
virtual RID get_rid() const;
- void set_bounds( const BSP_Tree& p_bounds );
- BSP_Tree get_bounds() const;
void set_geometry_hint(const DVector<Face3>& geometry_hint);
DVector<Face3> get_geometry_hint() const;
@@ -63,4 +61,6 @@ public:
};
+
+
#endif // ROOM_H
diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp
index 8000941157..3ce1a00af4 100644
--- a/scene/resources/shader.cpp
+++ b/scene/resources/shader.cpp
@@ -39,37 +39,17 @@ Shader::Mode Shader::get_mode() const {
return mode;
}
-void Shader::set_code( const String& p_vertex, const String& p_fragment, const String& p_light,int p_fragment_ofs,int p_light_ofs) {
+void Shader::set_code(const String& p_code) {
- VisualServer::get_singleton()->shader_set_code(shader,p_vertex,p_fragment,p_light,0,p_fragment_ofs,p_light_ofs);
+ VisualServer::get_singleton()->shader_set_code(shader,p_code);
params_cache_dirty=true;
emit_signal(SceneStringNames::get_singleton()->changed);
}
-String Shader::get_vertex_code() const {
+String Shader::get_code() const {
- return VisualServer::get_singleton()->shader_get_vertex_code(shader);
-}
-
-String Shader::get_fragment_code() const {
-
- return VisualServer::get_singleton()->shader_get_fragment_code(shader);
-
-}
-
-String Shader::get_light_code() const {
-
- return VisualServer::get_singleton()->shader_get_light_code(shader);
-
-}
-
-bool Shader::has_param(const StringName& p_param) const {
-
- if (params_cache_dirty)
- get_param_list(NULL);
-
- return (params_cache.has(p_param));
+ return VisualServer::get_singleton()->shader_get_code(shader);
}
@@ -101,48 +81,6 @@ RID Shader::get_rid() const {
return shader;
}
-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;
- Array arr;
- for(const Map<StringName,Ref<Texture> >::Element *E=default_textures.front();E;E=E->next()) {
- arr.push_back(E->key());
- arr.push_back(E->get());
- }
- if (arr.size())
- c["default_tex"]=arr;
- return c;
-}
-
-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"],light);
- if (p_string.has("default_tex")) {
- Array arr=p_string["default_tex"];
- if ((arr.size()&1)==0) {
- for(int i=0;i<arr.size();i+=2) {
-
- set_default_texture_param(arr[i],arr[i+1]);
- }
- }
- }
-}
void Shader::set_default_texture_param(const StringName& p_param,const Ref<Texture>& p_texture) {
@@ -171,33 +109,31 @@ void Shader::get_default_texture_param_list(List<StringName>* r_textures) const{
}
}
+bool Shader::has_param(const StringName& p_param) const {
+ return params_cache.has(p_param);
+}
void Shader::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_mode"),&Shader::get_mode);
- 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("set_code","code"),&Shader::set_code);
+ ObjectTypeDB::bind_method(_MD("get_code"),&Shader::get_code);
ObjectTypeDB::bind_method(_MD("set_default_texture_param","param","texture:Texture"),&Shader::set_default_texture_param);
ObjectTypeDB::bind_method(_MD("get_default_texture_param:Texture","param"),&Shader::get_default_texture_param);
ObjectTypeDB::bind_method(_MD("has_param","name"),&Shader::has_param);
- ObjectTypeDB::bind_method(_MD("_set_code","code"),&Shader::_set_code);
- ObjectTypeDB::bind_method(_MD("_get_code"),&Shader::_get_code);
-
//ObjectTypeDB::bind_method(_MD("get_param_list"),&Shader::get_fragment_code);
- ADD_PROPERTY( PropertyInfo(Variant::STRING, "_code",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_code"), _SCS("_get_code") );
+ ADD_PROPERTY( PropertyInfo(Variant::STRING, "code",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("set_code"), _SCS("get_code") );
- BIND_CONSTANT( MODE_MATERIAL );
+ BIND_CONSTANT( MODE_SPATIAL);
BIND_CONSTANT( MODE_CANVAS_ITEM );
- BIND_CONSTANT( MODE_POST_PROCESS );
+ BIND_CONSTANT( MODE_PARTICLES );
}
@@ -214,253 +150,3 @@ Shader::~Shader() {
}
-
-/************ Loader from text ***************/
-
-
-
-RES ResourceFormatLoaderShader::load(const String &p_path, const String& p_original_path, Error *r_error) {
-
- if (r_error)
- *r_error=ERR_FILE_CANT_OPEN;
-
- String fragment_code;
- String vertex_code;
- String light_code;
-
- int mode=-1;
-
- Error err;
- FileAccess *f = FileAccess::open(p_path,FileAccess::READ,&err);
-
-
- ERR_EXPLAIN("Unable to open shader file: "+p_path);
- ERR_FAIL_COND_V(err,RES());
- String base_path = p_path.get_base_dir();
-
- if (r_error)
- *r_error=ERR_FILE_CORRUPT;
-
- Ref<Shader> shader;//( memnew( Shader ) );
-
- int line=0;
-
- while(!f->eof_reached()) {
-
- String l = f->get_line();
- line++;
-
- if (mode<=0) {
- l = l.strip_edges();
- int comment = l.find(";");
- if (comment!=-1)
- l=l.substr(0,comment);
- }
-
- if (mode<1)
- vertex_code+="\n";
- if (mode<2)
- fragment_code+="\n";
-
- if (mode < 1 && l=="")
- continue;
-
- if (l.begins_with("[")) {
- l=l.strip_edges();
- if (l=="[params]") {
- if (mode>=0) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Misplaced [params] section.");
- ERR_FAIL_V(RES());
- }
- mode=0;
- } else if (l=="[vertex]") {
- if (mode>=1) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Misplaced [vertex] section.");
- ERR_FAIL_V(RES());
- }
- mode=1;
- } else if (l=="[fragment]") {
- if (mode>=2) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Misplaced [fragment] section.");
- ERR_FAIL_V(RES());
- }
- mode=1;
- } else {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Unknown section type: '"+l+"'.");
- ERR_FAIL_V(RES());
- }
- continue;
- }
-
- if (mode==0) {
-
- int eqpos = l.find("=");
- if (eqpos==-1) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Expected '='.");
- ERR_FAIL_V(RES());
- }
-
-
- String right=l.substr(eqpos+1,l.length()).strip_edges();
- if (right=="") {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Expected value after '='.");
- ERR_FAIL_V(RES());
- }
-
- Variant value;
-
- if (right=="true") {
- value = true;
- } else if (right=="false") {
- value = false;
- } else if (right.is_valid_float()) {
- //is number
- value = right.to_double();
- } else if (right.is_valid_html_color()) {
- //is html color
- value = Color::html(right);
- } else {
- //attempt to parse a constructor
- int popenpos = right.find("(");
-
- if (popenpos==-1) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid constructor syntax: "+right);
- ERR_FAIL_V(RES());
- }
-
- int pclosepos = right.find_last(")");
-
- if (pclosepos==-1) {
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid constructor parameter syntax: "+right);
- ERR_FAIL_V(RES());
-
- }
-
- String type = right.substr(0,popenpos);
- String param = right.substr(popenpos+1,pclosepos-popenpos-1).strip_edges();
-
-
- if (type=="tex") {
-
- if (param=="") {
-
- value=RID();
- } else {
-
- String path;
-
- if (param.is_abs_path())
- path=param;
- else
- path=base_path+"/"+param;
-
- Ref<Texture> texture = ResourceLoader::load(path);
- if (!texture.is_valid()) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Couldn't find icon at path: "+path);
- ERR_FAIL_V(RES());
- }
-
- value=texture;
- }
-
- } else if (type=="vec3") {
-
- if (param=="") {
- value=Vector3();
- } else {
- Vector<String> params = param.split(",");
- if (params.size()!=3) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid param count for vec3(): '"+right+"'.");
- ERR_FAIL_V(RES());
-
- }
-
- Vector3 v;
- for(int i=0;i<3;i++)
- v[i]=params[i].to_double();
- value=v;
- }
-
-
- } else if (type=="xform") {
-
- if (param=="") {
- value=Transform();
- } else {
-
- Vector<String> params = param.split(",");
- if (params.size()!=12) {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid param count for xform(): '"+right+"'.");
- ERR_FAIL_V(RES());
-
- }
-
- Transform t;
- for(int i=0;i<9;i++)
- t.basis[i%3][i/3]=params[i].to_double();
- for(int i=0;i<3;i++)
- t.origin[i]=params[i-9].to_double();
-
- value=t;
- }
-
- } else {
- memdelete(f);
- ERR_EXPLAIN(p_path+":"+itos(line)+": Invalid constructor type: '"+type+"'.");
- ERR_FAIL_V(RES());
-
- }
-
- }
-
- String left= l.substr(0,eqpos);
-
-// shader->set_param(left,value);
- } else if (mode==1) {
-
- vertex_code+=l;
-
- } else if (mode==2) {
-
- fragment_code+=l;
- }
- }
-
- shader->set_code(vertex_code,fragment_code,light_code);
-
- f->close();
- memdelete(f);
- if (r_error)
- *r_error=OK;
-
- return shader;
-}
-
-void ResourceFormatLoaderShader::get_recognized_extensions(List<String> *p_extensions) const {
-
- ObjectTypeDB::get_extensions_for_type("Shader", p_extensions);
-}
-
-bool ResourceFormatLoaderShader::handles_type(const String& p_type) const {
-
- return ObjectTypeDB::is_type(p_type, "Shader");
-}
-
-
-String ResourceFormatLoaderShader::get_resource_type(const String &p_path) const {
-
- if (p_path.extension().to_lower()=="shd")
- return "Shader";
- return "";
-}
-
diff --git a/scene/resources/shader.h b/scene/resources/shader.h
index 94ee04812a..279cf5b7c9 100644
--- a/scene/resources/shader.h
+++ b/scene/resources/shader.h
@@ -32,6 +32,7 @@
#include "resource.h"
#include "io/resource_loader.h"
#include "scene/resources/texture.h"
+
class Shader : public Resource {
OBJ_TYPE(Shader,Resource);
@@ -41,17 +42,14 @@ class Shader : public Resource {
public:
enum Mode {
- MODE_MATERIAL,
+ MODE_SPATIAL,
MODE_CANVAS_ITEM,
- MODE_POST_PROCESS,
+ MODE_PARTICLES,
MODE_MAX
};
private:
RID shader;
Mode mode;
- Dictionary _get_code();
- void _set_code(const Dictionary& p_string);
-
// hack the name of performance
// shaders keep a list of ShaderMaterial -> VisualServer name translations, to make
@@ -73,10 +71,8 @@ public:
//void set_mode(Mode p_mode);
Mode get_mode() const;
- 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 set_code( const String& p_code);
+ String get_code() const;
void get_param_list(List<PropertyInfo> *p_params) const;
bool has_param(const StringName& p_param) const;
@@ -104,13 +100,13 @@ public:
VARIANT_ENUM_CAST( Shader::Mode );
-class MaterialShader : public Shader {
+class SpatialShader : public Shader {
- OBJ_TYPE(MaterialShader,Shader);
+ OBJ_TYPE(SpatialShader,Shader);
public:
- MaterialShader() : Shader(MODE_MATERIAL) {};
+ SpatialShader() : Shader(MODE_SPATIAL) {};
};
class CanvasItemShader : public Shader {
@@ -123,15 +119,14 @@ public:
};
+class ParticlesShader : public Shader {
+
+ OBJ_TYPE(ParticlesShader,Shader);
-class ResourceFormatLoaderShader : public ResourceFormatLoader {
public:
- virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL);
- virtual void get_recognized_extensions(List<String> *p_extensions) const;
- virtual bool handles_type(const String& p_type) const;
- virtual String get_resource_type(const String &p_path) const;
-};
+ ParticlesShader() : Shader(MODE_PARTICLES) {};
+};
#endif // SHADER_H
diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp
index e019b455c0..f56aa8dbc1 100644
--- a/scene/resources/shader_graph.cpp
+++ b/scene/resources/shader_graph.cpp
@@ -29,6 +29,7 @@
#include "shader_graph.h"
#include "scene/scene_string_names.h"
+#if 0
Array ShaderGraph::_get_node_list(ShaderType p_type) const {
List<int> nodes;
@@ -2489,7 +2490,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
}
}
- Image gradient(color_ramp_len,1,0,Image::FORMAT_RGBA,cramp);
+ Image gradient(color_ramp_len,1,0,Image::FORMAT_RGBA8,cramp);
Ref<ImageTexture> it = memnew( ImageTexture );
it->create_from_image(gradient,Texture::FLAG_FILTER|Texture::FLAG_MIPMAPS);
@@ -2559,7 +2560,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
- Image gradient(curve_map_len,1,0,Image::FORMAT_GRAYSCALE,cmap);
+ Image gradient(curve_map_len,1,0,Image::FORMAT_L8,cmap);
Ref<ImageTexture> it = memnew( ImageTexture );
it->create_from_image(gradient,Texture::FLAG_FILTER|Texture::FLAG_MIPMAPS);
@@ -2660,3 +2661,5 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
#undef DEF_MATRIX
#undef DEF_VEC
}
+
+#endif
diff --git a/scene/resources/shader_graph.h b/scene/resources/shader_graph.h
index 2dfe6b66d4..c8d0d3d715 100644
--- a/scene/resources/shader_graph.h
+++ b/scene/resources/shader_graph.h
@@ -30,7 +30,7 @@
#define SHADER_GRAPH_H
-
+#if 0
#include "map.h"
#include "scene/resources/shader.h"
@@ -440,5 +440,5 @@ public:
}
};
-
+#endif
#endif // SHADER_GRAPH_H
diff --git a/scene/resources/shape.cpp b/scene/resources/shape.cpp
index 3e91fd0ead..f00443276f 100644
--- a/scene/resources/shape.cpp
+++ b/scene/resources/shape.cpp
@@ -77,7 +77,7 @@ Ref<Mesh> Shape::get_debug_mesh() {
SceneTree *st=OS::get_singleton()->get_main_loop()->cast_to<SceneTree>();
- debug_mesh_cache->add_surface(Mesh::PRIMITIVE_LINES,arr);
+ debug_mesh_cache->add_surface_from_arrays(Mesh::PRIMITIVE_LINES,arr);
if (st) {
debug_mesh_cache->surface_set_material(0,st->get_debug_collision_material());
diff --git a/scene/resources/sky_box.cpp b/scene/resources/sky_box.cpp
new file mode 100644
index 0000000000..e8017cb084
--- /dev/null
+++ b/scene/resources/sky_box.cpp
@@ -0,0 +1,158 @@
+#include "sky_box.h"
+#include "io/image_loader.h"
+
+
+void SkyBox::set_radiance_size(RadianceSize p_size) {
+ ERR_FAIL_INDEX(p_size,RADIANCE_SIZE_MAX);
+
+ radiance_size=p_size;
+ _radiance_changed();
+}
+
+SkyBox::RadianceSize SkyBox::get_radiance_size() const {
+
+ return radiance_size;
+}
+
+void SkyBox::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("set_radiance_size","size"),&SkyBox::set_radiance_size);
+ ObjectTypeDB::bind_method(_MD("get_radiance_size"),&SkyBox::get_radiance_size);
+
+ ADD_PROPERTY(PropertyInfo(Variant::INT,"radiance_size",PROPERTY_HINT_ENUM,"256,512,1024,2048"),_SCS("set_radiance_size"),_SCS("get_radiance_size"));
+
+
+ BIND_CONSTANT( RADIANCE_SIZE_256 );
+ BIND_CONSTANT( RADIANCE_SIZE_512 );
+ BIND_CONSTANT( RADIANCE_SIZE_1024 );
+ BIND_CONSTANT( RADIANCE_SIZE_2048 );
+ BIND_CONSTANT( RADIANCE_SIZE_MAX );
+}
+
+SkyBox::SkyBox()
+{
+ radiance_size=RADIANCE_SIZE_512;
+}
+
+/////////////////////////////////////////
+
+
+
+void ImageSkyBox::_radiance_changed() {
+
+ if (cube_map_valid) {
+ static const int size[RADIANCE_SIZE_MAX]={
+ 256,512,1024,2048
+ };
+ VS::get_singleton()->skybox_set_texture(sky_box,cube_map,size[get_radiance_size()]);
+ }
+}
+
+void ImageSkyBox::set_image_path(ImagePath p_image,const String &p_path) {
+
+ ERR_FAIL_INDEX(p_image,IMAGE_PATH_MAX);
+ image_path[p_image]=p_path;
+
+ bool all_ok=true;
+ for(int i=0;i<IMAGE_PATH_MAX;i++) {
+ if (image_path[i]==String()) {
+ all_ok=false;
+ }
+ }
+
+ cube_map_valid=false;
+
+ if (all_ok) {
+
+ Image images[IMAGE_PATH_MAX];
+ int w=0,h=0;
+ Image::Format format;
+
+ for(int i=0;i<IMAGE_PATH_MAX;i++) {
+ Error err = ImageLoader::load_image(image_path[i],&images[i]);
+ if (err) {
+ ERR_PRINTS("Error loading image for skybox: "+image_path[i]);
+ return;
+ }
+
+ if (i==0) {
+ w=images[0].get_width();
+ h=images[0].get_height();
+ format=images[0].get_format();
+ } else {
+ if (images[i].get_width()!=w || images[i].get_height()!=h || images[i].get_format()!=format) {
+ ERR_PRINTS("Image size mismatch ("+itos(images[i].get_width())+","+itos(images[i].get_height())+":"+Image::get_format_name(images[i].get_format())+" when it should be "+itos(w)+","+itos(h)+":"+Image::get_format_name(format)+"): "+image_path[i]);
+ return;
+ }
+ }
+ }
+
+ VS::get_singleton()->texture_allocate(cube_map,w,h,format,VS::TEXTURE_FLAG_FILTER|VS::TEXTURE_FLAG_CUBEMAP|VS::TEXTURE_FLAG_MIPMAPS);
+ for(int i=0;i<IMAGE_PATH_MAX;i++) {
+ VS::get_singleton()->texture_set_data(cube_map,images[i],VS::CubeMapSide(i));
+ }
+
+ cube_map_valid=true;
+ _radiance_changed();
+ }
+
+
+}
+
+String ImageSkyBox::get_image_path(ImagePath p_image) const {
+
+ ERR_FAIL_INDEX_V(p_image,IMAGE_PATH_MAX,String());
+ return image_path[p_image];
+
+}
+
+RID ImageSkyBox::get_rid() const {
+
+ return sky_box;
+}
+
+void ImageSkyBox::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("set_image_path","image","path"),&ImageSkyBox::set_image_path);
+ ObjectTypeDB::bind_method(_MD("get_image_path","image"),&ImageSkyBox::get_image_path);
+
+ List<String> extensions;
+ ImageLoader::get_recognized_extensions(&extensions);
+ String hints;
+ for(List<String>::Element *E=extensions.front();E;E=E->next()) {
+ if (hints!=String()) {
+ hints+=",";
+ }
+ hints+="*."+E->get();
+ }
+
+ ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path/negative_x",PROPERTY_HINT_FILE,hints),_SCS("set_image_path"),_SCS("get_image_path"),IMAGE_PATH_NEGATIVE_X);
+ ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path/positive_x",PROPERTY_HINT_FILE,hints),_SCS("set_image_path"),_SCS("get_image_path"),IMAGE_PATH_POSITIVE_X);
+ ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path/negative_y",PROPERTY_HINT_FILE,hints),_SCS("set_image_path"),_SCS("get_image_path"),IMAGE_PATH_NEGATIVE_Y);
+ ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path/positive_y",PROPERTY_HINT_FILE,hints),_SCS("set_image_path"),_SCS("get_image_path"),IMAGE_PATH_POSITIVE_Y);
+ ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path/negative_z",PROPERTY_HINT_FILE,hints),_SCS("set_image_path"),_SCS("get_image_path"),IMAGE_PATH_NEGATIVE_Z);
+ ADD_PROPERTYI(PropertyInfo(Variant::STRING,"image_path/positive_z",PROPERTY_HINT_FILE,hints),_SCS("set_image_path"),_SCS("get_image_path"),IMAGE_PATH_POSITIVE_Z);
+
+ BIND_CONSTANT( IMAGE_PATH_NEGATIVE_X );
+ BIND_CONSTANT( IMAGE_PATH_POSITIVE_X );
+ BIND_CONSTANT( IMAGE_PATH_NEGATIVE_Y );
+ BIND_CONSTANT( IMAGE_PATH_POSITIVE_Y );
+ BIND_CONSTANT( IMAGE_PATH_NEGATIVE_Z );
+ BIND_CONSTANT( IMAGE_PATH_POSITIVE_Z );
+ BIND_CONSTANT( IMAGE_PATH_MAX );
+
+}
+
+ImageSkyBox::ImageSkyBox() {
+
+ cube_map=VS::get_singleton()->texture_create();
+ sky_box=VS::get_singleton()->skybox_create();
+ cube_map_valid=false;
+}
+
+ImageSkyBox::~ImageSkyBox() {
+
+ VS::get_singleton()->free(cube_map);
+ VS::get_singleton()->free(sky_box);
+}
+
diff --git a/scene/resources/sky_box.h b/scene/resources/sky_box.h
new file mode 100644
index 0000000000..3a3dd1b2de
--- /dev/null
+++ b/scene/resources/sky_box.h
@@ -0,0 +1,71 @@
+#ifndef SKYBOX_H
+#define SKYBOX_H
+
+#include "scene/resources/texture.h"
+
+class SkyBox : public Resource {
+ OBJ_TYPE(SkyBox,Resource);
+
+public:
+
+ enum RadianceSize {
+ RADIANCE_SIZE_256,
+ RADIANCE_SIZE_512,
+ RADIANCE_SIZE_1024,
+ RADIANCE_SIZE_2048,
+ RADIANCE_SIZE_MAX
+ };
+private:
+
+ RadianceSize radiance_size;
+protected:
+ static void _bind_methods();
+ virtual void _radiance_changed()=0;
+public:
+
+ void set_radiance_size(RadianceSize p_size);
+ RadianceSize get_radiance_size() const;
+ SkyBox();
+};
+
+VARIANT_ENUM_CAST(SkyBox::RadianceSize)
+
+
+class ImageSkyBox : public SkyBox {
+ OBJ_TYPE(ImageSkyBox,SkyBox);
+
+public:
+
+ enum ImagePath {
+ IMAGE_PATH_NEGATIVE_X,
+ IMAGE_PATH_POSITIVE_X,
+ IMAGE_PATH_NEGATIVE_Y,
+ IMAGE_PATH_POSITIVE_Y,
+ IMAGE_PATH_NEGATIVE_Z,
+ IMAGE_PATH_POSITIVE_Z,
+ IMAGE_PATH_MAX
+ };
+private:
+ RID cube_map;
+ RID sky_box;
+ bool cube_map_valid;
+
+ String image_path[IMAGE_PATH_MAX];
+protected:
+ static void _bind_methods();
+ virtual void _radiance_changed();
+public:
+
+ void set_image_path(ImagePath p_image, const String &p_path);
+ String get_image_path(ImagePath p_image) const;
+
+ virtual RID get_rid() const;
+
+ ImageSkyBox();
+ ~ImageSkyBox();
+};
+
+VARIANT_ENUM_CAST(ImageSkyBox::ImagePath)
+
+
+#endif // SKYBOX_H
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index 1c708f9c11..cdb663b8f1 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -141,7 +141,7 @@ void StyleBoxTexture::draw(RID p_canvas_item,const Rect2& p_rect) const {
r.pos.y-=expand_margin[MARGIN_TOP];
r.size.x+=expand_margin[MARGIN_LEFT]+expand_margin[MARGIN_RIGHT];
r.size.y+=expand_margin[MARGIN_TOP]+expand_margin[MARGIN_BOTTOM];
- VisualServer::get_singleton()->canvas_item_add_style_box( p_canvas_item,r,region_rect,texture->get_rid(),Vector2(margin[MARGIN_LEFT],margin[MARGIN_TOP]),Vector2(margin[MARGIN_RIGHT],margin[MARGIN_BOTTOM]),draw_center,modulate);
+ VisualServer::get_singleton()->canvas_item_add_nine_patch( p_canvas_item,r,region_rect,texture->get_rid(),Vector2(margin[MARGIN_LEFT],margin[MARGIN_TOP]),Vector2(margin[MARGIN_RIGHT],margin[MARGIN_BOTTOM]),VS::NINE_PATCH_STRETCH,VS::NINE_PATCH_STRETCH,draw_center,modulate);
}
void StyleBoxTexture::set_draw_center(bool p_draw) {
@@ -423,127 +423,3 @@ StyleBoxFlat::~StyleBoxFlat() {
}
-////////////////
-
-
-
-void StyleBoxImageMask::_bind_methods() {
-
- ObjectTypeDB::bind_method(_MD("set_image","image"),&StyleBoxImageMask::set_image);
- ObjectTypeDB::bind_method(_MD("get_image"),&StyleBoxImageMask::get_image);
- ObjectTypeDB::bind_method(_MD("set_expand","expand"),&StyleBoxImageMask::set_expand);
- ObjectTypeDB::bind_method(_MD("get_expand"),&StyleBoxImageMask::get_expand);
- ObjectTypeDB::bind_method(_MD("set_expand_margin_size","margin","size"),&StyleBoxImageMask::set_expand_margin_size);
- ObjectTypeDB::bind_method(_MD("get_expand_margin_size","margin"),&StyleBoxImageMask::get_expand_margin_size);
-
- ADD_PROPERTY( PropertyInfo(Variant::IMAGE, "image"), _SCS("set_image"), _SCS("get_image"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "expand"), _SCS("set_expand"), _SCS("get_expand"));
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/left", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_LEFT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/right", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_RIGHT );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/top", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_TOP );
- ADD_PROPERTYI( PropertyInfo( Variant::REAL, "expand_margin/bottom", PROPERTY_HINT_RANGE,"0,2048,1" ), _SCS("set_expand_margin_size"),_SCS("get_expand_margin_size"), MARGIN_BOTTOM );
-
-}
-
-
-bool StyleBoxImageMask::test_mask(const Point2& p_point, const Rect2& p_rect) const {
-
- if (image.empty())
- return false;
- if (p_rect.size.x<1)
- return false;
- if (p_rect.size.y<1)
- return false;
-
- Size2i imgsize(image.get_width(),image.get_height());
- if (imgsize.x<=0 || imgsize.y<=0)
- return false;
-
- Point2i img_expand_size( imgsize.x - expand_margin[MARGIN_LEFT] - expand_margin[MARGIN_RIGHT], imgsize.y - expand_margin[MARGIN_TOP] - expand_margin[MARGIN_BOTTOM]);
- Point2i rect_expand_size( p_rect.size.x - expand_margin[MARGIN_LEFT] - expand_margin[MARGIN_RIGHT], p_rect.size.y - expand_margin[MARGIN_TOP] - expand_margin[MARGIN_BOTTOM]);
- if (rect_expand_size.x<1)
- rect_expand_size.x=1;
- if (rect_expand_size.y<1)
- rect_expand_size.y=1;
-
-
- Point2i click_pos;
-
-
- //treat x
-
- if (p_point.x<p_rect.pos.x)
- click_pos.x=0;
- else if (expand) {
-
- if (p_point.x>=p_rect.pos.x+p_rect.size.x)
- click_pos.x=imgsize.x-1;
- else if ((p_point.x-p_rect.pos.x)<expand_margin[MARGIN_LEFT])
- click_pos.x=p_point.x;
- else if ((p_point.x-(p_rect.pos.x+p_rect.size.x))<expand_margin[MARGIN_RIGHT])
- click_pos.x=imgsize.x-(p_point.x-(p_rect.pos.x+p_rect.size.x));
- else //expand
- click_pos.x=(p_point.x-p_rect.pos.x-expand_margin[MARGIN_LEFT])*img_expand_size.x/rect_expand_size.x;
- } else if ((p_point.x-p_rect.pos.x) > imgsize.x)
- click_pos.x=imgsize.x;
-
- //treat y
-
- if (p_point.y<p_rect.pos.y)
- click_pos.y=0;
- else if (expand) {
-
- if (p_point.y>=p_rect.pos.y+p_rect.size.y)
- click_pos.y=imgsize.y-1;
- else if ((p_point.y-p_rect.pos.y)<expand_margin[MARGIN_TOP])
- click_pos.y=p_point.y;
- else if ((p_point.y-(p_rect.pos.y+p_rect.size.y))<expand_margin[MARGIN_BOTTOM])
- click_pos.y=imgsize.y-(p_point.y-(p_rect.pos.y+p_rect.size.y));
- else //expand
- click_pos.y=(p_point.y-p_rect.pos.y-expand_margin[MARGIN_TOP])*img_expand_size.y/rect_expand_size.y;
- } else if ((p_point.y-p_rect.pos.y) > imgsize.y)
- click_pos.y=imgsize.y;
-
- return image.get_pixel(click_pos.x,click_pos.y).gray()>0.5;
-
-}
-
-
-void StyleBoxImageMask::set_image(const Image& p_image) {
-
- image=p_image;
-}
-Image StyleBoxImageMask::get_image() const {
-
- return image;
-}
-
-
-void StyleBoxImageMask::set_expand(bool p_expand) {
-
- expand=p_expand;
-}
-bool StyleBoxImageMask::get_expand() const {
-
- return expand;
-}
-void StyleBoxImageMask::set_expand_margin_size(Margin p_expand_margin,float p_size) {
-
- ERR_FAIL_INDEX(p_expand_margin,4);
- expand_margin[p_expand_margin]=p_size;
-}
-
-
-float StyleBoxImageMask::get_expand_margin_size(Margin p_expand_margin) const {
-
- ERR_FAIL_INDEX_V(p_expand_margin,4,0);
- return expand_margin[p_expand_margin];
-}
-
-StyleBoxImageMask::StyleBoxImageMask() {
-
- for (int i=0;i<4;i++) {
- expand_margin[i]=0;
- }
- expand=true;
-}
diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h
index e8127ee3ea..8d3ba3a360 100644
--- a/scene/resources/style_box.h
+++ b/scene/resources/style_box.h
@@ -167,35 +167,5 @@ public:
};
-class StyleBoxImageMask : public StyleBox {
-
- OBJ_TYPE( StyleBoxImageMask, StyleBox );
- virtual float get_style_margin(Margin p_margin) const { return 0; }
-
- Image image;
- float expand_margin[4];
- bool expand;
-
-protected:
-
- static void _bind_methods();
-
-public:
-
- virtual void draw(RID p_canvas_item,const Rect2& p_rect) const {}
- virtual bool test_mask(const Point2& p_point, const Rect2& p_rect) const;
-
- void set_image(const Image& p_image);
- Image get_image() const;
-
- void set_expand(bool p_expand);
- bool get_expand() const;
- void set_expand_margin_size(Margin p_expand_margin,float p_size);
- float get_expand_margin_size(Margin p_expand_margin) const;
-
- StyleBoxImageMask();
-
-};
-
#endif
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index f6147462f8..bcfacc62fa 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -355,7 +355,30 @@ Ref<Mesh> SurfaceTool::commit(const Ref<Mesh>& p_existing) {
w=DVector<Color>::Write();
a[i]=array;
} break;
- case Mesh::ARRAY_FORMAT_BONES:
+ case Mesh::ARRAY_FORMAT_BONES: {
+
+
+ DVector<int> array;
+ array.resize(varr_len*4);
+ DVector<int>::Write w = array.write();
+
+ int idx=0;
+ for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx+=4) {
+
+ const Vertex &v=E->get();
+
+ ERR_CONTINUE( v.bones.size()!=4 );
+
+ for(int j=0;j<4;j++) {
+ w[idx+j]=v.bones[j];
+ }
+
+ }
+
+ w=DVector<int>::Write();
+ a[i]=array;
+
+ } break;
case Mesh::ARRAY_FORMAT_WEIGHTS: {
@@ -367,18 +390,11 @@ Ref<Mesh> SurfaceTool::commit(const Ref<Mesh>& p_existing) {
for(List< Vertex >::Element *E=vertex_array.front();E;E=E->next(),idx+=4) {
const Vertex &v=E->get();
+ ERR_CONTINUE( v.weights.size()!=4 );
for(int j=0;j<4;j++) {
- switch(i) {
- case Mesh::ARRAY_WEIGHTS: {
- ERR_CONTINUE( v.weights.size()!=4 );
- w[idx+j]=v.weights[j];
- } break;
- case Mesh::ARRAY_BONES: {
- ERR_CONTINUE( v.bones.size()!=4 );
- w[idx+j]=v.bones[j];
- } break;
- }
+
+ w[idx+j]=v.weights[j];
}
}
@@ -410,7 +426,7 @@ Ref<Mesh> SurfaceTool::commit(const Ref<Mesh>& p_existing) {
}
- mesh->add_surface(primitive,a);
+ mesh->add_surface_from_arrays(primitive,a);
if (material.is_valid())
mesh->surface_set_material(surface,material);
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index f511e2ecef..c9c9d679b6 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -258,23 +258,13 @@ void ImageTexture::load(const String& p_path) {
void ImageTexture::set_data(const Image& p_image) {
VisualServer::get_singleton()->texture_set_data(texture,p_image);
- VisualServer::get_singleton()->texture_set_reload_hook(texture,0,StringName()); //hook is erased if data is changed
+
_change_notify();
}
void ImageTexture::_resource_path_changed() {
String path=get_path();
- if (VS::get_singleton()->has_feature(VS::FEATURE_NEEDS_RELOAD_HOOK)) {
- //this needs to be done much better, but probably will end up being deprecated as technology advances
- if (path.is_resource_file() && ImageLoader::recognize(path.extension())) {
-
- //hook is set only if path is hookable
- VisualServer::get_singleton()->texture_set_reload_hook(texture,get_instance_ID(),"_reload_hook");
- } else {
- VisualServer::get_singleton()->texture_set_reload_hook(texture,0,StringName());
- }
- }
}
Image ImageTexture::get_data() const {
@@ -300,7 +290,7 @@ RID ImageTexture::get_rid() const {
void ImageTexture::fix_alpha_edges() {
- if (format==Image::FORMAT_RGBA /*&& !(flags&FLAG_CUBEMAP)*/) {
+ if (format==Image::FORMAT_RGBA8 /*&& !(flags&FLAG_CUBEMAP)*/) {
Image img = get_data();
img.fix_alpha_edges();
@@ -310,7 +300,7 @@ void ImageTexture::fix_alpha_edges() {
void ImageTexture::premultiply_alpha() {
- if (format==Image::FORMAT_RGBA /*&& !(flags&FLAG_CUBEMAP)*/) {
+ if (format==Image::FORMAT_RGBA8 /*&& !(flags&FLAG_CUBEMAP)*/) {
Image img = get_data();
img.premultiply_alpha();
@@ -337,7 +327,7 @@ void ImageTexture::shrink_x2_and_keep_size() {
bool ImageTexture::has_alpha() const {
- return ( format==Image::FORMAT_GRAYSCALE_ALPHA || format==Image::FORMAT_INDEXED_ALPHA || format==Image::FORMAT_RGBA );
+ return ( format==Image::FORMAT_LA8 || format==Image::FORMAT_RGBA8 );
}
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index abc2939f26..945541e102 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -54,7 +54,7 @@ public:
FLAG_FILTER=VisualServer::TEXTURE_FLAG_FILTER,
FLAG_ANISOTROPIC_FILTER=VisualServer::TEXTURE_FLAG_ANISOTROPIC_FILTER,
FLAG_CONVERT_TO_LINEAR=VisualServer::TEXTURE_FLAG_CONVERT_TO_LINEAR,
- FLAG_VIDEO_SURFACE=VisualServer::TEXTURE_FLAG_VIDEO_SURFACE,
+ FLAG_VIDEO_SURFACE=VisualServer::TEXTURE_FLAG_USED_FOR_STREAMING,
FLAGS_DEFAULT=FLAG_MIPMAPS|FLAG_REPEAT|FLAG_FILTER,
FLAG_MIRRORED_REPEAT=VisualServer::TEXTURE_FLAG_MIRRORED_REPEAT
};