Newer
Older
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
"author": "Campbell Barton, Silvio Falcinelli, Maurice Raybaud, "
"Constantin Rahn, Bastien Montagne, Leonid Desyatkov",
Bastien Montagne
committed
"version": (0, 0, 9),
"blender": (2, 75, 0),
Jonathan Smith
committed
"location": "Render > Engine > POV-Ray 3.7",
"description": "Basic POV-Ray 3.7 integration for blender",
"warning": "this script is RC",
Campbell Barton
committed
"wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
"Scripts/Render/POV-Ray",
"category": "Render",
}
import importlib
importlib.reload(ui)
importlib.reload(render)
importlib.reload(update_files)
import addon_utils # To use some other addons
import nodeitems_utils #for Nodes
from nodeitems_utils import NodeCategory, NodeItem #for Nodes
from bpy.types import (
AddonPreferences,
PropertyGroup,
)
from bpy.props import (
StringProperty,
BoolProperty,
IntProperty,
FloatProperty,
FloatVectorProperty,
EnumProperty,
PointerProperty,
)
from . import (
ui,
render,
update_files,
)
CoDEmanX
committed
def string_strip_hyphen(name):
return name.replace("-", "")
Bastien Montagne
committed
###############################################################################
# Scene POV properties.
###############################################################################
class RenderPovSettingsScene(PropertyGroup):
Bastien Montagne
committed
tempfiles_enable = BoolProperty(
description="Enable the OS-Tempfiles. Otherwise set the path where"
" to save the files",
pov_editor = BoolProperty(
name="POV-Ray editor",
description="Don't Close POV-Ray editor after rendering (Overriden"
" by /EXIT command)",
Bastien Montagne
committed
deletefiles_enable = BoolProperty(
description="Delete files after rendering. "
"Doesn't work with the image",
Bastien Montagne
committed
scene_name = StringProperty(
description="Name of POV-Ray scene to create. Empty name will use "
"the name of the blend file",
Bastien Montagne
committed
scene_path = StringProperty(
# Bug in POV-Ray RC3
# description="Path to directory where the exported scene "
description="Path to directory where the files are created",
maxlen=1024, subtype="DIR_PATH")
Bastien Montagne
committed
renderimage_path = StringProperty(
description="Full path to directory where the rendered image is "
"saved",
maxlen=1024, subtype="DIR_PATH")
Bastien Montagne
committed
list_lf_enable = BoolProperty(
description="Enable line breaks in lists (vectors and indices). "
"Disabled: lists are exported in one line",
# Not a real pov option, just to know if we should write
Bastien Montagne
committed
radio_enable = BoolProperty(
description="Enable POV-Rays radiosity calculation",
Bastien Montagne
committed
radio_display_advanced = BoolProperty(
name="Advanced Options",
description="Show advanced options",
default=False)
Bastien Montagne
committed
media_enable = BoolProperty(
name="Enable Media",
description="Enable POV-Rays atmospheric media",
default=False)
Bastien Montagne
committed
media_samples = IntProperty(
name="Samples",
Campbell Barton
committed
description="Number of samples taken from camera to first object "
Bastien Montagne
committed
"encountered along ray path for media calculation",
min=1, max=100, default=35)
Bastien Montagne
committed
media_color = FloatVectorProperty(
name="Media Color", description="The atmospheric media color",
Bastien Montagne
committed
precision=4, step=0.01, min=0, soft_max=1,
default=(0.001, 0.001, 0.001),
Bastien Montagne
committed
baking_enable = BoolProperty(
description="Enable POV-Rays texture baking",
Bastien Montagne
committed
indentation_character = EnumProperty(
name="Indentation",
description="Select the indentation type",
Campbell Barton
committed
items=(('NONE', "None", "No indentation"),
('TAB', "Tabs", "Indentation with tabs"),
('SPACE', "Spaces", "Indentation with spaces")),
default='SPACE')
Bastien Montagne
committed
indentation_spaces = IntProperty(
name="Quantity of spaces",
description="The number of spaces for indentation",
Bastien Montagne
committed
comments_enable = BoolProperty(
Constantin Rahn
committed
description="Add comments to pov file",
Bastien Montagne
committed
command_line_switches = StringProperty(
name="Command Line Switches",
description="Command line switches consist of a + (plus) or - "
"(minus) sign, followed by one or more alphabetic "
"characters and possibly a numeric value",
Bastien Montagne
committed
antialias_enable = BoolProperty(
name="Anti-Alias", description="Enable Anti-Aliasing",
default=True)
Bastien Montagne
committed
antialias_method = EnumProperty(
description="AA-sampling method. Type 1 is an adaptive, "
"non-recursive, super-sampling method. Type 2 is an "
"adaptive and recursive super-sampling method. Type 3 "
"is a stochastic halton based super-sampling method",
items=(("0", "non-recursive AA", "Type 1 Sampling in POV-Ray"),
("1", "recursive AA", "Type 2 Sampling in POV-Ray"),
("2", "stochastic AA", "Type 3 Sampling in UberPOV")),
antialias_confidence = FloatProperty(
name="Antialias Confidence",
description="how surely the computed color "
"of a given pixel is indeed"
"within the threshold error margin",
min=0.0001, max=1.0000, default=0.9900, precision=4)
Bastien Montagne
committed
antialias_depth = IntProperty(
name="Antialias Depth", description="Depth of pixel for sampling",
min=1, max=9, default=3)
Bastien Montagne
committed
antialias_threshold = FloatProperty(
name="Antialias Threshold", description="Tolerance for sub-pixels",
min=0.0, max=1.0, soft_min=0.05, soft_max=0.5, default=0.03)
Bastien Montagne
committed
jitter_enable = BoolProperty(
name="Jitter",
description="Enable Jittering. Adds noise into the sampling "
"process (it should be avoided to use jitter in "
"animation)",
default=False)
Bastien Montagne
committed
jitter_amount = FloatProperty(
name="Jitter Amount", description="Amount of jittering",
min=0.0, max=1.0, soft_min=0.01, soft_max=1.0, default=1.0)
Bastien Montagne
committed
antialias_gamma = FloatProperty(
name="Antialias Gamma",
description="POV-Ray compares gamma-adjusted values for super "
"sampling. Antialias Gamma sets the Gamma before "
"comparison",
min=0.0, max=5.0, soft_min=0.01, soft_max=2.5, default=2.5)
Bastien Montagne
committed
max_trace_level = IntProperty(
name="Max Trace Level",
description="Number of reflections/refractions allowed on ray "
"path",
Maurice Raybaud
committed
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
adc_bailout_enable = BoolProperty(
name="Enable",
description="",
default=False)
adc_bailout = FloatProperty(
name="ADC Bailout",
description="",
min=0.0, max=1000.0,default=0.00392156862745, precision=3)
ambient_light_enable = BoolProperty(
name="Enable",
description="",
default=False)
ambient_light = FloatVectorProperty(
name="Ambient Light", description="Ambient light is used to simulate the effect of inter-diffuse reflection",
precision=4, step=0.01, min=0, soft_max=1,
default=(1, 1, 1), options={'ANIMATABLE'}, subtype='COLOR')
global_settings_advanced = BoolProperty(
name="Advanced",
description="",
default=False)
irid_wavelength_enable = BoolProperty(
name="Enable",
description="",
default=False)
irid_wavelength = FloatVectorProperty(
name="Irid Wavelength", description="Iridescence calculations depend upon the dominant wavelengths of the primary colors of red, green and blue light.",
precision=4, step=0.01, min=0, soft_max=1,
default=(0.25,0.18,0.14), options={'ANIMATABLE'}, subtype='COLOR')
charset = EnumProperty(
name="Charset",
description="This allows you to specify the assumed character set of all text strings.",
items=(("ascii", "ASCII", ""),
("utf8", "UTF-8", ""),
("sys", "SYS", "")),
default="utf8")
max_intersections_enable = BoolProperty(
name="Enable",
description="",
default=False)
max_intersections = IntProperty(
name="Max Intersections",
description="POV-Ray uses a set of internal stacks to collect ray/object intersection points.",
min=2, max=1024, default=64)
number_of_waves_enable = BoolProperty(
name="Enable",
description="",
default=False)
number_of_waves = IntProperty(
name="Number Waves",
description="The waves and ripples patterns are generated by summing a series of waves, each with a slightly different center and size.",
min=1, max=10, default=1000)
noise_generator_enable = BoolProperty(
name="Enable",
description="",
default=False)
noise_generator = IntProperty(
name="Noise Generator",
description="There are three noise generators implemented.",
min=1, max=3, default=2)
########################### PHOTONS #######################################
photon_enable = BoolProperty(
name="Photons",
description="Enable global photons",
default=False)
photon_enable_count = BoolProperty(
name="Spacing / Count",
description="Enable count photons",
default=False)
photon_count = IntProperty(
name="Count",
description="Photons count",
min=1, max=100000000, default=20000)
Bastien Montagne
committed
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, default=0.005,
soft_min=0.001, soft_max=1.000, precision=3)
Bastien Montagne
committed
photon_max_trace_level = IntProperty(
name="Max Trace Level",
description="Number of reflections/refractions allowed on ray "
"path",
Bastien Montagne
committed
photon_adc_bailout = FloatProperty(
name="ADC Bailout",
Campbell Barton
committed
description="The adc_bailout for photons. Use adc_bailout = "
Bastien Montagne
committed
"0.01 / brightest_ambient_object for good results",
min=0.0, max=1000.0, default=0.1,
soft_min=0.0, soft_max=1.0, precision=3)
Bastien Montagne
committed
photon_gather_min = IntProperty(
name="Gather Min", description="Minimum number of photons gathered"
"for each point",
Bastien Montagne
committed
photon_gather_max = IntProperty(
name="Gather Max", description="Maximum number of photons gathered for each point",
min=1, max=256, default=100)
photon_map_file_save_load = EnumProperty(
name="Operation",
description="Load or Save photon map file",
items=(("NONE", "None", ""),
("save", "Save", ""),
("load", "Load", "")),
default="NONE")
photon_map_filename = StringProperty(
name="Filename",
description="",
maxlen=1024)
photon_map_dir = StringProperty(
name="Directory",
description="",
maxlen=1024, subtype="DIR_PATH")
photon_map_file = StringProperty(
name="File",
description="",
maxlen=1024, subtype="FILE_PATH")
Bastien Montagne
committed
radio_adc_bailout = FloatProperty(
name="ADC Bailout",
Campbell Barton
committed
description="The adc_bailout for radiosity rays. Use "
Bastien Montagne
committed
"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.0039, precision=4)
Bastien Montagne
committed
radio_always_sample = BoolProperty(
name="Always Sample",
Campbell Barton
committed
description="Only use the data from the pretrace step and not gather "
Bastien Montagne
committed
"any new samples during the final radiosity pass",
Maurice Raybaud
committed
default=False)
Bastien Montagne
committed
radio_brightness = FloatProperty(
name="Brightness",
Campbell Barton
committed
description="Amount objects are brightened before being returned "
Bastien Montagne
committed
"upwards to the rest of the system",
min=0.0, max=1000.0, soft_min=0.0, soft_max=10.0, default=1.0)
Bastien Montagne
committed
radio_count = IntProperty(
name="Ray Count",
Campbell Barton
committed
description="Number of rays for each new radiosity value to be calculated "
Bastien Montagne
committed
"(halton sequence over 1600)",
Bastien Montagne
committed
radio_error_bound = FloatProperty(
name="Error Bound",
Campbell Barton
committed
description="One of the two main speed/quality tuning values, "
Bastien Montagne
committed
"lower values are more accurate",
min=0.0, max=1000.0, soft_min=0.1, soft_max=10.0, default=1.8)
Bastien Montagne
committed
radio_gray_threshold = FloatProperty(
name="Gray Threshold",
Campbell Barton
committed
description="One of the two main speed/quality tuning values, "
Bastien Montagne
committed
"lower values are more accurate",
min=0.0, max=1.0, soft_min=0, soft_max=1, default=0.0)
Bastien Montagne
committed
radio_low_error_factor = FloatProperty(
name="Low Error Factor",
Campbell Barton
committed
description="Just enough samples is slightly blotchy. Low error changes error "
Bastien Montagne
committed
"tolerance for less critical last refining pass",
Maurice Raybaud
committed
min=0.000001, max=1.0, soft_min=0.000001, soft_max=1.0, default=0.5)
Bastien Montagne
committed
radio_media = BoolProperty(
name="Media", description="Radiosity estimation can be affected by media",
default=False)
Maurice Raybaud
committed
radio_subsurface = BoolProperty(
name="Subsurface", description="Radiosity estimation can be affected by Subsurface Light Transport",
default=False)
Bastien Montagne
committed
radio_minimum_reuse = FloatProperty(
name="Minimum Reuse",
Campbell Barton
committed
description="Fraction of the screen width which sets the minimum radius of reuse "
Bastien Montagne
committed
"for each sample point (At values higher than 2% expect errors)",
Maurice Raybaud
committed
min=0.0, max=1.0, soft_min=0.1, soft_max=0.1, default=0.015, precision=3)
Maurice Raybaud
committed
radio_maximum_reuse = FloatProperty(
name="Maximum Reuse",
description="The maximum reuse parameter works in conjunction with, and is similar to that of minimum reuse, "
"the only difference being that it is an upper bound rather than a lower one.",
min=0.0, max=1.0,default=0.2, precision=3)
Bastien Montagne
committed
radio_nearest_count = IntProperty(
name="Nearest Count",
Campbell Barton
committed
description="Number of old ambient values blended together to "
Bastien Montagne
committed
"create a new interpolated value",
Bastien Montagne
committed
radio_normal = BoolProperty(
name="Normals", description="Radiosity estimation can be affected by normals",
default=False)
Bastien Montagne
committed
radio_recursion_limit = IntProperty(
name="Recursion Limit",
Campbell Barton
committed
description="how many recursion levels are used to calculate "
Bastien Montagne
committed
"the diffuse inter-reflection",
min=1, max=20, default=1)
Bastien Montagne
committed
radio_pretrace_start = FloatProperty(
name="Pretrace Start",
Campbell Barton
committed
description="Fraction of the screen width which sets the size of the "
Bastien Montagne
committed
"blocks in the mosaic preview first pass",
min=0.01, max=1.00, soft_min=0.02, soft_max=1.0, default=0.08)
Bastien Montagne
committed
radio_pretrace_end = FloatProperty(
name="Pretrace End",
Campbell Barton
committed
description="Fraction of the screen width which sets the size of the blocks "
Bastien Montagne
committed
"in the mosaic preview last pass",
min=0.000925, max=1.00, soft_min=0.01, soft_max=1.00, default=0.04, precision=3)
Maurice Raybaud
committed
Bastien Montagne
committed
###############################################################################
# Material POV properties.
###############################################################################
class RenderPovSettingsMaterial(PropertyGroup):
Bastien Montagne
committed
irid_enable = BoolProperty(
Maurice Raybaud
committed
name="Iridescence coating",
Campbell Barton
committed
description="Newton's thin film interference (like an oil slick on a puddle of "
Bastien Montagne
committed
"water or the rainbow hues of a soap bubble.)",
Bastien Montagne
committed
mirror_use_IOR = BoolProperty(
Campbell Barton
committed
description="Use same IOR as raytrace transparency to calculate mirror reflections. "
Bastien Montagne
committed
"More physically correct",
Bastien Montagne
committed
mirror_metallic = BoolProperty(
name="Metallic Reflection",
description="mirror reflections get colored as diffuse (for metallic materials)",
default=False)
Bastien Montagne
committed
conserve_energy = BoolProperty(
Campbell Barton
committed
description="Light transmitted is more correctly reduced by mirror reflections, "
Bastien Montagne
committed
"also the sum of diffuse and translucency gets reduced below one ",
Bastien Montagne
committed
irid_amount = FloatProperty(
Campbell Barton
committed
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",
min=0.0, max=1.0, soft_min=0.01, soft_max=1.0, default=0.25)
Bastien Montagne
committed
irid_thickness = FloatProperty(
Campbell Barton
committed
description="A very thin film will have a high frequency of color changes while a "
"thick film will have large areas of color",
min=0.0, max=1000.0, soft_min=0.1, soft_max=10.0, default=1)
Bastien Montagne
committed
irid_turbulence = FloatProperty(
name="turbulence", description="This parameter varies the thickness",
min=0.0, max=10.0, soft_min=0.000, soft_max=1.0, default=0)
Bastien Montagne
committed
interior_fade_color = FloatVectorProperty(
Maurice Raybaud
committed
name="Interior Fade Color", description="Color of filtered attenuation for transparent "
Bastien Montagne
committed
precision=4, step=0.01, min=0.0, soft_max=1.0,
default=(0, 0, 0), options={'ANIMATABLE'}, subtype='COLOR')
caustics_enable = BoolProperty(
Campbell Barton
committed
description="use only fake refractive caustics (default) or photon based "
Bastien Montagne
committed
"reflective/refractive caustics",
Bastien Montagne
committed
fake_caustics = BoolProperty(
name="Fake Caustics", description="use only (Fast) fake refractive caustics",
Bastien Montagne
committed
fake_caustics_power = FloatProperty(
Campbell Barton
committed
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 "
Bastien Montagne
committed
"tighter, smaller simulated focal points",
Maurice Raybaud
committed
min=0.00, max=10.0, soft_min=0.00, soft_max=5.0, default=0.07)
Maurice Raybaud
committed
refraction_caustics = BoolProperty(
name="Refractive Caustics", description="hotspots of light focused when going through the material",
default=True)
Bastien Montagne
committed
photons_dispersion = FloatProperty(
Maurice Raybaud
committed
name="Chromatic Dispersion",
Campbell Barton
committed
description="Light passing through will be separated according to wavelength. "
"This ratio of refractive indices for violet to red controls how much "
Bastien Montagne
committed
"the colors are spread out 1 = no dispersion, good values are 1.01 to 1.1",
Maurice Raybaud
committed
min=1.0000, max=10.000, soft_min=1.0000, soft_max=1.1000, precision=4, default=1.0000)
Maurice Raybaud
committed
photons_dispersion_samples = IntProperty(
name="Dispersion Samples", description="Number of color-steps for dispersion",
min=2, max=128, default=7)
Bastien Montagne
committed
photons_reflection = BoolProperty(
name="Reflective Photon Caustics",
description="Use this to make your Sauron's ring ;-P",
default=False)
Bastien Montagne
committed
refraction_type = EnumProperty(
Maurice Raybaud
committed
items=[
("1", "Fake Caustics", "use fake caustics"),
Bastien Montagne
committed
("2", "Photons Caustics", "use photons for refractive caustics")],
Maurice Raybaud
committed
name="Refraction Type:",
description="use fake caustics (fast) or true photons for refractive Caustics",
Maurice Raybaud
committed
default="1")
Bastien Montagne
committed
##################################CustomPOV Code############################
replacement_text = StringProperty(
Campbell Barton
committed
name="Declared name:",
Campbell Barton
committed
description="Type the declared name in custom POV code or an external "
Bastien Montagne
committed
".inc it points at. texture {} expected",
Maurice Raybaud
committed
default="")
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
def use_material_nodes_callback(self, context):
if hasattr(context.space_data, "tree_type"):
context.space_data.tree_type = 'ObjectNodeTree'
mat=context.object.active_material
if mat.pov.material_use_nodes:
mat.use_nodes=True
tree = mat.node_tree
tree.name=mat.name
links = tree.links
default = True
if len(tree.nodes) == 2:
o = 0
m = 0
for node in tree.nodes:
if node.type in {"OUTPUT","MATERIAL"}:
tree.nodes.remove(node)
default = True
for node in tree.nodes:
if node.bl_idname == 'PovrayOutputNode':
o+=1
if node.bl_idname == 'PovrayTextureNode':
m+=1
if o == 1 and m == 1:
default = False
elif len(tree.nodes) == 0:
default = True
else:
default = False
if default:
output = tree.nodes.new('PovrayOutputNode')
output.location = 200,200
tmap = tree.nodes.new('PovrayTextureNode')
tmap.location = 0,200
links.new(tmap.outputs[0],output.inputs[0])
tmap.select = True
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
else:
mat.use_nodes=False
def use_texture_nodes_callback(self, context):
tex=context.object.active_material.active_texture
if tex.pov.texture_use_nodes:
tex.use_nodes=True
if len(tex.node_tree.nodes)==2:
for node in tex.node_tree.nodes:
if node.type in {"OUTPUT","CHECKER"}:
tex.node_tree.nodes.remove(node)
else:
tex.use_nodes=False
def node_active_callback(self, context):
items = []
mat=context.material
mat.node_tree.nodes
for node in mat.node_tree.nodes:
node.select=False
for node in mat.node_tree.nodes:
if node.name==mat.pov.material_active_node:
node.select=True
mat.node_tree.nodes.active=node
return node
def node_enum_callback(self, context):
items = []
mat=context.material
nodes=mat.node_tree.nodes
for node in nodes:
items.append(("%s"%node.name,"%s"%node.name,""))
return items
def pigment_normal_callback(self, context):
render = context.scene.pov.render
items = [("pigment", "Pigment", ""),("normal", "Normal", "")]
if render == 'hgpovray':
items = [("pigment", "Pigment", ""),("normal", "Normal", ""),("modulation", "Modulation", "")]
return items
def glow_callback(self, context):
scene = context.scene
ob = context.object
ob.pov.mesh_write_as_old = ob.pov.mesh_write_as
if scene.pov.render == 'uberpov' and ob.pov.glow:
ob.pov.mesh_write_as = 'NONE'
else:
ob.pov.mesh_write_as = ob.pov.mesh_write_as_old
material_use_nodes = BoolProperty(name="Use nodes", description="", update=use_material_nodes_callback, default=False)
material_active_node = EnumProperty(name="Active node", description="", items=node_enum_callback, update=node_active_callback)
preview_settings = BoolProperty(name="Preview Settings", description="",default=False)
object_preview_transform = BoolProperty(name="Transform object", description="",default=False)
object_preview_scale = FloatProperty(name="XYZ", min=0.5, max=2.0, default=1.0)
object_preview_rotate = FloatVectorProperty(name="Rotate", description="", min=-180.0, max=180.0,default=(0.0,0.0,0.0), subtype='XYZ')
object_preview_bgcontrast = FloatProperty(name="Contrast", min=0.0, max=1.0, default=0.5)
###############################################################################
# Povray Nodes
###############################################################################
class PovraySocketUniversal(bpy.types.NodeSocket):
bl_idname = 'PovraySocketUniversal'
bl_label = 'Povray Socket'
value_unlimited = bpy.props.FloatProperty(default=0.0)
value_0_1 = bpy.props.FloatProperty(min=0.0,max=1.0,default=0.0)
value_0_10 = bpy.props.FloatProperty(min=0.0,max=10.0,default=0.0)
value_000001_10 = bpy.props.FloatProperty(min=0.000001,max=10.0,default=0.0)
value_1_9 = bpy.props.IntProperty(min=1,max=9,default=1)
value_0_255 = bpy.props.IntProperty(min=0,max=255,default=0)
percent = bpy.props.FloatProperty(min=0.0,max=100.0,default=0.0)
def draw(self, context, layout, node, text):
space = context.space_data
tree = space.edit_tree
links=tree.links
if self.is_linked:
value=[]
for link in links:
if link.from_node==node:
inps=link.to_node.inputs
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
if inp.bl_idname=="PovraySocketFloat_0_1" and inp.is_linked:
prop="value_0_1"
if prop not in value:
value.append(prop)
if inp.bl_idname=="PovraySocketFloat_000001_10" and inp.is_linked:
prop="value_000001_10"
if prop not in value:
value.append(prop)
if inp.bl_idname=="PovraySocketFloat_0_10" and inp.is_linked:
prop="value_0_10"
if prop not in value:
value.append(prop)
if inp.bl_idname=="PovraySocketInt_1_9" and inp.is_linked:
prop="value_1_9"
if prop not in value:
value.append(prop)
if inp.bl_idname=="PovraySocketInt_0_255" and inp.is_linked:
prop="value_0_255"
if prop not in value:
value.append(prop)
if inp.bl_idname=="PovraySocketFloatUnlimited" and inp.is_linked:
prop="value_unlimited"
if prop not in value:
value.append(prop)
if len(value)==1:
layout.prop(self, "%s"%value[0], text=text)
else:
layout.prop(self, "percent", text="Percent")
else:
layout.prop(self, "percent", text=text)
def draw_color(self, context, node):
return (1, 0, 0, 1)
class PovraySocketFloat_0_1(bpy.types.NodeSocket):
bl_idname = 'PovraySocketFloat_0_1'
bl_label = 'Povray Socket'
default_value = bpy.props.FloatProperty(description="Input node Value_0_1",min=0,max=1,default=0)
def draw(self, context, layout, node, text):
if self.is_linked:
layout.label(text)
else:
layout.prop(self, "default_value", text=text, slider=True)
def draw_color(self, context, node):
return (0.5, 0.7, 0.7, 1)
class PovraySocketFloat_0_10(bpy.types.NodeSocket):
bl_idname = 'PovraySocketFloat_0_10'
bl_label = 'Povray Socket'
default_value = bpy.props.FloatProperty(description="Input node Value_0_10",min=0,max=10,default=0)
def draw(self, context, layout, node, text):
if node.bl_idname == 'ShaderNormalMapNode' and node.inputs[2].is_linked:
layout.label('')
self.hide_value=True
if self.is_linked:
layout.label(text)
else:
layout.prop(self, "default_value", text=text, slider=True)
def draw_color(self, context, node):
return (0.65, 0.65, 0.65, 1)
class PovraySocketFloat_10(bpy.types.NodeSocket):
bl_idname = 'PovraySocketFloat_10'
bl_label = 'Povray Socket'
default_value = bpy.props.FloatProperty(description="Input node Value_10",min=-10,max=10,default=0)
def draw(self, context, layout, node, text):
if node.bl_idname == 'ShaderNormalMapNode' and node.inputs[2].is_linked:
layout.label('')
self.hide_value=True
if self.is_linked:
layout.label(text)
else:
layout.prop(self, "default_value", text=text, slider=True)
def draw_color(self, context, node):
return (0.65, 0.65, 0.65, 1)
class PovraySocketFloatPositive(bpy.types.NodeSocket):
bl_idname = 'PovraySocketFloatPositive'
bl_label = 'Povray Socket'
default_value = bpy.props.FloatProperty(description="Input Node Value Positive", min=0.0, default=0)
def draw(self, context, layout, node, text):
if self.is_linked:
layout.label(text)
else:
layout.prop(self, "default_value", text=text, slider=True)
def draw_color(self, context, node):
return (0.045, 0.005, 0.136, 1)
class PovraySocketFloat_000001_10(bpy.types.NodeSocket):
bl_idname = 'PovraySocketFloat_000001_10'
bl_label = 'Povray Socket'
default_value = bpy.props.FloatProperty(min=0.000001,max=10,default=0.000001)
def draw(self, context, layout, node, text):
if self.is_output or self.is_linked:
layout.label(text)
else:
layout.prop(self, "default_value", text=text, slider=True)
def draw_color(self, context, node):
return (1, 0, 0, 1)
class PovraySocketFloatUnlimited(bpy.types.NodeSocket):
bl_idname = 'PovraySocketFloatUnlimited'
bl_label = 'Povray Socket'
default_value = bpy.props.FloatProperty(default = 0.0)
def draw(self, context, layout, node, text):
if self.is_linked:
layout.label(text)
else:
layout.prop(self, "default_value", text=text, slider=True)
def draw_color(self, context, node):
return (0.7, 0.7, 1, 1)
class PovraySocketInt_1_9(bpy.types.NodeSocket):
bl_idname = 'PovraySocketInt_1_9'
bl_label = 'Povray Socket'
default_value = bpy.props.IntProperty(description="Input node Value_1_9",min=1,max=9,default=6)
def draw(self, context, layout, node, text):
if self.is_linked:
layout.label(text)
else:
layout.prop(self, "default_value", text=text)
def draw_color(self, context, node):
return (1, 0.7, 0.7, 1)
class PovraySocketInt_0_256(bpy.types.NodeSocket):
bl_idname = 'PovraySocketInt_0_256'
bl_label = 'Povray Socket'
default_value = bpy.props.IntProperty(min=0,max=255,default=0)
def draw(self, context, layout, node, text):
if self.is_linked:
layout.label(text)
else:
layout.prop(self, "default_value", text=text)
def draw_color(self, context, node):
return (0.5, 0.5, 0.5, 1)
class PovraySocketPattern(bpy.types.NodeSocket):
bl_idname = 'PovraySocketPattern'
bl_label = 'Povray Socket'
default_value = bpy.props.EnumProperty(
name="Pattern",
description="Select the pattern",
items=(('boxed', "Boxed", ""),('brick', "Brick", ""),('cells', "Cells", ""), ('checker', "Checker", ""),
('granite', "Granite", ""),('leopard', "Leopard", ""),('marble', "Marble", ""),
('onion', "Onion", ""),('planar', "Planar", ""), ('quilted', "Quilted", ""),
('ripples', "Ripples", ""), ('radial', "Radial", ""),('spherical', "Spherical", ""),
('spotted', "Spotted", ""), ('waves', "Waves", ""), ('wood', "Wood", ""),
('wrinkles', "Wrinkles", "")),
default='granite')
def draw(self, context, layout, node, text):
if self.is_output or self.is_linked:
layout.label("Pattern")
else:
layout.prop(self, "default_value", text=text)
def draw_color(self, context, node):
return (1, 1, 1, 1)
class PovraySocketColor(bpy.types.NodeSocket):
bl_idname = 'PovraySocketColor'
bl_label = 'Povray Socket'
default_value = bpy.props.FloatVectorProperty(
precision=4, step=0.01, min=0, soft_max=1,
default=(0.0, 0.0, 0.0), options={'ANIMATABLE'}, subtype='COLOR')
def draw(self, context, layout, node, text):
if self.is_output or self.is_linked:
layout.label(text)
else:
layout.prop(self, "default_value", text=text)
def draw_color(self, context, node):
return (1, 1, 0, 1)
class PovraySocketColorRGBFT(bpy.types.NodeSocket):
bl_idname = 'PovraySocketColorRGBFT'
bl_label = 'Povray Socket'
default_value = bpy.props.FloatVectorProperty(
precision=4, step=0.01, min=0, soft_max=1,
default=(0.0, 0.0, 0.0), options={'ANIMATABLE'}, subtype='COLOR')
f = bpy.props.FloatProperty(default = 0.0,min=0.0,max=1.0)
t = bpy.props.FloatProperty(default = 0.0,min=0.0,max=1.0)
def draw(self, context, layout, node, text):
if self.is_output or self.is_linked:
layout.label(text)
else:
layout.prop(self, "default_value", text=text)
def draw_color(self, context, node):
return (1, 1, 0, 1)
class PovraySocketTexture(bpy.types.NodeSocket):
bl_idname = 'PovraySocketTexture'
bl_label = 'Povray Socket'
default_value = bpy.props.IntProperty()
def draw(self, context, layout, node, text):
layout.label(text)
def draw_color(self, context, node):
return (0, 1, 0, 1)
class PovraySocketTransform(bpy.types.NodeSocket):
bl_idname = 'PovraySocketTransform'
bl_label = 'Povray Socket'
default_value = bpy.props.IntProperty(min=0,max=255,default=0)
def draw(self, context, layout, node, text):
layout.label(text)
def draw_color(self, context, node):
return (99/255, 99/255, 199/255, 1)
class PovraySocketNormal(bpy.types.NodeSocket):
bl_idname = 'PovraySocketNormal'
bl_label = 'Povray Socket'
default_value = bpy.props.IntProperty(min=0,max=255,default=0)
def draw(self, context, layout, node, text):
layout.label(text)
def draw_color(self, context, node):
return (0.65, 0.65, 0.65, 1)
class PovraySocketSlope(bpy.types.NodeSocket):
bl_idname = 'PovraySocketSlope'
bl_label = 'Povray Socket'
default_value = bpy.props.FloatProperty(min = 0.0, max = 1.0)
height = bpy.props.FloatProperty(min = 0.0, max = 10.0)
slope = bpy.props.FloatProperty(min = -10.0, max = 10.0)
def draw(self, context, layout, node, text):
if self.is_output or self.is_linked:
layout.label(text)
else:
layout.prop(self,'default_value',text='')
layout.prop(self,'height',text='')
layout.prop(self,'slope',text='')
def draw_color(self, context, node):
return (0, 0, 0, 1)
class PovraySocketMap(bpy.types.NodeSocket):
bl_idname = 'PovraySocketMap'
bl_label = 'Povray Socket'
default_value = bpy.props.StringProperty()
def draw(self, context, layout, node, text):
layout.label(text)
def draw_color(self, context, node):
return (0.2, 0, 0.2, 1)
class PovrayShaderNodeCategory(NodeCategory):
@classmethod
def poll(cls, context):
return context.space_data.tree_type == 'ObjectNodeTree'
class PovrayTextureNodeCategory(NodeCategory):
@classmethod
def poll(cls, context):
return context.space_data.tree_type == 'TextureNodeTree'
class PovraySceneNodeCategory(NodeCategory):
@classmethod
def poll(cls, context):
return context.space_data.tree_type == 'CompositorNodeTree'
node_categories = [
PovrayShaderNodeCategory("SHADEROUTPUT", "Output", items=[
NodeItem("PovrayOutputNode"),
]),
PovrayShaderNodeCategory("SIMPLE", "Simple texture", items=[
NodeItem("PovrayTextureNode"),
]),
PovrayShaderNodeCategory("MAPS", "Maps", items=[
NodeItem("PovrayBumpMapNode"),
NodeItem("PovrayColorImageNode"),
NodeItem("ShaderNormalMapNode"),
NodeItem("PovraySlopeNode"),
NodeItem("ShaderTextureMapNode"),
NodeItem("ShaderNodeValToRGB"),
]),
PovrayShaderNodeCategory("OTHER", "Other patterns", items=[
NodeItem("PovrayImagePatternNode"),
NodeItem("ShaderPatternNode"),
]),
PovrayShaderNodeCategory("COLOR", "Color", items=[
NodeItem("PovrayPigmentNode"),
]),
PovrayShaderNodeCategory("TRANSFORM", "Transform", items=[
NodeItem("PovrayMappingNode"),
NodeItem("PovrayMultiplyNode"),
NodeItem("PovrayModifierNode"),
NodeItem("PovrayTransformNode"),
NodeItem("PovrayValueNode"),
]),
PovrayShaderNodeCategory("FINISH", "Finish", items=[
NodeItem("PovrayFinishNode"),
NodeItem("PovrayDiffuseNode"),
NodeItem("PovraySpecularNode"),
NodeItem("PovrayPhongNode"),
NodeItem("PovrayAmbientNode"),
NodeItem("PovrayMirrorNode"),
NodeItem("PovrayIridescenceNode"),
NodeItem("PovraySubsurfaceNode"),
PovrayShaderNodeCategory("CYCLES", "Cycles", items=[