POV-Ray : Newsgroups : povray.newusers : Reflect light inside box : Re: Reflect light inside box Server Time
27 Sep 2024 18:45:31 EDT (-0400)
  Re: Reflect light inside box  
From: Kenneth
Date: 12 Dec 2012 22:15:00
Message: <web.50c94541cf1ff5fec2d977c20@news.povray.org>
Try this slightly corrected, working version. I found a few syntax
errors--nothing to worry about, as we all make them from time to time. I've
included some helpful notes in the code.

 #include "colors.inc" // for your "White" and "Blue" colors
 global_settings{photons{spacing 0.1}}

 #declare my_texture =
   texture {
    // Did you mean to leave out a pigment? If so, that's OK, because a
    // 'default' pigment is substituted (but I think it's black, i.e., <0,0,0>)
    pigment{rgb .7} // POV-Ray expands this to <.7,.7,.7> or a bright gray
     finish{
        reflection{
        0.3, 1 // Might be too much reflection; try .2,.7
        fresnel
        metallic
                }
      specular 1
      roughness 0.1
           }
           }

 background { color Blue }

 camera {
      location <0, 10, -50>
      look_at  <0, 0,  20>
    }

 difference{
    box{< -10,  0,  0>,<10,  20,   20>}//outside of the box
    box{<-9.6, 0.4, 0.4>,<9.6, 19.6, 19.6>}//inside of the box
 // the walls now have a thickness of 0.4 unit
    //box{<-9,1, 0>,<9, 10, 0.4>}// the opening. [This box doesn't work the
    //way you want, the dimensions are a little bit off. Try this one...
    box{<-9.1,1,-.1>,<9,10,.5>}
    texture{
      my_texture  // As Alain mentioned. BTW, no comma should go after this.
           }
  // There was an extra } bracket here, so I removed it

 photons{target reflection on}
 rotate y*30
 } // end of the difference

 light_source { <5, 20, -30>
   color White
 }

//-------------

Sometimes POV-Ray returns an error message that may not make sense (if you can't
easily find the flaw it's reporting.) You'll need to more thoroughly search your
code, up above the flagged error line, to check for any other syntax errors,
missing brackets, etc.

BTW, when making hollow boxes like yours, I find it easier to specify the boxes
like this:

difference{
box{0,1 translate -.5} // i.e., <0,0,0>,<1,1,1>  then centers this unit-size
// box on the origin.
box{0,1 translate -.5 scale .95} // same, but a slightly smaller box
box{0,1 scale <...>  translate <...>  // the cutaway box
 scale <....> // final scale of the completed difference
 texture{...}
 rotate ... // this rotates the difference (and its texture) around
            // the origin--usually more intuitive.
 translate <....> // wherever you want it to go
 }

This way, you don't need to spend time figuring out the precise dimensions of
the inner box to get it 'centered' in the outer box; the 2nd box's scale takes
care of all that. In this case, though, some of the walls may end up with
different thicknesses, if you scale everything into a 'rectangular' shape.

How to go about things most efficiently in POV-Ray just involves experimenting
and practice. You'll find there are many ways of getting a certain result.


Post a reply to this message

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