POV-Ray : Newsgroups : povray.newusers : Text textures? Server Time
29 Jul 2024 16:19:27 EDT (-0400)
  Text textures? (Message 1 to 5 of 5)  
From: Giuseppe Bilotta
Subject: Text textures?
Date: 19 May 2005 01:54:03
Message: <1imjmawfyhuaa$.1b8c1opq9icei$.dlg@40tude.net>
Hello all,

I definitively qualify as a newuser (heard about POV-Ray for the first
time last summer on a conference on TeX), so I might have missed
something obvious in the documentation, but for the heart of me I
can't find a simple, immediate way to "stamp" some text on an object,
esp. a curved one. For example: how would you write some text on a
spherical surface?

I've tried what seemed the most obvious thing, that is using an object
pattern where the object was a text object, but the results are barely
decent because the color alternation is based on the intersection with
the object, so the curved surface isn't followed in all aspects.

Is there some commonly used way to do it?

-- 
Giuseppe "Oblomov" Bilotta

Axiom I of the Giuseppe Bilotta
theory of IT:
Anything is better than MS


Post a reply to this message

From: Mike Williams
Subject: Re: Text textures?
Date: 19 May 2005 05:14:20
Message: <jSCL7BA5iFjCFw$B@econym.demon.co.uk>
Wasn't it Giuseppe Bilotta who wrote:
>Hello all,
>
>I definitively qualify as a newuser (heard about POV-Ray for the first
>time last summer on a conference on TeX), so I might have missed
>something obvious in the documentation, but for the heart of me I
>can't find a simple, immediate way to "stamp" some text on an object,
>esp. a curved one. For example: how would you write some text on a
>spherical surface?
>
>I've tried what seemed the most obvious thing, that is using an object
>pattern where the object was a text object, but the results are barely
>decent because the color alternation is based on the intersection with
>the object, so the curved surface isn't followed in all aspects.
>
>Is there some commonly used way to do it?
>


For objects that can be uv-mapped, you can create an object pattern and
uv-map that pattern onto the curved surface. 

  camera {location  <0,0,-20> look_at <0,0,0> angle 30}
  light_source {<-30, 100, -30> color rgb 1}

  #declare TEXT = text { ttf "crystal.ttf", "POV-Ray", 2, 0
                         scale 0.1 translate <0.57,0.6,-0.1> }
                                                
  #declare P = pigment { object {TEXT rgb <1,0,0> rgb <1,1,0>}}

  sphere {0,3 uv_mapping pigment {P}} 



For curved surfaces that have suitable map_types or can be uv_mapped,
you can create an image map of the text and use that as your pigment.

  sphere {0,3 pigment {image_map {jpeg "mytext.jpg" map_type 1 
          interpolate 2}}}

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Giuseppe Bilotta
Subject: Re: Text textures?
Date: 19 May 2005 06:45:22
Message: <173nvsrozm3vq.61l16mimoudp.dlg@40tude.net>
On Thu, 19 May 2005 10:13:29 +0100, Mike Williams wrote:

> Wasn't it Giuseppe Bilotta who wrote:
>>Hello all,
>>
>>I definitively qualify as a newuser (heard about POV-Ray for the first
>>time last summer on a conference on TeX), so I might have missed
>>something obvious in the documentation, but for the heart of me I
>>can't find a simple, immediate way to "stamp" some text on an object,
>>esp. a curved one. For example: how would you write some text on a
>>spherical surface?
> 
> For objects that can be uv-mapped, you can create an object pattern and
> uv-map that pattern onto the curved surface. 
> 
>   camera {location  <0,0,-20> look_at <0,0,0> angle 30}
>   light_source {<-30, 100, -30> color rgb 1}
> 
>   #declare TEXT = text { ttf "crystal.ttf", "POV-Ray", 2, 0
>                          scale 0.1 translate <0.57,0.6,-0.1> }
>                                                 
>   #declare P = pigment { object {TEXT rgb <1,0,0> rgb <1,1,0>}}
> 
>   sphere {0,3 uv_mapping pigment {P}} 

Thank you very much, I think I see the idea.

Am I right in saying that I should always scale the text so that it
fits within the unit box? (At least for spheres) I'm not sure what's
the purpose of the translation, though.

-- 
Giuseppe "Oblomov" Bilotta

[W]hat country can preserve its liberties, if its rulers are not
warned from time to time that [the] people preserve the spirit of
resistance? Let them take arms...The tree of liberty must be
refreshed from time to time, with the blood of patriots and
tyrants.
	-- Thomas Jefferson, letter to Col. William S. Smith, 1787


Post a reply to this message

