properties_data_lightprobe.py 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. # ##### BEGIN GPL LICENSE BLOCK #####
  2. #
  3. # This program is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU General Public License
  5. # as published by the Free Software Foundation; either version 2
  6. # of the License, or (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software Foundation,
  15. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. #
  17. # ##### END GPL LICENSE BLOCK #####
  18. # <pep8 compliant>
  19. from bpy.types import Panel
  20. class DataButtonsPanel:
  21. bl_space_type = 'PROPERTIES'
  22. bl_region_type = 'WINDOW'
  23. bl_context = "data"
  24. @classmethod
  25. def poll(cls, context):
  26. engine = context.engine
  27. return context.lightprobe and (engine in cls.COMPAT_ENGINES)
  28. class DATA_PT_context_lightprobe(DataButtonsPanel, Panel):
  29. bl_label = ""
  30. bl_options = {'HIDE_HEADER'}
  31. COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_RENDER'}
  32. def draw(self, context):
  33. layout = self.layout
  34. ob = context.object
  35. probe = context.lightprobe
  36. space = context.space_data
  37. if ob:
  38. layout.template_ID(ob, "data")
  39. elif probe:
  40. layout.template_ID(space, "pin_id")
  41. class DATA_PT_lightprobe(DataButtonsPanel, Panel):
  42. bl_label = "Probe"
  43. COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_RENDER'}
  44. def draw(self, context):
  45. layout = self.layout
  46. layout.use_property_split = True
  47. probe = context.lightprobe
  48. # layout.prop(probe, "type")
  49. if probe.type == 'GRID':
  50. col = layout.column()
  51. col.prop(probe, "influence_distance", text="Distance")
  52. col.prop(probe, "falloff")
  53. col.prop(probe, "intensity")
  54. sub = col.column(align=True)
  55. sub.prop(probe, "grid_resolution_x", text="Resolution X")
  56. sub.prop(probe, "grid_resolution_y", text="Y")
  57. sub.prop(probe, "grid_resolution_z", text="Z")
  58. elif probe.type == 'PLANAR':
  59. col = layout.column()
  60. col.prop(probe, "influence_distance", text="Distance")
  61. col.prop(probe, "falloff")
  62. else:
  63. col = layout.column()
  64. col.prop(probe, "influence_type")
  65. if probe.influence_type == 'ELIPSOID':
  66. col.prop(probe, "influence_distance", text="Radius")
  67. else:
  68. col.prop(probe, "influence_distance", text="Size")
  69. col.prop(probe, "falloff")
  70. col.prop(probe, "intensity")
  71. sub = col.column(align=True)
  72. if probe.type != 'PLANAR':
  73. sub.prop(probe, "clip_start", text="Clipping Start")
  74. else:
  75. sub.prop(probe, "clip_start", text="Clipping Offset")
  76. if probe.type != 'PLANAR':
  77. sub.prop(probe, "clip_end", text="End")
  78. class DATA_PT_lightprobe_visibility(DataButtonsPanel, Panel):
  79. bl_label = "Visibility"
  80. bl_parent_id = "DATA_PT_lightprobe"
  81. COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_RENDER'}
  82. def draw(self, context):
  83. layout = self.layout
  84. layout.use_property_split = True
  85. probe = context.lightprobe
  86. col = layout.column()
  87. if probe.type == 'GRID':
  88. col.prop(probe, "visibility_buffer_bias", text="Bias")
  89. col.prop(probe, "visibility_bleed_bias", text="Bleed Bias")
  90. col.prop(probe, "visibility_blur", text="Blur")
  91. row = col.row(align=True)
  92. row.prop(probe, "visibility_collection")
  93. row.prop(probe, "invert_visibility_collection", text="", icon='ARROW_LEFTRIGHT')
  94. class DATA_PT_lightprobe_parallax(DataButtonsPanel, Panel):
  95. bl_label = "Custom Parallax"
  96. bl_options = {'DEFAULT_CLOSED'}
  97. COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_RENDER'}
  98. @classmethod
  99. def poll(cls, context):
  100. engine = context.engine
  101. return context.lightprobe and context.lightprobe.type == 'CUBEMAP' and (engine in cls.COMPAT_ENGINES)
  102. def draw_header(self, context):
  103. probe = context.lightprobe
  104. self.layout.prop(probe, "use_custom_parallax", text="")
  105. def draw(self, context):
  106. layout = self.layout
  107. layout.use_property_split = True
  108. probe = context.lightprobe
  109. col = layout.column()
  110. col.active = probe.use_custom_parallax
  111. col.prop(probe, "parallax_type")
  112. if probe.parallax_type == 'ELIPSOID':
  113. col.prop(probe, "parallax_distance", text="Radius")
  114. else:
  115. col.prop(probe, "parallax_distance", text="Size")
  116. class DATA_PT_lightprobe_display(DataButtonsPanel, Panel):
  117. bl_label = "Viewport Display"
  118. bl_options = {'DEFAULT_CLOSED'}
  119. COMPAT_ENGINES = {'BLENDER_EEVEE', 'BLENDER_RENDER'}
  120. def draw(self, context):
  121. layout = self.layout
  122. layout.use_property_split = True
  123. ob = context.object
  124. probe = context.lightprobe
  125. col = layout.column()
  126. if probe.type == 'PLANAR':
  127. col.prop(ob, "empty_display_size", text="Arrow Size")
  128. col.prop(probe, "show_data")
  129. if probe.type in {'GRID', 'CUBEMAP'}:
  130. col.prop(probe, "show_influence")
  131. col.prop(probe, "show_clip")
  132. if probe.type == 'CUBEMAP':
  133. sub = col.column()
  134. sub.active = probe.use_custom_parallax
  135. sub.prop(probe, "show_parallax")
  136. classes = (
  137. DATA_PT_context_lightprobe,
  138. DATA_PT_lightprobe,
  139. DATA_PT_lightprobe_visibility,
  140. DATA_PT_lightprobe_parallax,
  141. DATA_PT_lightprobe_display,
  142. )
  143. if __name__ == "__main__": # only for live edit.
  144. from bpy.utils import register_class
  145. for cls in classes:
  146. register_class(cls)