[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11787] branches/soc-2007-maike/release/ glsl/light_calc.gsl: lights[N]. layer determines if the light will be used or not, changed the code to conditional execution instead of multiplying for that value as was done before improving efficiency
Miguel Torres Lima
torreslima at gmail.com
Wed Aug 22 18:21:48 CEST 2007
Revision: 11787
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11787
Author: maike
Date: 2007-08-22 18:21:48 +0200 (Wed, 22 Aug 2007)
Log Message:
-----------
lights[N].layer determines if the light will be used or not, changed the code to conditional execution instead of multiplying for that value as was done before improving efficiency
Modified Paths:
--------------
branches/soc-2007-maike/release/glsl/light_calc.gsl
Modified: branches/soc-2007-maike/release/glsl/light_calc.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/light_calc.gsl 2007-08-22 16:18:41 UTC (rev 11786)
+++ branches/soc-2007-maike/release/glsl/light_calc.gsl 2007-08-22 16:21:48 UTC (rev 11787)
@@ -1,63 +1,67 @@
#ifdef LIGHT_ID
-vis = VISIBILITY(lights[LIGHT_ID]);
+if(lights[LIGHT_ID].layer > 0.0 )
+ vis = VISIBILITY(lights[LIGHT_ID]);
#endif
#ifdef CALC_DIFFUSE
#ifdef LIGHT_ID
+if(lights[LIGHT_ID].layer > 0.0){
#ifdef DIFF_CB_TYPE
#ifdef HEMI
-rslt1 = DIFF_SHADER_ID(lights[LIGHT_ID], norm);
+ rslt1 = DIFF_SHADER_ID(lights[LIGHT_ID], norm);
#else
-rslt1 = DIFF_SHADER_ID(lights[LIGHT_ID], norm, diff2, diff3);
+ rslt1 = DIFF_SHADER_ID(lights[LIGHT_ID], norm, diff2, diff3);
#endif
#if DIFF_CB_TYPE == 0
-diff_fac = rslt1;
+ diff_fac = rslt1;
#else
#if DIFF_CB_TYPE == 1
-diff_fac = (0.3 * lights[LIGHT_ID].color.r + 0.58 * lights[LIGHT_ID].color.g + 0.12 * lights[LIGHT_ID].color.b) * vis * rslt1 * (lights[LIGHT_ID].energy * diff1);
+ diff_fac = (0.3 * lights[LIGHT_ID].color.r + 0.58 * lights[LIGHT_ID].color.g + 0.12 * lights[LIGHT_ID].color.b) * vis * rslt1 * (lights[LIGHT_ID].energy * diff1);
#else
-diff_fac = dot(normalize((eye - pos)), normalize(normal));
+ diff_fac = dot(normalize((eye - pos)), normalize(normal));
#endif
#endif
-diff_cb = texture1D(DIFF_CB_TEX, clamp(diff_fac, 0.000, 0.999));
-diff_rslt += DIFF_CB_BLEND_FUNC(diff_cb.rgb, diff_color, DIFF_CB_FAC * diff_cb.a) * rslt1 * diff1 * vec3(lights[LIGHT_ID].color) * lights[LIGHT_ID].layer * vis * lights[LIGHT_ID].energy;
+ diff_cb = texture1D(DIFF_CB_TEX, clamp(diff_fac, 0.000, 0.999));
+ diff_rslt += DIFF_CB_BLEND_FUNC(diff_cb.rgb, diff_color, DIFF_CB_FAC * diff_cb.a) * rslt1 * diff1 * vec3(lights[LIGHT_ID].color) * vis * lights[LIGHT_ID].energy;
#else
#ifdef HEMI
-diff_rslt+= (DIFF_SHADER_ID(lights[LIGHT_ID], norm) * diff1 * diff_color * vec3(lights[LIGHT_ID].color) * lights[LIGHT_ID].layer * lights[LIGHT_ID].energy * vis);
+ diff_rslt+= (DIFF_SHADER_ID(lights[LIGHT_ID], norm) * diff1 * diff_color * vec3(lights[LIGHT_ID].color) * lights[LIGHT_ID].energy * vis);
#else
-diff_rslt+= (DIFF_SHADER_ID(lights[LIGHT_ID], norm, diff2, diff3) * diff1 * diff_color * vec3(lights[LIGHT_ID].color) * lights[LIGHT_ID].layer * lights[LIGHT_ID].energy * vis);
+ diff_rslt+= (DIFF_SHADER_ID(lights[LIGHT_ID], norm, diff2, diff3) * diff1 * diff_color * vec3(lights[LIGHT_ID].color) * lights[LIGHT_ID].energy * vis);
#endif
#endif
+ }
#endif
#endif
#ifdef CALC_SPECULAR
#ifdef LIGHT_ID
-
+if(lights[LIGHT_ID].layer > 0.0){
#ifdef HEMI
-spec_rslt+= SPEC_SHADER_ID(lights[LIGHT_ID], norm, hard) * spec1 * spec_color * vec3(lights[LIGHT_ID].color) * lights[LIGHT_ID].layer * lights[LIGHT_ID].energy * vis;
+ spec_rslt+= SPEC_SHADER_ID(lights[LIGHT_ID], norm, hard) * spec1 * spec_color * vec3(lights[LIGHT_ID].color) * lights[LIGHT_ID].energy * vis;
#else
-rslt2 = SPEC_SHADER_ID(lights[LIGHT_ID], norm, spec2, spec3);
+ rslt2 = SPEC_SHADER_ID(lights[LIGHT_ID], norm, spec2, spec3);
#ifdef AREA
-rslt2 *= area_energy(lights[LIGHT_ID], norm);
+ rslt2 *= area_energy(lights[LIGHT_ID], norm);
#endif
#ifdef SPEC_CB_TYPE
#if SPEC_CB_TYPE == 0
-spec_fac = rslt2;
+ spec_fac = rslt2;
#else
#if SPEC_CB_TYPE == 1
-spec_fac = spec1 * vis * rslt2;
+ spec_fac = spec1 * vis * rslt2;
#else
-spec_fac = dot(normalize(eye - pos), normalize(normal));
+ spec_fac = dot(normalize(eye - pos), normalize(normal));
#endif
#endif
-spec_cb = texture1D(SPEC_CB_TEX, clamp(spec_fac, 0.0, 0.999));
-spec_rslt += SPEC_CB_BLEND_FUNC(spec_cb.rgb, spec_color, SPEC_CB_FAC * spec_cb.a) * rslt2 * spec1 * lights[LIGHT_ID].layer * vec3(lights[LIGHT_ID].color) * lights[LIGHT_ID].energy * vis;
+ spec_cb = texture1D(SPEC_CB_TEX, clamp(spec_fac, 0.0, 0.999));
+ spec_rslt += SPEC_CB_BLEND_FUNC(spec_cb.rgb, spec_color, SPEC_CB_FAC * spec_cb.a) * rslt2 * spec1 * vec3(lights[LIGHT_ID].color) * lights[LIGHT_ID].energy * vis;
#else
-spec_rslt+= rslt2 * spec1 * spec_color * vec3(lights[LIGHT_ID].color) * lights[LIGHT_ID].layer * lights[LIGHT_ID].energy * vis;
+ spec_rslt+= rslt2 * spec1 * spec_color * vec3(lights[LIGHT_ID].color) * lights[LIGHT_ID].energy * vis;
#endif
#endif
+ }
#endif
#endif
More information about the Bf-blender-cvs
mailing list