[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54175] branches/ge_harmony/source/blender /gpu/shaders/gpu_shader_light_frag.glsl: Using preprocessor directives to remove the material based branching from gpu_shader_light_frag .glsl.

Daniel Stokes kupomail at gmail.com
Tue Jan 29 05:26:14 CET 2013


Revision: 54175
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54175
Author:   kupoman
Date:     2013-01-29 04:26:05 +0000 (Tue, 29 Jan 2013)
Log Message:
-----------
Using preprocessor directives to remove the material based branching from gpu_shader_light_frag.glsl. This leaves the inferred lighting to only use lambert and phong shading by default, however the previous functionality of multiple shader types is still possible by using the custom shader UI. This simpler shader performs better.

Modified Paths:
--------------
    branches/ge_harmony/source/blender/gpu/shaders/gpu_shader_light_frag.glsl

Modified: branches/ge_harmony/source/blender/gpu/shaders/gpu_shader_light_frag.glsl
===================================================================
--- branches/ge_harmony/source/blender/gpu/shaders/gpu_shader_light_frag.glsl	2013-01-29 03:42:19 UTC (rev 54174)
+++ branches/ge_harmony/source/blender/gpu/shaders/gpu_shader_light_frag.glsl	2013-01-29 04:26:05 UTC (rev 54175)
@@ -1,3 +1,6 @@
+//#define ALL_SHADERS
+
+
 #define SPOT	0
 #define SUN		1
 #define HEMI	2
@@ -111,17 +114,23 @@
 	}
 	
 	attenuation = (attenuation < 0.001) ? 0.0 : attenuation;
+	
+#ifdef ALL_SHADERS
 	int matid = int(gbuffer.a)*65535;
 	int diff_shader = matid / 16;
 	int spec_shader = matid - (diff_shader*16);
+#endif
 	
 	// Diffuse term
 	float diff_term = 0.0;
+#ifdef ALL_SHADERS
 	float diff_param1 = mbuffer.r * 10.0;
 	float diff_param2 = mbuffer.g * 10.0;
+#endif
 	float lambert = max(dot(N, L), 0.0);
 	if (light.type == HEMI)
 		diff_term = 0.5*lambert + 0.5;
+#ifdef ALL_SHADERS
 	else if (diff_shader == DIFF_LAMBERT)
 		diff_term = lambert;
 	else if (diff_shader == DIFF_ORENNAYAR)
@@ -132,13 +141,20 @@
 		shade_diffuse_minnaert(lambert, N, V, diff_param1, diff_term);
 	else if (diff_shader == DIFF_FRESNEL)
 		shade_diffuse_fresnel(N, L, V, diff_param1, diff_param2, diff_term);
+#else
+	else
+		diff_term = lambert;
+#endif
 	
 	// Specular term
 	float hardness = exp(LN_511 * mbuffer.b);
+#ifdef ALL_SHADERS
 	float spec_param = mbuffer.a * 10.0;
+#endif
 	float spec_term = 0.0;
 	if (light.type == HEMI)
 		shade_hemi_spec(N, L, view, 1.0, hardness, 1.0, spec_term);
+#ifdef ALL_SHADERS
 	else if (spec_shader == SPEC_PHONG)
 		shade_phong_spec(N, L, view, hardness, spec_term);
 	else if (spec_shader == SPEC_COOKTORR)
@@ -152,6 +168,10 @@
 		hardness = mbuffer.b * 10.0;
 		shade_toon_spec(N, L, view, hardness, spec_param, spec_term);
 	}
+#else
+	else
+		shade_phong_spec(N, L, view, 1.0, hardness);
+#endif
 	
 	// Factor in light properties
 	vec3 diff = light.color * light.energy * diff_term * attenuation;




More information about the Bf-blender-cvs mailing list