Revision: 34653
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34653
Author:   ton
Date:     2011-02-05 13:10:20 +0000 (Sat, 05 Feb 2011)
Log Message:
-----------
Renamed texture.c in render module, to prevent debuggers to
complain about the same named file in blenkernel.

Added Paths:
-----------
    trunk/blender/source/blender/render/intern/source/render_texture.c

Removed Paths:
-------------
    trunk/blender/source/blender/render/intern/source/texture.c

Copied: trunk/blender/source/blender/render/intern/source/render_texture.c 
(from rev 34652, trunk/blender/source/blender/render/intern/source/texture.c)
===================================================================
--- trunk/blender/source/blender/render/intern/source/render_texture.c          
                (rev 0)
+++ trunk/blender/source/blender/render/intern/source/render_texture.c  
2011-02-05 13:10:20 UTC (rev 34653)
@@ -0,0 +1,3390 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * Contributor(s): 2004-2006, Blender Foundation, full recode
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include "BLI_blenlib.h"
+#include "BLI_math.h"
+#include "BLI_rand.h"
+#include "BLI_utildefines.h"
+
+#include "DNA_texture_types.h"
+#include "DNA_object_types.h"
+#include "DNA_lamp_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_material_types.h"
+#include "DNA_image_types.h"
+#include "DNA_node_types.h"
+
+#include "IMB_imbuf_types.h"
+#include "IMB_imbuf.h"
+
+#include "BKE_colortools.h"
+#include "BKE_image.h"
+#include "BKE_node.h"
+#include "BKE_plugin_types.h"
+
+
+#include "BKE_global.h"
+#include "BKE_main.h"
+#include "BKE_material.h"
+
+#include "BKE_library.h"
+#include "BKE_image.h"
+#include "BKE_texture.h"
+#include "BKE_key.h"
+#include "BKE_ipo.h"
+
+#include "envmap.h"
+#include "pointdensity.h"
+#include "voxeldata.h"
+#include "renderpipeline.h"
+#include "render_types.h"
+#include "rendercore.h"
+#include "shading.h"
+#include "texture.h"
+
+#include "renderdatabase.h" /* needed for UV */
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
+/* only to be used here in this file, it's for speed */
+extern struct Render R;
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+
+
+
+void init_render_texture(Render *re, Tex *tex)
+{
+       int cfra= re->scene->r.cfra;
+       
+       if(re) cfra= re->r.cfra;
+       
+       /* imap test */
+       if(tex->ima && ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) 
{
+               BKE_image_user_calc_frame(&tex->iuser, cfra, re?re->flag & 
R_SEC_FIELD:0);
+       }
+       
+       if(tex->type==TEX_PLUGIN) {
+               if(tex->plugin && tex->plugin->doit) {
+                       if(tex->plugin->cfra) {
+                               *(tex->plugin->cfra)= (float)cfra; 
//BKE_curframe(re->scene); // XXX old animsys - timing stuff to be fixed 
+                       }
+               }
+       }
+       else if(tex->type==TEX_ENVMAP) {
+               /* just in case */
+               tex->imaflag |= TEX_INTERPOL | TEX_MIPMAP;
+               tex->extend= TEX_CLIP;
+               
+               if(tex->env) {
+                       if(tex->env->type==ENV_PLANE)
+                               tex->extend= TEX_EXTEND;
+                       
+                       /* only free envmap when rendermode was set to render 
envmaps, for previewrender */
+                       if(G.rendering && re) {
+                               if (re->r.mode & R_ENVMAP)
+                                       if(tex->env->stype==ENV_ANIM) 
+                                               BKE_free_envmapdata(tex->env);
+                       }
+               }
+       }
+       
+       if(tex->nodetree && tex->use_nodes) {
+               ntreeBeginExecTree(tex->nodetree); /* has internal flag to 
detect it only does it once */
+       }
+}
+
+/* ------------------------------------------------------------------------- */
+
+void init_render_textures(Render *re)
+{
+       Tex *tex;
+       
+       tex= re->main->tex.first;
+       while(tex) {
+               if(tex->id.us) init_render_texture(re, tex);
+               tex= tex->id.next;
+       }
+}
+
+void end_render_texture(Tex *tex)
+{
+       if(tex && tex->use_nodes && tex->nodetree)
+               ntreeEndExecTree(tex->nodetree);
+}
+
+void end_render_textures(Render *re)
+{
+       Tex *tex;
+       for(tex= re->main->tex.first; tex; tex= tex->id.next)
+               if(tex->id.us)
+                       end_render_texture(tex);
+}
+
+/* ------------------------------------------------------------------------- */
+
+
+/* this allows colorbanded textures to control normals as well */
+static void tex_normal_derivate(Tex *tex, TexResult *texres)
+{
+       if (tex->flag & TEX_COLORBAND) {
+               float col[4];
+               if (do_colorband(tex->coba, texres->tin, col)) {
+                       float fac0, fac1, fac2, fac3;
+                       
+                       fac0= (col[0]+col[1]+col[2]);
+                       do_colorband(tex->coba, texres->nor[0], col);
+                       fac1= (col[0]+col[1]+col[2]);
+                       do_colorband(tex->coba, texres->nor[1], col);
+                       fac2= (col[0]+col[1]+col[2]);
+                       do_colorband(tex->coba, texres->nor[2], col);
+                       fac3= (col[0]+col[1]+col[2]);
+                       
+                       texres->nor[0]= 0.3333*(fac0 - fac1);
+                       texres->nor[1]= 0.3333*(fac0 - fac2);
+                       texres->nor[2]= 0.3333*(fac0 - fac3);
+                       
+                       return;
+               }
+       }
+       texres->nor[0]= texres->tin - texres->nor[0];
+       texres->nor[1]= texres->tin - texres->nor[1];
+       texres->nor[2]= texres->tin - texres->nor[2];
+}
+
+
+
+static int blend(Tex *tex, float *texvec, TexResult *texres)
+{
+       float x, y, t;
+
+       if(tex->flag & TEX_FLIPBLEND) {
+               x= texvec[1];
+               y= texvec[0];
+       }
+       else {
+               x= texvec[0];
+               y= texvec[1];
+       }
+
+       if(tex->stype==TEX_LIN) {       /* lin */
+               texres->tin= (1.0+x)/2.0;
+       }
+       else if(tex->stype==TEX_QUAD) { /* quad */
+               texres->tin= (1.0+x)/2.0;
+               if(texres->tin<0.0) texres->tin= 0.0;
+               else texres->tin*= texres->tin;
+       }
+       else if(tex->stype==TEX_EASE) { /* ease */
+               texres->tin= (1.0+x)/2.0;
+               if(texres->tin<=.0) texres->tin= 0.0;
+               else if(texres->tin>=1.0) texres->tin= 1.0;
+               else {
+                       t= texres->tin*texres->tin;
+                       texres->tin= (3.0*t-2.0*t*texres->tin);
+               }
+       }
+       else if(tex->stype==TEX_DIAG) { /* diag */
+               texres->tin= (2.0+x+y)/4.0;
+       }
+       else if(tex->stype==TEX_RAD) { /* radial */
+               texres->tin= (atan2(y,x) / (2*M_PI) + 0.5);
+       }
+       else {  /* sphere TEX_SPHERE */
+               texres->tin= 1.0-sqrt(x*x+      y*y+texvec[2]*texvec[2]);
+               if(texres->tin<0.0) texres->tin= 0.0;
+               if(tex->stype==TEX_HALO) texres->tin*= texres->tin;  /* halo */
+       }
+
+       BRICONT;
+
+       return TEX_INT;
+}
+
+/* ------------------------------------------------------------------------- */
+/* ************************************************************************* */
+
+/* newnoise: all noisebased types now have different noisebases to choose from 
*/
+
+static int clouds(Tex *tex, float *texvec, TexResult *texres)
+{
+       int rv = TEX_INT;
+       
+       texres->tin = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], 
texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
+
+       if (texres->nor!=NULL) {
+               // calculate bumpnormal
+               texres->nor[0] = BLI_gTurbulence(tex->noisesize, texvec[0] + 
tex->nabla, texvec[1], texvec[2], tex->noisedepth,  
(tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
+               texres->nor[1] = BLI_gTurbulence(tex->noisesize, texvec[0], 
texvec[1] + tex->nabla, texvec[2], tex->noisedepth,  
(tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
+               texres->nor[2] = BLI_gTurbulence(tex->noisesize, texvec[0], 
texvec[1], texvec[2] + tex->nabla, tex->noisedepth,  
(tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
+               
+               tex_normal_derivate(tex, texres);
+               rv |= TEX_NOR;
+       }
+
+       if (tex->stype==TEX_COLOR) {
+               // in this case, int. value should really be computed from 
color,
+               // and bumpnormal from that, would be too slow, looks ok as is
+               texres->tr = texres->tin;
+               texres->tg = BLI_gTurbulence(tex->noisesize, texvec[1], 
texvec[0], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), 
tex->noisebasis);
+               texres->tb = BLI_gTurbulence(tex->noisesize, texvec[1], 
texvec[2], texvec[0], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), 
tex->noisebasis);
+               BRICONTRGB;
+               texres->ta = 1.0;
+               return (rv | TEX_RGB);
+       }
+
+       BRICONT;
+
+       return rv;
+
+}
+
+/* creates a sine wave */
+static float tex_sin(float a)
+{
+       a = 0.5 + 0.5*sin(a);
+               
+       return a;
+}
+
+/* creates a saw wave */
+static float tex_saw(float a)
+{
+       const float b = 2*M_PI;
+       
+       int n = (int)(a / b);
+       a -= n*b;
+       if (a < 0) a += b;
+       return a / b;
+}
+
+/* creates a triangle wave */
+static float tex_tri(float a)
+{
+       const float b = 2*M_PI;
+       const float rmax = 1.0;
+       
+       a = rmax - 2.0*fabs(floor((a*(1.0/b))+0.5) - (a*(1.0/b)));
+       
+       return a;
+}
+
+/* computes basic wood intensity value at x,y,z */
+static float wood_int(Tex *tex, float x, float y, float z)
+{
+       float wi=0;                                             
+       short wf = tex->noisebasis2;    /* wave form:   TEX_SIN=0,  TEX_SAW=1,  
TEX_TRI=2                                                */
+       short wt = tex->stype;                  /* wood type:   TEX_BAND=0, 
TEX_RING=1, TEX_BANDNOISE=2, TEX_RINGNOISE=3 */
+
+       float (*waveform[3])(float);    /* create array of pointers to waveform 
functions */
+       waveform[0] = tex_sin;                  /* assign address of tex_sin() 
function to pointer array */
+       waveform[1] = tex_saw;
+       waveform[2] = tex_tri;
+       
+       if ((wf>TEX_TRI) || (wf<TEX_SIN)) wf=0; /* check to be sure noisebasis2 
is initialized ahead of time */
+               
+       if (wt==TEX_BAND) {
+               wi = waveform[wf]((x + y + z)*10.0);
+       }
+       else if (wt==TEX_RING) {
+               wi = waveform[wf](sqrt(x*x + y*y + z*z)*20.0);
+       }
+       else if (wt==TEX_BANDNOISE) {
+               wi = tex->turbul*BLI_gNoise(tex->noisesize, x, y, z, 
(tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
+               wi = waveform[wf]((x + y + z)*10.0 + wi);
+       }
+       else if (wt==TEX_RINGNOISE) {
+               wi = tex->turbul*BLI_gNoise(tex->noisesize, x, y, z, 
(tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
+               wi = waveform[wf](sqrt(x*x + y*y + z*z)*20.0 + wi);
+       }
+       
+       return wi;
+}
+
+static int wood(Tex *tex, float *texvec, TexResult *texres)
+{
+       int rv=TEX_INT;
+
+       texres->tin = wood_int(tex, texvec[0], texvec[1], texvec[2]);
+       if (texres->nor!=NULL) {
+               /* calculate bumpnormal */
+               texres->nor[0] = wood_int(tex, texvec[0] + tex->nabla, 
texvec[1], texvec[2]);
+               texres->nor[1] = wood_int(tex, texvec[0], texvec[1] + 
tex->nabla, texvec[2]);
+               texres->nor[2] = wood_int(tex, texvec[0], texvec[1], texvec[2] 
+ tex->nabla);
+               
+               tex_normal_derivate(tex, texres);
+               rv |= TEX_NOR;
+       }
+
+       BRICONT;
+
+       return rv;
+}
+
+/* computes basic marble intensity at x,y,z */

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to