[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12298] branches/qdune/blender/extern/ qdune: Added more filters for Blender compatibility.

Alfredo de Greef eeshlo at yahoo.com
Fri Oct 19 05:07:29 CEST 2007


Revision: 12298
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12298
Author:   eeshlo
Date:     2007-10-19 05:07:28 +0200 (Fri, 19 Oct 2007)

Log Message:
-----------
Added more filters for Blender compatibility.

Modified Paths:
--------------
    branches/qdune/blender/extern/qdune/framebuffer/FrameBuffer.cpp
    branches/qdune/blender/extern/qdune/hider/ZbufferHider.cpp
    branches/qdune/blender/extern/qdune/ribparse/ri.cpp
    branches/qdune/blender/extern/qdune/ribparse/ri.h

Modified: branches/qdune/blender/extern/qdune/framebuffer/FrameBuffer.cpp
===================================================================
--- branches/qdune/blender/extern/qdune/framebuffer/FrameBuffer.cpp	2007-10-18 23:58:13 UTC (rev 12297)
+++ branches/qdune/blender/extern/qdune/framebuffer/FrameBuffer.cpp	2007-10-19 03:07:28 UTC (rev 12298)
@@ -340,6 +340,8 @@
 
 void FrameBuffer::finalize()
 {
+	// nothing to do if rendering from blender
+	if (type == TP_BLENDER) return;
 #ifdef WITH_CIMG
 	if (fbdisplay_img) {
 		// draw final scanline block too

Modified: branches/qdune/blender/extern/qdune/hider/ZbufferHider.cpp
===================================================================
--- branches/qdune/blender/extern/qdune/hider/ZbufferHider.cpp	2007-10-18 23:58:13 UTC (rev 12297)
+++ branches/qdune/blender/extern/qdune/hider/ZbufferHider.cpp	2007-10-19 03:07:28 UTC (rev 12298)
@@ -79,6 +79,12 @@
 		pixelfilter = RiSepCatmullRomFilter;
 	else if (opt.pixelFilter == RiSincFilter)
 		pixelfilter = RiSepSincFilter;
+	else if (opt.pixelFilter == RiQuadFilter)
+		pixelfilter = RiSepQuadFilter;
+	else if (opt.pixelFilter == RiCubicFilter)
+		pixelfilter = RiSepCubicFilter;
+	else if (opt.pixelFilter == RiMitchellFilter)
+		pixelfilter = RiSepMitchellFilter;
 	else
 		pixelfilter = RiSepGaussianFilter;
 
@@ -90,7 +96,7 @@
 	pixelfilter = RiSepBoxFilter;
 	xwidth = ywidth = 1;
 #endif
-	
+
 	xsamples = MAX2(1, (int)opt.xSamples);
 	ysamples = MAX2(1, (int)opt.ySamples);
 	zbuf = NULL;
@@ -108,6 +114,9 @@
 	// if only z channel set, then filtering can be skipped
 	only_z = (opt.displayMode == Options::DM_Z);
 
+	cout << "Current filterwidth: " << xwidth << ", " << ywidth << endl;
+	cout << "Current samples: " << xsamples << ", " << ysamples << endl;
+
 	// the amount of extra samples needed for filtering
 	// one pixel covers one full set of samples in each direction,
 	// filterwidth is in pixels, so the number of samples covered by the filter is width*samples,

Modified: branches/qdune/blender/extern/qdune/ribparse/ri.cpp
===================================================================
--- branches/qdune/blender/extern/qdune/ribparse/ri.cpp	2007-10-18 23:58:13 UTC (rev 12297)
+++ branches/qdune/blender/extern/qdune/ribparse/ri.cpp	2007-10-19 03:07:28 UTC (rev 12298)
@@ -315,6 +315,9 @@
 //------------------------------------------------------------------------------
 // Pixel Filters
 
+// original code, not used anymore
+// now implemented using the separable versions of the filters, see below
+/*
 RtFloat RiGaussianFilter(RtFloat x, RtFloat y, RtFloat xwidth, RtFloat ywidth)
 {
 	x *= (RtFloat)2 / xwidth;
@@ -360,6 +363,7 @@
 		t = sinf(y)/y;
 	return s*t;
 }
+*/
 
 //------------------------------------------------------------------------------
 // separable versions of all of the above (though not necessarly exactly the same...)
@@ -397,8 +401,86 @@
 	return (sinf(v) / v);
 }
 
+// some extra ones for Blender compatibility
+RtFloat RiSepQuadFilter(RtFloat v, RtFloat width)
+{
+	if ((v = ABS(v)) < 0.5f) return 0.75f - v*v;
+	if (v < 1.5f) { v -= 1.5f;  return 0.5f*v*v; }
+	return 0.f;
+}
+
+RtFloat RiSepCubicFilter(RtFloat v, RtFloat width)
+{
+	const float OSX = 1.f/6.f;
+	if ((v = ABS(v)) < 0.f) return 4.f + v*v*(-6.f - 3.f*v)*OSX;
+	if (v < 1.f) return 4.f + v*v*(v*3.f - 6.f)*OSX;
+	if (v < 2.f) { v = 2.f - v;  return v*v*v*OSX; }
+	return 0.f;
+}
+
+RtFloat RiSepMitchellFilter(RtFloat v, RtFloat width)
+{
+	const float OSX = 1.f/6.f;
+	const float OTH = 1.f/3.f;
+	const float v2 = v*v;
+	v = ABS(v);
+	if (v < 1.f)
+		return (((12.f - 9.f*OTH - 6.f*OTH)*v*v2)
+	       +  ((-18.f + 12.f*OTH + 6.f*OTH)*v2)
+	       +  (6.f - 2.f*OTH))*OSX;
+	else if (v < 2.f)
+		return (((-OTH - 6.f*OTH)*v*v2)
+		      + ((6.f*OTH + 30.f*OTH)*v2)
+		      + ((-12.f*OTH - 48.f*OTH)*v)
+		      + (8.f*OTH + 24.f*OTH))*OSX;
+	return 0.f;
+}
+
 //------------------------------------------------------------------------------
+// The original Ri filter functions implemented using the above seperable funcs
 
+RtFloat RiGaussianFilter(RtFloat x, RtFloat y, RtFloat xwidth, RtFloat ywidth)
+{
+	return RiSepGaussianFilter(x, xwidth)*RiSepGaussianFilter(y, ywidth);
+}
+
+RtFloat RiBoxFilter(RtFloat x, RtFloat y, RtFloat xwidth, RtFloat ywidth)
+{
+	return (RtFloat)1;
+}
+
+RtFloat RiTriangleFilter(RtFloat x, RtFloat y, RtFloat xwidth, RtFloat ywidth)
+{
+	return RiSepTriangleFilter(x, xwidth)*RiSepTriangleFilter(y, ywidth);
+}
+
+RtFloat RiCatmullRomFilter(RtFloat x, RtFloat y, RtFloat xwidth, RtFloat ywidth)
+{
+	return RiSepCatmullRomFilter(x, xwidth)*RiSepCatmullRomFilter(y, ywidth);
+}
+
+RtFloat RiSincFilter(RtFloat x, RtFloat y, RtFloat xwidth, RtFloat ywidth)
+{
+	return RiSepSincFilter(x, xwidth)*RiSepSincFilter(y, ywidth);
+}
+
+RtFloat RiQuadFilter(RtFloat x, RtFloat y, RtFloat xwidth, RtFloat ywidth)
+{
+	return RiSepQuadFilter(x, xwidth)*RiSepQuadFilter(y, ywidth);
+}
+
+RtFloat RiCubicFilter(RtFloat x, RtFloat y, RtFloat xwidth, RtFloat ywidth)
+{
+	return RiSepCubicFilter(x, xwidth)*RiSepCubicFilter(y, ywidth);
+}
+
+RtFloat RiMitchellFilter(RtFloat x, RtFloat y, RtFloat xwidth, RtFloat ywidth)
+{
+	return RiSepMitchellFilter(x, xwidth)*RiSepMitchellFilter(y, ywidth);
+}
+
+//------------------------------------------------------------------------------
+
 RtToken RiDeclare(const char* name, const char* declaration)
 {
 	if (!mbCheck()) return NULL;

Modified: branches/qdune/blender/extern/qdune/ribparse/ri.h
===================================================================
--- branches/qdune/blender/extern/qdune/ribparse/ri.h	2007-10-18 23:58:13 UTC (rev 12297)
+++ branches/qdune/blender/extern/qdune/ribparse/ri.h	2007-10-19 03:07:28 UTC (rev 12298)
@@ -108,12 +108,19 @@
 extern RtFloat RiTriangleFilter(RtFloat x, RtFloat y, RtFloat xwidth, RtFloat ywidth);
 extern RtFloat RiCatmullRomFilter(RtFloat x, RtFloat y, RtFloat xwidth, RtFloat ywidth);
 extern RtFloat RiSincFilter(RtFloat x, RtFloat y, RtFloat xwidth, RtFloat ywidth);
+/* extra filters for Blender compatibility */
+extern RtFloat RiQuadFilter(RtFloat x, RtFloat y, RtFloat xwidth, RtFloat ywidth);
+extern RtFloat RiCubicFilter(RtFloat x, RtFloat y, RtFloat xwidth, RtFloat ywidth);
+extern RtFloat RiMitchellFilter(RtFloat x, RtFloat y, RtFloat xwidth, RtFloat ywidth);
 /* separable versions of all of the above */
 extern RtFloat RiSepGaussianFilter(RtFloat v, RtFloat width);
 extern RtFloat RiSepBoxFilter(RtFloat v, RtFloat width);
 extern RtFloat RiSepTriangleFilter(RtFloat v, RtFloat width);
 extern RtFloat RiSepCatmullRomFilter(RtFloat v, RtFloat width);
 extern RtFloat RiSepSincFilter(RtFloat v, RtFloat width);
+extern RtFloat RiSepQuadFilter(RtFloat v, RtFloat width);
+extern RtFloat RiSepCubicFilter(RtFloat v, RtFloat width);
+extern RtFloat RiSepMitchellFilter(RtFloat v, RtFloat width);
 
 /* Graphics State */
 extern RtVoid RiBegin(RtToken name);





More information about the Bf-blender-cvs mailing list