Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurice Raybaud <mauriceraybaud@hotmail.fr>2011-01-26 14:10:53 +0300
committerMaurice Raybaud <mauriceraybaud@hotmail.fr>2011-01-26 14:10:53 +0300
commit814f0bebc36cc5ac13d055a0559a13b3da6ce082 (patch)
treea06c23d755d3d04bf56f08aeb2bb8732ba4e0bae /render_povray
parent3ead9e602a2a9d5c5aef23845710f75ab5ffcff3 (diff)
Photons and transparency improvements
Diffstat (limited to 'render_povray')
-rw-r--r--render_povray/__init__.py74
-rw-r--r--render_povray/render.py57
-rw-r--r--render_povray/ui.py63
3 files changed, 139 insertions, 55 deletions
diff --git a/render_povray/__init__.py b/render_povray/__init__.py
index 91764960..9b633517 100644
--- a/render_povray/__init__.py
+++ b/render_povray/__init__.py
@@ -91,9 +91,14 @@ def register():
Scene.pov_media_samples = IntProperty(
name="Samples", description="Number of samples taken from camera to first object encountered along ray path for media calculation",
min=1, max=100, default=35)
- Scene.pov_media_color = FloatProperty(
- name="Media Color", description="The atmospheric media color. Grey value for now",
- min=0.00, max=1.00, soft_min=0.01, soft_max=1.00, default=0.01)
+
+ Scene.pov_media_color = FloatVectorProperty(
+ name="Media Color",
+ description="The atmospheric media color.",
+ #min=(0.0, 0.0, 0.0), soft_max=(1.0, 1.0, 1.0),#change this to what's needed for colors
+ subtype='COLOR')
+ #default=(0.01, 0.01, 0.01)#change this to what's needed for colors
+
Scene.pov_baking_enable = BoolProperty(
name="Enable Baking",
description="Enable POV-Rays texture baking",
@@ -155,6 +160,26 @@ def register():
name="Max Trace Level", description="Number of reflections/refractions allowed on ray path",
min=1, max=256, default=5)
+ Scene.pov_photon_spacing = FloatProperty(
+ name="Spacing", description="Average distance between photons on surfaces. half this get four times as many surface photons",
+ min=0.001, max=1.000, soft_min=0.001, soft_max=1.000, default=0.005, precision=3)
+
+ Scene.pov_photon_max_trace_level = IntProperty(
+ name="Max Trace Level", description="Number of reflections/refractions allowed on ray path",
+ min=1, max=256, default=5)
+
+ Scene.pov_photon_adc_bailout = FloatProperty(
+ name="ADC Bailout", description="The adc_bailout for radiosity rays. Use adc_bailout = 0.01 / brightest_ambient_object for good results",
+ min=0.0, max=1000.0, soft_min=0.0, soft_max=1.0, default=0.1, precision=3)
+
+ Scene.pov_photon_gather_min = IntProperty(
+ name="Gather Min", description="Minimum number of photons gathered for each point",
+ min=1, max=256, default=20)
+
+ Scene.pov_photon_gather_max = IntProperty(
+ name="Gather Max", description="Maximum number of photons gathered for each point",
+ min=1, max=256, default=100)
+
Scene.pov_radio_adc_bailout = FloatProperty(
name="ADC Bailout", description="The adc_bailout for radiosity rays. Use adc_bailout = 0.01 / brightest_ambient_object for good results",
min=0.0, max=1000.0, soft_min=0.0, soft_max=1.0, default=0.01, precision=3)
@@ -212,7 +237,7 @@ def register():
name="Pretrace End", description="Fraction of the screen width which sets the size of the blocks in the mosaic preview last pass",
min=0.001, max=1.00, soft_min=0.01, soft_max=1.00, default=0.04, precision=3)
- ########################################MR######################################
+ ###########################################################################
Mat = bpy.types.Material
Mat.pov_irid_enable = BoolProperty(
@@ -250,6 +275,14 @@ def register():
description="This parameter varies the thickness.",
min=0.0, max=10.0, soft_min=0.000, soft_max=1.0, default=0)
+
+ Mat.pov_interior_fade_color = FloatVectorProperty(
+ name="Fade Color",
+ description="Color of filtered attenuation for transparent materials",
+ #min=(0.0, 0.0, 0.0), soft_max=(1.0, 1.0, 1.0),#change this to what's needed for colors
+ subtype='COLOR')
+ #default=(0.0, 0.0, 0.0)
+
Mat.pov_caustics_enable = BoolProperty(
name="Caustics",
description="use only fake refractive caustics (default) or photon based reflective/refractive caustics",
@@ -289,34 +322,46 @@ def register():
description="use fake caustics (fast) or true photons for refractive Caustics",
default="1") # ui.py has to be loaded before render.py with this.
- ########################################################################################
- #Custom texture gamma
+ ###########################################################################
+
Tex = bpy.types.Texture
+
+ #Custom texture gamma
Tex.pov_tex_gamma_enable = BoolProperty(
name="Enable custom texture gamma",
description="Notify some custom gamma for which texture has been precorrected without the file format carrying it and only if it differs from your OS expected standard (see pov doc)",
default=False)
+
Tex.pov_tex_gamma_value = FloatProperty(
name="Custom texture gamma",
description="value for which the file was issued e.g. a Raw photo is gamma 1.0",
min=0.45, max=5.00, soft_min=1.00, soft_max=2.50, default=1.00)
- #Importance sampling
+ ###########################################################################
+
Obj = bpy.types.Object
+
+ #Importance sampling
Obj.pov_importance_value = FloatProperty(
name="Radiosity Importance",
description="Priority value relative to other objects for sampling radiosity rays. Increase to get more radiosity rays at comparatively small yet bright objects",
min=0.01, max=1.00, default=1.00)
- ######################################EndMR#####################################
+ #Collect photons
+ Obj.pov_collect_photons = BoolProperty(
+ name="Receive Photon Caustics",
+ description="Enable object to collect photons from other objects caustics. Turn off for objects that don't really need to receive caustics (e.g. objects that generate caustics often don't need to show any on themselves) ",
+ default=True)
+
+ ###########################################################################
def unregister():
import bpy
Scene = bpy.types.Scene
- Mat = bpy.types.Material # MR
- Tex = bpy.types.Texture # MR
- Obj = bpy.types.Object # MR
+ Mat = bpy.types.Material
+ Tex = bpy.types.Texture
+ Obj = bpy.types.Object
del Scene.pov_tempfiles_enable # CR
del Scene.pov_scene_name # CR
del Scene.pov_deletefiles_enable # CR
@@ -344,6 +389,11 @@ def unregister():
del Scene.pov_media_color # MR
del Scene.pov_baking_enable # MR
del Scene.pov_max_trace_level # MR
+ del Scene.pov_photon_spacing # MR
+ del Scene.pov_photon_max_trace_level # MR
+ del Scene.pov_photon_adc_bailout # MR
+ del Scene.pov_photon_gather_min # MR
+ del Scene.pov_photon_gather_max # MR
del Scene.pov_antialias_enable # CR
del Scene.pov_antialias_method # CR
del Scene.pov_antialias_depth # CR
@@ -362,6 +412,7 @@ def unregister():
del Mat.pov_irid_amount # MR
del Mat.pov_irid_thickness # MR
del Mat.pov_irid_turbulence # MR
+ del Mat.pov_interior_fade_color # MR
del Mat.pov_caustics_enable # MR
del Mat.pov_fake_caustics # MR
del Mat.pov_fake_caustics_power # MR
@@ -372,6 +423,7 @@ def unregister():
del Tex.pov_tex_gamma_enable # MR
del Tex.pov_tex_gamma_value # MR
del Obj.pov_importance_value # MR
+ del Obj.pov_collect_photons # MR
if __name__ == "__main__":
register()
diff --git a/render_povray/render.py b/render_povray/render.py
index 38450d74..1b868f7d 100644
--- a/render_povray/render.py
+++ b/render_povray/render.py
@@ -258,7 +258,7 @@ def write_pov(filename, scene=None, info_callback=None):
tabWrite("matrix <%.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f>\n" %\
(matrix[0][0], matrix[0][1], matrix[0][2], matrix[1][0], matrix[1][1], matrix[1][2], matrix[2][0], matrix[2][1], matrix[2][2], matrix[3][0], matrix[3][1], matrix[3][2]))
- def writeObjectMaterial(material):
+ def writeObjectMaterial(material, ob):
# DH - modified some variables to be function local, avoiding RNA write
# this should be checked to see if it is functionally correct
@@ -279,10 +279,11 @@ def write_pov(filename, scene=None, info_callback=None):
pov_photons_refraction = False
pov_photons_reflection = False
+ if material.pov_photons_reflection:
+ pov_photons_reflection = True
if material.pov_refraction_type == "0":
pov_fake_caustics = False
pov_photons_refraction = False
- pov_photons_reflection = True # should respond only to proper checkerbox
elif material.pov_refraction_type == "1":
pov_fake_caustics = True
pov_photons_refraction = False
@@ -299,13 +300,21 @@ def write_pov(filename, scene=None, info_callback=None):
tabWrite("dispersion %.3g\n" % material.pov_photons_dispersion) # Default of 1 means no dispersion
#TODO
# Other interior args
- # if material.use_transparency and material.transparency_method == 'RAYTRACE':
- # fade_distance 2
- # fade_power [Value]
- # fade_color
+ if material.use_transparency and material.transparency_method == 'RAYTRACE':
+ # fade_distance
+ # In Blender this value has always been reversed compared to what tooltip says. 100.001 rather than 100 so that it does not get to 0
+ # which deactivates the feature in POV
+ tabWrite("fade_distance %.3g\n" % (100.001 - material.raytrace_transparency.depth_max))
+ # fade_power
+ tabWrite("fade_power %.3g\n" % material.raytrace_transparency.falloff)
+ # fade_color
+ tabWrite("fade_color <%.3g, %.3g, %.3g>\n" % material.pov_interior_fade_color[:])
# (variable) dispersion_samples (constant count for now)
tabWrite("}\n")
+ if not ob.pov_collect_photons:
+ tabWrite("photons{collect off}\n")
+
if pov_photons_refraction or pov_photons_reflection:
tabWrite("photons{\n")
tabWrite("target\n")
@@ -683,22 +692,23 @@ def write_pov(filename, scene=None, info_callback=None):
if material:
diffuse_color = material.diffuse_color
-
+ trans= 1.0 - material.alpha
if material.use_transparency and material.transparency_method == 'RAYTRACE':
- trans = 1.0 - material.raytrace_transparency.filter
+ povFilter = material.raytrace_transparency.filter * (1.0 - material.alpha)
+ trans = (1.0 - material.alpha) - povFilter
else:
- trans = 0.0
+ povFilter = 0.0
material_finish = materialNames[material.name]
- tabWrite("pigment {rgbft<%.3g, %.3g, %.3g, %.3g, %.3g>} \n" % (diffuse_color[0], diffuse_color[1], diffuse_color[2], 1.0 - material.alpha, trans))
+ tabWrite("pigment {rgbft<%.3g, %.3g, %.3g, %.3g, %.3g>} \n" % (diffuse_color[0], diffuse_color[1], diffuse_color[2], povFilter, trans))
tabWrite("finish {%s}\n" % safety(material_finish, Level=2))
else:
tabWrite("pigment {rgb<1 1 1>} \n")
tabWrite("finish {%s}\n" % (safety(DEF_MAT_NAME, Level=1))) # Write the finish last.
- writeObjectMaterial(material)
+ writeObjectMaterial(material, ob)
writeMatrix(global_matrix * ob.matrix_world)
#Importance for radiosity sampling added here:
@@ -906,6 +916,11 @@ def write_pov(filename, scene=None, info_callback=None):
else:
trans = 0.0
+ if material.use_transparency and material.transparency_method == 'RAYTRACE':
+ povFilter = material.raytrace_transparency.filter * (1.0 - material.alpha)
+ trans = (1.0 - material.alpha) - povFilter
+ else:
+ povFilter = 0.0
else:
material_finish = DEF_MAT_NAME # not working properly,
trans = 0.0
@@ -1015,13 +1030,13 @@ def write_pov(filename, scene=None, info_callback=None):
tabWrite("}\n")
tabWrite("pigment_map {\n")
tabWrite("[0 color rgbft<0,0,0,1,1>]\n")
- tabWrite("[1 color rgbft<%.3g, %.3g, %.3g, %.3g, %.3g>]\n" % (col[0], col[1], col[2], 1.0 - material.alpha, trans))
+ tabWrite("[1 color rgbft<%.3g, %.3g, %.3g, %.3g, %.3g>]\n" % (col[0], col[1], col[2], povFilter, trans))
tabWrite("}\n")
tabWrite("}\n")
else:
- tabWrite("pigment {rgbft<%.3g, %.3g, %.3g, %.3g, %.3g>}\n" % (col[0], col[1], col[2], 1.0 - material.alpha, trans))
+ tabWrite("pigment {rgbft<%.3g, %.3g, %.3g, %.3g, %.3g>}\n" % (col[0], col[1], col[2], povFilter, trans))
if texturesSpec != "":
tabWrite("finish {%s}\n" % (safety(material_finish, Level=1))) # Level 1 is no specular
@@ -1080,12 +1095,12 @@ def write_pov(filename, scene=None, info_callback=None):
tabWrite("pigment {pigment_pattern {uv_mapping image_map{%s \"%s\" %s}%s}\n" % (imageFormat(texturesAlpha), texturesAlpha, imgMap(t_alpha), mappingAlpha))
tabWrite("pigment_map {\n")
tabWrite("[0 color rgbft<0,0,0,1,1>]\n")
- tabWrite("[1 color rgbft<%.3g, %.3g, %.3g, %.3g, %.3g>]\n" % (col[0], col[1], col[2], 1.0 - material.alpha, trans))
+ tabWrite("[1 color rgbft<%.3g, %.3g, %.3g, %.3g, %.3g>]\n" % (col[0], col[1], col[2], povFilter, trans))
tabWrite("}\n")
tabWrite("}\n")
else:
- tabWrite("pigment {rgbft<%.3g, %.3g, %.3g, %.3g, %.3g>}\n" % (col[0], col[1], col[2], 1.0 - material.alpha, trans))
+ tabWrite("pigment {rgbft<%.3g, %.3g, %.3g, %.3g, %.3g>}\n" % (col[0], col[1], col[2], povFilter, trans))
if texturesSpec != "":
tabWrite("finish {%s}\n" % (safety(material_finish, Level=3))) # Level 3 is full specular
@@ -1280,7 +1295,7 @@ def write_pov(filename, scene=None, info_callback=None):
if me.materials:
try:
material = me.materials[0] # dodgy
- writeObjectMaterial(material)
+ writeObjectMaterial(material, ob)
except IndexError:
print(me)
@@ -1397,7 +1412,7 @@ def write_pov(filename, scene=None, info_callback=None):
tabWrite("}\n")
if scene.pov_media_enable:
tabWrite("media {\n")
- tabWrite("scattering { 1, rgb %.3g}\n" % scene.pov_media_color)
+ tabWrite("scattering { 1, rgb <%.4g, %.4g, %.4g>}\n" % scene.pov_media_color[:])
tabWrite("samples %.d\n" % scene.pov_media_samples)
tabWrite("}\n")
@@ -1435,10 +1450,10 @@ def write_pov(filename, scene=None, info_callback=None):
if material.pov_photons_refraction or material.pov_photons_reflection:
tabWrite("photons {\n")
- tabWrite("spacing 0.003\n")
- tabWrite("max_trace_level 5\n")
- tabWrite("adc_bailout 0.1\n")
- tabWrite("gather 30, 150\n")
+ tabWrite("spacing %.6f\n" % scene.pov_photon_spacing)
+ tabWrite("max_trace_level %d\n" % scene.pov_photon_max_trace_level)
+ tabWrite("adc_bailout %.3g\n" % scene.pov_photon_adc_bailout)
+ tabWrite("gather %d, %d\n" % (scene.pov_photon_gather_min, scene.pov_photon_gather_max))
tabWrite("}\n")
tabWrite("}\n")
diff --git a/render_povray/ui.py b/render_povray/ui.py
index 4a68bc70..b302f5b5 100644
--- a/render_povray/ui.py
+++ b/render_povray/ui.py
@@ -197,9 +197,18 @@ class RENDER_PT_povray_render_settings(RenderButtonsPanel, bpy.types.Panel):
layout.active = scene.pov_max_trace_level
split = layout.split()
+
col = split.column()
+ col.label(text="Global Settings")
col.prop(scene, "pov_max_trace_level", text="Ray Depth")
- col = split.column()
+ row = col.row()
+ col.label(text="Global Photons")
+ col.prop(scene, "pov_photon_max_trace_level", text="Photon Depth")
+ row = col.row()
+ col.prop(scene, "pov_photon_spacing", text="Spacing")
+ col.prop(scene, "pov_photon_adc_bailout", text="Photon ADC")
+ col.prop(scene, "pov_photon_gather_min", text="Photons gathered min")
+ col.prop(scene, "pov_photon_gather_max", text="Photons gathered max")
class RENDER_PT_povray_antialias(RenderButtonsPanel, bpy.types.Panel):
@@ -315,7 +324,6 @@ class RENDER_PT_povray_media(RenderButtonsPanel, bpy.types.Panel):
col = split.column()
col.prop(scene, "pov_media_samples", text="Samples")
- col = split.column()
col.prop(scene, "pov_media_color", text="Color")
##class RENDER_PT_povray_baking(RenderButtonsPanel, bpy.types.Panel):
@@ -377,6 +385,20 @@ class MATERIAL_PT_povray_metallic(MaterialButtonsPanel, bpy.types.Panel):
mat = context.material
layout.active = mat.pov_mirror_metallic
+class MATERIAL_PT_povray_fade_color(MaterialButtonsPanel, bpy.types.Panel):
+ bl_label = "Interior Fade Color"
+ COMPAT_ENGINES = {'POVRAY_RENDER'}
+
+ def draw_header(self, context):
+ mat = context.material
+
+ self.layout.prop(mat, "pov_interior_fade_color", text="")
+
+ def draw(self, context):
+ layout = self.layout
+
+ mat = context.material
+ layout.active = mat.pov_interior_fade_color
class MATERIAL_PT_povray_conserve_energy(MaterialButtonsPanel, bpy.types.Panel):
bl_label = "conserve energy"
@@ -433,38 +455,29 @@ class MATERIAL_PT_povray_caustics(MaterialButtonsPanel, bpy.types.Panel):
mat = context.material
layout.active = mat.pov_caustics_enable
- Radio = 1
+
if mat.pov_caustics_enable:
split = layout.split()
col = split.column()
col.prop(mat, "pov_refraction_type")
-## if mat.pov_refraction_type=="0":
-## mat.pov_fake_caustics = False
-## mat.pov_photons_refraction = False
-## mat.pov_photons_reflection = True
+
if mat.pov_refraction_type == "1":
-## mat.pov_fake_caustics = True
-## mat.pov_photons_refraction = False
col.prop(mat, "pov_fake_caustics_power", slider=True)
elif mat.pov_refraction_type == "2":
-## mat.pov_fake_caustics = False
-## mat.pov_photons_refraction = True
col.prop(mat, "pov_photons_dispersion", slider=True)
col.prop(mat, "pov_photons_reflection")
+
+ if mat.pov_refraction_type=="0" and not mat.pov_photons_reflection:
+ split = layout.split()
+ col = split.column()
+ row = col.row()
+ row.alignment = 'CENTER'
+ row.label(text="Caustics override is on, ")
+ row = col.row()
+ row.alignment = 'CENTER'
+ row.label(text="but you didn't chose any !")
-## col.prop(mat, "pov_fake_caustics")
-## if mat.pov_fake_caustics:
-## col.prop(mat, "pov_fake_caustics_power", slider=True)
-## mat.pov_photons_refraction=0
-## else:
-## col.prop(mat, "pov_photons_refraction")
-## if mat.pov_photons_refraction:
-## col.prop(mat, "pov_photons_dispersion", slider=True)
-## Radio = 0
-## mat.pov_fake_caustics=Radio
-## col.prop(mat, "pov_photons_reflection")
-####TODO : MAKE THIS A real RADIO BUTTON (using EnumProperty?)
class TEXTURE_PT_povray_tex_gamma(TextureButtonsPanel, bpy.types.Panel):
@@ -501,4 +514,8 @@ class OBJECT_PT_povray_obj_importance(ObjectButtonsPanel, bpy.types.Panel):
split = layout.split()
col = split.column()
+ col.label(text="Radiosity")
col.prop(obj, "pov_importance_value", text="Importance")
+ row = col.row()
+ col.label(text="Photons")
+ col.prop(obj, "pov_collect_photons", text="Receive Photon Caustics")