[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13582] trunk/blender/source: SCA_ISencor: :Evaluate in Python, patched by Benoit Bolsee

Hamed Zaghaghi hamed.zaghaghi at gmail.com
Tue Feb 5 21:40:06 CET 2008


Revision: 13582
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13582
Author:   zaghaghi
Date:     2008-02-05 21:40:06 +0100 (Tue, 05 Feb 2008)

Log Message:
-----------
SCA_ISencor::Evaluate in Python, patched by Benoit Bolsee

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_arithb.h
    trunk/blender/source/blender/blenlib/intern/arithb.c
    trunk/blender/source/blender/makesdna/DNA_lamp_types.h
    trunk/blender/source/blender/render/intern/include/pixelshading.h
    trunk/blender/source/blender/render/intern/include/render_types.h
    trunk/blender/source/blender/render/intern/source/convertblender.c
    trunk/blender/source/blender/render/intern/source/pixelshading.c
    trunk/blender/source/blender/render/intern/source/rendercore.c
    trunk/blender/source/blender/src/buttons_shading.c
    trunk/blender/source/gameengine/GameLogic/SCA_ISensor.cpp
    trunk/blender/source/gameengine/GameLogic/SCA_ISensor.h

Added Paths:
-----------
    trunk/blender/source/blender/render/intern/include/spectrum.h
    trunk/blender/source/blender/render/intern/include/spectrum_constants.h
    trunk/blender/source/blender/render/intern/include/sunsky.h
    trunk/blender/source/blender/render/intern/source/spectrum.c
    trunk/blender/source/blender/render/intern/source/sunsky.c

Modified: trunk/blender/source/blender/blenlib/BLI_arithb.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_arithb.h	2008-02-05 19:49:42 UTC (rev 13581)
+++ trunk/blender/source/blender/blenlib/BLI_arithb.h	2008-02-05 20:40:06 UTC (rev 13582)
@@ -319,6 +319,9 @@
 void ycc_to_rgb(float y, float cb, float cr, float *lr, float *lg, float *lb);
 void rgb_to_ycc(float r, float g, float b, float *ly, float *lcb, float *lcr);
 void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv);
+void xyz_to_rgb(float x, float y, float z, float *r, float *g, float *b);
+int constrain_rgb(float *r, float *g, float *b);
+void gamma_correct_rgb(float *r, float *g, float *b);
 unsigned int hsv_to_cpack(float h, float s, float v);
 unsigned int rgb_to_cpack(float r, float g, float b);
 void cpack_to_rgb(unsigned int col, float *r, float *g, float *b);

Modified: trunk/blender/source/blender/blenlib/intern/arithb.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/arithb.c	2008-02-05 19:49:42 UTC (rev 13581)
+++ trunk/blender/source/blender/blenlib/intern/arithb.c	2008-02-05 20:40:06 UTC (rev 13582)
@@ -3354,7 +3354,67 @@
 	*lv = v;
 }
 
+/*http://brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
+ * SMPTE-C XYZ to RGB matrix*/
+void xyz_to_rgb(float xc, float yc, float zc, float *r, float *g, float *b)
+{
+	*r = (3.50570	* xc) + (-1.73964	* yc) + (-0.544011	* zc);
+	*g = (-1.06906	* xc) + (1.97781	* yc) + (0.0351720	* zc);
+	*b = (0.0563117	* xc) + (-0.196994	* yc) + (1.05005	* zc);
+}
 
