[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59933] branches/soc-2013-dingto: Cycles / Volume Rendering:

Thomas Dinges blender at dingto.org
Mon Sep 9 03:02:11 CEST 2013


Revision: 59933
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59933
Author:   dingto
Date:     2013-09-09 01:02:09 +0000 (Mon, 09 Sep 2013)
Log Message:
-----------
Cycles / Volume Rendering:
* Initial and experimental implementation of volumetric rendering. 

At this stage it is already usable, although there are a lot of limitations still:
- No Volume rendering in Branched Path integrator. 
- No Smoke volume rendering
- No OSL support
- UI and data structures are WIP, be careful when saving files with this. 
- ...

Credits:
* Based on the original patch by "storm". 
* Cleanup and improvements by Stuart Broadfoot. 
* A crash fix by Lukas T?\195?\182nne.
Thanks a lot guys!

* Also some cleanup and refactor by myself. 

Some WIP docs and infos: http://wiki.blender.org/index.php/User:DingTo/Volume

Modified Paths:
--------------
    branches/soc-2013-dingto/intern/cycles/blender/addon/presets.py
    branches/soc-2013-dingto/intern/cycles/blender/addon/properties.py
    branches/soc-2013-dingto/intern/cycles/blender/addon/ui.py
    branches/soc-2013-dingto/intern/cycles/blender/blender_shader.cpp
    branches/soc-2013-dingto/intern/cycles/blender/blender_sync.cpp
    branches/soc-2013-dingto/intern/cycles/kernel/CMakeLists.txt
    branches/soc-2013-dingto/intern/cycles/kernel/closure/bsdf.h
    branches/soc-2013-dingto/intern/cycles/kernel/closure/volume.h
    branches/soc-2013-dingto/intern/cycles/kernel/kernel_accumulate.h
    branches/soc-2013-dingto/intern/cycles/kernel/kernel_emission.h
    branches/soc-2013-dingto/intern/cycles/kernel/kernel_path.h
    branches/soc-2013-dingto/intern/cycles/kernel/kernel_path_state.h
    branches/soc-2013-dingto/intern/cycles/kernel/kernel_random.h
    branches/soc-2013-dingto/intern/cycles/kernel/kernel_shader.h
    branches/soc-2013-dingto/intern/cycles/kernel/kernel_types.h
    branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_closure.h
    branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_types.h
    branches/soc-2013-dingto/intern/cycles/render/integrator.cpp
    branches/soc-2013-dingto/intern/cycles/render/integrator.h
    branches/soc-2013-dingto/intern/cycles/render/nodes.cpp
    branches/soc-2013-dingto/intern/cycles/render/scene.h
    branches/soc-2013-dingto/intern/cycles/render/shader.cpp
    branches/soc-2013-dingto/release/scripts/presets/cycles/integrator/direct_light.py
    branches/soc-2013-dingto/release/scripts/presets/cycles/integrator/full_global_illumination.py
    branches/soc-2013-dingto/release/scripts/presets/cycles/integrator/limited_global_illumination.py
    branches/soc-2013-dingto/release/scripts/startup/nodeitems_builtins.py
    branches/soc-2013-dingto/source/blender/blenkernel/intern/node.c
    branches/soc-2013-dingto/source/blender/nodes/shader/nodes/node_shader_volume_isotropic.c

Added Paths:
-----------
    branches/soc-2013-dingto/intern/cycles/kernel/kernel_volume.h

Modified: branches/soc-2013-dingto/intern/cycles/blender/addon/presets.py
===================================================================
--- branches/soc-2013-dingto/intern/cycles/blender/addon/presets.py	2013-09-09 00:22:00 UTC (rev 59932)
+++ branches/soc-2013-dingto/intern/cycles/blender/addon/presets.py	2013-09-09 01:02:09 UTC (rev 59933)
@@ -34,9 +34,11 @@
         "cycles.max_bounces",
         "cycles.min_bounces",
         "cycles.no_caustics",
+        "cycles.use_volumetric",
         "cycles.diffuse_bounces",
         "cycles.glossy_bounces",
         "cycles.transmission_bounces",
+        "cycles.scattering_bounces",
         "cycles.transparent_min_bounces",
         "cycles.transparent_max_bounces"
     ]

Modified: branches/soc-2013-dingto/intern/cycles/blender/addon/properties.py
===================================================================
--- branches/soc-2013-dingto/intern/cycles/blender/addon/properties.py	2013-09-09 00:22:00 UTC (rev 59932)
+++ branches/soc-2013-dingto/intern/cycles/blender/addon/properties.py	2013-09-09 01:02:09 UTC (rev 59933)
@@ -85,6 +85,18 @@
     ('TOP_TO_BOTTOM', "Top to Bottom", "Render from top to bottom"),
     ('BOTTOM_TO_TOP', "Bottom to Top", "Render from bottom to top"),
     )
