Manta Interactive Ray Tracer Development Mailing List

Text archives Help


Re: [Manta] r1665 - in trunk: Model/Textures SwigInterface


Chronological Thread 
  • From: Solomon Boulos <boulos@cs.utah.edu>
  • Cc: MANTA <manta@sci.utah.edu>
  • Subject: Re: [Manta] r1665 - in trunk: Model/Textures SwigInterface
  • Date: Sun, 19 Aug 2007 18:07:44 -0600

Seems like a cool addition, but the cloud_coordinate variable should probably be an enum instead of a Real (and then switch the separated if's into a switch statement).

Also, if there is some paper which this model comes from (or any source for that matter), it would be good to mention that in the header. Other than that, looks good.


On Aug 19, 2007, at 12:19 AM, leenak@sci.utah.edu wrote:

Author: leenak
Date: Sun Aug 19 00:19:56 2007
New Revision: 1665

Added:
   trunk/Model/Textures/CloudTexture.cc
   trunk/Model/Textures/CloudTexture.h
Modified:
   trunk/Model/Textures/CMakeLists.txt
   trunk/SwigInterface/manta.i
Log:
Cloud Texture has been added

Modified: trunk/Model/Textures/CMakeLists.txt
====================================================================== ========
--- trunk/Model/Textures/CMakeLists.txt (original)
+++ trunk/Model/Textures/CMakeLists.txt Sun Aug 19 00:19:56 2007
@@ -15,6 +15,8 @@
      Textures/HeightColorMap.h
      Textures/MarbleTexture.cc
      Textures/MarbleTexture.h
+     Textures/CloudTexture.cc
+     Textures/CloudTexture.h
      Textures/NormalTexture.cc
      Textures/NormalTexture.h
      Textures/OakTexture.cc

Added: trunk/Model/Textures/CloudTexture.cc
====================================================================== ========
--- (empty file)
+++ trunk/Model/Textures/CloudTexture.cc        Sun Aug 19 00:19:56 2007
@@ -0,0 +1,5 @@
+#include<Model/Textures/CloudTexture.h>
+
+namespace Manta {
+
+}

Added: trunk/Model/Textures/CloudTexture.h
====================================================================== ========
--- (empty file)
+++ trunk/Model/Textures/CloudTexture.h Sun Aug 19 00:19:56 2007
@@ -0,0 +1,119 @@
+
+/*
+ * This texture class takes two arguments.
+ * First one indicates coverage of cloud in the sky(0-1) and
+ * Second one indicates the dimension in which clouds occur(0, 1 or 2)
+ * 0 indicates x-axis, 1 indicates y-axis and 2 z-axis.
+ *
+ */
+
+#ifndef Manta_Model_CloudTexture_h
+#define Manta_Model_CloudTexture_h
+
+#include <Interface/Texture.h>
+#include <Interface/RayPacket.h>
+#include <Core/Geometry/Vector.h>
+#include <Core/Math/Noise.h>
+#include <Core/Math/MiscMath.h>
+#include <Core/Math/Trig.h>
+
+
+namespace Manta {
+  class RayPacket;
+  class RenderContext;
+  template< typename ValueType >
+  class CloudTexture : public Texture< ValueType > {
+    public:
+ CloudTexture( Real const cloud_cover, Real const cloud_coordinate );
+    virtual ~CloudTexture();
+    virtual void mapValues(Packet<Color>& results,
+                           const RenderContext&,
+                           RayPacket& rays) const;
+    Real cloud_coverage(Real value) const;
+    private:
+    CloudTexture(
+      CloudTexture const & );
+    CloudTexture& operator=(
+      CloudTexture const & );
+
+    ValueType skycolor;
+    Real scale;
+    Real fscale;
+    Real tscale;
+    int octaves;
+    Real lacunarity;
+    Real gain;
+    Real cloud_coordinate;
+    Real cloud_cover;
+  };
+
+  template< class ValueType >
+ CloudTexture< ValueType >::CloudTexture( Real const cloud_cover, Real const cloud_coordinate)
+               : cloud_cover( cloud_cover ),
+      cloud_coordinate(cloud_coordinate)
+  {
+    skycolor=Color(RGBColor(1,1,1))-Color(RGBColor(0,0,1));
+    scale=0.1;
+    fscale=1;
+    tscale=1;
+    octaves=8;
+    lacunarity=1.8;
+    gain=0.48;
+  }
+
+  template< class ValueType >
+  CloudTexture< ValueType >::~CloudTexture()
+  {
+  }
+
+  template< class ValueType >
+  void CloudTexture< ValueType >::mapValues(Packet<Color>& results,
+ const RenderContext& context,
+                                             RayPacket& rays) const
+  {
+    rays.computeTextureCoordinates3( context );
+    for( int i = rays.begin(); i < rays.end(); i++ ) {
+
+      Vector T = rays.getTexCoords(i) * (scale * tscale);
+      ColorComponent density;
+      ColorComponent value;
+
+      if(cloud_coordinate==0)
+      {
+       density=cloud_coverage(rays.getTexCoords(i).x());
+ value =(( rays.getTexCoords(i).x()) * fscale + (Real) Turbulence( T, octaves, lacunarity, gain ));
+      }
+      if(cloud_coordinate==1)
+      {
+       density=cloud_coverage(rays.getTexCoords(i).y());
+ value =(( rays.getTexCoords(i).y()) * fscale + (Real) Turbulence( T, octaves, lacunarity, gain ));
+      }
+      if(cloud_coordinate==2)
+      {
+       density=cloud_coverage(rays.getTexCoords(i).z());
+ value =(( rays.getTexCoords(i).z()) * fscale + (Real) Turbulence( T, octaves, lacunarity, gain ));
+      }
+
+      value=value*(Real)0.5+(Real)0.5;
+      value=value*density;
+      value=value*(Real)0.5+(Real)0.5;
+ results.set(i, (SCIRun::Interpolate( skycolor, Color(RGBColor (0,0,0)), value))+Color(RGBColor(1,1,1)));
+
+    }
+  }
+
+  template< class ValueType >
+  Real CloudTexture< ValueType >::cloud_coverage(Real value) const
+               {
+      Real total_cover=(cloud_cover*1.6215)+249.8;
+      Real c_value = total_cover-value;
+      if(c_value < 0)
+      {
+       c_value=0;
+      }
+      Real density_value = 255 - ((c_value));
+      return density_value;
+    }
+}
+
+#endif

Modified: trunk/SwigInterface/manta.i
====================================================================== ========
--- trunk/SwigInterface/manta.i (original)
+++ trunk/SwigInterface/manta.i Sun Aug 19 00:19:56 2007
@@ -180,6 +180,7 @@
 #include <Model/Textures/TileTexture.h>
 #include <Model/Textures/ImageTexture.h>
 #include <Model/Textures/MarbleTexture.h>
+#include <Model/Textures/CloudTexture.h>
 %}

 %include <Model/Textures/Constant.h>
@@ -187,7 +188,7 @@
 %include <Model/Textures/TileTexture.h>
 %include <Model/Textures/ImageTexture.h>
 %include <Model/Textures/MarbleTexture.h>
-
+%include <Model/Textures/CloudTexture.h>

 namespace Manta {
// Textures. If you add a new texture like FunkyTexture<MagicType>,
@@ -213,6 +214,7 @@
   %template(Constant_Color) Constant<Color>;
   %template(ImageTexture_Color) ImageTexture<Manta::Color>;
   %template(MarbleTexture_Color) MarbleTexture<Manta::Color>;
+  %template(CloudTexture_Color) CloudTexture<Manta::Color>;

 }







Archive powered by MHonArc 2.6.16.

Top of page