Import images: add file handler
[blender-addons.git] / render_povray / shading_ray_properties.py
blobb36b191d3762323ab938977967083a58d97926b6
1 # SPDX-FileCopyrightText: 2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 """Declare shading properties exported to POV textures."""
6 import bpy
7 from bpy.utils import register_class, unregister_class
8 from bpy.types import PropertyGroup
9 from bpy.props import (
10 FloatVectorProperty,
11 StringProperty,
12 BoolProperty,
13 IntProperty,
14 FloatProperty,
15 EnumProperty,
16 PointerProperty,
20 class MaterialRaytraceTransparency(PropertyGroup):
21 """Declare transparency panel properties controllable in UI and translated to POV."""
23 depth: IntProperty(
24 name="Depth",
25 description="Maximum allowed number of light inter-refractions",
26 min=0,
27 max=32767,
28 default=2,
31 depth_max: FloatProperty(
32 name="Depth",
33 description="Maximum depth for light to travel through the "
34 "transparent material before becoming fully filtered (0.0 is disabled)",
35 min=0,
36 max=100,
37 default=0.0,
40 falloff: FloatProperty(
41 name="Falloff",
42 description="Falloff power for transmissivity filter effect (1.0 is linear)",
43 min=0.1,
44 max=10.0,
45 default=1.0,
46 precision=3,
49 filter: FloatProperty(
50 name="Filter",
51 description="Amount to blend in the material’s diffuse color in raytraced "
52 "transparency (simulating absorption)",
53 min=0.0,
54 max=1.0,
55 default=0.0,
56 precision=3,
59 fresnel: FloatProperty(
60 name="Fresnel",
61 description="Power of Fresnel for transparency (Ray or ZTransp)",
62 min=0.0,
63 max=5.0,
64 soft_min=0.0,
65 soft_max=5.0,
66 default=0.0,
67 precision=3,
70 fresnel_factor: FloatProperty(
71 name="Blend",
72 description="Blending factor for Fresnel",
73 min=0.0,
74 max=5.0,
75 soft_min=0.0,
76 soft_max=5.0,
77 default=1.250,
78 precision=3,
81 gloss_factor: FloatProperty(
82 name="Amount",
83 description="The clarity of the refraction. "
84 "(values < 1.0 give diffuse, blurry refractions)",
85 min=0.0,
86 max=1.0,
87 soft_min=0.0,
88 soft_max=1.0,
89 default=1.0,
90 precision=3,
93 gloss_samples: IntProperty(
94 name="Samples",
95 description="frequency of the noise sample used for blurry refractions",
96 min=0,
97 max=1024,
98 default=18,
101 gloss_threshold: FloatProperty(
102 name="Threshold",
103 description="Threshold for adaptive sampling (if a sample "
104 "contributes less than this amount [as a percentage], "
105 "sampling is stopped)",
106 min=0.0,
107 max=1.0,
108 soft_min=0.0,
109 soft_max=1.0,
110 default=0.005,
111 precision=3,
114 ior: FloatProperty(
115 name="IOR",
116 description="Sets angular index of refraction for raytraced refraction",
117 min=-0.0,
118 max=10.0,
119 soft_min=0.25,
120 soft_max=4.0,
121 default=1.3,
125 class MaterialRaytraceMirror(PropertyGroup):
126 """Declare reflection panel properties controllable in UI and translated to POV."""
128 bl_description = ("Raytraced reflection settings for the Material",)
130 use: BoolProperty(name="Mirror", description="Enable raytraced reflections", default=False)
132 depth: IntProperty(
133 name="Depth",
134 description="Maximum allowed number of light inter-reflections",
135 min=0,
136 max=32767,
137 default=2,
140 distance: FloatProperty(
141 name="Max Dist",
142 description="Maximum distance of reflected rays "
143 "(reflections further than this range "
144 "fade to sky color or material color)",
145 min=0.0,
146 max=100000.0,
147 soft_min=0.0,
148 soft_max=10000.0,
149 default=0.0,
150 precision=3,
153 fade_to: EnumProperty(
154 items=[
155 ("FADE_TO_SKY", "Fade to sky", ""),
156 ("FADE_TO_MATERIAL", "Fade to material color", ""),
158 name="Fade-out Color",
159 description="The color that rays with no intersection within the "
160 "Max Distance take (material color can be best for "
161 "indoor scenes, sky color for outdoor)",
162 default="FADE_TO_SKY",
165 fresnel: FloatProperty(
166 name="Fresnel",
167 description="Power of Fresnel for mirror reflection",
168 min=0.0,
169 max=5.0,
170 soft_min=0.0,
171 soft_max=5.0,
172 default=0.0,
173 precision=3,
176 fresnel_factor: FloatProperty(
177 name="Blend",
178 description="Blending factor for Fresnel",
179 min=0.0,
180 max=5.0,
181 soft_min=0.0,
182 soft_max=5.0,
183 default=1.250,
184 precision=3,
187 gloss_anisotropic: FloatProperty(
188 name="Anisotropic",
189 description="The shape of the reflection, from 0.0 (circular) "
190 "to 1.0 (fully stretched along the tangent",
191 min=0.0,
192 max=1.0,
193 soft_min=0.0,
194 soft_max=1.0,
195 default=1.0,
196 precision=3,
199 gloss_factor: FloatProperty(
200 name="Amount",
201 description="The shininess of the reflection "
202 "(values < 1.0 give diffuse, blurry reflections)",
203 min=0.0,
204 max=1.0,
205 soft_min=0.0,
206 soft_max=1.0,
207 default=1.0,
208 precision=3,
211 gloss_samples: IntProperty(
212 name="Noise",
213 description="Frequency of the noise pattern bumps averaged for blurry reflections",
214 min=0,
215 max=1024,
216 default=18,
219 gloss_threshold: FloatProperty(
220 name="Threshold",
221 description="Threshold for adaptive sampling (if a sample "
222 "contributes less than this amount [as a percentage], "
223 "sampling is stopped)",
224 min=0.0,
225 max=1.0,
226 soft_min=0.0,
227 soft_max=1.0,
228 default=0.005,
229 precision=3,
232 mirror_color: FloatVectorProperty(
233 name="Mirror color",
234 description="Mirror color of the material",
235 precision=4,
236 step=0.01,
237 default=(1.0, 1.0, 1.0),
238 options={"ANIMATABLE"},
239 subtype="COLOR",
242 reflect_factor: FloatProperty(
243 name="Reflectivity",
244 description="Amount of mirror reflection for raytrace",
245 min=0.0,
246 max=1.0,
247 soft_min=0.0,
248 soft_max=1.0,
249 default=1.0,
250 precision=3,
254 class MaterialSubsurfaceScattering(PropertyGroup):
255 """Declare SSS/SSTL properties controllable in UI and translated to POV."""
257 bl_description = ("Subsurface scattering settings for the material",)
259 use: BoolProperty(
260 name="Subsurface Scattering",
261 description="Enable diffuse subsurface scatting " "effects in a material",
262 default=False,
265 back: FloatProperty(
266 name="Back",
267 description="Back scattering weight",
268 min=0.0,
269 max=10.0,
270 soft_min=0.0,
271 soft_max=10.0,
272 default=1.0,
273 precision=3,
276 color: FloatVectorProperty(
277 name="Scattering color",
278 description="Scattering color",
279 precision=4,
280 step=0.01,
281 default=(0.604, 0.604, 0.604),
282 options={"ANIMATABLE"},
283 subtype="COLOR",
286 color_factor: FloatProperty(
287 name="Color",
288 description="Blend factor for SSS colors",
289 min=0.0,
290 max=1.0,
291 soft_min=0.0,
292 soft_max=1.0,
293 default=1.0,
294 precision=3,
297 error_threshold: FloatProperty(
298 name="Error",
299 description="Error tolerance (low values are slower and higher quality)",
300 default=0.050,
301 precision=3,
304 front: FloatProperty(
305 name="Front",
306 description="Front scattering weight",
307 min=0.0,
308 max=2.0,
309 soft_min=0.0,
310 soft_max=2.0,
311 default=1.0,
312 precision=3,
315 ior: FloatProperty(
316 name="IOR",
317 description="Index of refraction (higher values are denser)",
318 min=-0.0,
319 max=10.0,
320 soft_min=0.1,
321 soft_max=2.0,
322 default=1.3,
325 radius: FloatVectorProperty(
326 name="RGB Radius",
327 description="Mean red/green/blue scattering path length",
328 precision=4,
329 step=0.01,
330 min=0.001,
331 default=(1.0, 1.0, 1.0),
332 options={"ANIMATABLE"},
335 scale: FloatProperty(
336 name="Scale", description="Object scale factor", default=0.100, precision=3
339 texture_factor: FloatProperty(
340 name="Texture",
341 description="Texture scattering blend factor",
342 min=0.0,
343 max=1.0,
344 soft_min=0.0,
345 soft_max=1.0,
346 default=0.0,
347 precision=3,
350 classes = (
351 MaterialRaytraceTransparency,
352 MaterialRaytraceMirror,
353 MaterialSubsurfaceScattering,
356 def register():
357 for cls in classes:
358 register_class(cls)
360 bpy.types.Material.pov_raytrace_transparency = PointerProperty(
361 type=MaterialRaytraceTransparency
363 bpy.types.Material.pov_subsurface_scattering = PointerProperty(
364 type=MaterialSubsurfaceScattering
366 bpy.types.Material.pov_raytrace_mirror = PointerProperty(type=MaterialRaytraceMirror)
369 def unregister():
370 del bpy.types.Material.pov_subsurface_scattering
371 del bpy.types.Material.pov_raytrace_mirror
372 del bpy.types.Material.pov_raytrace_transparency
374 for cls in reversed(classes):
375 unregister_class(cls)