Recently I've been looking at Povray, pyprocessing, and cfdg (version 3.0) as tools for creating digital images. I have branched two separate blogs where I mainly explore jruby + processing and processing.py

Sunday, 19 December 2010

Getting to grips with povray and processing

I've been hacking away at the supercad library and its export to povray feature.  Guillaume comments in the code that the hard coded pov template is a hack, so I have created my own template text file that is imported into the application. This template features #declared COLOR, #declared PIGMENT and #declared FINISH. Since I'm using povray version 3.7 beta, I have set that versions features (seemingly gamma in version 3.6 was a right mess and many fudges were introduced to overcome the issue) to be used when rendering. Here is my template:-

   1 #include "stdinc.inc"
   2 // #include "stones.inc"   // include only pre-defined scene elements 
   3 // #include "textures.inc" // that you are using?
   4 // #include "shapes.inc"
   5 // #include "glass.inc"
   6 // #include "metals.inc"
   7 // #include "woods.inc"
   8 
   9 #declare COL1 = color rgb<0.6, 0.1, 0.0>;
  10 #declare PIGMENT1 = pigment { COL1 }
  11 #declare PHONG1 = finish { emission 0.1
  12                             phong 0.5
  13                             phong_size 60
  14                             metallic
  15                           }
  16 #declare SPECULAR1 = finish { 
  17                               emission 0.1
  18                               specular 0.9
  19                               roughness 0.03
  20                             }
  21                    
  22                        
  23                           
  24 #version 3.7; // favor version 3.7, gamma setup was/is a mess in version 3.6
  25 
  26 global_settings{
  27   charset utf8  // we are not American charset utf8 or iso-9660-1
  28   max_trace_level 5
  29 }
  30 
  31 camera {
  32   location <200, 20, -300>
  33   look_at<0, 0, 0>
  34 }
  35 
  36 sky_sphere {
  37   pigment {
  38     gradient y
  39     color_map {
  40       [ 0.5  color CornflowerBlue ]
  41       [ 1.0  color MidnightBlue ]
  42     }
  43     scale 2
  44     translate x
  45   }
  46 }
  47 
  48 plane{ <0, 1, 0>, -400
  49   texture{
  50   pigment{    
  51     checker color Red, color Blue
  52   }
  53   scale 500
  54   }
  55 }
  56 
  57 light_source { <0, 400, 30> color White}

I have yet to resolve the conflicting coordinate system +ve Z into screen povray +ve Y is up povray (disagrees with processing, now solved). But here is one of the results so far. In this sketch I hand edited color to Silver, used with specular finish (also added metallic keyword for finish) for the menger. I don't know why I had to scale the floor texture by so  much. A feature of my modified 'supercad' is more OO features, I have created a PovObject class to store an objects attributes, that uses StringBuilder to create the pov script. PovTriangle inherits from PovObject. A PovWriter class, reads in the pov template and then writes the merged StringBuilder (representing the pov file) directly to file (no-need to convert to String).  I am tempted to create direct support for box and sphere primitives, rather than rely on the mesh triangle interface that makes for rather large pov files (must checkout how joons does this for sunflow).

povray rendered

No comments:

Post a Comment

Followers

Blog Archive

About Me

My photo
Pembrokeshire, United Kingdom
I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2