[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29786] branches/render25/source/blender/ render/intern: Render Branch: fixes for shaded halo rendering.
Brecht Van Lommel
brecht at blender.org
Tue Jun 29 12:58:11 CEST 2010
Revision: 29786
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29786
Author: blendix
Date: 2010-06-29 12:58:10 +0200 (Tue, 29 Jun 2010)
Log Message:
-----------
Render Branch: fixes for shaded halo rendering.
Modified Paths:
--------------
branches/render25/source/blender/render/intern/include/shading.h
branches/render25/source/blender/render/intern/source/halo.c
branches/render25/source/blender/render/intern/source/object_halo.c
branches/render25/source/blender/render/intern/source/rayshade.c
branches/render25/source/blender/render/intern/source/rendercore.c
Removed Paths:
-------------
branches/render25/source/blender/render/intern/source/ray_trace.c
Modified: branches/render25/source/blender/render/intern/include/shading.h
===================================================================
--- branches/render25/source/blender/render/intern/include/shading.h 2010-06-29 09:48:11 UTC (rev 29785)
+++ branches/render25/source/blender/render/intern/include/shading.h 2010-06-29 10:58:10 UTC (rev 29786)
@@ -122,7 +122,7 @@
int shadeHaloFloat(struct Render *re, struct HaloRen *har,
float *col, int zz,
float dist, float xn,
- float yn, short flarec);
+ float yn, short flarec, int thread);
#endif /* __RENDER_SHADING_H__ */
Modified: branches/render25/source/blender/render/intern/source/halo.c
===================================================================
--- branches/render25/source/blender/render/intern/source/halo.c 2010-06-29 09:48:11 UTC (rev 29785)
+++ branches/render25/source/blender/render/intern/source/halo.c 2010-06-29 10:58:10 UTC (rev 29786)
@@ -49,7 +49,7 @@
extern float hashvectf[];
-static void render_lighting_halo(Render *re, HaloRen *har, float *colf)
+static void render_lighting_halo(Render *re, HaloRen *har, float *colf, int thread)
{
GroupObject *go;
LampRen *lar;
@@ -69,6 +69,8 @@
copy_v3_v3(shi.geometry.vn, har->no);
shi.geometry.osatex= 0;
shi.shading.lay= -1;
+ shi.shading.thread= thread;
+ shi.shading.samplenr= re->sample.shadowsamplenr[shi.shading.thread]++;
shi.material.mat= har->mat;
zero_v3(inf);
@@ -128,7 +130,7 @@
* @param yn The y coordinate of the pixel relaticve to the center of the halo. given in pixels
*/
int shadeHaloFloat(Render *re, HaloRen *har, float *col, int zz,
- float dist, float xn, float yn, short flarec)
+ float dist, float xn, float yn, short flarec, int thread)
{
/* fill in col */
float t, zn, radist, ringf=0.0f, linef=0.0f, alpha, si, co;
@@ -312,7 +314,7 @@
if(har->mat) {
if(har->mat->mode & MA_HALO_SHADE) {
/* we test for lights because of preview... */
- if(re->db.lights.first) render_lighting_halo(re, har, col);
+ if(re->db.lights.first) render_lighting_halo(re, har, col, thread);
}
/* Next, we do the line and ring factor modifications. */
Modified: branches/render25/source/blender/render/intern/source/object_halo.c
===================================================================
--- branches/render25/source/blender/render/intern/source/object_halo.c 2010-06-29 09:48:11 UTC (rev 29785)
+++ branches/render25/source/blender/render/intern/source/object_halo.c 2010-06-29 10:58:10 UTC (rev 29786)
@@ -703,7 +703,7 @@
dist= xsq+ysq;
if(dist<har->radsq) {
- if(shadeHaloFloat(re, har, colf, 0x7FFFFF, dist, xn, yn, har->flarec))
+ if(shadeHaloFloat(re, har, colf, 0x7FFFFF, dist, xn, yn, har->flarec, 0))
pxf_add_alpha_fac(rtf, colf, har->add);
}
rtf+=4;
Deleted: branches/render25/source/blender/render/intern/source/ray_trace.c
===================================================================
--- branches/render25/source/blender/render/intern/source/ray_trace.c 2010-06-29 09:48:11 UTC (rev 29785)
+++ branches/render25/source/blender/render/intern/source/ray_trace.c 2010-06-29 10:58:10 UTC (rev 29786)
@@ -1,1954 +0,0 @@
-/**
- * $Id$
- *
- * ***** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 1990-1998 NeoGeo BV.
- * All rights reserved.
- *
- * Contributors: 2004/2005 Blender Foundation, full recode
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include <stdio.h>
-#include <math.h>
-#include <string.h>
-#include <stdlib.h>
-#include <float.h>
-#include <assert.h>
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_material_types.h"
-#include "DNA_lamp_types.h"
-
-#include "BKE_global.h"
-#include "BKE_node.h"
-#include "BKE_utildefines.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_jitter.h"
-#include "BLI_math.h"
-#include "BLI_rand.h"
-
-#include "PIL_time.h"
-
-#include "cache.h"
-#include "database.h"
-#include "environment.h"
-#include "lamp.h"
-#include "material.h"
-#include "object.h"
-#include "object_mesh.h"
-#include "object_strand.h"
-#include "pixelfilter.h"
-#include "raycounter.h"
-#include "rayintersection.h"
-#include "rayobject.h"
-#include "raytrace.h"
-#include "render_types.h"
-#include "rendercore.h"
-#include "result.h"
-#include "sampler.h"
-#include "shading.h"
-#include "texture.h"
-#include "volumetric.h"
-
-
-#define RAY_TRA 1
-#define RAY_TRAFLIP 2
-
-#define DEPTH_SHADOW_TRA 10
-
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-/* defined in pipeline.c, is hardcopy of active dynamic allocated Render */
-/* only to be used here in this file, it's for speed */
-extern struct Render R;
-/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
-static int test_break(void *data)
-{
- Render *re = (Render*)data;
- return re->cb.test_break(re->cb.tbh);
-}
-
-static int re_object_raycast(RayObject *rayob, Isect *isec, ShadeInput *shi)
-{
- ObjectRen *obr= shi->primitive.obr;
- float *vn= shi->geometry.vn, nor[3];
- float dist= 1.0f, mindist= FLT_MAX, offset;
- int a, hit= 0;
-
- if(!(obr->flag & R_HIGHRES))
- return RE_rayobject_raycast(rayob, isec);
-
- offset= obr->ob->displacebound;
-
- for(a=0; a<2; a++) {
- Isect subisec;
- float direction= (a == 0)? -1.0f: 1.0f;
-
- memset(&subisec, 0, sizeof(subisec));
- subisec.skip = RE_SKIP_VLR_RENDER_CHECK;
- subisec.mode = RE_RAY_MIRROR;
- subisec.lay = isec->lay;
-
- copy_v3_v3(subisec.start, isec->start);
- mul_v3_v3fl(subisec.dir, isec->dir, direction*offset);
- subisec.dist = normalize_v3(subisec.dir);
-
- if(!RE_rayobject_raycast(rayob, &subisec))
- continue;
-
- render_vlak_get_normal(subisec.hit.ob, subisec.hit.face, nor, (subisec.isect == 2));
- if(dot_v3v3(nor, vn) < 0.0f) /* face normal is flipped */
- continue;
-
- if(subisec.dist < mindist) {
- mindist= subisec.dist;
-
- isec->orig.ob= subisec.hit.ob;
- isec->orig.face= subisec.hit.face;
- dist= direction*subisec.dist*offset;
-
- hit= 1;
- }
- }
-
- if(hit)
- madd_v3_v3fl(isec->start, isec->dir, dist);
-
- return RE_rayobject_raycast(rayob, isec);
-}
-
-RayObject* RE_rayobject_create(Render *re, int type, int size)
-{
- RayObject * res = NULL;
-
- if(type == R_RAYSTRUCTURE_AUTO)
- {
- //TODO
- //if(detect_simd())
-#ifdef __SSE__
- type = R_RAYSTRUCTURE_SIMD_SVBVH;
-#else
- type = R_RAYSTRUCTURE_VBVH;
-#endif
- }
-
-#ifndef __SSE__
- if(type == R_RAYSTRUCTURE_SIMD_SVBVH || type == R_RAYSTRUCTURE_SIMD_QBVH)
- {
- puts("Warning: Using VBVH (SSE was disabled at compile time)");
- type = R_RAYSTRUCTURE_VBVH;
- }
-#endif
-
-
- if(type == R_RAYSTRUCTURE_OCTREE) //TODO dynamic ocres
- res = RE_rayobject_octree_create(re->params.r.ocres, size);
- else if(type == R_RAYSTRUCTURE_BLIBVH)
- res = RE_rayobject_blibvh_create(size);
- else if(type == R_RAYSTRUCTURE_VBVH)
- res = RE_rayobject_vbvh_create(size);
- else if(type == R_RAYSTRUCTURE_SIMD_SVBVH)
- res = RE_rayobject_svbvh_create(size);
- else if(type == R_RAYSTRUCTURE_SIMD_QBVH)
- res = RE_rayobject_qbvh_create(size);
- else
- res = RE_rayobject_vbvh_create(size); //Fallback
-
-
- if(res)
- RE_rayobject_set_control(res, re, test_break);
-
- return res;
-}
-
-#ifdef RE_RAYCOUNTER
-RayCounter re_rc_counter[BLENDER_MAX_THREADS];
-#endif
-
-
-void raytree_free(RenderDB *rdb)
-{
- ObjectInstanceRen *obi;
-
- if(rdb->raytree)
- {
- RE_rayobject_free(rdb->raytree);
- rdb->raytree = NULL;
- }
- if(rdb->rayfaces)
- {
- MEM_freeN(rdb->rayfaces);
- rdb->rayfaces = NULL;
- }
- if(rdb->rayprimitives)
- {
- MEM_freeN(rdb->rayprimitives);
- rdb->rayprimitives = NULL;
- }
-
- for(obi=rdb->instancetable.first; obi; obi=obi->next)
- {
- ObjectRen *obr = obi->obr->lowres;
- if(obr->raytree)
- {
- RE_rayobject_free(obr->raytree);
- obr->raytree = NULL;
- }
- if(obr->rayfaces)
- {
- MEM_freeN(obr->rayfaces);
- obr->rayfaces = NULL;
- }
- if(obi->raytree)
- {
- RE_rayobject_free(obi->raytree);
- obi->raytree = NULL;
- }
- }
-
-#ifdef RE_RAYCOUNTER
- {
- RayCounter sum;
- int i;
- memset( &sum, 0, sizeof(sum) );
- for(i=0; i<BLENDER_MAX_THREADS; i++)
- RE_RC_MERGE(&sum, re_rc_counter+i);
- RE_RC_INFO(&sum);
- }
-#endif
-}
-
-static int is_raytraceable_vlr(Render *re, VlakRen *vlr)
-{
- /* note: volumetric must be tracable, wire must not */
- if((re->params.flag & R_BAKE_TRACE) || (vlr->flag & R_TRACEBLE) || (vlr->mat->material_type == MA_TYPE_VOLUME))
- if(vlr->mat->material_type != MA_TYPE_WIRE)
- return 1;
- return 0;
-}
-
-static int is_raytraceable(Render *re, ObjectInstanceRen *obi)
-{
- int v;
- ObjectRen *obr = obi->obr->lowres;
-
- if(re->db.excludeob && obr->ob == re->db.excludeob)
- return 0;
-
- for(v=0;v<obr->totvlak;v++)
- {
- VlakRen *vlr = obr->vlaknodes[v>>8].vlak + (v&255);
- if(is_raytraceable_vlr(re, vlr))
- return 1;
- }
- return 0;
-}
-
-
-RayObject* raytree_create_object(Render *re, ObjectInstanceRen *obi)
-{
- //TODO
- // out-of-memory safeproof
- // break render
- // update render stats
- ObjectRen *obr = obi->obr->lowres;
-
- if(obr->raytree == NULL)
- {
- RayObject *raytree;
- RayFace *face = NULL;
- VlakPrimitive *vlakprimitive = NULL;
- int v;
-
- //Count faces
- int faces = 0;
- for(v=0;v<obr->totvlak;v++)
- {
- VlakRen *vlr = obr->vlaknodes[v>>8].vlak + (v&255);
- if(is_raytraceable_vlr(re, vlr))
- faces++;
- }
- assert( faces > 0 );
-
- //Create Ray cast accelaration structure
- raytree = RE_rayobject_create( re, re->params.r.raytrace_structure, faces );
- if(!(re->params.r.raytrace_options & R_RAYTRACE_USE_LOCAL_COORDS))
- vlakprimitive = obr->rayprimitives = (VlakPrimitive*)MEM_callocN(faces*sizeof(VlakPrimitive), "ObjectRen primitives");
- else
- face = obr->rayfaces = (RayFace*)MEM_callocN(faces*sizeof(RayFace), "ObjectRen faces");
-
- obr->rayobi = obi;
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list