+/*If the requested RGB shade contains a negative weight for
+  one of the primaries, it lies outside the colour gamut 
+  accessible from the given triple of primaries.  Desaturate
+  it by adding white, equal quantities of R, G, and B, enough
+  to make RGB all positive.  The function returns 1 if the
+  components were modified, zero otherwise.*/
+int constrain_rgb(float *r, float *g, float *b)
+{
+	float w;
+
+    /* Amount of white needed is w = - min(0, *r, *g, *b) */
+    
+    w = (0 < *r) ? 0 : *r;
+    w = (w < *g) ? w : *g;
+    w = (w < *b) ? w : *b;
+    w = -w;
+
+    /* Add just enough white to make r, g, b all positive. */
+    
+    if (w > 0) {
+        *r += w;  *g += w; *b += w;
+        return 1;                     /* Colour modified to fit RGB gamut */
+    }
+
+    return 0;                         /* Colour within RGB gamut */
+}
+
+/*Transform linear RGB values to nonlinear RGB values. Rec.
+  709 is ITU-R Recommendation BT. 709 (1990) ``Basic
+  Parameter Values for the HDTV Standard for the Studio and
+  for International Programme Exchange'', formerly CCIR Rec.
+  709.*/
+void gamma_correct(float *c)
+{
+	/* Rec. 709 gamma correction. */
+	float cc = 0.018;
+	
+	if (*c < cc) {
+	    *c *= ((1.099 * pow(cc, 0.45)) - 0.099) / cc;
+	} else {
+	    *c = (1.099 * pow(*c, 0.45)) - 0.099;
+	}
+}
+
+void gamma_correct_rgb(float *r, float *g, float *b)
+{
+    gamma_correct(r);
+    gamma_correct(g);
+    gamma_correct(b);
+}
+
+
 /* we define a 'cpack' here as a (3 byte color code) number that can be expressed like 0xFFAA66 or so.
    for that reason it is sensitive for endianness... with this function it works correctly
 */

Modified: trunk/blender/source/blender/makesdna/DNA_lamp_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_lamp_types.h	2008-02-05 19:49:42 UTC (rev 13581)
+++ trunk/blender/source/blender/makesdna/DNA_lamp_types.h	2008-02-05 20:40:06 UTC (rev 13582)
@@ -79,6 +79,20 @@
 	/* texact is for buttons */
 	short texact, shadhalostep;
 	
+	/* atmosphere */
+	short sun_effect_type;
+	short atm_pad[3];
+    float horizon_brightness;
+    float spread;
+    float sun_brightness;
+    float sun_size;
+    float backscattered_light;
+	float atm_turbidity;
+    float atm_inscattering_factor;
+    float atm_extinction_factor;
+    float atm_distance_factor;
+    float atm_distance_over_sky;
+    
 	/* yafray: photonlight params */
 	int YF_numphotons, YF_numsearch;
 	short YF_phdepth, YF_useqmc, YF_bufsize, YF_pad;
@@ -126,6 +140,11 @@
 /* Since it is used with LOCAL lamp, can't use LA_SHAD */
 #define LA_YF_SOFT		16384
 
+/* sun effect type*/
+#define LA_SUN_EFFECT_SKY			1
+#define LA_SUN_EFFECT_AP			2
+#define LA_SUN_EFFECT_AP_OVER_SKY	4
+
 /* falloff_type */
 #define LA_FALLOFF_CONSTANT		0
 #define LA_FALLOFF_INVLINEAR		1

Modified: trunk/blender/source/blender/render/intern/include/pixelshading.h
===================================================================
--- trunk/blender/source/blender/render/intern/include/pixelshading.h	2008-02-05 19:49:42 UTC (rev 13581)
+++ trunk/blender/source/blender/render/intern/include/pixelshading.h	2008-02-05 20:40:06 UTC (rev 13582)
@@ -55,6 +55,7 @@
  */
 void shadeSkyPixel(float *collector, float fx, float fy);
 void shadeSkyView(float *colf, float *rco, float *view, float *dxyview);
+void shadeAtmPixel(struct SunSky *sunsky, float *collector, float fx, float fy, float intensity, float distance);
 
 /* ------------------------------------------------------------------------- */
 

Modified: trunk/blender/source/blender/render/intern/include/render_types.h
===================================================================
--- trunk/blender/source/blender/render/intern/include/render_types.h	2008-02-05 19:49:42 UTC (rev 13581)
+++ trunk/blender/source/blender/render/intern/include/render_types.h	2008-02-05 20:40:06 UTC (rev 13582)
@@ -43,6 +43,8 @@
 #include "RE_pipeline.h"
 #include "RE_shader_ext.h"	/* TexResult, ShadeResult, ShadeInput */
 