+    
+enum_volumetric_sampling_algorithm = (
+    ('VOLUMETRIC_MARCHING', "Ray Marching", "Use ray marching algorithm"),
+    ('VOLUMETRIC_WOODCOCK', "Woodcock", "Use Woodcock algorithm"),
+    ('VOLUMETRIC_MARCHING_EXP', "Ray Marching(Exp)", "Use ray marching algorithm (experimental)"),
+    ('VOLUMETRIC_WOODCOCK_EXP', "Woodcock(Exp)", "Use Woodcock algorithm (experimental)"),
+    )
+    
+enum_homogeneous_volumetric_sampling_algorithm = (
+    ('VOLUMETRIC_IMPORTANCE_SAMPLING', "Importance Sampling", "Use perfect importance sampling"),
+    ('VOLUMETRIC_EQUIANGULAR', "Equi-angular light(Exp)", "Use angular sampling based on lighting (experimental)"),
+    )
 
 enum_use_layer_samples = (
     ('USE', "Use", "Per render layer number of samples override scene samples"),
@@ -274,6 +286,12 @@
                 min=0, max=1024,
                 default=128,
                 )
+        cls.scattering_bounces = IntProperty(
+                name="Scattering Bounces",
+                description="Maximum number of volumetric scattering events",
+                min=0, max=1024,
+                default=128,
+                )
 
         cls.transparent_min_bounces = IntProperty(
                 name="Transparent Min Bounces",
@@ -402,7 +420,54 @@
                             "but time can be saved by manually stopping the render when the noise is low enough)",
                 default=False,
                 )
+        cls.use_volumetric = BoolProperty(
+                name="Use Volumetric",
+                description="Turn on volumetric rendering",
+                default=False
+                )
 
+        cls.volume_density_factor = FloatProperty(
+                name="Density Factor",
+                description="global attenuation coefficient (material volume density) multiplyer",
+                default=1.0,
+                min=0.0, max=100000.0
+                )
+        
+        cls.volume_sampling_algorithm = EnumProperty(
+                name="Sampling algorithm",
+                description="Choose volumetric sampling algorithm for inhomogeneous volumes",
+                items=enum_volumetric_sampling_algorithm,
+                default='VOLUMETRIC_MARCHING',
+                )
+                
+        cls.volume_homogeneous_sampling = EnumProperty(
+                name="Homogeneous Sampling",
+                description="Choose volumetric sampling algorithm for homogeneous volumes",
+                items=enum_homogeneous_volumetric_sampling_algorithm,
+                default='VOLUMETRIC_IMPORTANCE_SAMPLING',
+                )
+
+        cls.volume_max_iterations = IntProperty(
+                name="Max Iterations",
+                description="Number of iterations before we give up, protect for very slow deep volume marching",
+                default=200,
+                min=10, max=8192
+                )
+
+        cls.volume_cell_step = FloatProperty(
+                name="Cell Step",
+                description="cell size when probing for density, work same as 3d texture resolution",
+                default=0.1,
+                min=0.0000001, max=100000.0
+                )
+
+        cls.volume_woodcock_max_density = FloatProperty(
+                name="Max Woodcock Density",
+                description="Max density in volume, band aid, I need to calculate it from texture",
+                default=0.95,
+                min=0.0000001, max=100000.0
+                )
+
     @classmethod
     def unregister(cls):
         del bpy.types.Scene.cycles
@@ -571,6 +636,12 @@
                 min=1, max=10000,
                 default=4,
                 )
+        cls.homogeneous_volume = BoolProperty(
+                name="Homogeneous Volume",
+                description="When using volume rendering, assume volume has the same density everywhere, "
+                            "for faster rendering",
+                default=False,
+                )
 
     @classmethod
     def unregister(cls):

Modified: branches/soc-2013-dingto/intern/cycles/blender/addon/ui.py
===================================================================
--- branches/soc-2013-dingto/intern/cycles/blender/addon/ui.py	2013-09-09 00:22:00 UTC (rev 59932)
+++ branches/soc-2013-dingto/intern/cycles/blender/addon/ui.py	2013-09-09 01:02:09 UTC (rev 59933)
@@ -193,8 +193,40 @@
         sub.prop(cscene, "diffuse_bounces", text="Diffuse")
         sub.prop(cscene, "glossy_bounces", text="Glossy")
         sub.prop(cscene, "transmission_bounces", text="Transmission")
+        sub.prop(cscene, "scattering_bounces", text="Scattering")
+        
+class CyclesRender_PT_volumetrics(CyclesButtonsPanel, Panel):
+    bl_label = "Volumetrics"
+    bl_options = {'DEFAULT_CLOSED'}
+    
+    def draw_header(self, context):
+        rd = context.scene.cycles
 
