Add roughness and metallic to p3d_Material struct

This commit is contained in:
rdb 2016-01-01 11:36:09 +01:00
parent f4f7df9949
commit 1d098b0099
3 changed files with 36 additions and 0 deletions

View File

@ -1067,6 +1067,17 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name,
spc[0],spc[1],spc[2],spc[3]);
return &t;
}
case Shader::SMO_attr_material2: {
const MaterialAttrib *target_material = (const MaterialAttrib *)
_target_rs->get_attrib_def(MaterialAttrib::get_class_slot());
if (target_material->is_off()) {
t = LMatrix4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
return &t;
}
Material *m = target_material->get_material();
t.set_row(3, LVecBase4(m->get_metallic(), 0, 0, m->get_roughness()));
return &t;
}
case Shader::SMO_attr_color: {
const ColorAttrib *target_color = (const ColorAttrib *)
_target_rs->get_attrib_def(ColorAttrib::get_class_slot());

View File

@ -954,6 +954,28 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) {
_shader->_mat_spec.push_back(bind);
_shader->_mat_deps |= bind._dep[0];
return;
} else if (noprefix == "Material.roughness") {
if (param_type != GL_FLOAT) {
GLCAT.error()
<< "p3d_Material.roughness should be float\n";
}
bind._part[0] = Shader::SMO_attr_material2;
bind._piece = Shader::SMP_cell15;
_shader->_mat_spec.push_back(bind);
_shader->_mat_deps |= bind._dep[0];
return;
} else if (noprefix == "Material.metallic") {
if (param_type != GL_FLOAT && param_type != GL_BOOL) {
GLCAT.error()
<< "p3d_Material.metallic should be bool or float\n";
}
bind._part[0] = Shader::SMO_attr_material2;
bind._piece = Shader::SMP_row3x1;
_shader->_mat_spec.push_back(bind);
_shader->_mat_deps |= bind._dep[0];
return;
}
}
if (noprefix == "ColorScale") {

View File

@ -194,6 +194,9 @@ public:
SMO_inv_texmat_i,
// Additional properties for PBR materials
SMO_attr_material2,
SMO_INVALID
};