POV-Ray : Newsgroups : povray.general : Need for new pattern - cubediv? Server Time
23 Dec 2024 22:33:13 EST (-0500)
  Need for new pattern - cubediv? (Message 1 to 9 of 9)  
From: Raf256
Subject: Need for new pattern - cubediv?
Date: 21 Sep 2006 02:00:14
Message: <45122a6d@news.povray.org>
Imho there is a need for new pigment pattern.

The problem: I have an object close to cube (but this is not exacly a typial
box but some shape).

I want to texture it as it would be a box, applying different texture to
each of 6 direction/faces (if a face is not exacly a face of a box, then
choose the closest of 6 possible textures/directions)

This trivial task turns out very hard, one have to create 3 or 6 shapes each
with different texture and try to combine them. It not always work, and it
is an ugly hack imho.

The slope y texture_map solves the problem if we need just 2 directions,
like a texture for "up" and "down".

Imho the solution would be a pattern returning one of 6 values (so like 0,
1/6, 2/6 etc) basing on the direction.

If (x>y) && (x>z) then the main direction is +x 
If (x<y) && (x<z) then the main direction is -x 
end so on.

then just use a texture_map with 6 entries on that function, and you got a
nice texturing for faces of box-like objects.

What do you think?

How to implement that exacly?


Post a reply to this message

From: Raf256
Subject: Re: Need for new pattern - cubediv?
Date: 21 Sep 2006 02:50:48
Message: <45123647@news.povray.org>
Raf256 <45122a6d@news.povray.org> Thursday 21 of September 2006 08:00


> Imho the solution would be a pattern returning one of 6 values (so like 0,
> 1/6, 2/6 etc) basing on the direction.
> If (x>y) && (x>z) then the main direction is +x
> If (x<y) && (x<z) then the main direction is -x
> end so on.

So far I think I was able to work around using function...

  #declare choose_texture = function(x,y,z) {
    (
    ((y>=abs(x))&(y>=abs(z)))*1+
    ((x>=abs(y))&(x>=abs(z)))*2+
    ((z>=abs(x))&(z>=abs(y)))*3+

    ((-y>=abs(x))&(-y>=abs(z)))*4+
    ((-x>=abs(y))&(-x>=abs(z)))*5+
    ((-z>=abs(x))&(-z>=abs(y)))*6
    )/6
  }


-- 

Cytat tygodnia:


Post a reply to this message

From: Slime
Subject: Re: Need for new pattern - cubediv?
Date: 21 Sep 2006 03:43:18
Message: <45124296$1@news.povray.org>
> The slope y texture_map solves the problem if we need just 2 directions,
> like a texture for "up" and "down".

Wouldn't it be possible to do something like this? (Sorry for lack of
tabbing, and this isn't tested code)

#declare uppercutoff = (cos(degrees(45)) + 1) * 0.5;
#declare lowercutoff = 1 - uppercutoff;

#declare ZSlope = texture {
slope {z}
texture_map {
[0.5
// -z texture here
]
[0.5
// +z texture here
]
}
}

#declare YSlope = texture {
slope {y}
texture_map {
[lowercutoff
// -y texture here
]
[lowercutoff XSlope]
[uppercutoff XSlope]
[uppercutoff
// +y texture here
]
}
}

texture{
slope {x}
texture_map {
[lowercutoff
// -x texture here
]
[lowercutoff YSlope]
[uppercutoff YSlope]
[uppercutoff
// +x texture here
]
}
}


 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Warp
Subject: Re: Need for new pattern - cubediv?
Date: 21 Sep 2006 04:42:11
Message: <45125062@news.povray.org>
Raf256 <spa### [at] raf256invalid> wrote:
> This trivial task turns out very hard, one have to create 3 or 6 shapes each
> with different texture and try to combine them. It not always work, and it
> is an ugly hack imho.

  No, one have not. I have posted this before:


camera { location -z*6 look_at 0 angle 35 }
light_source { <15, 20, -50>, 2 }

#declare Pyramid = function { abs(x) < y & abs(z) < y };

#declare CubePattern =
  function
  { Pyramid(x, -z, y)*1/6+
    Pyramid(y, x, z)*2/6+
    Pyramid(x, z, y)*3/6+
    Pyramid(y, -x, z)*4/6+
    Pyramid(x, -y, z)*5/6
  };

#declare Image =
  pigment
  { image_map { jpeg "image" }
    translate -.5
    scale 2
  };

#declare ThePigment =
  pigment
  { function { CubePattern(x, y, z) }
    pigment_map
    { [0/6 Image rotate x*90]
      [1/6 Image]
      [2/6 Image rotate -y*90]
      [3/6 Image rotate -y*180]
      [4/6 Image rotate y*90]
      [5/6 Image rotate -x*90]
    }
  };

superellipsoid
{ <.2, .2>
  pigment { ThePigment }
  rotate y*30 rotate x*-30
}



-- 
                                                          - Warp


Post a reply to this message

From: Raf256
Subject: Re: Need for new pattern - cubediv?
Date: 21 Sep 2006 07:13:07
Message: <451273c2@news.povray.org>
Warp <45125062@news.povray.org> Thursday 21 of September 2006 10:42

>   No, one have not. I have posted this before:

