[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27113] branches/render25: Render Branch: Irradiance Cache

Brecht Van Lommel brecht at blender.org
Tue Feb 23 20:48:55 CET 2010


Revision: 27113
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27113
Author:   blendix
Date:     2010-02-23 20:48:55 +0100 (Tue, 23 Feb 2010)

Log Message:
-----------
Render Branch: Irradiance Cache

Implementation borrows some code from Pixie though has changed quite
a bit. This is work in progress and has artifacts and hardcoded
parameters still.

I tried irradiance gradients and found them problematic, they seem
to reduce part of the artifacts but for others have no effect, and
can even make things worse. There's a clamping trick that helps a
bit here, but I couldn't get that reliable either.

Currently it is using least squares reconstruction to smooth out the
results, it's too smooth now, still trying to find out the best way
to weight samples without introducing problems, but I'm finding this
much more promising than gradients.

Modified Paths:
--------------
    branches/render25/release/scripts/ui/properties_world.py
    branches/render25/source/blender/makesrna/intern/rna_world.c
    branches/render25/source/blender/render/intern/include/cache.h
    branches/render25/source/blender/render/intern/include/object.h
    branches/render25/source/blender/render/intern/include/part.h
    branches/render25/source/blender/render/intern/include/raytrace.h
    branches/render25/source/blender/render/intern/include/render_types.h
    branches/render25/source/blender/render/intern/include/rendercore.h
    branches/render25/source/blender/render/intern/include/result.h
    branches/render25/source/blender/render/intern/include/shading.h
    branches/render25/source/blender/render/intern/include/zbuf.h
    branches/render25/source/blender/render/intern/source/cache.c
    branches/render25/source/blender/render/intern/source/lamp.c
    branches/render25/source/blender/render/intern/source/material.c
    branches/render25/source/blender/render/intern/source/object.c
    branches/render25/source/blender/render/intern/source/object_strand.c
    branches/render25/source/blender/render/intern/source/path.c
    branches/render25/source/blender/render/intern/source/rayshade.c
    branches/render25/source/blender/render/intern/source/rendercore.c
    branches/render25/source/blender/render/intern/source/shadeinput.c
    branches/render25/source/blender/render/intern/source/shadeoutput.c
    branches/render25/source/blender/render/intern/source/shadowbuf.c
    branches/render25/source/blender/render/intern/source/zbuf.c

Modified: branches/render25/release/scripts/ui/properties_world.py
===================================================================
--- branches/render25/release/scripts/ui/properties_world.py	2010-02-23 19:34:12 UTC (rev 27112)
+++ branches/render25/release/scripts/ui/properties_world.py	2010-02-23 19:48:55 UTC (rev 27113)
@@ -181,6 +181,11 @@
         split.prop(light, "ao_factor", text="Factor")
         split.prop(light, "ao_blend_mode", text="")
 
+        split = layout.split()
+        split.prop(light, "ao_falloff")
+        sub = split.row()
+        sub.active = light.ao_falloff
+        sub.prop(light, "ao_falloff_strength", text="Strength")
 
 class WORLD_PT_environment_lighting(WorldButtonsPanel):
     bl_label = "Environment Lighting"
@@ -234,19 +239,9 @@
 
         split = layout.split()
 
-        col = split.column()
-        col.label(text="Attenuation:")
         if light.gather_method == 'RAYTRACE':
-            col.prop(light, "distance")
-        col.prop(light, "falloff")
-        sub = col.row()
-        sub.active = light.falloff
-        sub.prop(light, "falloff_strength", text="Strength")
-
-        if light.gather_method == 'RAYTRACE':
             col = split.column()
 
-            col.label(text="Sampling:")
             col.prop(light, "sample_method", text="")
 
             sub = col.column()
@@ -256,17 +251,21 @@
                 sub.prop(light, "threshold")
                 sub.prop(light, "adapt_to_speed", slider=True)
 
-            sub.prop(light, "pixel_cache")
-
         if light.gather_method == 'APPROXIMATE':
             col = split.column()
 
-            col.label(text="Sampling:")
             col.prop(light, "passes")
             col.prop(light, "error_tolerance", text="Error")
-            col.prop(light, "pixel_cache")
             col.prop(light, "correction")
 
+        col = split.column()
+
+        col.prop(light, "use_cache")
+
+        if light.gather_method == 'RAYTRACE':
+            col.label(text="Attenuation:")
+            col.prop(light, "distance")
+
 bpy.types.register(WORLD_PT_context_world)
 bpy.types.register(WORLD_PT_preview)
 bpy.types.register(WORLD_PT_world)