+        self.layout.prop(rd, "use_volumetric", text="")
 
+    def draw(self, context):
+        layout = self.layout
+
+        scene = context.scene
+        cscene = scene.cycles
+        
+        layout.active = cscene.use_volumetric
+        
+        col = layout.column()
+        col.label(text="Sampling:")
+        col.prop(cscene, "volume_sampling_algorithm", text="Inhomogeneous")
+        col.prop(cscene, "volume_homogeneous_sampling", text="Homogeneous")
+        
+        layout.separator()
+        
+        col = layout.column()
+        col.prop(cscene, "volume_density_factor")
+        row = col.row()
+        row.prop(cscene, "volume_max_iterations")
+        row.prop(cscene, "volume_cell_step")
+        if cscene.volume_sampling_algorithm == 'VOLUMETRIC_WOODCOCK_EXP' or cscene.volume_sampling_algorithm == 'VOLUMETRIC_WOODCOCK':
+            col.prop(cscene, "volume_woodcock_max_density")
+
 class CyclesRender_PT_motion_blur(CyclesButtonsPanel, Panel):
     bl_label = "Motion Blur"
     bl_options = {'DEFAULT_CLOSED'}
@@ -805,15 +837,16 @@
 
     @classmethod
     def poll(cls, context):
-        # world = context.world
-        # world and world.node_tree and CyclesButtonsPanel.poll(context)
-        return False
+        world = context.world
+        return world and world.node_tree and CyclesButtonsPanel.poll(context)
 
     def draw(self, context):
         layout = self.layout
 
         world = context.world
         panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Volume')
+        
+        layout.prop(world.cycles, "homogeneous_volume")
 
 
 class CyclesWorld_PT_ambient_occlusion(CyclesButtonsPanel, Panel):
@@ -950,9 +983,8 @@
 
     @classmethod
     def poll(cls, context):
-        # mat = context.material
-        # mat and mat.node_tree and CyclesButtonsPanel.poll(context)
-        return False
+        mat = context.material
+        return mat and mat.node_tree and CyclesButtonsPanel.poll(context)
 
     def draw(self, context):
         layout = self.layout

Modified: branches/soc-2013-dingto/intern/cycles/blender/blender_shader.cpp
===================================================================
--- branches/soc-2013-dingto/intern/cycles/blender/blender_shader.cpp	2013-09-09 00:22:00 UTC (rev 59932)
+++ branches/soc-2013-dingto/intern/cycles/blender/blender_shader.cpp	2013-09-09 01:02:09 UTC (rev 59933)
@@ -932,6 +932,10 @@
 			graph->connect(closure->output("Background"), out->input("Surface"));
 		}
 
+		/* settings */
+		PointerRNA wmat = RNA_pointer_get(&b_world.ptr, "cycles");
+		shader->homogeneous_volume = get_boolean(wmat, "homogeneous_volume");
+
 		if(b_world) {
 			/* AO */
 			BL::WorldLighting b_light = b_world.light_settings();

Modified: branches/soc-2013-dingto/intern/cycles/blender/blender_sync.cpp
===================================================================
--- branches/soc-2013-dingto/intern/cycles/blender/blender_sync.cpp	2013-09-09 00:22:00 UTC (rev 59932)
+++ branches/soc-2013-dingto/intern/cycles/blender/blender_sync.cpp	2013-09-09 01:02:09 UTC (rev 59933)
@@ -165,12 +165,21 @@
 	integrator->max_diffuse_bounce = get_int(cscene, "diffuse_bounces");
 	integrator->max_glossy_bounce = get_int(cscene, "glossy_bounces");
 	integrator->max_transmission_bounce = get_int(cscene, "transmission_bounces");
+	integrator->max_scattering_bounce = get_int(cscene, "scattering_bounces");
 
 	integrator->transparent_max_bounce = get_int(cscene, "transparent_max_bounces");
 	integrator->transparent_min_bounce = get_int(cscene, "transparent_min_bounces");
 	integrator->transparent_shadows = get_boolean(cscene, "use_transparent_shadows");
 
 	integrator->no_caustics = get_boolean(cscene, "no_caustics");
+	integrator->use_volumetric = get_boolean(cscene, "use_volumetric");
+	integrator->volume_density_factor = get_float(cscene, "volume_density_factor");
+	integrator->volume_sampling_algorithm = get_enum(cscene, "volume_sampling_algorithm");
+	integrator->volume_homogeneous_sampling = get_enum(cscene, "volume_homogeneous_sampling");
+	integrator->volume_max_iterations = get_int(cscene, "volume_max_iterations");
+	integrator->volume_cell_step = get_float(cscene, "volume_cell_step");
+	integrator->volume_woodcock_max_density = get_float(cscene, "volume_woodcock_max_density");
+
 	integrator->filter_glossy = get_float(cscene, "blur_glossy");
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list