mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
Add roughness and metallic to p3d_Material struct
This commit is contained in:
parent
f4f7df9949
commit
1d098b0099
@ -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());
|
||||
|
@ -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") {
|
||||
|
@ -194,6 +194,9 @@ public:
|
||||
|
||||
SMO_inv_texmat_i,
|
||||
|
||||
// Additional properties for PBR materials
|
||||
SMO_attr_material2,
|
||||
|
||||
SMO_INVALID
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user