POV-Ray : Newsgroups : povray.newusers : Simple 2D text, take 2 Server Time
28 Jul 2024 16:20:19 EDT (-0400)
  Simple 2D text, take 2 (Message 1 to 4 of 4)  
From: Leef me
Subject: Simple 2D text, take 2
Date: 26 Oct 2007 03:15:01
Message: <web.4721939cca8d169b892adb1d0@news.povray.org>
Hi gang, I'm working to understand 2d text mapping onto a surface. I believe
the term is UV mapping.

Anyway, In a different thread in P.n-u called "Simple 2D text on a
cylinder's surface "
 I asked about mapping, and Samuel B gave a nice example that I have been
playing with.
When I have a problem understanding how to apply the text, I go back to a
flat object.

Well, I'm stumped, so below is my code. Both the mesh and the disc have the
same exact material.
The non-text part of the pattern -background- shows up the same on both
objects.
And they have (I think) the same location.

But, the disc gets the 2d text map, the mesh doesn't.

WHy?


I included a rotation of the camera and use +kff20 so I can see the scene
revolve.

I'm not brain-dead, but I am height-challenged; as in, this is over my head.


Thanks in advance for the help, code below.

Leef_me

//------------------------------------------------------------------------



// Persistence of Vision Ray Tracer Scene Description File
// File: ?.pov
// Vers: 3.6
// Desc: Basic Scene Example
// Date: mm/dd/yy
// Auth: ?
//

#version 3.6;

#include "colors.inc"

global_settings {
  assumed_gamma 1.0
}

camera {
orthographic

  location  <0.0, 0, -5.0>
  look_at   <0.0, 0.0,  0.0>
  rotate y*-15
  rotate -x*180*clock             // look at both sides of the disc

}

sky_sphere {
  pigment {
    gradient y
    color_map {
      [0.0 rgb <0.6,0.7,1.0>]
      [0.7 rgb <0.0,0.1,0.8>]
    }
  }
}

light_source {
  <0, 0, 0>            // light's position (translated below)
  color rgb <1, 1, 1>  // light's color
  translate <15, 15, -10>
}


light_source {
  <0, 0, 0>            // light's position (translated below)
  color rgb <1, 1, 1>  // light's color
  translate <15, 15, 10>
}


#declare my_text=
text{
  ttf"arialbd.ttf"      "This is a test"    1,0
  translate -z/2
// suggested by fellow pover Samuel Benge  Date: 21 Oct 2007 20:39:07
}



#declare q1 = material {

     texture {                     // one side has background and text
      pigment{
        pigment_pattern{
          object{my_text 0,1}
          }
        pigment_map{
            [0 color Pink]
            [1 color MediumBlue]
        }
      }
    }
    interior_texture {             // the other side has another background

  pigment { color Yellow }
   }
}



#if(1)

mesh {
    triangle { <2,0,0>, <0,3,0>, <0,0,0> }
    uv_mapping
    material {q1}
}

#end


#if(1)

disc {
  <0, 0, 0>  // center position
  z*-1,         // normal vector
  2,       // outer radius
    uv_mapping
    material {q1}
}

#end




cylinder {
  -4*x,  4*x,  .05
  pigment { color Red }
}

cylinder {
  -4*y,  4*y,  .05
  pigment { color Green }
}

cylinder {
  -4*z,  4*z,  .05
  pigment { color Yellow }
}


Post a reply to this message

From: Warp
Subject: Re: Simple 2D text, take 2
Date: 26 Oct 2007 06:06:52
Message: <4721bc3c@news.povray.org>
POV-Ray cannot guess the uv coordinates for your mesh if you don't
tell it what they are.

  Besides, if you are simply applying a texture to an object using regular
planar mapping, that's not uv-mapping.

-- 
                                                          - Warp


Post a reply to this message

From: Tim Attwood
Subject: Re: Simple 2D text, take 2
Date: 26 Oct 2007 06:32:15
Message: <4721c22f$1@news.povray.org>
> Hi gang, I'm working to understand 2d text mapping onto a surface. I 
> believe
> the term is UV mapping.

Text can be textured onto objects without using uv_mapping.

UV mapping refers to assigning 2d coordinates (u,v) to points on
the surface of an object.  This is done for you on many, but not
all, primitive objects in POV.  The uv_mapping texture keyword
tells a texture to follow these (u,v) coordinates if available.

> Anyway, In a different thread in P.n-u called "Simple 2D text on a
> cylinder's surface "
> I asked about mapping, and Samuel B gave a nice example that I have been
> playing with.
> When I have a problem understanding how to apply the text, I go back to a
> flat object.
>
> Well, I'm stumped, so below is my code. Both the mesh and the disc have 
> the
> same exact material.
> The non-text part of the pattern -background- shows up the same on both
> objects.
> And they have (I think) the same location.
>
> But, the disc gets the 2d text map, the mesh doesn't.
>
> WHy?

The mesh object doesn't have a default UV mapping, you need
to supply one. This is because a mesh has no set geometry, it
might be a scroll, or a car, or a twisty geometric star do-dad.

When it comes to UV mapping a complex mesh it's possible,
but not advisable to do it by hand. It's better to use a tool
built for it.

Here's an example bu hand...
try commenting out the uv_mapping,
note the difference in scale and orientation etc...
try changing scale...
note the number of checkers on the mesh...

mesh {
    triangle {
       <0,0,0>, <2,0,0>, <3,3,0>
       uv_vectors
       <0,0>,<1,0>,<1,1>
    }
    triangle {
       <0,0,0>, <1,3,0>,<3,3,0>
       uv_vectors
       <0,0>,<1,0>,<1,1>
    }
    texture {
       uv_mapping
       pigment {
          checker White Tan
          scale 1/10
       }
    }
}


Post a reply to this message

From: JetRacer
Subject: Re: Simple 2D text, take 2
Date: 1 Dec 2007 21:15:00
Message: <web.475214c26bd11cc3278fa6d50@news.povray.org>
uv = xy on texture (roughly)

The uv is generally used as image texture coordinates ranging from 0.0
(left/down) to 1.0 (right/up) in the image. You need to specify what goes to
which vector by giving each triangle corner a uv vector. Imagine that the
texture image is a flexible piece of cloth and you use needles to force it to
wrap around the surface. Each uv vector represent a "needle" that forces the
specified uv location in the image to attach itself to a triangle corner.

Hint: The uv is a very powerfull tool which can be used for f.ex. morphing
images and for lens distortion removal in photos.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.