From: Mike Williams
Subject: Re: Text textures?
Date: 19 May 2005 09:02:49
Message: <4v6d0DAa5IjCFwO8@econym.demon.co.uk>
Wasn't it Giuseppe Bilotta who wrote:
>On Thu, 19 May 2005 10:13:29 +0100, Mike Williams wrote:
>
>> Wasn't it Giuseppe Bilotta who wrote:
>>>Hello all,
>>>
>>>I definitively qualify as a newuser (heard about POV-Ray for the first
>>>time last summer on a conference on TeX), so I might have missed
>>>something obvious in the documentation, but for the heart of me I
>>>can't find a simple, immediate way to "stamp" some text on an object,
>>>esp. a curved one. For example: how would you write some text on a
>>>spherical surface?
>> 
>> For objects that can be uv-mapped, you can create an object pattern and
>> uv-map that pattern onto the curved surface. 
>> 
>>   camera {location  <0,0,-20> look_at <0,0,0> angle 30}
>>   light_source {<-30, 100, -30> color rgb 1}
>> 
>>   #declare TEXT = text { ttf "crystal.ttf", "POV-Ray", 2, 0
>>                          scale 0.1 translate <0.57,0.6,-0.1> }
>>                                                 
>>   #declare P = pigment { object {TEXT rgb <1,0,0> rgb <1,1,0>}}
>> 
>>   sphere {0,3 uv_mapping pigment {P}} 
>
>Thank you very much, I think I see the idea.
>
>Am I right in saying that I should always scale the text so that it
>fits within the unit box? (At least for spheres) I'm not sure what's
>the purpose of the translation, though.

Uv_mapping takes the pigment from the square <0,0,0><1,1,0> and maps it
onto a surface. That's not the unit cube, it's a z-plane slice through
the positive quadrant of the unit cube. It doesn't matter whether it's
for a sphere or for any other uv_mappable surface (except that uv-mapped
cubes use only parts of the square).

The x and y parts of the translation were just there to move the text to
the front of the sphere. I just judged them by eye until they looked
right. In this default orientation of the sphere, the left half of the
square [<0,0,0><0.5,1,0>] maps to the back of the sphere, and I chose to
put the text on the front and a little over half way up. 

Note that text objects are initially positioned with the bottom left
front corner of the text at the origin.

The z part of the translation copes with the fact that the front face of
the text starts off being at z=0, so when you grab the object pattern
from the z-plane slice you get something similar to a coincident surface
situation, and parts of the text go missing. Moving the object slightly
forwards ensures that the z-plane cuts cleanly through the body of the
text instead of skipping over the front face.


-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Giuseppe Bilotta
Subject: Re: Text textures?
Date: 19 May 2005 13:39:31
Message: <173usdq3y396e$.1rxmz2uxz6b7k$.dlg@40tude.net>
On Thu, 19 May 2005 14:02:18 +0100, Mike Williams wrote:
> Uv_mapping takes the pigment from the square <0,0,0><1,1,0> and maps it
> onto a surface. That's not the unit cube, it's a z-plane slice through
> the positive quadrant of the unit cube. It doesn't matter whether it's
> for a sphere or for any other uv_mappable surface (except that uv-mapped
> cubes use only parts of the square).
> 
> The x and y parts of the translation were just there to move the text to
> the front of the sphere. I just judged them by eye until they looked
> right. In this default orientation of the sphere, the left half of the
> square [<0,0,0><0.5,1,0>] maps to the back of the sphere, and I chose to
> put the text on the front and a little over half way up. 
> 
> Note that text objects are initially positioned with the bottom left
> front corner of the text at the origin.
> 
> The z part of the translation copes with the fact that the front face of
> the text starts off being at z=0, so when you grab the object pattern
> from the z-plane slice you get something similar to a coincident surface
> situation, and parts of the text go missing. Moving the object slightly
> forwards ensures that the z-plane cuts cleanly through the body of the
> text instead of skipping over the front face.

This is what I came up with in the end, which seems to be a pretty
decent:

#declare big_text = text {
	ttf "tahomabd.ttf"
	"T1"
	1, 0
} ;

#declare text_size = max_extent(big_text)-min_extent(big_text) ;
#declare text_scale_gen = 1/4 ;
#declare text_scale_x = 1 ;
#declare text_scale_y = 1 ;
#declare text_scale_f = (1/text_size.x) ;
#declare text_scale = text_scale_gen * text_scale_f * (
	text_scale_x * x +
	text_scale_y * y) ;

#declare text_obj =	object {
		big_text
			translate -1/2*text_size
			scale text_scale
			//translate (1-text_scale/big_text_ext.y)*y
			//translate (1-text_scale/big_text_ext.x)*x
			translate 1/2*(x+y)
} ;

#declare text_tex = pigment {
	object {
		text_obj
		color .6*Magenta
		color Black
	}
} ;

This is of course very specific, but my guess is that it could be
build into a function or macro which takes a text object plus a few
parameters and returns the pigment ... do you think it's worth doing?

-- 
Giuseppe "Oblomov" Bilotta


"Ma niente: prima si fanno delle cazzate,
 poi si studia che cazzate si sono fatte"
(Altan)
("And what about the history of the human race, dad?"
 "Oh, nothing special: first they make some foolish things,
  then you study what foolish things have been made")


Post a reply to this message

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