2009-11-01 15:21:20 +00:00
|
|
|
# ##### 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.
|
2009-11-03 07:23:02 +00:00
|
|
|
#
|
2009-11-01 15:21:20 +00:00
|
|
|
# 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.
|
2009-11-03 07:23:02 +00:00
|
|
|
#
|
2009-11-01 15:21:20 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-11-01 15:21:20 +00:00
|
|
|
#
|
|
|
|
|
# ##### END GPL LICENSE BLOCK #####
|
2009-10-31 20:16:59 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
# <pep8 compliant>
|
2009-05-08 18:17:57 +00:00
|
|
|
import bpy
|
2011-08-12 06:57:00 +00:00
|
|
|
from bpy.types import Menu, Panel
|
2010-01-08 08:54:41 +00:00
|
|
|
from rna_prop_ui import PropertyPanel
|
2009-11-14 13:35:44 +00:00
|
|
|
|
2011-09-20 18:29:19 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class LAMP_MT_sunsky_presets(Menu):
|
2011-09-21 15:18:38 +00:00
|
|
|
bl_label = "Sun & Sky Presets"
|
2010-02-07 13:56:36 +00:00
|
|
|
preset_subdir = "sunsky"
|
* Interaction Presets
This adds a new presets menu in the splash screen and the Input section of
User Preferences to choose a preset interaction style, consisting of key configurations
and also other user preferences such as select mouse button, view rotation style, etc.
Currently, just 'Blender' and 'Maya' presets are included, hopefully we can have more
presets contributed (and maintained!) by the community.
It's best to keep these presets minimal to avoid too many key conflicts. In the Maya one
I changed the view manipulation key/mouse combos and also the transform
manipulator keys, not much more than that.
To save an interaction preset, open the user preferences Input section, and press the
[ + ] button next to the presets menu. It will save out a .py file containing any edited key
maps and navigation preferences to the presets/interaction folder in your scripts folder.
---
Part of this commit changes the way that key maps are exported/displayed in
preferences - now partial key configs are allowed. Previously it would export/import the
entire key configuration, regardless of whether individual key maps were edited or not
(which would make them more susceptible to conflicts in unexpected areas).
(note, in blender terminology, a key map is a category of key items, such as
'Object Mode' or 'View 2d'.)
Now, the export and the UI display work in a similar way to how key maps are
processed internally - Locally edited key maps (after pressing the 'Edit' button) are
processed first, falling back to other key maps in the current key config, and then falling
back to the default key config. So it's possible for a key config to only include a few
key maps, and the rest just gets pulled from the default key config. The preferences
UI display works like this too behind the scenes in deciding what to show users,
however using it is just like it was before, the complexity is hidden.
2010-04-14 06:27:50 +00:00
|
|
|
preset_operator = "script.execute_preset"
|
2018-04-16 14:07:42 +02:00
|
|
|
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
|
2011-08-12 06:57:00 +00:00
|
|
|
draw = Menu.draw_preset
|
2010-02-07 13:56:36 +00:00
|
|
|
|
|
|
|
|
|
2015-01-29 15:35:06 +11:00
|
|
|
class DataButtonsPanel:
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_space_type = 'PROPERTIES'
|
|
|
|
|
bl_region_type = 'WINDOW'
|
|
|
|
|
bl_context = "data"
|
|
|
|
|
|
2010-08-09 01:37:09 +00:00
|
|
|
@classmethod
|
|
|
|
|
def poll(cls, context):
|
2017-10-16 17:15:03 -02:00
|
|
|
engine = context.engine
|
2010-08-09 01:37:09 +00:00
|
|
|
return context.lamp and (engine in cls.COMPAT_ENGINES)
|
|
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class DATA_PT_context_lamp(DataButtonsPanel, Panel):
|
2009-10-31 19:31:45 +00:00
|
|
|
bl_label = ""
|
2010-08-26 01:05:37 +00:00
|
|
|
bl_options = {'HIDE_HEADER'}
|
2018-04-16 14:07:42 +02:00
|
|
|
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
|
|
ob = context.object
|
|
|
|
|
lamp = context.lamp
|
|
|
|
|
space = context.space_data
|
2010-08-06 15:17:44 +00:00
|
|
|
|
|
|
|
|
split = layout.split(percentage=0.65)
|
2010-08-06 15:36:38 +00:00
|
|
|
|
2010-08-06 15:17:44 +00:00
|
|
|
if ob:
|
|
|
|
|
split.template_ID(ob, "data")
|
|
|
|
|
elif lamp:
|
|
|
|
|
split.template_ID(space, "pin_id")
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2010-09-07 15:17:42 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class DATA_PT_preview(DataButtonsPanel, Panel):
|
2011-09-15 13:20:18 +00:00
|
|
|
bl_label = "Preview"
|
2018-04-16 14:07:42 +02:00
|
|
|
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
|
2010-08-12 19:36:10 +00:00
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
self.layout.template_preview(context.lamp)
|
2010-08-05 16:05:30 +00:00
|
|
|
|
2010-01-08 08:54:41 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class DATA_PT_lamp(DataButtonsPanel, Panel):
|
2011-09-15 13:20:18 +00:00
|
|
|
bl_label = "Lamp"
|
2018-04-16 14:07:42 +02:00
|
|
|
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY'}
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
|
|
lamp = context.lamp
|
|
|
|
|
|
2017-06-01 16:38:32 +03:00
|
|
|
layout.row().prop(lamp, "type", expand=True)
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2018-06-01 18:44:06 +02:00
|
|
|
layout.use_property_split = True
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2018-06-01 18:44:06 +02:00
|
|
|
col = col.column()
|
|
|
|
|
col.prop(lamp, "color")
|
|
|
|
|
col.prop(lamp, "energy")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2011-03-07 13:23:45 +00:00
|
|
|
if lamp.type in {'POINT', 'SPOT'}:
|
2018-06-01 18:44:06 +02:00
|
|
|
|
|
|
|
|
col = col.column()
|
|
|
|
|
col.label(text="Falloff")
|
|
|
|
|
col.prop(lamp, "falloff_type")
|
|
|
|
|
col.prop(lamp, "distance")
|
|
|
|
|
col.prop(lamp, "shadow_soft_size")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
|
if lamp.falloff_type == 'LINEAR_QUADRATIC_WEIGHTED':
|
|
|
|
|
sub = col.column(align=True)
|
2011-09-21 15:18:38 +00:00
|
|
|
sub.prop(lamp, "linear_attenuation", slider=True, text="Linear")
|
|
|
|
|
sub.prop(lamp, "quadratic_attenuation", slider=True, text="Quadratic")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2016-03-13 02:00:12 +01:00
|
|
|
elif lamp.falloff_type == 'INVERSE_COEFFICIENTS':
|
2018-06-01 18:44:06 +02:00
|
|
|
col.label(text="Inverse Coefficients")
|
2016-03-13 02:00:12 +01:00
|
|
|
sub = col.column(align=True)
|
|
|
|
|
sub.prop(lamp, "constant_coefficient", text="Constant")
|
|
|
|
|
sub.prop(lamp, "linear_coefficient", text="Linear")
|
|
|
|
|
sub.prop(lamp, "quadratic_coefficient", text="Quadratic")
|
|
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
if lamp.type == 'AREA':
|
2009-11-23 00:27:30 +00:00
|
|
|
col.prop(lamp, "distance")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2010-08-06 15:17:44 +00:00
|
|
|
col = split.column()
|
Remove Blender Internal and legacy viewport from Blender 2.8.
Brecht authored this commit, but he gave me the honours to actually
do it. Here it goes; Blender Internal. Bye bye, you did great!
* Point density, voxel data, ocean, environment map textures were removed,
as these only worked within BI rendering. Note that the ocean modifier
and the Cycles point density shader node continue to work.
* Dynamic paint using material shading was removed, as this only worked
with BI. If we ever wanted to support this again probably it should go
through the baking API.
* GPU shader export through the Python API was removed. This only worked
for the old BI GLSL shaders, which no longer exists. Doing something
similar for Eevee would be significantly more complicated because it
uses a lot of multiplass rendering and logic outside the shader, it's
probably impractical.
* Collada material import / export code is mostly gone, as it only worked
for BI materials. We need to add Cycles / Eevee material support at some
point.
* The mesh noise operator was removed since it only worked with BI
material texture slots. A displacement modifier can be used instead.
* The delete texture paint slot operator was removed since it only worked
for BI material texture slots. Could be added back with node support.
* Not all legacy viewport features are supported in the new viewport, but
their code was removed. If we need to bring anything back we can look at
older git revisions.
* There is some legacy viewport code that I could not remove yet, and some
that I probably missed.
* Shader node execution code was left mostly intact, even though it is not
used anywhere now. We may eventually use this to replace the texture
nodes with Cycles / Eevee shader nodes.
* The Cycles Bake panel now includes settings for baking multires normal
and displacement maps. The underlying code needs to be merged properly,
and we plan to add back support for multires AO baking and add support
to Cycles baking for features like vertex color, displacement, and other
missing baking features.
* This commit removes DNA and the Python API for BI material, lamp, world
and scene settings. This breaks a lot of addons.
* There is more DNA that can be removed or renamed, where Cycles or Eevee
are reusing some old BI properties but the names are not really correct
anymore.
* Texture slots for materials, lamps and world were removed. They remain
for brushes, particles and freestyle linestyles.
* 'BLENDER_RENDER' remains in the COMPAT_ENGINES of UI panels. Cycles and
other renderers use this to find all panels to show, minus a few panels
that they have their own replacement for.
2018-04-19 17:34:44 +02:00
|
|
|
col.label()
|
2009-07-27 20:39:10 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2017-06-02 15:27:57 +02:00
|
|
|
class DATA_PT_EEVEE_lamp(DataButtonsPanel, Panel):
|
|
|
|
|
bl_label = "Lamp"
|
|
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE'}
|
|
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
lamp = context.lamp
|
|
|
|
|
|
|
|
|
|
layout.row().prop(lamp, "type", expand=True)
|
|
|
|
|
|
2018-06-01 18:44:06 +02:00
|
|
|
layout.use_property_split = True
|
2017-06-02 15:27:57 +02:00
|
|
|
|
2018-06-01 18:44:06 +02:00
|
|
|
col = layout.column()
|
|
|
|
|
col.prop(lamp, "color")
|
|
|
|
|
col.prop(lamp, "energy")
|
|
|
|
|
col.prop(lamp, "specular_factor", text="Specular")
|
|
|
|
|
|
|
|
|
|
col.separator()
|
2017-06-02 15:27:57 +02:00
|
|
|
|
|
|
|
|
if lamp.type in {'POINT', 'SPOT', 'SUN'}:
|
2018-06-01 18:44:06 +02:00
|
|
|
col.prop(lamp, "shadow_soft_size", text="Radius")
|
2017-06-02 15:27:57 +02:00
|
|
|
elif lamp.type == 'AREA':
|
2018-06-01 18:44:06 +02:00
|
|
|
col.prop(lamp, "shape")
|
|
|
|
|
|
|
|
|
|
sub = col.column(align=True)
|
|
|
|
|
|
|
|
|
|
if lamp.shape in {'SQUARE', 'DISK'}:
|
2017-06-02 15:27:57 +02:00
|
|
|
sub.prop(lamp, "size")
|
Cycles/Eevee: Implement disk and ellipse shapes for area lamps
The implementation is pretty straightforward.
In Cycles, sampling the shapes is currently done w.r.t. area instead of solid angle.
There is a paper on solid angle sampling for disks [1], but the described algorithm is based on
simply sampling the enclosing square and rejecting samples outside of the disk, which is not exactly
great for Cycles' RNG (we'd need to setup a LCG for the repeated sampling) and for GPU divergence.
Even worse, the algorithm is only defined for disks. For ellipses, the basic idea still works, but a
way to analytically calculate the solid angle is required. This is technically possible [2], but the
calculation is extremely complex and still requires a lookup table for the Heuman Lambda function.
Therefore, I've decided to not implement that for now, we could still look into it later on.
In Eevee, the code uses the existing ltc_evaluate_disk to implement the lighting calculations.
[1]: "Solid Angle Sampling of Disk and Cylinder Lights"
[2]: "Analytical solution for the solid angle subtended at any point by an ellipse via a point source radiation vector potential"
Reviewers: sergey, brecht, fclem
Differential Revision: https://developer.blender.org/D3171
2018-05-24 03:50:16 +02:00
|
|
|
elif lamp.shape in {'RECTANGLE', 'ELLIPSE'}:
|
2017-06-02 15:27:57 +02:00
|
|
|
sub.prop(lamp, "size", text="Size X")
|
2018-06-01 18:44:06 +02:00
|
|
|
sub.prop(lamp, "size_y", text="Y")
|
2017-06-02 15:27:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class DATA_PT_EEVEE_shadow(DataButtonsPanel, Panel):
|
|
|
|
|
bl_label = "Shadow"
|
|
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE'}
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def poll(cls, context):
|
|
|
|
|
lamp = context.lamp
|
2017-10-16 17:15:03 -02:00
|
|
|
engine = context.engine
|
2017-06-02 15:27:57 +02:00
|
|
|
return (lamp and lamp.type in {'POINT', 'SUN', 'SPOT', 'AREA'}) and (engine in cls.COMPAT_ENGINES)
|
|
|
|
|
|
|
|
|
|
def draw_header(self, context):
|
|
|
|
|
lamp = context.lamp
|
|
|
|
|
self.layout.prop(lamp, "use_shadow", text="")
|
|
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
2018-06-01 18:44:06 +02:00
|
|
|
layout.use_property_split = True
|
2017-06-02 15:27:57 +02:00
|
|
|
|
|
|
|
|
lamp = context.lamp
|
|
|
|
|
|
2018-06-01 18:44:06 +02:00
|
|
|
layout.active = lamp.use_shadow
|
2017-09-05 21:02:17 +02:00
|
|
|
|
2018-06-01 18:44:06 +02:00
|
|
|
col = layout.column()
|
|
|
|
|
sub = col.column(align=True)
|
|
|
|
|
sub.prop(lamp, "shadow_buffer_clip_start", text="Clip Start")
|
|
|
|
|
sub.prop(lamp, "shadow_buffer_clip_end", text="End")
|
|
|
|
|
|
|
|
|
|
col.prop(lamp, "shadow_buffer_soft", text="Softness")
|
|
|
|
|
|
|
|
|
|
col.separator()
|
2017-09-05 21:02:17 +02:00
|
|
|
|
|
|
|
|
col.prop(lamp, "shadow_buffer_bias", text="Bias")
|
|
|
|
|
col.prop(lamp, "shadow_buffer_exp", text="Exponent")
|
|
|
|
|
col.prop(lamp, "shadow_buffer_bleed_bias", text="Bleed Bias")
|
2009-05-10 12:12:05 +00:00
|
|
|
|
2017-09-09 21:11:58 +02:00
|
|
|
|
2018-06-04 17:26:47 +02:00
|
|
|
class DATA_PT_EEVEE_shadow_cascaded_shadow_map(DataButtonsPanel, Panel):
|
|
|
|
|
bl_label = "Cascaded Shadow Map"
|
|
|
|
|
bl_parent_id = "DATA_PT_EEVEE_shadow"
|
|
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
|
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE'}
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def poll(cls, context):
|
|
|
|
|
lamp = context.lamp
|
|
|
|
|
engine = context.engine
|
|
|
|
|
|
|
|
|
|
return (lamp and lamp.type == 'SUN') and (engine in cls.COMPAT_ENGINES)
|
|
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
lamp = context.lamp
|
|
|
|
|
layout.use_property_split = True
|
2017-09-09 21:11:58 +02:00
|
|
|
|
2018-06-04 17:26:47 +02:00
|
|
|
col = layout.column()
|
|
|
|
|
|
|
|
|
|
col.prop(lamp, "shadow_cascade_count", text="Count")
|
|
|
|
|
col.prop(lamp, "shadow_cascade_fade", text="Fade")
|
2017-09-07 15:31:11 +02:00
|
|
|
|
2018-06-04 17:26:47 +02:00
|
|
|
col.prop(lamp, "shadow_cascade_max_distance", text="Max Distance")
|
|
|
|
|
col.prop(lamp, "shadow_cascade_exponent", text="Distribution")
|
2017-10-06 23:43:36 +02:00
|
|
|
|
2018-06-04 17:26:47 +02:00
|
|
|
|
|
|
|
|
class DATA_PT_EEVEE_shadow_contact(DataButtonsPanel, Panel):
|
|
|
|
|
bl_label = "Contact Shadows"
|
|
|
|
|
bl_parent_id = "DATA_PT_EEVEE_shadow"
|
|
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE'}
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def poll(cls, context):
|
|
|
|
|
lamp = context.lamp
|
|
|
|
|
engine = context.engine
|
|
|
|
|
return (lamp and lamp.type in {'POINT', 'SUN', 'SPOT', 'AREA'}) and (engine in cls.COMPAT_ENGINES)
|
|
|
|
|
|
|
|
|
|
def draw_header(self, context):
|
|
|
|
|
lamp = context.lamp
|
|
|
|
|
|
|
|
|
|
layout = self.layout
|
|
|
|
|
layout.active = lamp.use_shadow
|
|
|
|
|
layout.prop(lamp, "use_contact_shadow", text="")
|
|
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
lamp = context.lamp
|
|
|
|
|
layout.use_property_split = True
|
2017-10-06 23:43:36 +02:00
|
|
|
|
2018-06-01 18:44:06 +02:00
|
|
|
col = layout.column()
|
2018-06-04 17:26:47 +02:00
|
|
|
col.active = lamp.use_shadow and lamp.use_contact_shadow
|
2018-06-01 18:44:06 +02:00
|
|
|
|
|
|
|
|
col.prop(lamp, "contact_shadow_distance", text="Distance")
|
|
|
|
|
col.prop(lamp, "contact_shadow_soft_size", text="Softness")
|
2017-10-06 23:43:36 +02:00
|
|
|
col.prop(lamp, "contact_shadow_bias", text="Bias")
|
|
|
|
|
col.prop(lamp, "contact_shadow_thickness", text="Thickness")
|
|
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class DATA_PT_area(DataButtonsPanel, Panel):
|
2011-09-15 13:20:18 +00:00
|
|
|
bl_label = "Area Shape"
|
2018-04-16 14:07:42 +02:00
|
|
|
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY'}
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2010-08-09 01:37:09 +00:00
|
|
|
@classmethod
|
|
|
|
|
def poll(cls, context):
|
2009-10-31 19:31:45 +00:00
|
|
|
lamp = context.lamp
|
2017-10-16 17:15:03 -02:00
|
|
|
engine = context.engine
|
2010-08-09 01:37:09 +00:00
|
|
|
return (lamp and lamp.type == 'AREA') and (engine in cls.COMPAT_ENGINES)
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
|
def draw(self, context):
|
2010-08-06 15:36:38 +00:00
|
|
|
layout = self.layout
|
2011-02-26 16:27:58 +00:00
|
|
|
|
2011-02-26 16:04:14 +00:00
|
|
|
lamp = context.lamp
|
2010-09-07 15:17:42 +00:00
|
|
|
|
2011-02-26 16:04:14 +00:00
|
|
|
col = layout.column()
|
2010-08-06 15:17:44 +00:00
|
|
|
col.row().prop(lamp, "shape", expand=True)
|
2010-08-06 15:36:38 +00:00
|
|
|
sub = col.row(align=True)
|
2009-10-31 19:31:45 +00:00
|
|
|
|
Cycles/Eevee: Implement disk and ellipse shapes for area lamps
The implementation is pretty straightforward.
In Cycles, sampling the shapes is currently done w.r.t. area instead of solid angle.
There is a paper on solid angle sampling for disks [1], but the described algorithm is based on
simply sampling the enclosing square and rejecting samples outside of the disk, which is not exactly
great for Cycles' RNG (we'd need to setup a LCG for the repeated sampling) and for GPU divergence.
Even worse, the algorithm is only defined for disks. For ellipses, the basic idea still works, but a
way to analytically calculate the solid angle is required. This is technically possible [2], but the
calculation is extremely complex and still requires a lookup table for the Heuman Lambda function.
Therefore, I've decided to not implement that for now, we could still look into it later on.
In Eevee, the code uses the existing ltc_evaluate_disk to implement the lighting calculations.
[1]: "Solid Angle Sampling of Disk and Cylinder Lights"
[2]: "Analytical solution for the solid angle subtended at any point by an ellipse via a point source radiation vector potential"
Reviewers: sergey, brecht, fclem
Differential Revision: https://developer.blender.org/D3171
2018-05-24 03:50:16 +02:00
|
|
|
if lamp.shape in {'SQUARE', 'DISK'}:
|
2009-11-23 00:27:30 +00:00
|
|
|
sub.prop(lamp, "size")
|
Cycles/Eevee: Implement disk and ellipse shapes for area lamps
The implementation is pretty straightforward.
In Cycles, sampling the shapes is currently done w.r.t. area instead of solid angle.
There is a paper on solid angle sampling for disks [1], but the described algorithm is based on
simply sampling the enclosing square and rejecting samples outside of the disk, which is not exactly
great for Cycles' RNG (we'd need to setup a LCG for the repeated sampling) and for GPU divergence.
Even worse, the algorithm is only defined for disks. For ellipses, the basic idea still works, but a
way to analytically calculate the solid angle is required. This is technically possible [2], but the
calculation is extremely complex and still requires a lookup table for the Heuman Lambda function.
Therefore, I've decided to not implement that for now, we could still look into it later on.
In Eevee, the code uses the existing ltc_evaluate_disk to implement the lighting calculations.
[1]: "Solid Angle Sampling of Disk and Cylinder Lights"
[2]: "Analytical solution for the solid angle subtended at any point by an ellipse via a point source radiation vector potential"
Reviewers: sergey, brecht, fclem
Differential Revision: https://developer.blender.org/D3171
2018-05-24 03:50:16 +02:00
|
|
|
elif lamp.shape in {'RECTANGLE', 'ELLIPSE'}:
|
2011-09-21 15:18:38 +00:00
|
|
|
sub.prop(lamp, "size", text="Size X")
|
|
|
|
|
sub.prop(lamp, "size_y", text="Size Y")
|
2009-07-30 13:56:39 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class DATA_PT_spot(DataButtonsPanel, Panel):
|
2011-09-15 13:20:18 +00:00
|
|
|
bl_label = "Spot Shape"
|
2018-04-16 14:07:42 +02:00
|
|
|
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY'}
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2010-08-09 01:37:09 +00:00
|
|
|
@classmethod
|
|
|
|
|
def poll(cls, context):
|
2009-10-31 19:31:45 +00:00
|
|
|
lamp = context.lamp
|
2017-10-16 17:15:03 -02:00
|
|
|
engine = context.engine
|
2010-08-09 01:37:09 +00:00
|
|
|
return (lamp and lamp.type == 'SPOT') and (engine in cls.COMPAT_ENGINES)
|
2009-10-31 19:31:45 +00:00
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
|
|
|
|
|
|
|
|
|
lamp = context.lamp
|
|
|
|
|
|
|
|
|
|
split = layout.split()
|
|
|
|
|
|
|
|
|
|
col = split.column()
|
|
|
|
|
sub = col.column()
|
2011-09-21 15:18:38 +00:00
|
|
|
sub.prop(lamp, "spot_size", text="Size")
|
|
|
|
|
sub.prop(lamp, "spot_blend", text="Blend", slider=True)
|
2010-08-21 04:51:00 +00:00
|
|
|
col.prop(lamp, "use_square")
|
2010-01-25 14:47:32 +00:00
|
|
|
col.prop(lamp, "show_cone")
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2010-08-06 15:17:44 +00:00
|
|
|
col = split.column()
|
|
|
|
|
|
2015-04-03 11:17:58 +02:00
|
|
|
col.active = (lamp.shadow_method != 'BUFFER_SHADOW' or lamp.shadow_buffer_type != 'DEEP')
|
2010-08-18 04:10:23 +00:00
|
|
|
col.prop(lamp, "use_halo")
|
2009-10-31 19:31:45 +00:00
|
|
|
sub = col.column(align=True)
|
2010-08-18 04:10:23 +00:00
|
|
|
sub.active = lamp.use_halo
|
2011-09-21 15:18:38 +00:00
|
|
|
sub.prop(lamp, "halo_intensity", text="Intensity")
|
2009-10-31 19:31:45 +00:00
|
|
|
if lamp.shadow_method == 'BUFFER_SHADOW':
|
2011-09-21 15:18:38 +00:00
|
|
|
sub.prop(lamp, "halo_step", text="Step")
|
2009-05-08 18:17:57 +00:00
|
|
|
|
2009-10-31 23:35:56 +00:00
|
|
|
|
2017-06-02 15:27:57 +02:00
|
|
|
class DATA_PT_spot(DataButtonsPanel, Panel):
|
|
|
|
|
bl_label = "Spot Shape"
|
2018-06-04 17:26:47 +02:00
|
|
|
bl_parent_id = "DATA_PT_EEVEE_lamp"
|
2017-06-02 15:27:57 +02:00
|
|
|
COMPAT_ENGINES = {'BLENDER_EEVEE'}
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def poll(cls, context):
|
|
|
|
|
lamp = context.lamp
|
2017-10-16 17:15:03 -02:00
|
|
|
engine = context.engine
|
2017-06-02 15:27:57 +02:00
|
|
|
return (lamp and lamp.type == 'SPOT') and (engine in cls.COMPAT_ENGINES)
|
|
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
|
layout = self.layout
|
2018-06-01 18:44:06 +02:00
|
|
|
layout.use_property_split = True
|
2017-06-02 15:27:57 +02:00
|
|
|
|
|
|
|
|
lamp = context.lamp
|
|
|
|
|
|
2018-06-01 18:44:06 +02:00
|
|
|
col = layout.column()
|
|
|
|
|
|
|
|
|
|
col.prop(lamp, "spot_size", text="Size")
|
|
|
|
|
col.prop(lamp, "spot_blend", text="Blend", slider=True)
|
2017-06-02 15:27:57 +02:00
|
|
|
|
|
|
|
|
col.prop(lamp, "show_cone")
|
|
|
|
|
|
|
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class DATA_PT_falloff_curve(DataButtonsPanel, Panel):
|
2011-09-15 13:20:18 +00:00
|
|
|
bl_label = "Falloff Curve"
|
2010-08-26 01:05:37 +00:00
|
|
|
bl_options = {'DEFAULT_CLOSED'}
|
2018-04-16 14:07:42 +02:00
|
|
|
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
|
2009-10-31 19:31:45 +00:00
|
|
|
|
2010-08-09 01:37:09 +00:00
|
|
|
@classmethod
|
|
|
|
|
def poll(cls, context):
|
2009-10-31 19:31:45 +00:00
|
|
|
lamp = context.lamp
|
2017-10-16 17:15:03 -02:00
|
|
|
engine = context.engine
|
2009-06-03 00:17:35 +00:00
|
|
|
|
2011-03-07 13:23:45 +00:00
|
|
|
return (lamp and lamp.type in {'POINT', 'SPOT'} and lamp.falloff_type == 'CUSTOM_CURVE') and (engine in cls.COMPAT_ENGINES)
|
2009-06-03 00:17:35 +00:00
|
|
|
|
2009-10-31 19:31:45 +00:00
|
|
|
def draw(self, context):
|
|
|
|
|
lamp = context.lamp
|
2009-06-03 00:17:35 +00:00
|
|
|
|
2014-06-30 16:20:02 +02:00
|
|
|
self.layout.template_curve_mapping(lamp, "falloff_curve", use_negative_slope=True)
|
2009-06-03 00:17:35 +00:00
|
|
|
|
2010-01-08 08:54:41 +00:00
|
|
|
|
2011-08-12 06:57:00 +00:00
|
|
|
class DATA_PT_custom_props_lamp(DataButtonsPanel, PropertyPanel, Panel):
|
2018-04-16 14:07:42 +02:00
|
|
|
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
|
2010-08-12 19:36:10 +00:00
|
|
|
_context_path = "object.data"
|
2010-12-17 10:33:28 +00:00
|
|
|
_property_type = bpy.types.Lamp
|
2011-04-04 10:13:04 +00:00
|
|
|
|
2017-03-18 20:03:24 +11:00
|
|
|
|
|
|
|
|
classes = (
|
2017-03-20 02:34:32 +11:00
|
|
|
LAMP_MT_sunsky_presets,
|
2017-03-18 20:03:24 +11:00
|
|
|
DATA_PT_context_lamp,
|
|
|
|
|
DATA_PT_preview,
|
2017-03-20 02:34:32 +11:00
|
|
|
DATA_PT_lamp,
|
2017-06-02 15:27:57 +02:00
|
|
|
DATA_PT_EEVEE_lamp,
|
|
|
|
|
DATA_PT_EEVEE_shadow,
|
2018-06-04 17:26:47 +02:00
|
|
|
DATA_PT_EEVEE_shadow_contact,
|
|
|
|
|
DATA_PT_EEVEE_shadow_cascaded_shadow_map,
|
2017-03-20 02:34:32 +11:00
|
|
|
DATA_PT_area,
|
2017-03-18 20:03:24 +11:00
|
|
|
DATA_PT_spot,
|
2017-03-20 02:34:32 +11:00
|
|
|
DATA_PT_falloff_curve,
|
|
|
|
|
DATA_PT_custom_props_lamp,
|
2017-03-18 20:03:24 +11:00
|
|
|
)
|
|
|
|
|
|
2011-04-04 10:13:04 +00:00
|
|
|
if __name__ == "__main__": # only for live edit.
|
2017-03-18 20:03:24 +11:00
|
|
|
from bpy.utils import register_class
|
|
|
|
|
for cls in classes:
|
|
|
|
|
register_class(cls)
|