I browsed few posts in archiwum before ;)

>   pigment
>   { function { CubePattern(x, y, z) }
>     pigment_map
>     { [0/6 Image rotate x*90]
>       [1/6 Image]
>       [2/6 Image rotate -y*90]
>       [3/6 Image rotate -y*180]
>       [4/6 Image rotate y*90]
>       [5/6 Image rotate -x*90]
>     }
>   };
> 

Wow, awesome - I invented almost identical solution on my own (see the other
post).

Before I tried also making actual 6 pyramids shape and intersecting it with
the shape we want, but it didnt worked when using 6 prisms intersected with
superellipsoid; Neither it worked when intersecting mesh with superelis -
in general the texture from mash was not used.

Still I think it is common enought to code there a function to do that
fastly, not by using function{}

-- 

Cytat tygodnia:


Post a reply to this message

From: chaps
Subject: Re: Need for new pattern - cubediv?
Date: 28 Sep 2006 16:45:00
Message: <web.451c337e49dcb598a2c2e8e00@news.povray.org>
What do you think about a 2 steps approach:

first step: render a box, with 6 different pigments, one for each face, with
a spherical camera at the box center, ambient light only.

second step: use the previous image as spherical image map for texture
mapping?

Sorry I am too lazy and too busy to try this.

Bye,

Pascal


Post a reply to this message

From: Warp
Subject: Re: Need for new pattern - cubediv?
Date: 28 Sep 2006 17:27:21
Message: <451c3e39@news.povray.org>
chaps <cha### [at] yahoocom> wrote:
> What do you think about a 2 steps approach:

  How is this better than my solution?

-- 
                                                          - Warp


Post a reply to this message

From: chaps
Subject: Re: Need for new pattern - cubediv?
Date: 29 Sep 2006 17:20:01
Message: <web.451d8cd349dcb598b2cc20f30@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> chaps <cha### [at] yahoocom> wrote:
> > What do you think about a 2 steps approach:
>
>   How is this better than my solution?
>
> --
>                                                           - Warp

Well Warp, I was not looking for better solution.

The fact is that I am reading these news very late in the night, after a
full day working, and that I saw the x y and z axis melting and mixing in
front of me while I tried to figure out what cout be the value of the
cube_pattern function...

So I tried to avoid headhache and proposed to kindly ask to pov (and its
designer) to do the work for me :p.

May be I will look at this deeper during the week end.

Pascal


Post a reply to this message

From: chaps
Subject: Re: Need for new pattern - cubediv?
Date: 30 Sep 2006 15:45:01
Message: <web.451ec7a549dcb598eb7c3d8d0@news.povray.org>
I have tried the 2 solutions and here are the results:

                    Warp          |  Pascal
                   method         |  method
                                  |
complexity       Warp win:        |  I got some
                 cut & paste      |  syntax error
                                  |
result           Warp win:        |  blured picture
                 good definition  |
                                  |
render time      41s on my PC     |  Pascal win
                                  |  14s on my PC
                                  |
evolution        Can be use for   |  I dont see how
                 texture mapping? |  to extend to
                 I guess yes.     |  texture mapping

So I think your method is much better....
...... and understandable after some rest + 1 cofee.

Pascal

the code I used:

##############  create spherical image
global_settings {
  ambient_light color rgb <1,1,1>
}
camera {
  spherical
  location <0,0,0>
  look_at  <0,0,-1>
  angle 360             // horizontal degrees
        180             // vertical degrees
}
#declare Image =
  pigment
  { image_map { jpeg "mosquee1.jpg" once}
    translate -.5
    scale 2
  };
#declare face =
         plane {
                -z,
                1.0
                hollow on
                no_shadow
                pigment { Image }
                finish {
                ambient 1
        }
}
object {face rotate x*-90}
object {face rotate x*90}
object {face rotate y*90}
object {face rotate y*-90}
object {face rotate y*0}
object {face rotate y*180}

######################"  Test methods: looks like Warp code :))

camera { location -z*6 look_at 0 angle 35 }
light_source { <15, 20, -50>, 2 }
#declare Pyramid = function { abs(x) < y & abs(z) < y };
#declare CubePattern =
  function
  { Pyramid(x, -z, y)*1/6+
    Pyramid(y, x, z)*2/6+
    Pyramid(x, z, y)*3/6+
    Pyramid(y, -x, z)*4/6+
    Pyramid(x, -y, z)*5/6
  };
#declare Image =
  pigment
  { image_map { jpeg "mosquee1.jpg" }
    translate -.5
    scale 2
  };
#declare ThePigment =
  pigment
  { function { CubePattern(x, y, z) }
    pigment_map
    { [0/6 Image rotate x*90]
      [1/6 Image]
      [2/6 Image rotate -y*90]
      [3/6 Image rotate -y*180]
      [4/6 Image rotate y*90]
      [5/6 Image rotate -x*90]
    }
  };
#declare ThePigment2 =
  pigment
  {
     image_map {
        tga "SpericalMap.tga"
        map_type 1        // 1=spherical
        interpolate 2     // 2=bilinear,
        once              // for no repetitive tiling
     }
  };
superellipsoid
{ <.2, .2>
  pigment { ThePigment }
  rotate y*30 rotate x*-30
}


Post a reply to this message

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