Force update SpatialMaterial when texture set and always use ALBEDO

This commit is contained in:
clayjohn 2019-11-02 17:42:36 -07:00
parent 033ae8a543
commit 21e1f1df0f

View file

@ -476,9 +476,7 @@ void SpatialMaterial::_update_shader() {
code += ";\n";
code += "uniform vec4 albedo : hint_color;\n";
if (textures[TEXTURE_ALBEDO] != NULL) {
code += "uniform sampler2D texture_albedo : hint_albedo;\n";
}
code += "uniform float specular;\n";
code += "uniform float metallic;\n";
if (grow_enabled) {
@ -781,7 +779,6 @@ void SpatialMaterial::_update_shader() {
code += "\t}\n";
}
if (textures[TEXTURE_ALBEDO] != NULL) {
if (flags[FLAG_USE_POINT_SIZE]) {
code += "\tvec4 albedo_tex = texture(texture_albedo,POINT_COORD);\n";
} else {
@ -795,9 +792,6 @@ void SpatialMaterial::_update_shader() {
if (flags[FLAG_ALBEDO_TEXTURE_FORCE_SRGB]) {
code += "\talbedo_tex.rgb = mix(pow((albedo_tex.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)),vec3(2.4)),albedo_tex.rgb.rgb * (1.0 / 12.92),lessThan(albedo_tex.rgb,vec3(0.04045)));\n";
}
} else {
code += "\tvec4 albedo_tex = vec4(1.0, 1.0, 1.0, 1.0);\n";
}
if (flags[FLAG_ALBEDO_FROM_VERTEX_COLOR]) {
code += "\talbedo_tex *= COLOR;\n";
@ -1411,6 +1405,8 @@ void SpatialMaterial::set_texture(TextureParam p_param, const Ref<Texture> &p_te
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);
_queue_shader_change();
_change_notify();
}
Ref<Texture> SpatialMaterial::get_texture(TextureParam p_param) const {