POV-Ray : Newsgroups : povray.binaries.images : Re: blurring bump map image in pov ? : Re: blurring bump map image in pov ? Server Time
7 Nov 2024 13:36:48 EST (-0500)
  Re: blurring bump map image in pov ?  
From: Jaap
Date: 30 Jul 2004 10:55:01
Message: <web.410a611d880ae268a8399d8d0@news.povray.org>
hi,
using a simple
((myFunction(x-1,y,z).gray + myFunction(x+1,y,z).gray)/2)
works fine, but i'm having some trouble converting a value
to float (so i can use it in an #if statement.
tricks like:
0.0+myFunction(x,y,z).red
1.0*myFunction(x,y,z).red
(myFunction(x,y,z).red)
does not seem to work.

is it possible to get a float value from the function.

jaap.

#declare myTextObject =
text {
  ttf "Quenya.ttf" "test test test test" 5, 0
  //pigment { White }
  rotate -x*90
  scale <-1,1,-1>
  scale <1,2,1>
  translate <4,-3,11>
}

#declare myFunction = function {
  pigment {
    object {
      myTextObject
      color rgb 0 // outside text
      color rgb 1 // inside  text
    }
  }
}

#declare myBlurredFunction = function {
  #declare myOffset = 1;
  #declare edgeDistance = 0;

  // ((myFunction(x-1,y,z).gray + myFunction(x+1,y,z).gray)/2)  // ok.


  #declare myFloat = (myFunction(x,y,z).red); // ???????????????


  #if ( myFloat <  0.5)
    // find distance to neerest edge, seaching in a spiral pattern:
    #while(myOffset < 10)
      #declare myDirection = 0;
      #while(myDirection < 4)
        #switch (myDirection)
        #case (0)
          #if(myFunction(x+0.01*myOffset,y,z).gray > 0.5) // +X
            #declare edgeDistance = myOffset;
            #declare myOffset = 100; //done.
          #end
        #break
        #case (1)
          #if(myFunction(x,y+0.01*myOffset,z).gray > 0.5) // +Y
            #declare edgeDistance = myOffset;
            #declare myOffset = 100; //done.
          #end
        #break
        #case (2)
          #if(myFunction(x-0.01*myOffset,y,z).gray > 0.5) // -X
            #declare edgeDistance = myOffset;
            #declare myOffset = 100; //done.
          #end
        #break
        #case (3)
          #if(myFunction(x,y-0.01*myOffset,z).gray > 0.5) // -Y
            #declare edgeDistance = myOffset;
            #declare myOffset = 100; //done.
          #end
        #break
        #end
        #declare Direction = Direction + 1;
      #end
      #declare myOffset = myOffset + 1;
    #end

    #if(edgeDistance==0)
      // no edge found:
      1
    #else
      // return 0..1 slope depending on distance to edge:
      (1-(edgeDistance/10))
    #end
  #else
    // this is on the lettering:
    0
  #end
}


Post a reply to this message

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