description="Newton's thin film interference (like an oil slick on a puddle of water or the rainbow hues of a soap bubble.)",
default=False)
Mat.pov_mirror_use_IOR=BoolProperty(
name="Correct Reflection",
description="Use same IOR as raytrace transparency to calculate mirror reflections. More physically correct",
default=False)
Mat.pov_mirror_metallic=BoolProperty(
name="Metallic Reflection",
description="mirror reflections get colored as diffuse (for metallic materials)",
default=False)
Mat.pov_conserve_energy=BoolProperty(
name="Conserve Energy",
description="Light transmitted is more correctly reduced by mirror reflections, also the sum of diffuse and translucency gets reduced below one ",
default=True)
Mat.pov_irid_amount=FloatProperty(
name="amount",
description="Contribution of the iridescence effect to the overall surface color. As a rule of thumb keep to around 0.25 (25% contribution) or less, but experiment. If the surface is coming out too white, try lowering the diffuse and possibly the ambient values of the surface.",
description="use only fake refractive caustics (default) or photon based reflective/refractive caustics",
default=True)
Mat.pov_fake_caustics=BoolProperty(
name="Fake Caustics",
description="use only (Fast) fake refractive caustics",
default=True)
Mat.pov_fake_caustics_power=FloatProperty(
name="Fake caustics power",
description="Values typically range from 0.0 to 1.0 or higher. Zero is no caustics. Low, non-zero values give broad hot-spots while higher values give tighter, smaller simulated focal points",
description="Light passing through will be separated according to wavelength. This ratio of refractive indices for violet to red controls how much the colors are spread out 1 = no dispersion, good values are 1.01 to 1.1",
ifnotext:print(' WARNING: texture image format not supported ')# % (imgF , '')) #(ext_orig)))
returnext
defimgMap(ts):
image_map=''
ifts.mapping=='FLAT':image_map=' map_type 0 '
ifts.mapping=='SPHERE':image_map=' map_type 1 '# map_type 7 in megapov
ifts.mapping=='TUBE':image_map=' map_type 2 '
#if ts.mapping=='?':image_map= ' map_type 3 '# map_type 3 and 4 in development (?) for Povray, currently they just seem to default back to Flat (type 0)
#if ts.mapping=='?':image_map= ' map_type 4 '# map_type 3 and 4 in development (?) for Povray, currently they just seem to default back to Flat (type 0)
ifts.texture.extension=='CLIP':image_map+=' once '
#image_map+='}'
#if ts.mapping=='CUBE':image_map+= 'warp { cubic } rotate <-90,0,180>' #no direct cube type mapping. Though this should work in POV 3.7 it doesn't give that good results(best suited to environment maps?)
#if image_map=='': print(' No texture image found ')
returnimage_map
defimgMapBG(wts):
image_mapBG=''
ifwts.texture_coords=='VIEW':image_mapBG=' map_type 0 '#texture_coords refers to the mapping of world textures
ifwts.texture.extension=='CLIP':image_mapBG+=' once '
#image_mapBG+='}'
#if wts.mapping=='CUBE':image_mapBG+= 'warp { cubic } rotate <-90,0,180>' #no direct cube type mapping. Though this should work in POV 3.7 it doesn't give that good results(best suited to environment maps?)
#if image_mapBG=='': print(' No background texture image found ')
elifmaterial.pov_mirror_use_IOR:#Then the raytrace IOR taken from raytrace transparency properties and used for reflections if IOR Mirror option is checked
#If only Raytrace transparency is set, its IOR will be used for refraction, but user can set up "un-physical" fresnel reflections in raytrace mirror parameters.
#Last, if none of the above is specified, user can set up "un-physical" fresnel reflections in raytrace mirror parameters. And pov IOR defaults to 1.
##################Plain version of the finish (previous ones are variations for specular/Mirror texture channel map with alternative finish of 0 specular and no mirror reflection###
file.write('\tspecular %.3g\n'%(material.specular_intensity/(material.specular_slope+0.0005)))#find best suited default constant for brilliance Use both phong and specular for some values.
file.write('\troughness %.4g\n'%(0.0005+material.specular_slope/10))#find best suited default constant for brilliance Use both phong and specular for some values.
file.write('\tbrilliance %.4g\n'%(1.8-material.specular_slope*1.8))#find best suited default constant for brilliance Use both phong and specular for some values.
file.write('\tspecular %.3g\n'%(material.specular_intensity/(material.specular_slope+0.0005)))#find best suited default constant for brilliance Use both phong and specular for some values.
file.write('\troughness %.4g\n'%(0.0005+material.specular_slope*5))#Multiplied for max value of Textured Spec.
file.write('\tbrilliance %.4g\n'%(1.8-material.specular_slope*1.8))#find best suited default constant for brilliance Use both phong and specular for some values.
##sqrt(subsurface_scattering.radius[1] above is just some non linear relation to keep "proportions" between blender presets values and povray. The following paper has samples of sigma numbers we can put directly into pov to get good results:
iflamp.type!='SUN'andlamp.type!='AREA':#Sun shouldn't be attenuated. and area lights have no falloff attribute so they are put to type 2 attenuation a little higher above.
file.write('\tfade_power %d\n'%1)# Could use blenders lamp quad?
mappingSpec=(" translate <%.4g-0.75,%.4g-0.75,%.4g-0.75> scale <%.4g,%.4g,%.4g>"%(t_spec.offset.x/10,t_spec.offset.y/10,t_spec.offset.z/10,t_spec.scale.x/2.25,t_spec.scale.y/2.25,t_spec.scale.z/2.25))#strange that the translation factor for scale is not the same as for translate. ToDo: verify both matches with blender internal.
mappingAlpha=(" translate <%.4g-0.75,%.4g-0.75,%.4g-0.75> scale <%.4g,%.4g,%.4g>"%(t_alpha.offset.x/10,t_alpha.offset.y/10,t_alpha.offset.z/10,t_alpha.scale.x/2.25,t_alpha.scale.y/2.25,t_alpha.scale.z/2.25))#strange that the translation factor for scale is not the same as for translate. ToDo: verify both matches with blender internal.
mappingDif=(" translate <%.4g-0.75,%.4g-0.75,%.4g-0.75> scale <%.4g,%.4g,%.4g>"%(t_dif.offset.x/10,t_dif.offset.y/10,t_dif.offset.z/10,t_dif.scale.x/2.25,t_dif.scale.y/2.25,t_dif.scale.z/2.25))#strange that the translation factor for scale is not the same as for translate. ToDo: verify both matches with blender internal.
iftexturesAlpha!='':
mappingAlpha=(" translate <%.4g-0.75,%.4g-0.75,%.4g-0.75> scale <%.4g,%.4g,%.4g>"%(t_alpha.offset.x/10,t_alpha.offset.y/10,t_alpha.offset.z/10,t_alpha.scale.x/2.25,t_alpha.scale.y/2.25,t_alpha.scale.z/2.25))#strange that the translation factor for scale is not the same as for translate. ToDo: verify both matches with blender internal.
################################Second index for mapping specular max value##################################################################################################
file.write('\n\t\t\t\t\t\t\t[1 ')
iftexturesDif=='':
iftexturesAlpha!='':
mappingAlpha=(" translate <%.4g-0.75,%.4g-0.75,%.4g-0.75> scale <%.4g,%.4g,%.4g>"%(t_alpha.offset.x/10,t_alpha.offset.y/10,t_alpha.offset.z/10,t_alpha.scale.x/2.25,t_alpha.scale.y/2.25,t_alpha.scale.z/2.25))#strange that the translation factor for scale is not the same as for translate. ToDo: verify both matches with blender internal.
mappingDif=(" translate <%.4g-0.75,%.4g-0.75,%.4g-0.75> scale <%.4g,%.4g,%.4g>"%(t_dif.offset.x/10,t_dif.offset.y/10,t_dif.offset.z/10,t_dif.scale.x/2.25,t_dif.scale.y/2.25,t_dif.scale.z/2.25))#strange that the translation factor for scale is not the same as for translate. ToDo: verify both matches with blender internal.
iftexturesAlpha!='':
mappingAlpha=(" translate <%.4g-0.75,%.4g-0.75,%.4g-0.75> scale <%.4g,%.4g,%.4g>"%(t_alpha.offset.x/10,t_alpha.offset.y/10,t_alpha.offset.z/10,t_alpha.scale.x/2.25,t_alpha.scale.y/2.25,t_alpha.scale.z/2.25))#strange that the translation factor for scale is not the same as for translate. ToDo: verify both matches with blender internal.
#These lines added to get sky gradient (visible with PNG output)
ifworld:
#For simple flat background:
ifnotworld.use_sky_blend:
file.write('background {rgbt<%.3g, %.3g, %.3g, 1>}\n'%(tuple(world.horizon_color)))#Non fully transparent background could premultiply alpha and avoid anti-aliasing problem. Put transmit to 1 reveals pov problem with nonpremult antialiased.
#For Background image textures
fortinworld.texture_slots:#risk to write several sky_spheres but maybe ok.
iftandt.texture.type=='IMAGE':#and t.use: #No enable checkbox for world textures yet (report it?)
#commented below was an idea to make the Background image oriented as camera taken here: http://news.povray.org/povray.newusers/thread/%3Cweb.4a5cddf4e9c9822ba2f93e20@news.povray.org%3E/
#mappingBlend = (" translate <%.4g,%.4g,%.4g> rotate z*degrees(atan((camLocation - camLookAt).x/(camLocation - camLookAt).y)) rotate x*degrees(atan((camLocation - camLookAt).y/(camLocation - camLookAt).z)) rotate y*degrees(atan((camLocation - camLookAt).z/(camLocation - camLookAt).x)) scale <%.4g,%.4g,%.4g>b" % (t_blend.offset.x / 10 ,t_blend.offset.y / 10 ,t_blend.offset.z / 10, t_blend.scale.x ,t_blend.scale.y ,t_blend.scale.z))#replace 4/3 by the ratio of each image found by some custom or existing function
#using camera rotation valuesdirectly from blender seems much easier
#Putting the map on a plane would not introduce the skysphere distortion and allow for better image scale matching but also some waay to chose depth and size of the plane relative to camera.
file.write('\t\t\t[1.0 rgbt<%.3g, %.3g, %.3g, 0.99>]\n'%(tuple(world.horizon_color)))#aa premult not solved with transmit 1
file.write('\t\t}\n')
file.write('\t}\n')
file.write('}\n')
#problem with sky_sphere alpha (transmit) not translating into image alpha as well as "background" replace 0.75 by 1 when solved and later by some variable linked to background alpha state
file.write("\tmm_per_unit %.6f\n"%(material.subsurface_scattering.scale*(-100)+15))#In pov, the scale has reversed influence compared to blender. these number should correct that
once=0#In povray, the scale factor for all subsurface shaders needs to be the same
file.write('Bounding_method=2\n')#The new automatic BSP is faster in most scenes
file.write('Display=1\n')#Activated (turn this back off when better live exchange is done between the two programs (see next comment)
file.write('Pause_When_Done=0\n')
file.write('Pause_When_Done=0\n')
file.write('Output_File_Type=T\n')# TGA, best progressive loading
file.write('Output_File_Type=N\n')# PNG, with POV 3.7, can show background color with alpha. In the long run using the Povray interactive preview like bishop 3D could solve the preview for all formats.
#file.write('Output_File_Type=T\n') # TGA, best progressive loading
self._temp_file_out=tempfile.mktemp(suffix='.png')#PNG with POV 3.7, can show the background color with alpha. In the long run using the Povray interactive preview like bishop 3D could solve the preview for all formats.
self._temp_file_out = '/test.png'#PNG with POV 3.7, can show the background color with alpha. In the long run using the Povray interactive preview like bishop 3D could solve the preview for all formats.
#self._temp_file_out = '/test.tga'
self._temp_file_ini = '/test.ini'
self._temp_file_ini = '/test.ini'
'''
'''
definfo_callback(txt):
definfo_callback(txt):
self.update_stats("","POVRAY: "+txt)
self.update_stats("","POVRAY 3.7: "+txt)
write_pov(self._temp_file_in,scene,info_callback)
write_pov(self._temp_file_in,scene,info_callback)
...
@@ -673,7 +1369,7 @@ class PovrayRender(bpy.types.RenderEngine):
...
@@ -673,7 +1369,7 @@ class PovrayRender(bpy.types.RenderEngine):