Added triplanar mapping, toon mode, and more specular modes for materials. Added multipass support for materials.
This commit is contained in:
parent
0067982f5e
commit
f4c8c552f9
|
@ -1879,6 +1879,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
|
|||
|
||||
glBindBufferBase(GL_UNIFORM_BUFFER, 0, state.scene_ubo); //bind globals ubo
|
||||
|
||||
bool use_radiance_map = false;
|
||||
if (!p_shadow && !p_directional_add) {
|
||||
glBindBufferBase(GL_UNIFORM_BUFFER, 2, state.env_radiance_ubo); //bind environment radiance info
|
||||
|
||||
|
@ -1892,6 +1893,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
|
|||
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP, true);
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP_ARRAY, storage->config.use_texture_array_environment);
|
||||
use_radiance_map = true;
|
||||
} else {
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP, false);
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP_ARRAY, false);
|
||||
|
@ -1966,6 +1968,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
|
|||
state.scene_shader.set_conditional(SceneShaderGLES3::SHADOW_MODE_PCF_5, false);
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::SHADOW_MODE_PCF_13, false);
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::USE_GI_PROBES, false);
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP, false);
|
||||
|
||||
//state.scene_shader.set_conditional(SceneShaderGLES3::SHADELESS,true);
|
||||
} else {
|
||||
|
@ -1981,6 +1984,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
|
|||
state.scene_shader.set_conditional(SceneShaderGLES3::LIGHT_USE_PSSM_BLEND, false);
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::SHADOW_MODE_PCF_5, shadow_filter_mode == SHADOW_FILTER_PCF5);
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::SHADOW_MODE_PCF_13, shadow_filter_mode == SHADOW_FILTER_PCF13);
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::USE_RADIANCE_MAP, use_radiance_map);
|
||||
|
||||
if (p_directional_add || (directional_light && (e->sort_key & SORT_KEY_NO_DIRECTIONAL_FLAG) == 0)) {
|
||||
state.scene_shader.set_conditional(SceneShaderGLES3::USE_LIGHT_DIRECTIONAL, true);
|
||||
|
@ -2163,7 +2167,19 @@ void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geo
|
|||
|
||||
ERR_FAIL_COND(!m);
|
||||
|
||||
bool has_base_alpha = (m->shader->spatial.uses_alpha || m->shader->spatial.uses_screen_texture);
|
||||
_add_geometry_with_material(p_geometry, p_instance, p_owner, m, p_shadow);
|
||||
|
||||
while (m->next_pass.is_valid()) {
|
||||
m = storage->material_owner.getornull(m->next_pass);
|
||||
if (!m)
|
||||
break;
|
||||
_add_geometry_with_material(p_geometry, p_instance, p_owner, m, p_shadow);
|
||||
}
|
||||
}
|
||||
|
||||
void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *m, bool p_shadow) {
|
||||
|
||||
bool has_base_alpha = (m->shader->spatial.uses_alpha || m->shader->spatial.uses_screen_texture || m->shader->spatial.unshaded);
|
||||
bool has_blend_alpha = m->shader->spatial.blend_mode != RasterizerStorageGLES3::Shader::Spatial::BLEND_MODE_MIX || m->shader->spatial.ontop;
|
||||
bool has_alpha = has_base_alpha || has_blend_alpha;
|
||||
bool shadow = false;
|
||||
|
|
|
@ -769,6 +769,8 @@ public:
|
|||
|
||||
_FORCE_INLINE_ void _add_geometry(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, int p_material, bool p_shadow);
|
||||
|
||||
_FORCE_INLINE_ void _add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *p_material, bool p_shadow);
|
||||
|
||||
void _draw_sky(RasterizerStorageGLES3::Sky *p_sky, const CameraMatrix &p_projection, const Transform &p_transform, bool p_vflip, float p_scale, float p_energy);
|
||||
|
||||
void _setup_environment(Environment *env, const CameraMatrix &p_cam_projection, const Transform &p_cam_transform);
|
||||
|
|
|
@ -1870,6 +1870,14 @@ void RasterizerStorageGLES3::material_set_line_width(RID p_material, float p_wid
|
|||
material->line_width = p_width;
|
||||
}
|
||||
|
||||
void RasterizerStorageGLES3::material_set_next_pass(RID p_material, RID p_next_material) {
|
||||
|
||||
Material *material = material_owner.get(p_material);
|
||||
ERR_FAIL_COND(!material);
|
||||
|
||||
material->next_pass = p_next_material;
|
||||
}
|
||||
|
||||
bool RasterizerStorageGLES3::material_is_animated(RID p_material) {
|
||||
|
||||
Material *material = material_owner.get(p_material);
|
||||
|
@ -1878,7 +1886,11 @@ bool RasterizerStorageGLES3::material_is_animated(RID p_material) {
|
|||
_update_material(material);
|
||||
}
|
||||
|
||||
return material->is_animated_cache;
|
||||
bool animated = material->is_animated_cache;
|
||||
if (!animated && material->next_pass.is_valid()) {
|
||||
animated = material_is_animated(material->next_pass);
|
||||
}
|
||||
return animated;
|
||||
}
|
||||
bool RasterizerStorageGLES3::material_casts_shadows(RID p_material) {
|
||||
|
||||
|
@ -1888,7 +1900,13 @@ bool RasterizerStorageGLES3::material_casts_shadows(RID p_material) {
|
|||
_update_material(material);
|
||||
}
|
||||
|
||||
return material->can_cast_shadow_cache;
|
||||
bool casts_shadows = material->can_cast_shadow_cache;
|
||||
|
||||
if (!casts_shadows && material->next_pass.is_valid()) {
|
||||
casts_shadows = material_casts_shadows(material->next_pass);
|
||||
}
|
||||
|
||||
return casts_shadows;
|
||||
}
|
||||
|
||||
void RasterizerStorageGLES3::material_add_instance_owner(RID p_material, RasterizerScene::InstanceBase *p_instance) {
|
||||
|
|
|
@ -496,6 +496,8 @@ public:
|
|||
Vector<RID> textures;
|
||||
float line_width;
|
||||
|
||||
RID next_pass;
|
||||
|
||||
uint32_t index;
|
||||
uint64_t last_pass;
|
||||
|
||||
|
@ -533,6 +535,7 @@ public:
|
|||
virtual Variant material_get_param(RID p_material, const StringName &p_param) const;
|
||||
|
||||
virtual void material_set_line_width(RID p_material, float p_width);
|
||||
virtual void material_set_next_pass(RID p_material, RID p_next_material);
|
||||
|
||||
virtual bool material_is_animated(RID p_material);
|
||||
virtual bool material_casts_shadows(RID p_material);
|
||||
|
|
|
@ -791,6 +791,11 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
|
|||
actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_burley"] = "#define DIFFUSE_BURLEY\n";
|
||||
actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_oren_nayar"] = "#define DIFFUSE_OREN_NAYAR\n";
|
||||
actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_half_lambert"] = "#define DIFFUSE_HALF_LAMBERT\n";
|
||||
actions[VS::SHADER_SPATIAL].render_mode_defines["diffuse_toon"] = "#define DIFFUSE_TOON\n";
|
||||
|
||||
actions[VS::SHADER_SPATIAL].render_mode_defines["specular_blinn"] = "#define SPECULAR_BLINN\n";
|
||||
actions[VS::SHADER_SPATIAL].render_mode_defines["specular_phong"] = "#define SPECULAR_PHONG\n";
|
||||
actions[VS::SHADER_SPATIAL].render_mode_defines["specular_toon"] = "#define SPECULAR_TOON\n";
|
||||
|
||||
/* PARTICLES SHADER */
|
||||
|
||||
|
|
|
@ -204,7 +204,9 @@ vec4 textureDualParaboloidArray(vec3 normal) {
|
|||
vec3 norm = normalize(normal);
|
||||
norm.xy/=1.0+abs(norm.z);
|
||||
norm.xy=norm.xy * vec2(0.5,0.25) + vec2(0.5,0.25);
|
||||
norm.y+=max(0.0,sign(-norm.z))*0.5;
|
||||
if (norm.z<0) {
|
||||
norm.y=0.5-norm.y+0.5;
|
||||
}
|
||||
return textureLod(source_dual_paraboloid_array, vec3(norm.xy, float(source_array_index) ), 0.0);
|
||||
|
||||
}
|
||||
|
|
|
@ -775,6 +775,10 @@ LIGHT_SHADER_CODE
|
|||
diffuse += diffuse_color * max(0.0, NdotL) * (A + vec3(B) * s / t) / M_PI;
|
||||
}
|
||||
|
||||
#elif defined(DIFFUSE_TOON)
|
||||
|
||||
diffuse += smoothstep(-roughness,roughness,dot(N,L)) * light_color * diffuse_color;
|
||||
|
||||
#elif defined(DIFFUSE_BURLEY)
|
||||
|
||||
{
|
||||
|
@ -805,6 +809,34 @@ LIGHT_SHADER_CODE
|
|||
|
||||
if (roughness > 0.0) {
|
||||
|
||||
|
||||
// D
|
||||
|
||||
#if defined(SPECULAR_BLINN)
|
||||
|
||||
vec3 H = normalize(V + L);
|
||||
float dotNH = max(dot(N,H), 0.0 );
|
||||
float intensity = pow( dotNH, (1.0-roughness) * 256.0);
|
||||
specular += light_color * intensity;
|
||||
|
||||
#elif defined(SPECULAR_PHONG)
|
||||
|
||||
vec3 R = normalize(-reflect(L,N));
|
||||
float dotNV = max(0.0,dot(R,V));
|
||||
float intensity = pow( dotNV, (1.0-roughness) * 256.0);
|
||||
specular += light_color * intensity;
|
||||
|
||||
#elif defined(SPECULAR_TOON)
|
||||
|
||||
vec3 R = normalize(-reflect(L,N));
|
||||
float dotNV = dot(R,V);
|
||||
float mid = 1.0-roughness;
|
||||
float intensity = smoothstep(mid-roughness*0.5,mid+roughness*0.5,dotNV);
|
||||
diffuse += light_color * intensity; //write to diffuse, as in toon shading you generally want no reflection
|
||||
|
||||
|
||||
#else
|
||||
// shlick+ggx as default
|
||||
float alpha = roughness * roughness;
|
||||
|
||||
vec3 H = normalize(V + L);
|
||||
|
@ -812,7 +844,6 @@ LIGHT_SHADER_CODE
|
|||
float dotNH = max(dot(N,H), 0.0 );
|
||||
float dotLH = max(dot(L,H), 0.0 );
|
||||
|
||||
// D
|
||||
#if defined(LIGHT_USE_ANISOTROPY)
|
||||
|
||||
float aspect = sqrt(1.0-anisotropy*0.9);
|
||||
|
@ -844,6 +875,7 @@ LIGHT_SHADER_CODE
|
|||
float speci = dotNL * D * F * vis;
|
||||
|
||||
specular += speci * light_color * specular_blob_intensity;
|
||||
#endif
|
||||
|
||||
#if defined(LIGHT_USE_CLEARCOAT)
|
||||
float Dr = GTR1(dotNH, mix(.1,.001,clearcoat_gloss));
|
||||
|
@ -1686,7 +1718,7 @@ FRAGMENT_SHADER_CODE
|
|||
float ndotv = clamp(dot(normal,eye_vec),0.0,1.0);
|
||||
|
||||
//energy conservation
|
||||
vec3 dielectric = vec3(0.034) * 0.5 * 2.0;
|
||||
vec3 dielectric = vec3(0.034) * specular * 2.0;
|
||||
vec3 f0 = mix(dielectric, albedo, metallic);
|
||||
const vec4 c0 = vec4(-1.0, -0.0275, -0.572, 0.022);
|
||||
const vec4 c1 = vec4( 1.0, 0.0425, 1.04, -0.04);
|
||||
|
|
|
@ -30,11 +30,36 @@
|
|||
#include "material.h"
|
||||
#include "scene/scene_string_names.h"
|
||||
|
||||
void Material::set_next_pass(const Ref<Material> &p_pass) {
|
||||
|
||||
if (next_pass == p_pass)
|
||||
return;
|
||||
|
||||
next_pass = p_pass;
|
||||
RID next_pass_rid;
|
||||
if (next_pass.is_valid())
|
||||
next_pass_rid = next_pass->get_rid();
|
||||
VS::get_singleton()->material_set_next_pass(material, next_pass_rid);
|
||||
}
|
||||
|
||||
Ref<Material> Material::get_next_pass() const {
|
||||
|
||||
return next_pass;
|
||||
}
|
||||
|
||||
RID Material::get_rid() const {
|
||||
|
||||
return material;
|
||||
}
|
||||
|
||||
void Material::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_next_pass", "next_pass:Material"), &Material::set_next_pass);
|
||||
ClassDB::bind_method(D_METHOD("get_next_pass:Material"), &Material::get_next_pass);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "next_pass", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_next_pass", "get_next_pass");
|
||||
}
|
||||
|
||||
Material::Material() {
|
||||
|
||||
material = VisualServer::get_singleton()->material_create();
|
||||
|
@ -207,6 +232,8 @@ void SpatialMaterial::init_shaders() {
|
|||
shader_names->depth_min_layers = "depth_min_layers";
|
||||
shader_names->depth_max_layers = "depth_max_layers";
|
||||
|
||||
shader_names->grow = "grow";
|
||||
|
||||
shader_names->texture_names[TEXTURE_ALBEDO] = "texture_albedo";
|
||||
shader_names->texture_names[TEXTURE_METALLIC] = "texture_metallic";
|
||||
shader_names->texture_names[TEXTURE_ROUGHNESS] = "texture_roughness";
|
||||
|
@ -291,6 +318,13 @@ void SpatialMaterial::_update_shader() {
|
|||
case DIFFUSE_HALF_LAMBERT: code += ",diffuse_half_lambert"; break;
|
||||
case DIFFUSE_OREN_NAYAR: code += ",diffuse_oren_nayar"; break;
|
||||
case DIFFUSE_BURLEY: code += ",diffuse_burley"; break;
|
||||
case DIFFUSE_TOON: code += ",diffuse_toon"; break;
|
||||
}
|
||||
switch (specular_mode) {
|
||||
case SPECULAR_SCHLICK_GGX: code += ",specular_schlick_ggx"; break;
|
||||
case SPECULAR_BLINN: code += ",specular_blinn"; break;
|
||||
case SPECULAR_PHONG: code += ",specular_phong"; break;
|
||||
case SPECULAR_TOON: code += ",specular_toon"; break;
|
||||
}
|
||||
|
||||
if (flags[FLAG_UNSHADED]) {
|
||||
|
@ -309,6 +343,9 @@ void SpatialMaterial::_update_shader() {
|
|||
code += "uniform sampler2D texture_albedo : hint_albedo;\n";
|
||||
code += "uniform float specular;\n";
|
||||
code += "uniform float metallic;\n";
|
||||
if (grow_enabled) {
|
||||
code += "uniform float grow;\n";
|
||||
}
|
||||
|
||||
code += "uniform float roughness : hint_range(0,1);\n";
|
||||
code += "uniform float point_size : hint_range(0,128);\n";
|
||||
|
@ -492,6 +529,10 @@ void SpatialMaterial::_update_shader() {
|
|||
code += "\tuv2_world_pos *= vec3(1.0,-1.0, 1.0);\n";
|
||||
}
|
||||
|
||||
if (grow_enabled) {
|
||||
code += "\tVERTEX+=NORMAL*grow;\n";
|
||||
}
|
||||
|
||||
code += "}\n";
|
||||
code += "\n\n";
|
||||
if (flags[FLAG_UV1_USE_TRIPLANAR] || flags[FLAG_UV2_USE_TRIPLANAR]) {
|
||||
|
@ -642,7 +683,7 @@ void SpatialMaterial::_update_shader() {
|
|||
} else {
|
||||
code += "\tvec3 anisotropy_tex = texture(texture_flowmap,base_uv).rga;\n";
|
||||
}
|
||||
code += "\tANISOTROPY = anisotropy_ratio*anisotropy_tex.a;\n";
|
||||
code += "\tANISOTROPY = anisotropy_ratio*anisotropy_tex.b;\n";
|
||||
code += "\tANISOTROPY_FLOW = anisotropy_tex.rg*2.0-1.0;\n";
|
||||
}
|
||||
|
||||
|
@ -1003,6 +1044,19 @@ SpatialMaterial::DiffuseMode SpatialMaterial::get_diffuse_mode() const {
|
|||
return diffuse_mode;
|
||||
}
|
||||
|
||||
void SpatialMaterial::set_specular_mode(SpecularMode p_mode) {
|
||||
|
||||
if (specular_mode == p_mode)
|
||||
return;
|
||||
|
||||
specular_mode = p_mode;
|
||||
_queue_shader_change();
|
||||
}
|
||||
SpatialMaterial::SpecularMode SpatialMaterial::get_specular_mode() const {
|
||||
|
||||
return specular_mode;
|
||||
}
|
||||
|
||||
void SpatialMaterial::set_flag(Flags p_flag, bool p_enabled) {
|
||||
|
||||
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
|
||||
|
@ -1075,6 +1129,10 @@ void SpatialMaterial::_validate_property(PropertyInfo &property) const {
|
|||
if (property.name.begins_with("particles_anim_") && billboard_mode != BILLBOARD_PARTICLES) {
|
||||
property.usage = 0;
|
||||
}
|
||||
|
||||
if (property.name == "params_grow_amount" && !grow_enabled) {
|
||||
property.usage = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void SpatialMaterial::set_line_width(float p_line_width) {
|
||||
|
@ -1240,6 +1298,26 @@ int SpatialMaterial::get_depth_deep_parallax_max_layers() const {
|
|||
return deep_parallax_max_layers;
|
||||
}
|
||||
|
||||
void SpatialMaterial::set_grow_enabled(bool p_enable) {
|
||||
grow_enabled = p_enable;
|
||||
_queue_shader_change();
|
||||
_change_notify();
|
||||
}
|
||||
|
||||
bool SpatialMaterial::is_grow_enabled() const {
|
||||
return grow_enabled;
|
||||
}
|
||||
|
||||
void SpatialMaterial::set_grow(float p_grow) {
|
||||
grow = p_grow;
|
||||
VS::get_singleton()->material_set_param(_get_material(), shader_names->grow, p_grow);
|
||||
}
|
||||
|
||||
float SpatialMaterial::get_grow() const {
|
||||
|
||||
return grow;
|
||||
}
|
||||
|
||||
void SpatialMaterial::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_albedo", "albedo"), &SpatialMaterial::set_albedo);
|
||||
|
@ -1308,6 +1386,9 @@ void SpatialMaterial::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_diffuse_mode", "diffuse_mode"), &SpatialMaterial::set_diffuse_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_diffuse_mode"), &SpatialMaterial::get_diffuse_mode);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_specular_mode", "specular_mode"), &SpatialMaterial::set_specular_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_specular_mode"), &SpatialMaterial::get_specular_mode);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_flag", "flag", "enable"), &SpatialMaterial::set_flag);
|
||||
ClassDB::bind_method(D_METHOD("get_flag"), &SpatialMaterial::get_flag);
|
||||
|
||||
|
@ -1359,6 +1440,12 @@ void SpatialMaterial::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_depth_deep_parallax_max_layers", "layer"), &SpatialMaterial::set_depth_deep_parallax_max_layers);
|
||||
ClassDB::bind_method(D_METHOD("get_depth_deep_parallax_max_layers"), &SpatialMaterial::get_depth_deep_parallax_max_layers);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_grow", "amount"), &SpatialMaterial::set_grow);
|
||||
ClassDB::bind_method(D_METHOD("get_grow"), &SpatialMaterial::get_grow);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_grow_enabled", "enable"), &SpatialMaterial::set_grow_enabled);
|
||||
ClassDB::bind_method(D_METHOD("is_grow_enabled"), &SpatialMaterial::is_grow_enabled);
|
||||
|
||||
ADD_GROUP("Flags", "flags_");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_transparent"), "set_feature", "get_feature", FEATURE_TRANSPARENT);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_unshaded"), "set_flag", "get_flag", FLAG_UNSHADED);
|
||||
|
@ -1370,13 +1457,16 @@ void SpatialMaterial::_bind_methods() {
|
|||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "vertex_color_is_srgb"), "set_flag", "get_flag", FLAG_SRGB_VERTEX_COLOR);
|
||||
|
||||
ADD_GROUP("Parameters", "params_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "params_diffuse_mode", PROPERTY_HINT_ENUM, "Lambert,Lambert Wrap,Oren Nayar,Burley"), "set_diffuse_mode", "get_diffuse_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "params_diffuse_mode", PROPERTY_HINT_ENUM, "Lambert,Lambert Wrap,Oren Nayar,Burley,Toon"), "set_diffuse_mode", "get_diffuse_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "params_specular_mode", PROPERTY_HINT_ENUM, "SchlickGGX,Blinn,Phong,Toon"), "set_specular_mode", "get_specular_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "params_blend_mode", PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul"), "set_blend_mode", "get_blend_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "params_cull_mode", PROPERTY_HINT_ENUM, "Back,Front,Disabled"), "set_cull_mode", "get_cull_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "params_depth_draw_mode", PROPERTY_HINT_ENUM, "Opaque Only,Always,Never,Opaque Pre-Pass"), "set_depth_draw_mode", "get_depth_draw_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "params_line_width", PROPERTY_HINT_RANGE, "0.1,128,0.1"), "set_line_width", "get_line_width");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "params_point_size", PROPERTY_HINT_RANGE, "0.1,128,0.1"), "set_point_size", "get_point_size");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "params_billboard_mode", PROPERTY_HINT_ENUM, "Disabled,Enabled,Y-Billboard,Particle Billboard"), "set_billboard_mode", "get_billboard_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "params_grow"), "set_grow_enabled", "is_grow_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "params_grow_amount", PROPERTY_HINT_RANGE, "-16,10,0.01"), "set_grow", "get_grow");
|
||||
ADD_GROUP("Particles Anim", "particles_anim_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "particles_anim_h_frames", PROPERTY_HINT_RANGE, "1,128,1"), "set_particles_anim_h_frames", "get_particles_anim_h_frames");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "particles_anim_v_frames", PROPERTY_HINT_RANGE, "1,128,1"), "set_particles_anim_v_frames", "get_particles_anim_v_frames");
|
||||
|
@ -1458,13 +1548,13 @@ void SpatialMaterial::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "uv1_scale"), "set_uv1_scale", "get_uv1_scale");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "uv1_offset"), "set_uv1_offset", "get_uv1_offset");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "uv1_triplanar"), "set_flag", "get_flag", FLAG_UV1_USE_TRIPLANAR);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "uv1_triplanar_sharpness"), "set_uv1_triplanar_blend_sharpness", "get_uv1_triplanar_blend_sharpness");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "uv1_triplanar_sharpness", PROPERTY_HINT_EXP_EASING), "set_uv1_triplanar_blend_sharpness", "get_uv1_triplanar_blend_sharpness");
|
||||
|
||||
ADD_GROUP("UV2", "uv2_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "uv2_scale"), "set_uv2_scale", "get_uv2_scale");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "uv2_offset"), "set_uv2_offset", "get_uv2_offset");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "uv2_triplanar"), "set_flag", "get_flag", FLAG_UV2_USE_TRIPLANAR);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "uv2_triplanar_sharpness"), "set_uv2_triplanar_blend_sharpness", "get_uv2_triplanar_blend_sharpness");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "uv2_triplanar_sharpness", PROPERTY_HINT_EXP_EASING), "set_uv2_triplanar_blend_sharpness", "get_uv2_triplanar_blend_sharpness");
|
||||
|
||||
BIND_CONSTANT(TEXTURE_ALBEDO);
|
||||
BIND_CONSTANT(TEXTURE_METALLIC);
|
||||
|
@ -1525,6 +1615,12 @@ void SpatialMaterial::_bind_methods() {
|
|||
BIND_CONSTANT(DIFFUSE_HALF_LAMBERT);
|
||||
BIND_CONSTANT(DIFFUSE_OREN_NAYAR);
|
||||
BIND_CONSTANT(DIFFUSE_BURLEY);
|
||||
BIND_CONSTANT(DIFFUSE_TOON);
|
||||
|
||||
BIND_CONSTANT(SPECULAR_SCHLICK_GGX);
|
||||
BIND_CONSTANT(SPECULAR_BLINN);
|
||||
BIND_CONSTANT(SPECULAR_PHONG);
|
||||
BIND_CONSTANT(SPECULAR_TOON);
|
||||
|
||||
BIND_CONSTANT(BILLBOARD_DISABLED);
|
||||
BIND_CONSTANT(BILLBOARD_ENABLED);
|
||||
|
@ -1564,6 +1660,9 @@ SpatialMaterial::SpatialMaterial()
|
|||
set_particles_anim_v_frames(1);
|
||||
set_particles_anim_loop(false);
|
||||
|
||||
grow_enabled = false;
|
||||
set_grow(0.0);
|
||||
|
||||
deep_parallax = false;
|
||||
set_depth_deep_parallax_min_layers(8);
|
||||
set_depth_deep_parallax_max_layers(32);
|
||||
|
@ -1577,6 +1676,7 @@ SpatialMaterial::SpatialMaterial()
|
|||
flags[i] = 0;
|
||||
}
|
||||
diffuse_mode = DIFFUSE_LAMBERT;
|
||||
specular_mode = SPECULAR_SCHLICK_GGX;
|
||||
|
||||
for (int i = 0; i < FEATURE_MAX; i++) {
|
||||
features[i] = false;
|
||||
|
|
|
@ -47,11 +47,16 @@ class Material : public Resource {
|
|||
OBJ_SAVE_TYPE(Material)
|
||||
|
||||
RID material;
|
||||
Ref<Material> next_pass;
|
||||
|
||||
protected:
|
||||
_FORCE_INLINE_ RID _get_material() const { return material; }
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void set_next_pass(const Ref<Material> &p_pass);
|
||||
Ref<Material> get_next_pass() const;
|
||||
|
||||
virtual RID get_rid() const;
|
||||
Material();
|
||||
virtual ~Material();
|
||||
|
@ -166,6 +171,14 @@ public:
|
|||
DIFFUSE_HALF_LAMBERT,
|
||||
DIFFUSE_OREN_NAYAR,
|
||||
DIFFUSE_BURLEY,
|
||||
DIFFUSE_TOON,
|
||||
};
|
||||
|
||||
enum SpecularMode {
|
||||
SPECULAR_SCHLICK_GGX,
|
||||
SPECULAR_BLINN,
|
||||
SPECULAR_PHONG,
|
||||
SPECULAR_TOON,
|
||||
};
|
||||
|
||||
enum BillboardMode {
|
||||
|
@ -186,10 +199,12 @@ private:
|
|||
uint64_t cull_mode : 2;
|
||||
uint64_t flags : 9;
|
||||
uint64_t detail_blend_mode : 2;
|
||||
uint64_t diffuse_mode : 2;
|
||||
uint64_t diffuse_mode : 3;
|
||||
uint64_t specular_mode : 2;
|
||||
uint64_t invalid_key : 1;
|
||||
uint64_t deep_parallax : 1;
|
||||
uint64_t billboard_mode : 2;
|
||||
uint64_t grow : 1;
|
||||
};
|
||||
|
||||
uint64_t key;
|
||||
|
@ -228,9 +243,10 @@ private:
|
|||
}
|
||||
mk.detail_blend_mode = detail_blend_mode;
|
||||
mk.diffuse_mode = diffuse_mode;
|
||||
mk.specular_mode = specular_mode;
|
||||
mk.billboard_mode = billboard_mode;
|
||||
mk.deep_parallax = deep_parallax ? 1 : 0;
|
||||
;
|
||||
mk.grow = grow_enabled;
|
||||
|
||||
return mk;
|
||||
}
|
||||
|
@ -263,6 +279,7 @@ private:
|
|||
StringName depth_max_layers;
|
||||
StringName uv1_blend_sharpness;
|
||||
StringName uv2_blend_sharpness;
|
||||
StringName grow;
|
||||
|
||||
StringName texture_names[TEXTURE_MAX];
|
||||
};
|
||||
|
@ -294,6 +311,8 @@ private:
|
|||
float refraction;
|
||||
float line_width;
|
||||
float point_size;
|
||||
bool grow_enabled;
|
||||
float grow;
|
||||
int particles_anim_h_frames;
|
||||
int particles_anim_v_frames;
|
||||
bool particles_anim_loop;
|
||||
|
@ -317,6 +336,7 @@ private:
|
|||
DepthDrawMode depth_draw_mode;
|
||||
CullMode cull_mode;
|
||||
bool flags[FLAG_MAX];
|
||||
SpecularMode specular_mode;
|
||||
DiffuseMode diffuse_mode;
|
||||
BillboardMode billboard_mode;
|
||||
|
||||
|
@ -409,6 +429,9 @@ public:
|
|||
void set_diffuse_mode(DiffuseMode p_mode);
|
||||
DiffuseMode get_diffuse_mode() const;
|
||||
|
||||
void set_specular_mode(SpecularMode p_mode);
|
||||
SpecularMode get_specular_mode() const;
|
||||
|
||||
void set_flag(Flags p_flag, bool p_enabled);
|
||||
bool get_flag(Flags p_flag) const;
|
||||
|
||||
|
@ -447,6 +470,12 @@ public:
|
|||
void set_particles_anim_loop(int p_frames);
|
||||
int get_particles_anim_loop() const;
|
||||
|
||||
void set_grow_enabled(bool p_enable);
|
||||
bool is_grow_enabled() const;
|
||||
|
||||
void set_grow(float p_grow);
|
||||
float get_grow() const;
|
||||
|
||||
static void init_shaders();
|
||||
static void finish_shaders();
|
||||
static void flush_changes();
|
||||
|
@ -463,6 +492,7 @@ VARIANT_ENUM_CAST(SpatialMaterial::DepthDrawMode)
|
|||
VARIANT_ENUM_CAST(SpatialMaterial::CullMode)
|
||||
VARIANT_ENUM_CAST(SpatialMaterial::Flags)
|
||||
VARIANT_ENUM_CAST(SpatialMaterial::DiffuseMode)
|
||||
VARIANT_ENUM_CAST(SpatialMaterial::SpecularMode)
|
||||
VARIANT_ENUM_CAST(SpatialMaterial::BillboardMode)
|
||||
|
||||
//////////////////////
|
||||
|
|
|
@ -225,6 +225,8 @@ public:
|
|||
|
||||
virtual void material_set_line_width(RID p_material, float p_width) = 0;
|
||||
|
||||
virtual void material_set_next_pass(RID p_material, RID p_next_material) = 0;
|
||||
|
||||
virtual bool material_is_animated(RID p_material) = 0;
|
||||
virtual bool material_casts_shadows(RID p_material) = 0;
|
||||
|
||||
|
|
|
@ -136,6 +136,12 @@ ShaderTypes::ShaderTypes() {
|
|||
shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_half_lambert");
|
||||
shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_oren_nayar");
|
||||
shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_burley");
|
||||
shader_modes[VS::SHADER_SPATIAL].modes.insert("diffuse_toon");
|
||||
|
||||
shader_modes[VS::SHADER_SPATIAL].modes.insert("specular_schlick_ggx");
|
||||
shader_modes[VS::SHADER_SPATIAL].modes.insert("specular_blinn");
|
||||
shader_modes[VS::SHADER_SPATIAL].modes.insert("specular_phong");
|
||||
shader_modes[VS::SHADER_SPATIAL].modes.insert("specular_toon");
|
||||
|
||||
shader_modes[VS::SHADER_SPATIAL].modes.insert("skip_vertex_transform");
|
||||
shader_modes[VS::SHADER_SPATIAL].modes.insert("world_vertex_coords");
|
||||
|
|
|
@ -685,6 +685,7 @@ public:
|
|||
BIND2RC(Variant, material_get_param, RID, const StringName &)
|
||||
|
||||
BIND2(material_set_line_width, RID, float)
|
||||
BIND2(material_set_next_pass, RID, RID)
|
||||
|
||||
/* MESH API */
|
||||
|
||||
|
|
|
@ -129,6 +129,7 @@ public:
|
|||
FUNC2RC(Variant, material_get_param, RID, const StringName &)
|
||||
|
||||
FUNC2(material_set_line_width, RID, float)
|
||||
FUNC2(material_set_next_pass, RID, RID)
|
||||
|
||||
/* MESH API */
|
||||
|
||||
|
|
|
@ -177,6 +177,7 @@ public:
|
|||
virtual Variant material_get_param(RID p_material, const StringName &p_param) const = 0;
|
||||
|
||||
virtual void material_set_line_width(RID p_material, float p_width) = 0;
|
||||
virtual void material_set_next_pass(RID p_material, RID p_next_material) = 0;
|
||||
|
||||
/* MESH API */
|
||||
|
||||
|
|
Loading…
Reference in New Issue