mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 00:32:57 -04:00
ShaderGenerator: fix updating color of combine stages with CS_constant
This also changes the function of TextureStage::uses_color(), which no longer incorporate TextureStage::involves_color_scale() Fixes: #177
This commit is contained in:
parent
51d948a7fa
commit
0db3d27247
@ -4438,7 +4438,7 @@ set_texture_blend_mode(int i, const TextureStage *stage) {
|
|||||||
set_texture_stage_state(i, D3DTSS_RESULTARG, D3DTA_CURRENT);
|
set_texture_stage_state(i, D3DTSS_RESULTARG, D3DTA_CURRENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stage->uses_color()) {
|
if (stage->uses_color() || stage->involves_color_scale()) {
|
||||||
// Set up the constant color for this stage.
|
// Set up the constant color for this stage.
|
||||||
|
|
||||||
D3DCOLOR constant_color;
|
D3DCOLOR constant_color;
|
||||||
|
@ -658,8 +658,7 @@ update_color_flags() {
|
|||||||
_combine_alpha_source2 == CS_constant_color_scale)));
|
_combine_alpha_source2 == CS_constant_color_scale)));
|
||||||
|
|
||||||
_uses_color =
|
_uses_color =
|
||||||
(_involves_color_scale ||
|
(_mode == M_blend ||
|
||||||
_mode == M_blend ||
|
|
||||||
(_mode == M_combine &&
|
(_mode == M_combine &&
|
||||||
(_combine_rgb_source0 == CS_constant ||
|
(_combine_rgb_source0 == CS_constant ||
|
||||||
_combine_rgb_source1 == CS_constant ||
|
_combine_rgb_source1 == CS_constant ||
|
||||||
|
@ -424,6 +424,11 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) {
|
|||||||
info._stage = stage;
|
info._stage = stage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Does this stage need a texcolor_# input?
|
||||||
|
if (stage->uses_color()) {
|
||||||
|
info._flags |= ShaderKey::TF_uses_color;
|
||||||
|
}
|
||||||
|
|
||||||
key._textures.push_back(info);
|
key._textures.push_back(info);
|
||||||
key._texture_flags |= info._flags;
|
key._texture_flags |= info._flags;
|
||||||
}
|
}
|
||||||
@ -827,7 +832,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) {
|
|||||||
text << "\t uniform float4x4 texmat_" << i << ",\n";
|
text << "\t uniform float4x4 texmat_" << i << ",\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tex._mode == TextureStage::M_blend) {
|
if (tex._flags & ShaderKey::TF_uses_color) {
|
||||||
text << "\t uniform float4 texcolor_" << i << ",\n";
|
text << "\t uniform float4 texcolor_" << i << ",\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1562,10 +1567,9 @@ combine_source_as_string(CPT(TextureStage) stage, short num, bool alpha, bool si
|
|||||||
case TextureStage::CS_texture:
|
case TextureStage::CS_texture:
|
||||||
csource << "tex" << texindex;
|
csource << "tex" << texindex;
|
||||||
break;
|
break;
|
||||||
case TextureStage::CS_constant: {
|
case TextureStage::CS_constant:
|
||||||
LVecBase4 c = stage->get_color();
|
csource << "texcolor_" << texindex;
|
||||||
csource << "float4(" << c[0] << ", " << c[1] << ", " << c[2] << ", " << c[3] << ")";
|
break;
|
||||||
break; }
|
|
||||||
case TextureStage::CS_primary_color:
|
case TextureStage::CS_primary_color:
|
||||||
csource << "primary_color";
|
csource << "primary_color";
|
||||||
break;
|
break;
|
||||||
|
@ -110,6 +110,7 @@ protected:
|
|||||||
TF_map_height = 64,
|
TF_map_height = 64,
|
||||||
TF_map_glow = 128,
|
TF_map_glow = 128,
|
||||||
TF_map_gloss = 256,
|
TF_map_gloss = 256,
|
||||||
|
TF_uses_color = 512,
|
||||||
};
|
};
|
||||||
|
|
||||||
ColorAttrib::Type _color_type;
|
ColorAttrib::Type _color_type;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user