[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11047] branches/soc-2007-maike/release: Glsl generic function files

Miguel Torres Lima torreslima at gmail.com
Mon Jun 25 20:02:13 CEST 2007


Revision: 11047
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11047
Author:   maike
Date:     2007-06-25 20:02:12 +0200 (Mon, 25 Jun 2007)

Log Message:
-----------
Glsl generic function files

Added Paths:
-----------
    branches/soc-2007-maike/release/glsl/
    branches/soc-2007-maike/release/glsl/area_visibility.gsl
    branches/soc-2007-maike/release/glsl/blinn.gsl
    branches/soc-2007-maike/release/glsl/blinn_hemi.gsl
    branches/soc-2007-maike/release/glsl/blinn_sun.gsl
    branches/soc-2007-maike/release/glsl/cooktorr.gsl
    branches/soc-2007-maike/release/glsl/cooktorr_hemi.gsl
    branches/soc-2007-maike/release/glsl/cooktorr_sun.gsl
    branches/soc-2007-maike/release/glsl/difftoon.gsl
    branches/soc-2007-maike/release/glsl/difftoon_hemi.gsl
    branches/soc-2007-maike/release/glsl/difftoon_sun.gsl
    branches/soc-2007-maike/release/glsl/fragment_shader.gsl
    branches/soc-2007-maike/release/glsl/fresnel.gsl
    branches/soc-2007-maike/release/glsl/fresnel_hemi.gsl
    branches/soc-2007-maike/release/glsl/fresnel_sun.gsl
    branches/soc-2007-maike/release/glsl/hemi_visibility.gsl
    branches/soc-2007-maike/release/glsl/lambert.gsl
    branches/soc-2007-maike/release/glsl/lambert_hemi.gsl
    branches/soc-2007-maike/release/glsl/lambert_sun.gsl
    branches/soc-2007-maike/release/glsl/lamp_visibility.gsl
    branches/soc-2007-maike/release/glsl/light_calc.gsl
    branches/soc-2007-maike/release/glsl/light_struct.gsl
    branches/soc-2007-maike/release/glsl/material.gsl
    branches/soc-2007-maike/release/glsl/material_return.gsl
    branches/soc-2007-maike/release/glsl/material_uniforms.gsl
    branches/soc-2007-maike/release/glsl/minnaert.gsl
    branches/soc-2007-maike/release/glsl/minnaert_hemi.gsl
    branches/soc-2007-maike/release/glsl/minnaert_sun.gsl
    branches/soc-2007-maike/release/glsl/orennayar.gsl
    branches/soc-2007-maike/release/glsl/orennayar_hemi.gsl
    branches/soc-2007-maike/release/glsl/orennayar_sun.gsl
    branches/soc-2007-maike/release/glsl/phong.gsl
    branches/soc-2007-maike/release/glsl/phong_hemi.gsl
    branches/soc-2007-maike/release/glsl/phong_sun.gsl
    branches/soc-2007-maike/release/glsl/spectoon.gsl
    branches/soc-2007-maike/release/glsl/spectoon_hemi.gsl
    branches/soc-2007-maike/release/glsl/spectoon_sun.gsl
    branches/soc-2007-maike/release/glsl/spot_visibility.gsl
    branches/soc-2007-maike/release/glsl/sun_visibility.gsl
    branches/soc-2007-maike/release/glsl/uniforms.gsl
    branches/soc-2007-maike/release/glsl/varyings.gsl
    branches/soc-2007-maike/release/glsl/vertex_shader.gsl
    branches/soc-2007-maike/release/glsl/wardiso.gsl
    branches/soc-2007-maike/release/glsl/wardiso_hemi.gsl
    branches/soc-2007-maike/release/glsl/wardiso_sun.gsl

Added: branches/soc-2007-maike/release/glsl/area_visibility.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/area_visibility.gsl	                        (rev 0)
+++ branches/soc-2007-maike/release/glsl/area_visibility.gsl	2007-06-25 18:02:12 UTC (rev 11047)
@@ -0,0 +1,8 @@
+float visibility_area(light l)
+{
+	vec3 lv = (pos - l.loc);
+	float dist = sqrt(dot(lv, lv));
+	float t = 1.0 / dist;
+	lv = lv * t;
+	return ceil(max(dot(lv, l.vec) - 0.00001, -0.00001));
+}

