diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-10-29 20:48:09 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-10-29 20:48:09 -0300 |
commit | d6567010bf1c65abcbe09b959cde63664778d923 (patch) | |
tree | 5a1ec061f317770c41ece7bb378c0ab2dbb2aef4 /scene/resources | |
parent | 53d8f2b1ec1d86b189800b7fe156c464fdf9e380 (diff) | |
download | redot-engine-d6567010bf1c65abcbe09b959cde63664778d923.tar.gz |
-Many many fixes
-Gizmos work again
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/environment.cpp | 224 | ||||
-rw-r--r-- | scene/resources/environment.h | 69 | ||||
-rw-r--r-- | scene/resources/material.cpp | 69 | ||||
-rw-r--r-- | scene/resources/material.h | 16 |
4 files changed, 370 insertions, 8 deletions
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index 3897c86d5b..47f4370cc2 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -134,6 +134,151 @@ float Environment::get_ambient_light_skybox_contribution() const{ +void Environment::set_tonemapper(ToneMapper p_tone_mapper) { + + tone_mapper=p_tone_mapper; + VS::get_singleton()->environment_set_tonemap(environment,tonemap_auto_exposure,tonemap_exposure,tonemap_white,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_scale,VS::EnvironmentToneMapper(tone_mapper)); +} + +Environment::ToneMapper Environment::get_tonemapper() const{ + + return tone_mapper; +} + +void Environment::set_tonemap_exposure(float p_exposure){ + + tonemap_exposure=p_exposure; + VS::get_singleton()->environment_set_tonemap(environment,tonemap_auto_exposure,tonemap_exposure,tonemap_white,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_scale,VS::EnvironmentToneMapper(tone_mapper)); +} + +float Environment::get_tonemap_exposure() const{ + + return get_tonemap_auto_exposure(); +} + +void Environment::set_tonemap_white(float p_white){ + + tonemap_white=p_white; + VS::get_singleton()->environment_set_tonemap(environment,tonemap_auto_exposure,tonemap_exposure,tonemap_white,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_scale,VS::EnvironmentToneMapper(tone_mapper)); + +} +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,tonemap_auto_exposure,tonemap_exposure,tonemap_white,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_scale,VS::EnvironmentToneMapper(tone_mapper)); + +} +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,tonemap_auto_exposure,tonemap_exposure,tonemap_white,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_scale,VS::EnvironmentToneMapper(tone_mapper)); + +} +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,tonemap_auto_exposure,tonemap_exposure,tonemap_white,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_scale,VS::EnvironmentToneMapper(tone_mapper)); + +} +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,tonemap_auto_exposure,tonemap_exposure,tonemap_white,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_scale,VS::EnvironmentToneMapper(tone_mapper)); + +} +float Environment::get_tonemap_auto_exposure_speed() const { + + return tonemap_auto_exposure_speed; +} + +void Environment::set_tonemap_auto_exposure_scale(float p_auto_exposure_scale) { + + tonemap_auto_exposure_scale=p_auto_exposure_scale; + VS::get_singleton()->environment_set_tonemap(environment,tonemap_auto_exposure,tonemap_exposure,tonemap_white,tonemap_auto_exposure_min,tonemap_auto_exposure_max,tonemap_auto_exposure_speed,tonemap_auto_exposure_scale,VS::EnvironmentToneMapper(tone_mapper)); + +} +float Environment::get_tonemap_auto_exposure_scale() const { + + return tonemap_auto_exposure_scale; +} + +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()); + +} +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") { @@ -190,6 +335,61 @@ void Environment::_bind_methods() { 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_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_scale","exposure_scale"),&Environment::set_tonemap_auto_exposure_scale); + ObjectTypeDB::bind_method(_MD("get_tonemap_auto_exposure_scale"),&Environment::get_tonemap_auto_exposure_scale); + + ADD_PROPERTY(PropertyInfo(Variant::INT,"tonemap/mode",PROPERTY_HINT_ENUM,"Linear,Log,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/enable"),_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_scale"),_SCS("get_tonemap_auto_exposure_scale") ); + 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); @@ -203,6 +403,12 @@ void Environment::_bind_methods() { BIND_CONSTANT(GLOW_BLEND_MODE_SCREEN); BIND_CONSTANT(GLOW_BLEND_MODE_SOFTLIGHT); BIND_CONSTANT(GLOW_BLEND_MODE_DISABLED); + BIND_CONSTANT(TONE_MAPPER_LINEAR); + BIND_CONSTANT(TONE_MAPPER_LOG); + BIND_CONSTANT(TONE_MAPPER_REINHARDT); + BIND_CONSTANT(TONE_MAPPER_FILMIC); + BIND_CONSTANT(TONE_MAPPER_ACES_FILMIC); + } @@ -216,6 +422,24 @@ Environment::Environment() { 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.4; + tonemap_auto_exposure_speed=0.5; + tonemap_auto_exposure_scale=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(); } diff --git a/scene/resources/environment.h b/scene/resources/environment.h index 6478f6420f..394b67dadf 100644 --- a/scene/resources/environment.h +++ b/scene/resources/environment.h @@ -55,6 +55,16 @@ public: GLOW_BLEND_MODE_DISABLED, }; + enum ToneMapper { + TONE_MAPPER_LINEAR, + TONE_MAPPER_LOG, + TONE_MAPPER_REINHARDT, + TONE_MAPPER_FILMIC, + TONE_MAPPER_ACES_FILMIC + }; + + + private: RID environment; @@ -68,6 +78,21 @@ private: 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_scale; + + bool adjustment_enabled; + float adjustment_contrast; + float adjustment_saturation; + float adjustment_brightness; + Ref<Texture> adjustment_color_correction; + protected: static void _bind_methods(); @@ -97,14 +122,58 @@ public: 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_scale(float p_auto_exposure_scale); + float get_tonemap_auto_exposure_scale() 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; + + virtual RID get_rid() const; Environment(); ~Environment(); }; + + + VARIANT_ENUM_CAST(Environment::BGMode) VARIANT_ENUM_CAST(Environment::GlowBlendMode) +VARIANT_ENUM_CAST(Environment::ToneMapper) #endif // ENVIRONMENT_H diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index e3df1461c7..3c7b0fbe6c 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -74,6 +74,7 @@ void FixedSpatialMaterial::init_shaders() { shader_names->subsurface_scattering="subsurface_scattering"; shader_names->refraction="refraction"; shader_names->refraction_roughness="refraction_roughness"; + shader_names->point_size="point_size"; shader_names->texture_names[TEXTURE_ALBEDO]="texture_albedo"; shader_names->texture_names[TEXTURE_SPECULAR]="texture_specular"; @@ -166,15 +167,33 @@ void FixedSpatialMaterial::_update_shader() { code+="uniform vec4 albedo : hint_color;\n"; - code+="uniform sampler2D albedo_texture : hint_albedo;\n"; + code+="uniform sampler2D texture_albedo : hint_albedo;\n"; code+="uniform vec4 specular : hint_color;\n"; code+="uniform float roughness : hint_range(0,1);\n"; - code+="uniform sampler2D specular_texture : hint_white;\n"; + code+="uniform float point_size : hint_range(0,128);\n"; + code+="uniform sampler2D texture_specular : 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+="}\n"; code+="\n\n"; code+="void fragment() {\n"; - code+="\tvec4 albedo_tex = texture(albedo_texture,UV);\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"; @@ -184,7 +203,7 @@ void FixedSpatialMaterial::_update_shader() { if (features[FEATURE_TRANSPARENT]) { code+="\tALPHA = albedo.a * albedo_tex.a;\n"; } - code+="\tvec4 specular_tex = texture(specular_texture,UV);\n"; + code+="\tvec4 specular_tex = texture(texture_specular,UV);\n"; code+="\tSPECULAR = specular.rgb * specular_tex.rgb;\n"; code+="\tROUGHNESS = specular.a * roughness;\n"; code+="}\n"; @@ -526,7 +545,8 @@ void FixedSpatialMaterial::set_texture(TextureParam p_param, const Ref<Texture> ERR_FAIL_INDEX(p_param,TEXTURE_MAX); textures[p_param]=p_texture; - VS::get_singleton()->material_set_param(_get_material(),shader_names->texture_names[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 { @@ -540,6 +560,7 @@ void FixedSpatialMaterial::_validate_feature(const String& text, Feature feature if (property.name.begins_with(text) && property.name!=text+"/enabled" && !features[feature]) { property.usage=0; } + } void FixedSpatialMaterial::_validate_property(PropertyInfo& property) const { @@ -555,6 +576,28 @@ void FixedSpatialMaterial::_validate_property(PropertyInfo& property) const { } +void FixedSpatialMaterial::set_line_width(float p_line_width) { + + line_width=p_line_width; + VS::get_singleton()->material_set_line_width(_get_material(),line_width); +} + +float FixedSpatialMaterial::get_line_width() const { + + return line_width; +} + +void FixedSpatialMaterial::set_point_size(float p_point_size) { + + 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 { + + return point_size; +} + void FixedSpatialMaterial::_bind_methods() { @@ -600,6 +643,12 @@ void FixedSpatialMaterial::_bind_methods() { 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); @@ -630,12 +679,16 @@ void FixedSpatialMaterial::_bind_methods() { 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/vcol_albedo"),_SCS("set_flag"),_SCS("get_flag"),FLAG_ALBEDO_FROM_VERTEX_COLOR); + 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); @@ -737,6 +790,8 @@ void FixedSpatialMaterial::_bind_methods() { 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 ); @@ -763,6 +818,8 @@ FixedSpatialMaterial::FixedSpatialMaterial() : element(this) { set_subsurface_scattering(0); set_refraction(0); set_refraction_roughness(0); + set_line_width(1); + set_point_size(1); detail_uv=DETAIL_UV_1; blend_mode=BLEND_MODE_MIX; diff --git a/scene/resources/material.h b/scene/resources/material.h index 0f0bf48025..35f01d4756 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -132,6 +132,8 @@ public: FLAG_UNSHADED, FLAG_ONTOP, FLAG_ALBEDO_FROM_VERTEX_COLOR, + FLAG_SRGB_VERTEX_COLOR, + FLAG_USE_POINT_SIZE, FLAG_MAX }; @@ -146,12 +148,12 @@ private: union MaterialKey { struct { - uint32_t feature_mask : 16; + uint32_t feature_mask : 15; uint32_t detail_uv : 1; uint32_t blend_mode : 2; uint32_t depth_draw_mode : 2; uint32_t cull_mode : 2; - uint32_t flags : 3; + uint32_t flags : 5; uint32_t detail_blend_mode : 2; uint32_t diffuse_mode : 2; uint32_t invalid_key : 1; @@ -213,7 +215,9 @@ private: StringName subsurface_scattering; StringName refraction; StringName refraction_roughness; + StringName point_size; StringName texture_names[TEXTURE_MAX]; + }; static Mutex *material_mutex; @@ -240,6 +244,8 @@ private: float subsurface_scattering; float refraction; float refraction_roughness; + float line_width; + float point_size; DetailUV detail_uv; @@ -306,6 +312,12 @@ public: void set_refraction_roughness(float p_refraction_roughness); float get_refraction_roughness() const; + void set_line_width(float p_line_width); + float get_line_width() const; + + void set_point_size(float p_point_size); + float get_point_size() const; + void set_detail_uv(DetailUV p_detail_uv); DetailUV get_detail_uv() const; |