[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11597] branches/soc-2007-maike/release/ glsl: Added texture generic glsl function (basic) and texture value blending functions
Miguel Torres Lima
torreslima at gmail.com
Tue Aug 14 18:12:28 CEST 2007
Revision: 11597
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11597
Author: maike
Date: 2007-08-14 18:12:28 +0200 (Tue, 14 Aug 2007)
Log Message:
-----------
Added texture generic glsl function (basic) and texture value blending functions
Modified Paths:
--------------
branches/soc-2007-maike/release/glsl/material.gsl
branches/soc-2007-maike/release/glsl/material_return.gsl
branches/soc-2007-maike/release/glsl/tex_magic.gsl
Added Paths:
-----------
branches/soc-2007-maike/release/glsl/texture.gsl
branches/soc-2007-maike/release/glsl/texture_blend_val_add.gsl
branches/soc-2007-maike/release/glsl/texture_blend_val_dark.gsl
branches/soc-2007-maike/release/glsl/texture_blend_val_diff.gsl
branches/soc-2007-maike/release/glsl/texture_blend_val_div.gsl
branches/soc-2007-maike/release/glsl/texture_blend_val_light.gsl
branches/soc-2007-maike/release/glsl/texture_blend_val_mix.gsl
branches/soc-2007-maike/release/glsl/texture_blend_val_mul.gsl
branches/soc-2007-maike/release/glsl/texture_blend_val_screen.gsl
branches/soc-2007-maike/release/glsl/texture_blend_val_sub.gsl
Modified: branches/soc-2007-maike/release/glsl/material.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/material.gsl 2007-08-14 16:10:01 UTC (rev 11596)
+++ branches/soc-2007-maike/release/glsl/material.gsl 2007-08-14 16:12:28 UTC (rev 11597)
@@ -8,7 +8,10 @@
float spec_cb_res = 0.0;
vec3 norm = normal;
- if(shless == 0.0){
+#ifdef IS_SHADELESS
+ return(diff_color);
+#endif
+#undef IS_SHADELESS
if(tanv > 0.0){
norm = -(cross(cross(eye - pos, normal), normal));
Modified: branches/soc-2007-maike/release/glsl/material_return.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/material_return.gsl 2007-08-14 16:10:01 UTC (rev 11596)
+++ branches/soc-2007-maike/release/glsl/material_return.gsl 2007-08-14 16:12:28 UTC (rev 11597)
@@ -41,10 +41,7 @@
#else
return(vec3(0.0, 0.0, 0.0));
#endif
-}
-return(diff_color);
-
#undef DIFF_CB_TYPE
#undef SPEC_CB_TYPE
#undef DIFF_CB_BLEND_FUNC
Modified: branches/soc-2007-maike/release/glsl/tex_magic.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/tex_magic.gsl 2007-08-14 16:10:01 UTC (rev 11596)
+++ branches/soc-2007-maike/release/glsl/tex_magic.gsl 2007-08-14 16:12:28 UTC (rev 11597)
@@ -1,8 +1,8 @@
-vec4 magic(vec3 coords, vec3 colfac, float depth, float turbulence, float contrast, float brightness)
+vec4 tex_magic(vec3 coords, vec3 colfac, float depth, float turbulence, float contrast, float brightness)
{
float x, y, z;
float turb = turbulence / 5.0;
- float i;
+ float i = 0.0;
x = sin((coords.x + coords.y + coords.z) * 5.0);
y = cos((-coords.x + coords.y - coords.z) * 5.0);
Added: branches/soc-2007-maike/release/glsl/texture.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/texture.gsl (rev 0)
+++ branches/soc-2007-maike/release/glsl/texture.gsl 2007-08-14 16:12:28 UTC (rev 11597)
@@ -0,0 +1,59 @@
+void TEX_FUNC(inout vec3 dc, inout vec3 sc, inout vec3 nor, inout float alph, inout float d1, inout float s1, inout float ambf, inout float e, inout float h)
+{
+ vec4 res = TEX_CALC_FUNC;
+
+#ifdef TEX_DIFFCOL
+ dc = TEX_BLEND(res.rgb, dc, res.a, TEX_COLFAC);
+#endif
+
+#ifdef TEX_SPECCOL
+ sc = TEX_BLEND(res.rgb, sc, res.a, TEX_COLFAC);
+#endif
+
+#ifdef TEX_NORMAL
+
+#endif
+
+#ifdef TEX_ALPHA
+ alph = TEX_BLEND_VAL(TEX_DVAR, alph, res.a, TEX_VARFAC);
+#endif
+
+#ifdef TEX_REF
+ d1 = TEX_BLEND_VAL(TEX_DVAR, d1, res.a, TEX_VARFAC);
+#endif
+
+#ifdef TEX_SPEC
+ s1 = TEX_BLEND_VAL(TEX_DVAR, s1, res.a, TEX_VARFAC);
+#endif
+
+#ifdef TEX_AMB
+ ambf = TEX_BLEND_VAL(TEX_DVAR, ambf, res.a, TEX_VARFAC);
+#endif
+
+#ifdef TEX_EMIT
+ e = TEX_BLEND_VAL(TEX_DVAR, e, res.a, TEX_VARFAC);
+#endif
+
+#ifdef TEX_HARD
+ h = TEX_BLEND_VAL(TEX_DVAR, h, res.a, TEX_VARFAC);
+#endif
+}
+
+#undef TEX_FUNC
+#undef TEX_CALC_FUNC
+#undef TEX_BLEND
+#undef TEX_BLEND_VAL
+#undef TEX_DIFFCOL
+#undef TEX_SPECCOL
+#undef TEX_NORMAL
+#undef TEX_ALPHA
+#undef TEX_REF
+#undef TEX_SPEC
+#undef TEX_AMB
+#undef TEX_EMIT
+#undef TEX_HARD
+
+#undef TEX_DVAR
+#undef TEX_VARFAC
+#undef TEX_COLFAC
+#undef TEX_NORFAC
Added: branches/soc-2007-maike/release/glsl/texture_blend_val_add.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/texture_blend_val_add.gsl (rev 0)
+++ branches/soc-2007-maike/release/glsl/texture_blend_val_add.gsl 2007-08-14 16:12:28 UTC (rev 11597)
@@ -0,0 +1,9 @@
+float tex_blend_val_add(float tex, float param, float fac1, float fac2)
+{
+ float res = 0.0;
+ float fact = fac1 * fac2;
+
+ res = fact * tex + param;
+
+ return(res);
+}
Added: branches/soc-2007-maike/release/glsl/texture_blend_val_dark.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/texture_blend_val_dark.gsl (rev 0)
+++ branches/soc-2007-maike/release/glsl/texture_blend_val_dark.gsl 2007-08-14 16:12:28 UTC (rev 11597)
@@ -0,0 +1,6 @@
+float tex_blend_val_dark(float tex, float param, float fac1, float fac2)
+{
+ float fact = fac1 * fac2;
+
+ return(min(fact * tex, param));
+}
Added: branches/soc-2007-maike/release/glsl/texture_blend_val_diff.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/texture_blend_val_diff.gsl (rev 0)
+++ branches/soc-2007-maike/release/glsl/texture_blend_val_diff.gsl 2007-08-14 16:12:28 UTC (rev 11597)
@@ -0,0 +1,10 @@
+float tex_blend_val_diff(float tex, float param, float fac1, float fac2)
+{
+ float res = 0.0;
+ float fact = fac1 * fac2;
+ float facm = 1.0 - fact;
+
+ res = facm * param + fact * fabs(tex - param);
+
+ return(res);
+}
Added: branches/soc-2007-maike/release/glsl/texture_blend_val_div.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/texture_blend_val_div.gsl (rev 0)
+++ branches/soc-2007-maike/release/glsl/texture_blend_val_div.gsl 2007-08-14 16:12:28 UTC (rev 11597)
@@ -0,0 +1,11 @@
+float tex_blend_val_div(float tex, float param, float fac1, float fac2)
+{
+ float res = 0.0;
+ float fact = fac1 * fac2;
+ float facm = 1.0 - fact;
+
+ if(tex != 0.0)
+ res = facm * param + fact * param / tex;
+
+ return(res);
+}
Added: branches/soc-2007-maike/release/glsl/texture_blend_val_light.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/texture_blend_val_light.gsl (rev 0)
+++ branches/soc-2007-maike/release/glsl/texture_blend_val_light.gsl 2007-08-14 16:12:28 UTC (rev 11597)
@@ -0,0 +1,6 @@
+float tex_blend_val_light(float tex, float param, float fac1, float fac2)
+{
+ float fact = fac1 * fac2;
+
+ return(max(fact * tex, param));
+}
Added: branches/soc-2007-maike/release/glsl/texture_blend_val_mix.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/texture_blend_val_mix.gsl (rev 0)
+++ branches/soc-2007-maike/release/glsl/texture_blend_val_mix.gsl 2007-08-14 16:12:28 UTC (rev 11597)
@@ -0,0 +1,10 @@
+float tex_blend_val_mix(float tex, float param, float fac1, float fac2)
+{
+ float res = 0.0;
+ float fact = fac1 * fac2;
+ float facm = 1.0 - fact;
+
+ res = fact * tex + facm * param;
+
+ return(res);
+}
Added: branches/soc-2007-maike/release/glsl/texture_blend_val_mul.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/texture_blend_val_mul.gsl (rev 0)
+++ branches/soc-2007-maike/release/glsl/texture_blend_val_mul.gsl 2007-08-14 16:12:28 UTC (rev 11597)
@@ -0,0 +1,10 @@
+float tex_blend_val_mul(float tex, float param, float fac1, float fac2)
+{
+ float res = 0.0;
+ float fact = fac1 * fac2;
+ float facm = 1.0 - fac2;
+
+ res = (facm + fact * tex) * param;
+
+ return(res);
+}
Added: branches/soc-2007-maike/release/glsl/texture_blend_val_screen.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/texture_blend_val_screen.gsl (rev 0)
+++ branches/soc-2007-maike/release/glsl/texture_blend_val_screen.gsl 2007-08-14 16:12:28 UTC (rev 11597)
@@ -0,0 +1,10 @@
+float tex_blend_val_screen(float tex, float param, float fac1, float fac2)
+{
+ float res = 0.0;
+ float fact = fac1 * fac2;
+ float facm = 1.0 - fac;
+
+ res = 1.0 - (facm + fact * (1.0 - tex)) * (1.0 - param);
+
+ return(res);
+}
Added: branches/soc-2007-maike/release/glsl/texture_blend_val_sub.gsl
===================================================================
--- branches/soc-2007-maike/release/glsl/texture_blend_val_sub.gsl (rev 0)
+++ branches/soc-2007-maike/release/glsl/texture_blend_val_sub.gsl 2007-08-14 16:12:28 UTC (rev 11597)
@@ -0,0 +1,9 @@
+float tex_blend_val_sub(float tex, float param, float fac1, float fac2)
+{
+ float res = 0.0;
+ float fact = fac1 * fac2;
+
+ res = -fact * tex + param;
+
+ return(res);
+}
More information about the Bf-blender-cvs
mailing list