Added: branches/soc-2007-maike/release/glsl/blinn.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/blinn.gsl	                        (rev 0)
+++ branches/soc-2007-maike/release/glsl/blinn.gsl	2007-06-25 18:02:12 UTC (rev 11047)
@@ -0,0 +1,23 @@
+vec3 blinndef(light l, vec3 vnormal, vec3 spec_color, float spec, float hard, float refrac){
+	vec3 view = normalize(eye - pos);
+
+	float har;
+	if(refrac < 1.0 || hard == 0.0) return(0.0, 0.0, 0.0, 0.0);
+	if(hard < 100.0) har = sqrt(1.0 / hard);
+	else har = 10.0 / hard;
+
+	vec3 h = normalize((eye - pos) + (l.loc - pos));
+	float nh = dot(vnormal, h);
+	float nv = max(dot(vnormal, view), 0.01);
+	float nl = dot(vnormal, normalize(l.loc - pos));
+	float vh = max(dot(view, h), 0.01);
+	float a = 1.0;
+	float b = (2.0 * nh * nv) / vh;
+	float c = (2.0 * nh * nl) / vh;
+	float ang = acos(clamp(nh, -1.0, 1.0));
+	float g = min(a, min(b, c));
+	float p = sqrt((refrac * refrac) + (vh * vh) - 1.0);
+	float f = (((p - vh) * (p - vh)) / ((p + vh) * (p + vh))) * (1.0 + ((((vh * (p + vh)) - 1.0) * ((vh * (p + vh)) - 1.0)) / (((vh * (p - vh)) + 1.0) * ((vh * (p - vh)) + 1.0))));
+	float rslt = max(f * g * exp((-1 * (ang * ang)) / (2.0 * har * har)), 0.0);
+	return(spec * rslt * vec3(l.color + vert_color) * spec_color);
+}

Added: branches/soc-2007-maike/release/glsl/blinn_hemi.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/blinn_hemi.gsl	                        (rev 0)
+++ branches/soc-2007-maike/release/glsl/blinn_hemi.gsl	2007-06-25 18:02:12 UTC (rev 11047)
@@ -0,0 +1,12 @@
+vec3 blinnhemi(light l, vec3 vnormal, vec3 spec_color, float spec, int hard){
+	vec3 view = normalize(eye - pos);
+
+	float har;
+	if(hard == 0.0) return(0.0, 0.0, 0.0, 0.0);
+	if(hard < 100.0) har = sqrt(1.0 / hard);
+	else har = 10.0 / hard;
+
+	vec3 h = normalize((eye - pos) + l.vec);
+	float nh = 0.5 * dot(vnormal, h) + 0.5;
+	return(spec * nh * pow(nh, hard) * vec3(l.color + vert_color) * spec_color);
+}

Added: branches/soc-2007-maike/release/glsl/blinn_sun.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/blinn_sun.gsl	                        (rev 0)
+++ branches/soc-2007-maike/release/glsl/blinn_sun.gsl	2007-06-25 18:02:12 UTC (rev 11047)
@@ -0,0 +1,23 @@
+vec3 blinnsun(light l, vec3 vnormal, vec3 spec_color, float spec, float hard, float refrac){
+	vec3 view = normalize(eye - pos);
+
+	float har;
+	if(refrac < 1.0 || hard == 0.0) return(0.0, 0.0, 0.0, 0.0);
+	if(hard < 100.0) har = sqrt(1.0 / hard);
+	else har = 10.0 / hard;
+
+	vec3 h = normalize((eye - pos) + l.vec);
+	float nh = dot(vnormal, h);
+	float nv = max(dot(vnormal, view), 0.01);
+	float nl = dot(vnormal, normalize(l.loc - pos));
+	float vh = max(dot(view, h), 0.01);
+	float a = 1.0;
+	float b = (2.0 * nh * nv) / vh;
+	float c = (2.0 * nh * nl) / vh;
+	float ang = acos(clamp(nh, -1.0, 1.0));
+	float g = min(a, min(b, c));
+	float p = sqrt((refrac * refrac) + (vh * vh) - 1.0);
+	float f = (((p - vh) * (p - vh)) / ((p + vh) * (p + vh))) * (1.0 + ((((vh * (p + vh)) - 1.0) * ((vh * (p + vh)) - 1.0)) / (((vh * (p - vh)) + 1.0) * ((vh * (p - vh)) + 1.0))));
+	float rslt = max(f * g * exp((-1 * (ang * ang)) / (2.0 * har * har)), 0.0);
+	return(spec * rslt * vec3(l.color + vert_color) * spec_color);
+}

