|
|
"mwhidden" <nomail@nomail> wrote in message
news:web.43a19ad523905be9c739b8ad0@news.povray.org...
>
> Would it make any sense to allow multiple textures to be specified on
an
> object, where the texture selected is a function of the distance of
the
> surface to the camera? Similar to MIP mapping on scanline renderers --
so
> that my gorgeous wood floor texture (yeah right!) can switch to a
plain
> brown pigment with no normals when it is far from the camera.
These macros I made might come in handy:
--- start code ---
#macro MipmapNormal ()
pigment_pattern {
spherical scale Dsize translate Camera_Location poly_wave Dpoly
pigment_map {
[0 pigment_pattern {aoi color_map {[0 rgb 1][.5 rgb 0]}} color_map
{[0 rgb 0][1 rgb 0]} poly_wave AOIpoly]
[1 pigment_pattern {aoi color_map {[0 rgb 1][.5 rgb 0]}} color_map
{[0 rgb 0][1 rgb 1]} poly_wave AOIpoly]
}
}
normal_map {
#declare Teller=MipmapLevels;;
#while ( Teller > 0 )
[(MipmapLevels-Teller)/MipmapLevels
MipmapTexture(Teller, (MipmapLevels-Teller)/MipmapLevels)
]
#declare Teller=Teller-1;
#end
}
#end
#macro MipmapPigment ()
pigment_pattern {
spherical scale Dsize translate Camera_Location poly_wave Dpoly
pigment_map {
[0 pigment_pattern {aoi color_map {[0 rgb 1][.5 rgb 0]}} color_map
{[0 rgb 0][1 rgb 0]} poly_wave AOIpoly]
[1 pigment_pattern {aoi color_map {[0 rgb 1][.5 rgb 0]}} color_map
{[0 rgb 0][1 rgb 1]} poly_wave AOIpoly]
}
}
pigment_map {
#declare Teller=MipmapLevels;;
#while ( Teller > 0 )
[(MipmapLevels-Teller)/MipmapLevels
MipmapTexture(Teller, (MipmapLevels-Teller)/MipmapLevels)
]
#declare Teller=Teller-1;
#end
}
#end
--- end code ---
To use it, you first have to declare Camera_Location and the following
variables: AOIpoly, Dpoly, Dsize, MipmapLevels
For these variables, the following values seem to work fine:
// for 1600*1200
#declare AOIpoly=.125;
#declare Dpoly=4;
#declare Dsize=75;
// for 640*480
#declare AOIpoly=.125;
#declare Dpoly=4;
#declare Dsize=50;
// for 320*240
#declare AOIpoly=.125;
#declare Dpoly=4;
#declare Dsize=30;
// for 160*120
#declare AOIpoly=.125;
#declare Dpoly=4;
#declare Dsize=11;
MipmapLevels is pretty straightforward, I think.
Then you have to define the actual texture with a macro, for example:
(works only for image_maps and bump_maps of course, because you have to
prerender the mipmaps yourself)
#macro MipmapTexture(Image,Bumpsize)
image_map {
#local Afbeeldingnaam=concat("bakstenen",str(Image,0,0),".png");
png Afbeeldingnaam interpolate 2
}
scale 8
warp {turbulence .1 lambda 4}
scale 1/8
#end
Then you can use MipmapPigment as an ordinary pigment and MipmapNormal
as an ordinary normal, just be sure you don't transform it, or it will
give weird results.
It will not work properly with reflections or refractions, but I think
it's the best that is currently possible with POV-Ray, or at least the
best I could come up with :p
I hope it's more or less clear how to use it.
Oh yes, one more thing: you have to make the mipmaps yourself, as I
already said, and you have to name them
<imagename><mipmaplevel>.<extension>, so for example:
rocks1.png
rocks2.png
rocks3.png
hope this helps (for demo-images, check my mipmapping-posts on p.b.i, or
just take a look at the experiments-section on my site :))
cu!
--
#macro G(b,e)b+(e-b)*C/50#end#macro _(b,e,k,l)#local C=0;#while(C<50)
sphere{G(b,e)+3*z.1pigment{rgb G(k,l)}finish{ambient 1}}#local C=C+1;
#end#end _(y-x,y,x,x+y)_(y,-x-y,x+y,y)_(-x-y,-y,y,y+z)_(-y,y,y+z,x+y)
_(0x+y.5+y/2x)_(0x-y.5+y/2x) // ZK http://www.povplace.com
Post a reply to this message
|
|