mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
support color gain
This commit is contained in:
parent
c2f3a412dd
commit
05b08da109
@ -37,6 +37,8 @@
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
MayaShaderColorDef::
|
MayaShaderColorDef::
|
||||||
MayaShaderColorDef() {
|
MayaShaderColorDef() {
|
||||||
|
_color_gain.set(1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
_has_flat_color = false;
|
_has_flat_color = false;
|
||||||
_flat_color.set(0.0, 0.0, 0.0, 0.0);
|
_flat_color.set(0.0, 0.0, 0.0, 0.0);
|
||||||
|
|
||||||
@ -137,7 +139,8 @@ write(ostream &out) const {
|
|||||||
<< " wrap_v is " << _wrap_v << "\n"
|
<< " wrap_v is " << _wrap_v << "\n"
|
||||||
<< " repeat_uv is " << _repeat_uv << "\n"
|
<< " repeat_uv is " << _repeat_uv << "\n"
|
||||||
<< " offset is " << _offset << "\n"
|
<< " offset is " << _offset << "\n"
|
||||||
<< " rotate_uv is " << _rotate_uv << "\n";
|
<< " rotate_uv is " << _rotate_uv << "\n"
|
||||||
|
<< " color_gain is " << _color_gain << "\n";
|
||||||
|
|
||||||
} else if (_has_flat_color) {
|
} else if (_has_flat_color) {
|
||||||
out << " flat color is " << _flat_color << "\n";
|
out << " flat color is " << _flat_color << "\n";
|
||||||
@ -179,6 +182,13 @@ reset_maya_texture(const Filename &texture) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void MayaShaderColorDef::
|
void MayaShaderColorDef::
|
||||||
read_surface_color(MObject color) {
|
read_surface_color(MObject color) {
|
||||||
|
RGBColorf color_gain;
|
||||||
|
if (get_vec3f_attribute(color, "colorGain", color_gain)) {
|
||||||
|
_color_gain[0] *= color_gain[0];
|
||||||
|
_color_gain[1] *= color_gain[1];
|
||||||
|
_color_gain[2] *= color_gain[2];
|
||||||
|
}
|
||||||
|
|
||||||
if (color.hasFn(MFn::kFileTexture)) {
|
if (color.hasFn(MFn::kFileTexture)) {
|
||||||
_color_object = new MObject(color);
|
_color_object = new MObject(color);
|
||||||
string filename;
|
string filename;
|
||||||
|
@ -58,6 +58,7 @@ public:
|
|||||||
|
|
||||||
bool _has_texture;
|
bool _has_texture;
|
||||||
Filename _texture;
|
Filename _texture;
|
||||||
|
RGBColorf _color_gain;
|
||||||
|
|
||||||
bool _has_flat_color;
|
bool _has_flat_color;
|
||||||
Colord _flat_color;
|
Colord _flat_color;
|
||||||
|
@ -172,6 +172,43 @@ get_vec2f_attribute(MObject &node, const string &attribute_name,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: get_vec3f_attribute
|
||||||
|
// Description: Extracts the named three-component vector from the
|
||||||
|
// MObject.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool
|
||||||
|
get_vec3f_attribute(MObject &node, const string &attribute_name,
|
||||||
|
LVecBase3f &value) {
|
||||||
|
MStatus status;
|
||||||
|
|
||||||
|
MObject vec3f_object;
|
||||||
|
if (!get_maya_attribute(node, attribute_name, vec3f_object)) {
|
||||||
|
maya_cat.error()
|
||||||
|
<< "Attribute " << attribute_name
|
||||||
|
<< " does not have a vec3f object value.\n";
|
||||||
|
describe_maya_attribute(node, attribute_name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
MFnNumericData data(vec3f_object, &status);
|
||||||
|
if (!status) {
|
||||||
|
maya_cat.error()
|
||||||
|
<< "Attribute " << attribute_name << " is of type "
|
||||||
|
<< vec3f_object.apiTypeStr() << ", not a NumericData.\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = data.getData(value[0], value[1], value[2]);
|
||||||
|
if (!status) {
|
||||||
|
maya_cat.error()
|
||||||
|
<< "Unable to extract 3 floats from " << attribute_name
|
||||||
|
<< ", of type " << vec3f_object.apiTypeStr() << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: get_vec2d_attribute
|
// Function: get_vec2d_attribute
|
||||||
// Description: Extracts the named two-component vector from the
|
// Description: Extracts the named two-component vector from the
|
||||||
|
@ -63,6 +63,10 @@ bool
|
|||||||
get_vec2f_attribute(MObject &node, const string &attribute_name,
|
get_vec2f_attribute(MObject &node, const string &attribute_name,
|
||||||
LVecBase2f &value);
|
LVecBase2f &value);
|
||||||
|
|
||||||
|
bool
|
||||||
|
get_vec3f_attribute(MObject &node, const string &attribute_name,
|
||||||
|
LVecBase3f &value);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
get_vec2d_attribute(MObject &node, const string &attribute_name,
|
get_vec2d_attribute(MObject &node, const string &attribute_name,
|
||||||
LVecBase2d &value);
|
LVecBase2d &value);
|
||||||
|
@ -1940,6 +1940,11 @@ set_shader_attributes(EggPrimitive &primitive, const MayaShader &shader) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// But the color gain always gets applied.
|
||||||
|
rgba[0] *= color_def._color_gain[0];
|
||||||
|
rgba[1] *= color_def._color_gain[1];
|
||||||
|
rgba[2] *= color_def._color_gain[2];
|
||||||
|
|
||||||
primitive.set_color(rgba);
|
primitive.set_color(rgba);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user