Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] Re: Front v.s. Back Materials?


Chronological Thread 
  • From: "James Bigler" <jamesbigler@gmail.com>
  • To: ollie@lanl.gov
  • Cc: manta@sci.utah.edu
  • Subject: [Manta] Re: Front v.s. Back Materials?
  • Date: Mon, 2 Jun 2008 12:50:10 -0600
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=OPpd01wiiHSp/7z2glGg7vOBtHLaBrXhq+03s1wdY6Vk+YCQtxsy5zEncII7SFHUp6fb8jab8BlHPKuWlFLdL3U7Jyl/LrXRbNxNcXsyMzIcUAudC/wFeF3Ek6STNZgyUtPuIQy2tque3rLWHlsq0cMr8JSyH0eSn2MaJ+78pyg=

There was a post about this from Jan of 2007.  Too bad we don't have
an email archive on line (the new mail server at SCI will have an
online archive).

Here's what I wrote then:

You need to create a new Texture class.  This class will decide which
color will be used on the surface.

For example textures, see Model/Textures.  On in particular is the
CheckerTexture.  This makes a choice between two sub textures based on
some parameters from the ray.

Inside mapValues function instead of making the choice based on
texture coordinates, you will do it based on the dot product between
the ray direction and the normal.  You need to make sure you have ray
directions though, so the code would look something like this:

template<class ValueType>
 void TwoSidedTexture<ValueType>::mapValues(Packet<ValueType>& results,
                                            const RenderContext& context,
                                            RayPacket& rays) const
{
 rays.computeNormals();

 for(int i=rays.begin();i<rays.end();i++){
   // Compute the dot product
   Real side = Dot(rays.getNormal(i), rays.getDirection(i));
   if (side <= 0)
     results.set(i, value1);
   else
     results.set(i, value2);
 }
}

For an example of how to create a CheckerTexture see
createDefaultScene in StandAlone/manta.cc.

For now, you can either place the code in Model/Textures or in the
scene file you wish to use it in.  You will have to hack the objviewer
scene file to use this new texture instead of the ConstantTextures
currently being used (probably something like the opposite color:
Color::white()-color).

------------------------------------------------------------
James

On Mon, Jun 2, 2008 at 12:41 PM, Li-Ta Lo <ollie@lanl.gov> wrote:
> Hi,
>
> Does Manta support different materials for front and back faces as
> OpenGL?
>
> Ollie
>
>



Archive powered by MHonArc 2.6.16.

Top of page