Added: branches/soc-2007-maike/release/glsl/cooktorr.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/cooktorr.gsl	                        (rev 0)
+++ branches/soc-2007-maike/release/glsl/cooktorr.gsl	2007-06-25 18:02:12 UTC (rev 11047)
@@ -0,0 +1,7 @@
+vec3 cooktorrdef(light l, vec3 vnormal, vec3 spec_color, float spec, float hard, float unused){
+	vec3 view = normalize(eye - pos);
+	vec3 h = normalize((eye - pos) + (l.loc - pos));
+	float nh = max(dot(vnormal, h), 0.0);
+	float nv = max(dot(vnormal, view), 0.0);
+	return((spec * pow(nh, hard) * spec_color / (0.1 + nv)) * vec3(l.color + vert_color));
+}

Added: branches/soc-2007-maike/release/glsl/cooktorr_hemi.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/cooktorr_hemi.gsl	                        (rev 0)
+++ branches/soc-2007-maike/release/glsl/cooktorr_hemi.gsl	2007-06-25 18:02:12 UTC (rev 11047)
@@ -0,0 +1,6 @@
+vec3 cooktorrhemi(light l, vec3 vnormal, vec3 spec_color, float spec, float hard){
+	vec3 view = normalize(eye - pos);
+	vec3 h = normalize((eye - pos) + l.vec);
+	float nh = 0.5 * (max(dot(vnormal, h), 0.0)) + 0.5;
+	return(spec * nh * pow(nh, hard) * vec3(l.color + vert_color) * spec_color);
+}

Added: branches/soc-2007-maike/release/glsl/cooktorr_sun.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/cooktorr_sun.gsl	                        (rev 0)
+++ branches/soc-2007-maike/release/glsl/cooktorr_sun.gsl	2007-06-25 18:02:12 UTC (rev 11047)
@@ -0,0 +1,7 @@
+vec3 cooktorrsun(light l, vec3 vnormal, vec3 spec_color, float spec, float hard, float unused){
+	vec3 view = normalize(eye - pos);
+	vec3 h = normalize((eye - pos) + l.vec);
+	float nh = max(dot(vnormal, h), 0.0);
+	float nv = max(dot(vnormal, view), 0.0);
+	return(spec * pow(nh, hard) * vec3(l.color + vert_color) * spec_color / (0.1 + nv));
+}

Added: branches/soc-2007-maike/release/glsl/difftoon.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/difftoon.gsl	                        (rev 0)
+++ branches/soc-2007-maike/release/glsl/difftoon.gsl	2007-06-25 18:02:12 UTC (rev 11047)
@@ -0,0 +1,8 @@
+vec3 difftoondef(light l, vec3 vnormal, vec3 diff_color, float ref, float size, float smooth){
+	vec3 lightVec = normalize(l.loc - pos);
+	float rslt = max(dot(vnormal, lightVec), 0.0);
+	float ang;
+	ang = acos(clamp(rslt, -1.0, 1.0)) * (1 - floor(clamp(rslt, 0.1, 1.0) + 0.00001));
+	rslt = clamp(ceil(size + smooth - ang - 0.00001) * (1.0 - ((ang - size) / smooth)), 0.0, 1.0);
+	return(rslt * ref * vec3(l.color + vert_color) * diff_color);
+}

