|
|
"Samuel B." <stb### [at] hotmailcom> wrote:
> Thomas de Groot <tho### [at] degrootorg> wrote:
> > 3) so it appears (to me) that the texture does not follow the object
> > rotation. Why this is is a mystery to me and it is the first time I
> > witness such behaviour indeed.
>
> Regarding your third bullet point... The texture not following the object's
> rotation is an issue I predicted, but was unsure if it would manifest or not. My
> guess is that the slope inputs (x, y, z) need to be rotated independently of the
> object [...]
(To everyone: I'm sorry for not replying to everything right now.)
As you've seen, rotating an object using a slope pattern doesn't give the result
one would hope for. Whether the rotation is placed before or after the triplanar
pattern matters a /bit/, but not enough: in either case the result will be
wrong. The answer seems to be to rotate the slope vectors /independently/ of the
object.
In the attached image, the left object is rotated in a naive manner. The right
object uses a new macro that rotates the slope vectors in tandem with the
object. It can be a hassle to do it this way, but it would appear that if you
wish to rotate your object it's what you have to put up with ;)
Here's the scene code:
/*
triplanar-debug.pov
2024 stb
+fn +f +a0.3 +am2 +r2 +w1024 +h512
*/
#version 3.7;
global_settings{assumed_gamma 1.0}
camera{
orthographic
right x*2 up y
location <0, 5, -10>
look_at 0
angle 33
}
// sunlight
#if(true)
light_source{
<1, .5, 0>*1e5, srgb <1.5, 1.4, 1.3>
shadowless
}
#end
// starry background
#if(true)
background{rgb .5}
#end
// input image for triplanar color and normal
#declare PImg =
pigment{
image_map{
png "craters.png"
interpolate 2
}
scale 2
}
#declare ObjRotate = <0, 37, 0>;
/*
Triplanar macro
Pigment: a pigment oriented in the z-direction
Sharpness: a value between 0 and 1
Rotate: the object's rotation
*/
#macro TriplanarR(Pigment, Sharpness, Rotate)
pigment_pattern{
slope vrotate(x, Rotate)
triangle_wave
}
pigment_map{
[0+.5*Sharpness Pigment rotate y*90]
[1-.5*Sharpness
pigment_pattern{
slope vrotate(y, Rotate)
triangle_wave
}
pigment_map{
[0+.5*Sharpness Pigment rotate x*90]
[1-.5*Sharpness Pigment rotate z*165]
}
]
}
#end
// don't use this if you want to rotate your object
#macro Triplanar(Pigment, Sharpness)
pigment_pattern{
slope x
triangle_wave
}
pigment_map{
[0+.5*Sharpness Pigment rotate y*90]
[1-.5*Sharpness
pigment_pattern{
slope y
triangle_wave
}
pigment_map{
[0+.5*Sharpness Pigment rotate x*90]
[1-.5*Sharpness Pigment rotate z*165]
}
]
}
#end
// object on left (naive rotation)
superellipsoid{
<.2, .2>
texture{
pigment{pigment_pattern{Triplanar(PImg, .5)}}
normal{
pigment_pattern{Triplanar(PImg, .5)}
poly_wave .5
bump_size .75
accuracy .01
}
}
rotate ObjRotate
translate -x*1.5
}
// object on right (corrected rotation)
superellipsoid{
<.2, .2>
texture{
pigment{pigment_pattern{TriplanarR(PImg, .5, ObjRotate)}}
normal{
pigment_pattern{TriplanarR(PImg, .5, ObjRotate)}
poly_wave .5
bump_size .75
accuracy .01
}
}
rotate ObjRotate
translate x*1.5
}
Sam
Post a reply to this message
Attachments:
Download 'triplanar-debug.jpg' (59 KB)
Preview of image 'triplanar-debug.jpg'
|
|