1 # SPDX-License-Identifier: GPL-2.0-or-later
3 """Declare shading properties exported to POV textures."""
5 from bpy
.utils
import register_class
, unregister_class
6 from bpy
.types
import PropertyGroup
7 from bpy
.props
import (
15 class MaterialStrandSettings(PropertyGroup
):
16 """Declare strand properties controllable in UI and translated to POV."""
18 bl_description
= ("Strand settings for the material",)
20 blend_distance
: FloatProperty(
22 description
="Worldspace distance over which to blend in the surface normal",
31 root_size
: FloatProperty(
33 description
="Start size of strands in pixels or Blender units",
41 description
="Positive values make strands rounder, negative ones make strands spiky",
48 size_min
: FloatProperty(
50 description
="Minimum size of strands in pixels",
57 tip_size
: FloatProperty(
59 description
="End size of strands in pixels or Blender units",
65 use_blender_units
: BoolProperty(
67 description
="Use Blender units for widths instead of pixels",
71 use_surface_diffuse
: BoolProperty(
72 name
="Surface diffuse",
73 description
="Make diffuse shading more similar to shading the surface",
77 use_tangent_shading
: BoolProperty(
78 name
="Tangent Shading",
79 description
="Use direction of strands as normal for tangent-shading",
83 uv_layer
: StringProperty(
86 description
="Name of UV map to override",
90 width_fade
: FloatProperty(
92 description
="Transparency along the width of the strand",
101 # Halo settings for the material
102 # Type: MaterialHalo, (readonly, never None)
108 # Type: float in [0, 2], default 0.0
112 # Diffuse color of the material
113 # Type: float array of 3 items in [0, inf], default (0.0, 0.0, 0.0)
118 # Type: float in [0, 5], default 0.0
120 # diffuse_fresnel_factor
122 # Blending factor of Fresnel
123 # Type: float in [0, 5], default 0.0
127 # Amount of diffuse reflection
128 # Type: float in [0, 1], default 0.0
132 # Color ramp used to affect diffuse shading
133 # Type: ColorRamp, (readonly)
137 # Blending method of the ramp and the diffuse color
138 # Type: enum in [‘MIX’, ‘ADD’, ‘MULTIPLY’, ‘SUBTRACT’, ‘SCREEN’, ‘DIVIDE’, ‘DIFFERENCE’, ‘DARKEN’, ‘LIGHTEN’, ‘OVERLAY’, ‘DODGE’, ‘BURN’, ‘HUE’, ‘SATURATION’, ‘VALUE’, ‘COLOR’, ‘SOFT_LIGHT’, ‘LINEAR_LIGHT’], default ‘MIX’
140 # diffuse_ramp_factor
142 # Blending factor (also uses alpha in Colorband)
143 # Type: float in [0, 1], default 0.0
147 # How the ramp maps on the surface
148 # Type: enum in [‘SHADER’, ‘ENERGY’, ‘NORMAL’, ‘RESULT’], default ‘SHADER’
152 # LAMBERT Lambert, Use a Lambertian shader.
153 # OREN_NAYAR Oren-Nayar, Use an Oren-Nayar shader.
154 # TOON Toon, Use a toon shader.
155 # MINNAERT Minnaert, Use a Minnaert shader.
156 # FRESNEL Fresnel, Use a Fresnel shader.
158 # Type: enum in [‘LAMBERT’, ‘OREN_NAYAR’, ‘TOON’, ‘MINNAERT’, ‘FRESNEL’], default ‘LAMBERT’
162 # Size of diffuse toon area
163 # Type: float in [0, 3.14], default 0.0
165 # diffuse_toon_smooth
167 # Smoothness of diffuse toon area
168 # Type: float in [0, 1], default 0.0
172 # Amount of light to emit
173 # Type: float in [0, inf], default 0.0
177 # Halo settings for the material
178 # Type: MaterialHalo, (readonly, never None)
182 # Render material’s faces with an inverted Z buffer (scanline only)
183 # Type: boolean, default False
187 # Limit lighting to lamps in this Group
192 # Line color used for Freestyle line rendering
193 # Type: float array of 4 items in [0, inf], default (0.0, 0.0, 0.0, 0.0)
197 # The line color of a higher priority is used at material boundaries
198 # Type: int in [0, 32767], default 0
202 # Mirror color of the material
203 # Type: float array of 3 items in [0, inf], default (0.0, 0.0, 0.0)
207 # Node tree for node based materials
208 # Type: NodeTree, (readonly)
212 # Give faces an artificial offset in the Z buffer for Z transparency
213 # Type: float in [-inf, inf], default 0.0
217 # Index of active texture paint slot
218 # Type: int in [0, 32767], default 0
222 # Index of clone texture paint slot
223 # Type: int in [0, 32767], default 0
227 # Index number for the “Material Index” render pass
228 # Type: int in [0, 32767], default 0
232 # Game physics settings
233 # Type: MaterialPhysics, (readonly, never None)
235 # preview_render_type
237 # Type of preview render
239 # FLAT Flat, Flat XY plane.
240 # SPHERE Sphere, Sphere.
242 # MONKEY Monkey, Monkey.
243 # HAIR Hair, Hair strands.
244 # SPHERE_A World Sphere, Large sphere with sky.
246 # Type: enum in [‘FLAT’, ‘SPHERE’, ‘CUBE’, ‘MONKEY’, ‘HAIR’, ‘SPHERE_A’], default ‘FLAT’
250 # Oren-Nayar Roughness
251 # Type: float in [0, 3.14], default 0.0
255 # Factor to multiply shadow buffer bias with (0 is ignore)
256 # Type: float in [0, 10], default 0.0
260 # Shadow casting alpha, in use for Irregular and Deep shadow buffer
261 # Type: float in [0.001, 1], default 0.0
265 # How to draw shadows
267 # SHADOW_ONLY_OLD Shadow and Distance, Old shadow only method.
268 # SHADOW_ONLY Shadow Only, Improved shadow only method.
269 # SHADOW_ONLY_SHADED Shadow and Shading, Improved shadow only method which also renders lightless areas as shadows.
271 # Type: enum in [‘SHADOW_ONLY_OLD’, ‘SHADOW_ONLY’, ‘SHADOW_ONLY_SHADED’], default ‘SHADOW_ONLY_OLD’
275 # Shadow raytracing bias to prevent terminator problems on shadow boundary
276 # Type: float in [0, 0.25], default 0.0
280 # Specular color of the material
281 # Type: float array of 3 items in [0, inf], default (0.0, 0.0, 0.0)
285 # How hard (sharp) the specular reflection is
286 # Type: int in [1, 511], default 0
290 # How intense (bright) the specular reflection is
291 # Type: float in [0, 1], default 0.0
295 # Specular index of refraction
296 # Type: float in [1, 10], default 0.0
300 # Color ramp used to affect specular shading
301 # Type: ColorRamp, (readonly)
303 # specular_ramp_blend
305 # Blending method of the ramp and the specular color
306 # Type: enum in [‘MIX’, ‘ADD’, ‘MULTIPLY’, ‘SUBTRACT’, ‘SCREEN’, ‘DIVIDE’, ‘DIFFERENCE’, ‘DARKEN’, ‘LIGHTEN’, ‘OVERLAY’, ‘DODGE’, ‘BURN’, ‘HUE’, ‘SATURATION’, ‘VALUE’, ‘COLOR’, ‘SOFT_LIGHT’, ‘LINEAR_LIGHT’], default ‘MIX’
308 # specular_ramp_factor
310 # Blending factor (also uses alpha in Colorband)
311 # Type: float in [0, 1], default 0.0
313 # specular_ramp_input
315 # How the ramp maps on the surface
316 # Type: enum in [‘SHADER’, ‘ENERGY’, ‘NORMAL’, ‘RESULT’], default ‘SHADER’
319 # COOKTORR CookTorr, Use a Cook-Torrance shader.
320 # PHONG Phong, Use a Phong shader.
321 # BLINN Blinn, Use a Blinn shader.
322 # TOON Toon, Use a toon shader.
323 # WARDISO WardIso, Use a Ward anisotropic shader.
325 # Type: enum in [‘COOKTORR’, ‘PHONG’, ‘BLINN’, ‘TOON’, ‘WARDISO’], default ‘COOKTORR’
329 # The standard deviation of surface slope
330 # Type: float in [0, 0.4], default 0.0
334 # Size of specular toon area
335 # Type: float in [0, 1.53], default 0.0
337 # specular_toon_smooth
339 # Smoothness of specular toon area
340 # Type: float in [0, 1], default 0.0
344 # Strand settings for the material
345 # Type: MaterialStrand, (readonly, never None)
347 # subsurface_scattering
349 # Subsurface scattering settings for the material
350 # Type: MaterialSubsurfaceScattering, (readonly, never None)
352 # texture_paint_images
354 # Texture images used for texture painting
355 # Type: bpy_prop_collection of Image, (readonly)
357 # texture_paint_slots
359 # Texture slots defining the mapping and influence of textures
360 # Type: bpy_prop_collection of TexPaintSlot, (readonly)
364 # Texture slots defining the mapping and influence of textures
365 # Type: MaterialTextureSlots bpy_prop_collection of MaterialTextureSlot, (readonly)
369 # Material type defining how the object is rendered
371 # SURFACE Surface, Render object as a surface.
372 # WIRE Wire, Render the edges of faces as wires (not supported in raytracing).
373 # VOLUME Volume, Render object as a volume.
374 # HALO Halo, Render object as halo particles.
376 # Type: enum in [‘SURFACE’, ‘WIRE’, ‘VOLUME’, ‘HALO’], default ‘SURFACE’
380 # Allow this material to cast shadows
381 # Type: boolean, default False
383 # use_cast_shadows_only
385 # Make objects with this material appear invisible (not rendered), only casting shadows
386 # Type: boolean, default False
390 # Use cubic interpolation for diffuse values, for smoother transitions
391 # Type: boolean, default False
395 # Toggle diffuse ramp operations
396 # Type: boolean, default False
400 # Replace the object’s base color with color from UV map image textures
401 # Type: boolean, default False
403 # use_face_texture_alpha
405 # Replace the object’s base alpha value with alpha from UV map image textures
406 # Type: boolean, default False
408 # use_full_oversampling
410 # Force this material to render full shading/textures for all anti-aliasing samples
411 # Type: boolean, default False
413 # use_light_group_exclusive
415 # Material uses the light group exclusively - these lamps are excluded from other scene lighting
416 # Type: boolean, default False
418 # use_light_group_local
420 # When linked in, material uses local light group with the same name
421 # Type: boolean, default False
425 # Use mist with this material (in world settings)
426 # Type: boolean, default False
430 # Use shader nodes to render the material
431 # Type: boolean, default False
435 # Modulate the result with a per-object color
436 # Type: boolean, default False
440 # Render shadows as the material’s alpha value, making the material transparent except for shadowed areas
441 # Type: boolean, default False
443 # use_ray_shadow_bias
445 # Prevent raytraced shadow errors on surfaces with smooth shaded normals (terminator problem)
446 # Type: boolean, default False
450 # Include this material and geometry that uses it in raytracing calculations
451 # Type: boolean, default False
455 # Make this material insensitive to light or shadow
456 # Type: boolean, default False
460 # Allow this material to receive shadows
461 # Type: boolean, default False
465 # Render this material with zero alpha, with sky background in place (scanline only)
466 # Type: boolean, default False
470 # Toggle specular ramp operations
471 # Type: boolean, default False
473 # use_tangent_shading
475 # Use the material’s tangent vector instead of the normal for shading - for anisotropic shading effects
476 # Type: boolean, default False
480 # Enable/Disable each texture
481 # Type: boolean array of 18 items, default (False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False)
485 # Render material as transparent
486 # Type: boolean, default False
488 # use_transparent_shadows
490 # Allow this object to receive transparent shadows cast through other objects
491 # Type: boolean, default False
495 # Use to ensure UV interpolation is correct for camera projections (use with UV project modifier)
496 # Type: boolean, default False
498 # use_vertex_color_light
500 # Add vertex colors as additional lighting
501 # Type: boolean, default False
503 # use_vertex_color_paint
505 # Replace object base color with vertex colors (multiply with ‘texture face’ face assigned textures)
506 # Type: boolean, default False
510 # Volume settings for the material
511 # Type: MaterialVolume, (readonly, never None)
513 (mat.type in {'SURFACE', 'WIRE', 'VOLUME'})
518 mat.use_transparency and mat.pov.transparency_method == 'Z_TRANSPARENCY'
523 col.prop(mat, "use_raytrace")
524 col.prop(mat, "use_full_oversampling")
526 sub.prop(mat, "use_sky")
529 col.prop(mat, "use_cast_shadows", text="Cast")
530 col.prop(mat, "use_cast_shadows_only", text="Cast Only")
531 col.prop(mat, "use_cast_buffer_shadows")
533 sub.active = mat.use_cast_buffer_shadows
534 sub.prop(mat, "shadow_cast_alpha", text="Casting Alpha")
535 col.prop(mat, "use_cast_approximate")
539 col.prop(mat, "diffuse_color", text="")
541 sub.active = (not mat.use_shadeless)
543 sub.prop(mat, "diffuse_intensity", text="Intensity")
546 col.prop(mat, "diffuse_shader", text="")
547 col.prop(mat, "use_diffuse_ramp", text="Ramp")
550 if mat.diffuse_shader == 'OREN_NAYAR':
551 col.prop(mat, "roughness")
552 elif mat.diffuse_shader == 'MINNAERT':
553 col.prop(mat, "darkness")
554 elif mat.diffuse_shader == 'TOON':
556 row.prop(mat, "diffuse_toon_size", text="Size")
557 row.prop(mat, "diffuse_toon_smooth", text="Smooth")
558 elif mat.diffuse_shader == 'FRESNEL':
560 row.prop(mat, "diffuse_fresnel", text="Fresnel")
561 row.prop(mat, "diffuse_fresnel_factor", text="Factor")
563 if mat.use_diffuse_ramp:
565 col.template_color_ramp(mat, "diffuse_ramp", expand=True)
569 row.prop(mat, "diffuse_ramp_input", text="Input")
570 row.prop(mat, "diffuse_ramp_blend", text="Blend")
572 col.prop(mat, "diffuse_ramp_factor", text="Factor")
577 col.prop(mat, "specular_color", text="")
578 col.prop(mat, "specular_intensity", text="Intensity")
580 col.prop(mat, "specular_shader", text="")
581 col.prop(mat, "use_specular_ramp", text="Ramp")
583 if mat.pov.specular_shader in {'COOKTORR', 'PHONG'}:
584 col.prop(mat, "specular_hardness", text="Hardness")
585 elif mat.pov.specular_shader == 'BLINN':
587 row.prop(mat, "specular_hardness", text="Hardness")
588 row.prop(mat, "specular_ior", text="IOR")
589 elif mat.pov.specular_shader == 'WARDISO':
590 col.prop(mat, "specular_slope", text="Slope")
591 elif mat.pov.specular_shader == 'TOON':
593 row.prop(mat, "specular_toon_size", text="Size")
594 row.prop(mat, "specular_toon_smooth", text="Smooth")
596 if mat.use_specular_ramp:
598 layout.template_color_ramp(mat, "specular_ramp", expand=True)
602 row.prop(mat, "specular_ramp_input", text="Input")
603 row.prop(mat, "specular_ramp_blend", text="Blend")
605 layout.prop(mat, "specular_ramp_factor", text="Factor")
608 XXX remove unused props and relayout as done for transparent sky
611 class MATERIAL_PT_halo(MaterialButtonsPanel, Panel):
613 COMPAT_ENGINES = {'BLENDER_RENDER'}
616 def poll(cls, context):
617 mat = context.material
618 engine = context.scene.render.engine
619 return mat and (mat.type == 'HALO') and (engine in cls.COMPAT_ENGINES)
621 def draw(self, context):
624 mat = context.material # don't use node material
627 def number_but(layout, toggle, number, name, color):
628 row = layout.row(align=True)
629 row.prop(halo, toggle, text="")
630 sub = row.column(align=True)
631 sub.active = getattr(halo, toggle)
632 sub.prop(halo, number, text=name, translate=False)
634 sub.prop(mat, color, text="")
636 split = layout.split()
639 col.prop(mat, "alpha")
640 col.prop(mat, "diffuse_color", text="")
641 col.prop(halo, "seed")
644 col.prop(halo, "size")
645 col.prop(halo, "hardness")
646 col.prop(halo, "add")
648 layout.label(text="Options:")
650 split = layout.split()
652 col.prop(halo, "use_texture")
653 col.prop(halo, "use_vertex_normal")
654 col.prop(halo, "use_extreme_alpha")
655 col.prop(halo, "use_shaded")
656 col.prop(halo, "use_soft")
659 number_but(col, "use_ring", "ring_count", iface_("Rings"), "mirror_color")
660 number_but(col, "use_lines", "line_count", iface_("Lines"), "specular_color")
661 number_but(col, "use_star", "star_tip_count", iface_("Star Tips"), "")
664 class MATERIAL_PT_flare(MaterialButtonsPanel, Panel):
666 COMPAT_ENGINES = {'BLENDER_RENDER'}
669 def poll(cls, context):
670 mat = context.material
671 engine = context.scene.render.engine
672 return mat and (mat.type == 'HALO') and (engine in cls.COMPAT_ENGINES)
674 def draw_header(self, context):
675 halo = context.material.pov.halo
677 self.layout.prop(halo, "use_flare_mode", text="")
679 def draw(self, context):
682 mat = context.material # don't use node material
685 layout.active = halo.use_flare_mode
687 split = layout.split()
690 col.prop(halo, "flare_size", text="Size")
691 col.prop(halo, "flare_boost", text="Boost")
692 col.prop(halo, "flare_seed", text="Seed")
695 col.prop(halo, "flare_subflare_count", text="Subflares")
696 col.prop(halo, "flare_subflare_size", text="Subsize")
702 MaterialStrandSettings
,
710 bpy
.types
.Material
.strand
= PointerProperty(type=MaterialStrandSettings
)
714 del bpy
.types
.Material
.strand
716 for cls
in reversed(classes
):
717 unregister_class(cls
)