POV-Ray : Newsgroups : povray.general : Feature Request: Textures as a function of distance (?) Server Time
31 Oct 2024 08:19:12 EDT (-0400)
  Feature Request: Textures as a function of distance (?) (Message 1 to 6 of 6)  
From: mwhidden
Subject: Feature Request: Textures as a function of distance (?)
Date: 15 Dec 2005 11:35:00
Message: <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.


Post a reply to this message

From: Tim Nikias
Subject: Re: Feature Request: Textures as a function of distance (?)
Date: 15 Dec 2005 11:44:23
Message: <43a19d67$1@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.

Why not use a spherical-texture-map and map a detailed texture to the center
of the sphere and the brown pigment to the rim? Scaling the sphere would
adjust the "distance-mapping" of your texture.

You'd have to integrate some variables to keep track where the camera is and
translate the sphere accordingly. If you scale the sphere, you'd have to
reverse-scale the textures (I think, untested, but that's what often happens
to me, depending on the approach), but aside of that, there isn't much to be
found which would be impossible for POV-SDL (just the time required to do it
is a nuisance sometimes :-).

Regards,
Tim


-- 
aka "Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: mwhidden
Subject: Re: Feature Request: Textures as a function of distance (?)
Date: 15 Dec 2005 12:25:01
Message: <web.43a1a6c3dd5cc509c739b8ad0@news.povray.org>
"Tim Nikias" <JUSTTHELOWERCASE:timISNOTnikias(at)gmx.netWARE> wrote:

> Why not use a spherical-texture-map and map a detailed texture to the center
> of the sphere and the brown pigment to the rim? Scaling the sphere would
> adjust the "distance-mapping" of your texture.

I might give that a try, but my gut says that texture maps with complex
textures take even longer to render than complex textures. But, my gut has
been known to be wrong. Often.


Post a reply to this message

From: Zeger Knaepen
Subject: Re: Feature Request: Textures as a function of distance (?)
Date: 15 Dec 2005 13:26:09
Message: <43a1b541$1@news.povray.org>
"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

From: Marc Jacquier
Subject: Re: Feature Request: Textures as a function of distance (?)
Date: 15 Dec 2005 14:59:08
Message: <43a1cb0c$1@news.povray.org>

le message de news:43a19d67$1@news.povray.org...
>
> You'd have to integrate some variables to keep track where the camera is
and
> translate the sphere accordingly. If you scale the sphere, you'd have to
> reverse-scale the textures (I think, untested, but that's what often
happens
> to me, depending on the approach), but aside of that, there isn't much to
be
> found which would be impossible for POV-SDL (just the time required to do
it
> is a nuisance sometimes :-).
>
> Regards,
> Tim
>
The use of pigment_pattern for the texture_map allows independent pattern
and textures transformations

#version 3.5;

#include "colors.inc"

global_settings {
  assumed_gamma 1.0
}

// ----------------------------------------
#declare Cam_loc=<0.0, 1, -4.0>;  // Camera location declaration
camera {
  location  Cam_loc
  right     x*image_width/image_height
  look_at   <0.0, 0.0,  0.0>
}

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 <-30, 30, -30>
}

// ----------------------------------------
#declare Texture0  = texture {
    pigment {
      checker
      color rgb 1
      color rgb <1.0, 0.0, 0.0>

    }
  }
#declare Texture1  = texture { pigment {
      checker
      color rgb 1
      color rgb <0.0, 0.0, 1.0>

    }
  }
//*********************************************************** Here begins
the texture
#declare T_distance =
   texture
   {
      pigment_pattern
      {
            spherical
            /*
            color_map   {  [ 0.0     rgb 0 ] [ 1.0     rgb 1 ]} //optional
colormap
            */

       scale 100  //scale as needed
     translate Cam_loc   //pre declared Camera location
      }
      texture_map
      {
         [0.0 Texture0]
         [1.0 Texture1]
      }
   }


plane {
  y, -1
  texture{T_distance}}



sphere {              // reflective sphere
  0.0, 1
  texture {
    pigment {
      color rgb <0.8,0.8,1.0>
    }
    finish{
      diffuse 0.3
      ambient 0.0
      specular 0.6
      reflection {
        0.8
        metallic
      }
      conserve_energy
    }
  }
}


Post a reply to this message

From: mwhidden
Subject: Re: Feature Request: Textures as a function of distance (?)
Date: 6 Jan 2006 09:20:01
Message: <web.43be7c60dd5cc509c739b8ad0@news.povray.org>
Thanks to Tim, Zeger, and Marc for the great ideas, SDL and tips. Really
appreciated. And have a happy new year.

-Mike


Post a reply to this message

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