Modified: branches/render25/source/blender/makesrna/intern/rna_world.c
===================================================================
--- branches/render25/source/blender/makesrna/intern/rna_world.c	2010-02-23 19:34:12 UTC (rev 27112)
+++ branches/render25/source/blender/makesrna/intern/rna_world.c	2010-02-23 19:48:55 UTC (rev 27113)
@@ -287,7 +287,7 @@
 	RNA_def_property_ui_text(prop, "Distance", "Length of rays, defines how far away other faces give occlusion effect.");
 	RNA_def_property_update(prop, 0, "rna_World_update");
 
-	prop= RNA_def_property(srna, "falloff_strength", PROP_FLOAT, PROP_NONE);
+	prop= RNA_def_property(srna, "ao_falloff_strength", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "aodistfac");
 	RNA_def_property_ui_text(prop, "Strength", "Distance attenuation factor, the higher, the 'shorter' the shadows.");
 	RNA_def_property_update(prop, 0, "rna_World_update");
@@ -317,14 +317,14 @@
 	RNA_def_property_ui_text(prop, "Correction", "Ad-hoc correction for over-occlusion due to the approximation (for Approximate).");
 	RNA_def_property_update(prop, 0, "rna_World_update");
 
-	prop= RNA_def_property(srna, "falloff", PROP_BOOLEAN, PROP_NONE);
+	prop= RNA_def_property(srna, "ao_falloff", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "aomode", WO_AODIST);
 	RNA_def_property_ui_text(prop, "Falloff", "");
 	RNA_def_property_update(prop, 0, "rna_World_update");
 
-	prop= RNA_def_property(srna, "pixel_cache", PROP_BOOLEAN, PROP_NONE);
+	prop= RNA_def_property(srna, "use_cache", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "aomode", WO_AOCACHE);
-	RNA_def_property_ui_text(prop, "Pixel Cache", "Cache AO results in pixels and interpolate over neighbouring pixels for speedup (for Approximate).");
+	RNA_def_property_ui_text(prop, "Cache", "Cache AO results and interpolate over neighbouring pixels for speedup.");
 	RNA_def_property_update(prop, 0, "rna_World_update");
 
 	prop= RNA_def_property(srna, "samples", PROP_INT, PROP_NONE);

Modified: branches/render25/source/blender/render/intern/include/cache.h
===================================================================
--- branches/render25/source/blender/render/intern/include/cache.h	2010-02-23 19:34:12 UTC (rev 27112)
+++ branches/render25/source/blender/render/intern/include/cache.h	2010-02-23 19:48:55 UTC (rev 27113)
@@ -31,6 +31,7 @@
 struct ObjectRen;
 struct Render;
 struct RenderDB;
+struct RenderLayer;
 struct RenderPart;
 struct ShadeInput;
 struct ShadeSample;
@@ -78,5 +79,18 @@
 
 void surface_cache_sample(SurfaceCache *cache, struct ShadeInput *shi);
 
+/* Irradiance Cache */
+
+struct IrrCache;
+typedef struct IrrCache IrrCache;
+
+void irr_cache_create(struct Render *re, struct RenderPart *pa,
+	struct RenderLayer *rl, struct ShadeSample *ssamp);
+void irr_cache_free(struct Render *re, struct RenderPart *pa);
+
+int irr_cache_lookup(struct Render *re, struct ShadeInput *shi,
+	IrrCache *cache, float *ao, float env[3], float indirect[3],
+	float P[3], float dPdu[3], float dPdv[3], float N[3], int do_sample);
+
 #endif /* __RENDER_CACHE_H__ */
 

Modified: branches/render25/source/blender/render/intern/include/object.h
===================================================================
--- branches/render25/source/blender/render/intern/include/object.h	2010-02-23 19:34:12 UTC (rev 27112)
+++ branches/render25/source/blender/render/intern/include/object.h	2010-02-23 19:48:55 UTC (rev 27113)
@@ -48,6 +48,7 @@
 void render_instance_free(struct ObjectInstanceRen *obi);
 
 void render_instances_init(struct RenderDB *rdb);
+void render_instances_bound(struct RenderDB *db, float boundbox[2][3]);
 
 /* Data Layers */
 

Modified: branches/render25/source/blender/render/intern/include/part.h
===================================================================
--- branches/render25/source/blender/render/intern/include/part.h	2010-02-23 19:34:12 UTC (rev 27112)
+++ branches/render25/source/blender/render/intern/include/part.h	2010-02-23 19:48:55 UTC (rev 27113)
@@ -29,10 +29,14 @@
 
 #include "result.h"
 
+struct APixstr;
+struct APixstrand;
+struct PixStr;
+struct rctf;
 struct Render;
 struct RenderPart;
 struct RenderResult;
