From ef44e2515782749ccc1b6fdb94061f69692fa02a Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 21 Feb 2009 18:36:50 +0000 Subject: [PATCH] Fix shader generator bug when no diffuse defined --- panda/src/pgraphnodes/shaderGenerator.cxx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index 16467d8fda..7068549041 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -645,7 +645,7 @@ synthesize_shader(const RenderState *rs) { text << "\t lcolor = alight_alight" << i << ";\n"; if (_separate_ambient_diffuse && _have_ambient) { text << "\t tot_ambient += lcolor;\n"; - } else { + } else if(_have_diffuse) { text << "\t tot_diffuse += lcolor;\n"; } } @@ -655,7 +655,9 @@ synthesize_shader(const RenderState *rs) { text << "\t lspec = dlight_dlight" << i << "_rel_view[1];\n"; text << "\t lvec = dlight_dlight" << i << "_rel_view[2];\n"; text << "\t lcolor *= saturate(dot(l_normal, lvec.xyz));\n"; - text << "\t tot_diffuse += lcolor;\n"; + if (_have_diffuse) { + text << "\t tot_diffuse += lcolor;\n"; + } if (_have_specular) { if (_material->get_local()) { text << "\t lhalf = normalize(lvec - normalize(l_pos));\n"; @@ -677,7 +679,9 @@ synthesize_shader(const RenderState *rs) { text << "\t lvec /= ldist;\n"; text << "\t lattenv = 1/(latten.x + latten.y*ldist + latten.z*ldist*ldist);\n"; text << "\t lcolor *= lattenv * saturate(dot(l_normal, lvec.xyz));\n"; - text << "\t tot_diffuse += lcolor;\n"; + if (_have_diffuse) { + text << "\t tot_diffuse += lcolor;\n"; + } if (_have_specular) { if (_material->get_local()) { text << "\t lhalf = normalize(lvec - normalize(l_pos));\n"; @@ -704,7 +708,9 @@ synthesize_shader(const RenderState *rs) { text << "\t lattenv *= pow(langle, latten.w);\n"; text << "\t if (langle < ldir.w) lattenv = 0;\n"; text << "\t lcolor *= lattenv * saturate(dot(l_normal, lvec.xyz));\n"; - text << "\t tot_diffuse += lcolor;\n"; + if (_have_diffuse) { + text << "\t tot_diffuse += lcolor;\n"; + } if (_have_specular) { if (_material->get_local()) { text << "\t lhalf = normalize(lvec - normalize(l_pos));\n";