Added: branches/soc-2007-maike/release/glsl/difftoon_hemi.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/difftoon_hemi.gsl	                        (rev 0)
+++ branches/soc-2007-maike/release/glsl/difftoon_hemi.gsl	2007-06-25 18:02:12 UTC (rev 11047)
@@ -0,0 +1,4 @@
+vec3 difftoonhemi(light l, vec3 vnormal, vec3 diff_color, float ref){
+	vec3 lightVec = normalize(l.vec);
+	return((0.5 * dot(lightVec, vnormal) + 0.5) * ref * vec3(l.color + vert_color) * diff_color);
+}

Added: branches/soc-2007-maike/release/glsl/difftoon_sun.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/difftoon_sun.gsl	                        (rev 0)
+++ branches/soc-2007-maike/release/glsl/difftoon_sun.gsl	2007-06-25 18:02:12 UTC (rev 11047)
@@ -0,0 +1,8 @@
+vec3 difftoonsun(light l, vec3 vnormal, vec3 diff_color, float ref, float size, float smooth){
+	vec3 lightVec = normalize(l.vec);
+	float rslt = max(dot(vnormal, lightVec), 0.0);
+	float ang;
+	ang = acos(clamp(rslt, -1.0, 1.0)) * (1 - floor(clamp(rslt, 0.1, 1.0) + 0.00001));
+	rslt = clamp(ceil(size + smooth - ang - 0.00001) * (1.0 - (ang - size)) / smooth, 0.0, 1.0);
+	return(rslt * ref * vec3(l.color + vert_color) * diff_color);
+}

Added: branches/soc-2007-maike/release/glsl/fragment_shader.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/fragment_shader.gsl	                        (rev 0)
+++ branches/soc-2007-maike/release/glsl/fragment_shader.gsl	2007-06-25 18:02:12 UTC (rev 11047)
@@ -0,0 +1,9 @@
+varying vec3 normal, pos;
+varying vec3 vert_color;
+varying vec4 realcolor;
+
+
+void main(void)
+{
+	gl_FragColor = realcolor;
+}
\ No newline at end of file

Added: branches/soc-2007-maike/release/glsl/fresnel.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/fresnel.gsl	                        (rev 0)
+++ branches/soc-2007-maike/release/glsl/fresnel.gsl	2007-06-25 18:02:12 UTC (rev 11047)
@@ -0,0 +1,7 @@
+vec3 fresneldef(light l, vec3 vnormal, vec3 diff_color, float ref, float grad, float fac){
+	vec3 view = normalize(eye - pos);
+	float t1 = dot(view, vnormal);
+	float t2 = 1.0 + abs(t1);
+	t2 = grad + (1.0 - grad) * pow(t2, fac);
+	return(ref * clamp(t2, 0.0, 1.0) * vec3(l.color + vert_color) * diff_color);
+}

Added: branches/soc-2007-maike/release/glsl/fresnel_hemi.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/fresnel_hemi.gsl	                        (rev 0)
+++ branches/soc-2007-maike/release/glsl/fresnel_hemi.gsl	2007-06-25 18:02:12 UTC (rev 11047)
@@ -0,0 +1,4 @@
+vec3 fresnelhemi(light l, vec3 vnormal, vec3 diff_color, float ref){
+	vec3 view = normalize(l.vec);
+	return((0.5 * dot(view, vnormal) + 0.5) * ref * vec3(l.color + vert_color) * diff_color);
+}

Added: branches/soc-2007-maike/release/glsl/fresnel_sun.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/fresnel_sun.gsl	                        (rev 0)
+++ branches/soc-2007-maike/release/glsl/fresnel_sun.gsl	2007-06-25 18:02:12 UTC (rev 11047)
@@ -0,0 +1,7 @@
+vec3 fresnelsun(light l, vec3 vnormal, vec3 diff_color, float ref, float grad, float fac){
+	vec3 view = normalize(l.vec);
+	float t1 = dot(view, vnormal);
+	float t2 = 1.0 + abs(t1);
+	t2 = grad + (1.0 - grad) * pow(t2, fac);
+	return(ref * clamp(t2, 0.0, 1.0) * vec3(l.color + vert_color) * diff_color);
+}

Added: branches/soc-2007-maike/release/glsl/hemi_visibility.gsl
===================================================================

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list