+#include "sunsky.h"
+
 struct Object;
 struct MemArena;
 struct VertTableNode;
@@ -448,6 +450,8 @@
 	float area_size, area_sizey, area_sizez;
 	float adapt_thresh;
 
+	/* atmosphere */
+	struct SunSky *sunsky;
 	struct ShadBuf *shb;
 	float *jitter;
 	QMCSampler *qsa;

Added: trunk/blender/source/blender/render/intern/include/spectrum.h
===================================================================
--- trunk/blender/source/blender/render/intern/include/spectrum.h	                        (rev 0)
+++ trunk/blender/source/blender/render/intern/include/spectrum.h	2008-02-05 20:40:06 UTC (rev 13582)
@@ -0,0 +1,47 @@
+/**
+ * 
+ * ***** 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * Contributor(s): 
+ *
+ * ***** END GPL LICENSE BLOCK *****/
+
+#ifndef SPECTRUM_H_
+#define SPECTRUM_H_
+
+#define SPECTRUM_MAX_COMPONENTS     100
+#define SPECTRUM_START              350.0
+#define SPECTRUM_END                800.0
+
+float GetOzoneSample(float lambda);
+float GetWaterSample(float lambda);
+float GetGasSample(float lambda);
+float GetSolarSample(float lambda);
+
+float GetSampleFromIrregularSpectralCurve(float *amplitudes, float *wavelengths, int divisions, float lambda);
+float GetSampleFromRegularSpectralCurve(float *amplitudes, int waveStart, int waveEnd, int divisions, float lambda);
+float GetSampleFromChromaticitySpectrum(float x, float y, float lambda);
+void GetSpectrumDataFromRegularSpectralCurve(float *amplitudes, int waveStart, int waveEnd, int divisions,
+												float spectrumData[SPECTRUM_MAX_COMPONENTS]);
+void GetSpectrumDataFromChromaticitySpectrum(float x, float y, float spectrumData[SPECTRUM_MAX_COMPONENTS]);
+void ConvertSpectrumDataToCIEXYZ(float spectrumData[SPECTRUM_MAX_COMPONENTS], float color[3]);
+
+float mix(float a, float b, float s);
+#endif /*SPECTRUM_H_*/

Added: trunk/blender/source/blender/render/intern/include/spectrum_constants.h
===================================================================
--- trunk/blender/source/blender/render/intern/include/spectrum_constants.h	                        (rev 0)
+++ trunk/blender/source/blender/render/intern/include/spectrum_constants.h	2008-02-05 20:40:06 UTC (rev 13582)
@@ -0,0 +1,237 @@
+/**
+ * 
+ * ***** 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * Contributor(s): 
+ *
+ * ***** END GPL LICENSE BLOCK *****/
+
+#ifndef SPECTRUM_CONSTANTS_H_
+#define SPECTRUM_CONSTANTS_H_
+
+// k_o Spectrum table from pg 127, MI.
+static float k_oWavelengths[64] =
+{
+    300, 305, 310, 315, 320,
+    325, 330, 335, 340, 345,
+    350, 355,
+
+    445, 450, 455, 460, 465,
+    470, 475, 480, 485, 490,
+    495,
+
+    500, 505, 510, 515, 520,
+    525, 530, 535, 540, 545,
+    550, 555, 560, 565, 570,
+    575, 580, 585, 590, 595,
+
+    600, 605, 610, 620, 630,
+    640, 650, 660, 670, 680,
+    690,
+
+    700, 710, 720, 730, 740,
+    750, 760, 770, 780, 790,
+};
+
+static float k_oAmplitudes[65] = {
+    10.0, 4.8, 2.7, 1.35, .8, .380, .160, .075, .04, .019, .007, .0,
+
+    .003, .003, .004, .006, .008, .009, .012, .014, .017, .021, .025,
+
+    .03, .035, .04, .045, .048, .057, .063, .07, .075, .08, .085, .095,

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list