mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
Don't rely on color fregs, they have unintended side-effects. Also, don't use up unnecessary registers when texgen is enabled.
This commit is contained in:
parent
b781547956
commit
56577ec08a
@ -132,10 +132,12 @@ alloc_freg() {
|
|||||||
case 6: _ftregs_used += 1; return (char*)"TEXCOORD6";
|
case 6: _ftregs_used += 1; return (char*)"TEXCOORD6";
|
||||||
case 7: _ftregs_used += 1; return (char*)"TEXCOORD7";
|
case 7: _ftregs_used += 1; return (char*)"TEXCOORD7";
|
||||||
}
|
}
|
||||||
switch (_fcregs_used) {
|
// We really shouldn't rely on COLOR fregs,
|
||||||
case 0: _fcregs_used += 1; return (char*)"COLOR0";
|
// since the clamping can have unexpected side-effects.
|
||||||
case 1: _fcregs_used += 1; return (char*)"COLOR1";
|
//switch (_fcregs_used) {
|
||||||
}
|
//case 0: _fcregs_used += 1; return (char*)"COLOR0";
|
||||||
|
//case 1: _fcregs_used += 1; return (char*)"COLOR1";
|
||||||
|
//}
|
||||||
// These don't exist in arbvp1/arbfp1, though they're
|
// These don't exist in arbvp1/arbfp1, though they're
|
||||||
// reportedly supported by other profiles.
|
// reportedly supported by other profiles.
|
||||||
switch (_ftregs_used) {
|
switch (_ftregs_used) {
|
||||||
@ -655,12 +657,15 @@ synthesize_shader(const RenderState *rs) {
|
|||||||
text << "void vshader(\n";
|
text << "void vshader(\n";
|
||||||
const TextureAttrib *texture = DCAST(TextureAttrib, rs->get_attrib_def(TextureAttrib::get_class_slot()));
|
const TextureAttrib *texture = DCAST(TextureAttrib, rs->get_attrib_def(TextureAttrib::get_class_slot()));
|
||||||
const TexGenAttrib *tex_gen = DCAST(TexGenAttrib, rs->get_attrib_def(TexGenAttrib::get_class_slot()));
|
const TexGenAttrib *tex_gen = DCAST(TexGenAttrib, rs->get_attrib_def(TexGenAttrib::get_class_slot()));
|
||||||
for (int i=0; i<_num_textures; i++) {
|
for (int i = 0; i < _num_textures; ++i) {
|
||||||
|
TextureStage *stage = texture->get_on_stage(i);
|
||||||
|
if (!tex_gen->has_stage(stage)) {
|
||||||
texcoord_vreg.push_back(alloc_vreg());
|
texcoord_vreg.push_back(alloc_vreg());
|
||||||
texcoord_freg.push_back(alloc_freg());
|
texcoord_freg.push_back(alloc_freg());
|
||||||
text << "\t in float4 vtx_texcoord" << i << " : " << texcoord_vreg[i] << ",\n";
|
text << "\t in float4 vtx_texcoord" << i << " : " << texcoord_vreg[i] << ",\n";
|
||||||
text << "\t out float4 l_texcoord" << i << " : " << texcoord_freg[i] << ",\n";
|
text << "\t out float4 l_texcoord" << i << " : " << texcoord_freg[i] << ",\n";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (_vertex_colors) {
|
if (_vertex_colors) {
|
||||||
text << "\t in float4 vtx_color : COLOR0,\n";
|
text << "\t in float4 vtx_color : COLOR0,\n";
|
||||||
text << "\t out float4 l_color : COLOR0,\n";
|
text << "\t out float4 l_color : COLOR0,\n";
|
||||||
@ -763,7 +768,7 @@ synthesize_shader(const RenderState *rs) {
|
|||||||
text << "\t l_eye_normal.xyz = mul((float3x3)tpose_view_to_model, vtx_normal.xyz);\n";
|
text << "\t l_eye_normal.xyz = mul((float3x3)tpose_view_to_model, vtx_normal.xyz);\n";
|
||||||
text << "\t l_eye_normal.w = 0;\n";
|
text << "\t l_eye_normal.w = 0;\n";
|
||||||
}
|
}
|
||||||
for (int i=0; i<_num_textures; i++) {
|
for (int i = 0; i < _num_textures; ++i) {
|
||||||
if (!tex_gen->has_stage(texture->get_on_stage(i))) {
|
if (!tex_gen->has_stage(texture->get_on_stage(i))) {
|
||||||
text << "\t l_texcoord" << i << " = vtx_texcoord" << i << ";\n";
|
text << "\t l_texcoord" << i << " = vtx_texcoord" << i << ";\n";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user