-struct rctf;
+struct StrandShadeCache;
 
 /* Create/Free */
 
@@ -62,12 +66,18 @@
 	int *rectp;						/* polygon index table */
 	int *rectz;						/* zbuffer */
 	int *rectmask;					/* negative zmask */
-	void **rectdaps;				/* delta acum buffer for pixel structs */
 	int *rectbacko;					/* object table for backside sss */
 	int *rectbackp;					/* polygon index table for backside sss */
 	int *rectbackz;					/* zbuffer for backside sss */
 	void **rectall;					/* buffer for all faces for sss */
 
+	/* rasterization results */
+	struct PixStr **rectdaps;			/* solid */
+	struct APixstr *apixbuf;			/* ztransp */
+	struct APixstrand *apixbufstrand;	/* strand */
+	struct StrandShadeCache *sscache;	/* cache for per control point strand shading */
+	ListBase apsmbase;					/* storage for apixbuf */
+
 	rcti disprect;					/* part coordinates within total picture */
 	int rectx, recty;				/* the size */
 	short crop, ready;				/* crop is amount of pixels we crop, for filter */

Modified: branches/render25/source/blender/render/intern/include/raytrace.h
===================================================================
--- branches/render25/source/blender/render/intern/include/raytrace.h	2010-02-23 19:34:12 UTC (rev 27112)
+++ branches/render25/source/blender/render/intern/include/raytrace.h	2010-02-23 19:48:55 UTC (rev 27113)
@@ -11,6 +11,8 @@
 struct ShadeResult;
 struct World;
 
+#include "result.h"
+
 /* RayTree Create/Free */
 
 void raytree_create(struct Render *re);
@@ -24,11 +26,11 @@
 	struct Render *re, struct ShadeInput *shi, struct LampRen *lar,
 	float from[3], float to[3]);
 
-void ray_trace(struct Render *re, struct ShadeInput *, struct ShadeResult *);
-void ray_ao(struct Render *re, struct ShadeInput *, float *, float *);
-void ray_trace_mirror(struct Render *re, struct ShadeInput *shi, struct ShadeResult *shr);
+void ray_trace_specular(struct Render *re, struct ShadeInput *shi,
+	struct ShadeResult *shr);
 
-void ray_path(struct Render *re, struct ShadeInput *shi);
+void ray_ao_env_indirect(struct Render *re, struct ShadeInput *shi,
+	float *ao, float env[3], float indirect[3], float *Rmean);
 
 #endif /* __RENDER_RAYTRACE_H__ */
 

Modified: branches/render25/source/blender/render/intern/include/render_types.h
===================================================================
--- branches/render25/source/blender/render/intern/include/render_types.h	2010-02-23 19:34:12 UTC (rev 27112)
+++ branches/render25/source/blender/render/intern/include/render_types.h	2010-02-23 19:48:55 UTC (rev 27113)
@@ -43,10 +43,10 @@
 #include "object.h"
 
 struct GHash;
+struct IrrCache;
 struct MemArena;
 struct Object;
 struct ObjectInstanceRen;
-struct PixelCache;
 struct RayFace;
 struct RayObject;
 struct VlakPrimitive;
@@ -108,8 +108,8 @@
 	/* memory pool for quick alloc */
 	struct MemArena *memArena;
 
-	/* pixel cache for AO/env/indirect */
-	struct PixelCache *cache[BLENDER_MAX_THREADS];
+	/* irradiance cache for AO/env/indirect */
+	struct IrrCache *irrcache[BLENDER_MAX_THREADS];
 } RenderDB;
 
 typedef struct RenderSampleData {

Modified: branches/render25/source/blender/render/intern/include/rendercore.h
===================================================================
--- branches/render25/source/blender/render/intern/include/rendercore.h	2010-02-23 19:34:12 UTC (rev 27112)
+++ branches/render25/source/blender/render/intern/include/rendercore.h	2010-02-23 19:48:55 UTC (rev 27113)
@@ -83,5 +83,18 @@
 	void *ps;
 } APixstrMain;
 
+typedef struct PixelRow {
+	int obi;
+	int z;
+	int p;
+	int mask;
+	int segment;
+	float u, v;
+} PixelRow;
+
+/* Rasterization Utilities */
+
+int pixel_row_fill(PixelRow *row, struct Render *re, struct RenderPart *pa, int offs);
+
 #endif /* __RENDERCORE_H__ */
 

Modified: branches/render25/source/blender/render/intern/include/result.h
===================================================================
--- branches/render25/source/blender/render/intern/include/result.h	2010-02-23 19:34:12 UTC (rev 27112)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list