[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60090] branches/soc-2013-dingto/intern/ cycles/kernel: Volume:

Thomas Dinges blender at dingto.org
Fri Sep 13 00:29:20 CEST 2013


Revision: 60090
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60090
Author:   dingto
Date:     2013-09-12 22:29:20 +0000 (Thu, 12 Sep 2013)
Log Message:
-----------
Volume:
* Cleanup function headers. 
* Remove some unused variables, also remove another redundant "bounce" variable in shadow_blocked_new(). 

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

Modified: branches/soc-2013-dingto/intern/cycles/kernel/kernel_path.h
===================================================================
--- branches/soc-2013-dingto/intern/cycles/kernel/kernel_path.h	2013-09-12 22:08:56 UTC (rev 60089)
+++ branches/soc-2013-dingto/intern/cycles/kernel/kernel_path.h	2013-09-12 22:29:20 UTC (rev 60090)
@@ -679,7 +679,7 @@
 
 #ifdef __VOLUME__
 				float tmp_volume_pdf;
-				if(!shadow_blocked_new(kg, rng, rng_offset, &rng_congruential, sample, &state, &light_ray, &ao_shadow, media_volume_shader, &tmp_volume_pdf, state.bounce))
+				if(!shadow_blocked_new(kg, rng, rng_offset, &rng_congruential, sample, &state, &light_ray, &ao_shadow, media_volume_shader, &tmp_volume_pdf))
 #else
 				if(!shadow_blocked(kg, &state, &light_ray, &ao_shadow))
 #endif
@@ -769,7 +769,7 @@
 					float3 shadow;
 #ifdef __VOLUME__
 					float tmp_volume_pdf;
-					if(!shadow_blocked_new(kg, rng, rng_offset, &rng_congruential, sample, &state, &light_ray, &shadow, media_volume_shader, &tmp_volume_pdf, state.bounce)) {
+					if(!shadow_blocked_new(kg, rng, rng_offset, &rng_congruential, sample, &state, &light_ray, &shadow, media_volume_shader, &tmp_volume_pdf)) {
 #else
 					if(!shadow_blocked(kg, &state, &light_ray, &shadow)) {
 #endif

Modified: branches/soc-2013-dingto/intern/cycles/kernel/kernel_volume.h
===================================================================
--- branches/soc-2013-dingto/intern/cycles/kernel/kernel_volume.h	2013-09-12 22:08:56 UTC (rev 60089)
+++ branches/soc-2013-dingto/intern/cycles/kernel/kernel_volume.h	2013-09-12 22:29:20 UTC (rev 60090)
@@ -75,8 +75,7 @@
 	// NOTE: color must be constant as well, because we use it to modify extinction.
 
 	float3 res_sigma = make_float3(1.0f, 1.0f, 1.0f);
-	if((sd->flag & SD_HAS_VOLUME) != 0) // check for empty volume shader
-	{
+	if((sd->flag & SD_HAS_VOLUME) != 0) { // check for empty volume shader
 		// base sigma
 		float base_sigma = get_sigma_sample(kg, sd, trandp, path_flag, ray.P/* + ray.D * start*/);
 
@@ -153,8 +152,7 @@
 	int path_flag = PATH_RAY_SHADOW; // why ?
 
 	float3 res_sigma = make_float3(1.0f, 1.0f, 1.0f);
-	if((tsd.flag & SD_HAS_VOLUME) != 0) // check for empty volume shader
-	{
+	if((tsd.flag & SD_HAS_VOLUME) != 0) { // check for empty volume shader
 		// base sigma
 		float base_sigma = get_sigma_sample(kg, &tsd, trandp, path_flag, ray.P/* + ray.D * start*/);
 
@@ -228,8 +226,9 @@
 
 /*used */
 
-/*volumetric sampling */
-__device int kernel_volumetric_woodcock_sampler( KernelGlobals *kg, RNG* rng, int rng_offset, RNG* rng_congruential, int pass, float randv, ShaderData *sd, Ray ray, int path_flag, float end, float* new_t, float* pdf)
+/* Volumetric sampling */
+__device int kernel_volumetric_woodcock_sampler(KernelGlobals *kg, RNG *rng, int rng_offset, RNG *rng_congruential,
+	int pass, float randv, ShaderData *sd, Ray ray, int path_flag, float end, float *new_t, float *pdf)
 {
 	/* google "woodcock delta tracker" algorithm, must be preprocessed to guess max density in volume, better keep it as close to density as possible or we got lot of tiny steps and spend milenniums marching single volume ray segment. 0.95 is good default. */
 	float magic_eps = 1e-4f;
@@ -248,11 +247,8 @@
 	float sigma_factor = 1.0f;
 	*pdf = 1.0f;
 
-	if(end < magic_eps)
+	if((end < magic_eps) || (max_sigma_t == 0))
 		return 0;
-	
-	if(max_sigma_t == 0)
-		return 0;
 
 	do {
 		float r = my_rand_congruential();
@@ -264,8 +260,7 @@
 		t < (end - magic_eps) &&
 		i++ < max_iter);
 
-	if (t < (end - magic_eps) && i <= max_iter)
-	{
+	if (t < (end - magic_eps) && i <= max_iter) {
 		*new_t = t;
 	    sd->P = ray.P + ray.D * t;
 		// *pdf *= sigma_factor; // fixme: is it necessary ?
@@ -293,7 +288,8 @@
 
 	return 0;
 }
-__device int kernel_volumetric_woodcock_sampler2( KernelGlobals *kg, RNG* rng, int rng_offset, RNG* rng_congruential, int pass, float randv, ShaderData *sd, Ray ray, int path_flag, float end, float* new_t, float* pdf)
+__device int kernel_volumetric_woodcock_sampler2(KernelGlobals *kg, RNG *rng, int rng_offset, RNG *rng_congruential, int pass,
+	float randv, ShaderData *sd, Ray ray, int path_flag, float end, float *new_t, float *pdf)
 {
 	/* google "woodcock delta tracker" algorithm, must be preprocessed to guess max density in volume, better keep it as close to density as possible or we got lot of tiny steps and spend milenniums marching single volume ray segment. 0.95 is good default. */
 	float magic_eps = 1e-4f;
@@ -356,13 +352,9 @@
 
 	return 0;
 }
-__device int kernel_volumetric_marching_sampler( KernelGlobals *kg, RNG* rng, int rng_offset, RNG* rng_congruential, int pass, float randv, ShaderData *sd, Ray ray, int path_flag, float end, float* new_t, float* pdf)
-{
-	float distance_magic_eps = 1e-4f;
-	float sigma_magic_eps = 1e-15f;
-	float rand_magic_eps = 0.00001f;
-	float distance_eps = 1.0f - distance_magic_eps; // ensure we never check particle behind/at surface to stop light leaks, so decrease distance a bit
-	
+__device int kernel_volumetric_marching_sampler(KernelGlobals *kg, RNG *rng, int rng_offset, RNG *rng_congruential, int pass,
+	float randv, ShaderData *sd, Ray ray, int path_flag, float end, float *new_t, float *pdf)
+{	
 	int max_steps = kernel_data.integrator.volume_max_iterations;
 	//float step = end != FLT_MAX ? end / max_steps : kernel_data.integrator.volume_cell_step;
 	float step = kernel_data.integrator.volume_cell_step;
@@ -403,11 +395,10 @@
 	return 1;
 }
 
-__device int kernel_volumetric_marching_sampler2( KernelGlobals *kg, RNG* rng, int rng_offset, RNG* rng_congruential, int pass, float randv, ShaderData *sd, Ray ray, int path_flag, float end, float* new_t, float* pdf)
+__device int kernel_volumetric_marching_sampler2(KernelGlobals *kg, RNG *rng, int rng_offset, RNG *rng_congruential,
+	int pass, float randv, ShaderData *sd, Ray ray, int path_flag, float end, float *new_t, float *pdf)
 {
-	float distance_magic_eps = 1e-4f;
 	float sigma_magic_eps = 1e-15f;
-	float distance_eps = 1.0f - distance_magic_eps; // ensure we never check particle behind/at surface to stop light leaks, so decrease distance a bit
 	
 	float step = kernel_data.integrator.volume_cell_step;
 	int  max_steps = min(kernel_data.integrator.volume_max_iterations, (int)ceil(end / step));
@@ -438,7 +429,8 @@
 	return 1;
 }
 
-__device int kernel_volumetric_homogeneous_sampler( KernelGlobals *kg, RNG* rng, int rng_offset, int pass, float randv, float randp, ShaderData *sd, Ray ray, int path_flag, float end, float* new_t, float * pdf, float * eval, float *omega_cache)
+__device int kernel_volumetric_homogeneous_sampler(KernelGlobals *kg, RNG *rng, int rng_offset, int pass, float randv,
+	float randp, ShaderData *sd, Ray ray, int path_flag, float end, float *new_t, float *pdf, float *eval, float *omega_cache)
 {
 	/* return pdf of perfect importance volume sampling at given distance
 	only for homogeneous case, of course.
@@ -473,9 +465,9 @@
 	sigma = min( sigma, sigma3.z);
 #endif
 
-	if( sigma < sigma_magic_eps ) {
-		/*  Very transparent volume - Protect div by 0, *new_t = end; */
-		 return 0;
+	if(sigma < sigma_magic_eps) {
+		/* Very transparent volume - Protect div by 0, *new_t = end; */
+		return 0;
 	}
 
 #ifdef __VOLUME_USE_GUARANTEE_HIT_PROB
@@ -495,11 +487,10 @@
 
 	float sample_distance = -logf(randv) / sigma + start;
 	if (sample_distance > end) { // nothing hit in between [start, end]
-		//*new_t = sample_distance; // not used if return false 
 		//*eval = sigma * exp(-distance * sigma);
 		*eval = sigma * randv;
 		*pdf = sigma * randv;
-		 return 0;
+		return 0;
 	}
 	
 	// we hit particle!
@@ -510,7 +501,8 @@
 	return 1;
 }
 
-__device int kernel_volumetric_equiangular_sampler( KernelGlobals *kg, RNG* rng, int rng_offset, RNG* rng_congruential, int pass, float randv, float randp, ShaderData *sd, Ray ray, int path_flag, float end, float* new_t, float * pdf, float * eval, float *omega_cache)
+__device int kernel_volumetric_equiangular_sampler(KernelGlobals *kg, RNG *rng, int rng_offset, RNG *rng_congruential, int pass, float randv,
+	float randp, ShaderData *sd, Ray ray, int path_flag, float end, float *new_t, float *pdf, float *eval, float *omega_cache)
 {
 	float distance_magic_eps = 1e-4f;
 	float rand_magic_eps = 0.00001f;
@@ -559,22 +551,19 @@
 	float t = D * tan((randv * M_PI_2_F) - (1 - randv) * atheta);
 	sample_distance += t;
 
-	if (sample_distance > end) {
-		*pdf = D / ((M_PI_2_F + atheta) * (D * D + t * t));
-		*eval= *pdf;
-		 return 0;
-	}
-	
-	// we hit particle !
-	*new_t = sample_distance;
 	*pdf = D / ((M_PI_2_F + atheta) * (D * D + t * t));
 	*eval = *pdf;
-	sd->P = ray.P + ray.D * sample_distance;
-	return 1;
+	if(sample_distance > end)
+		return 0;
+	else
+		/* we hit particle */
+		*new_t = sample_distance;
+		sd->P = ray.P + ray.D * sample_distance;
+		return 1;
 }
 
 __device int kernel_volumetric_sample(KernelGlobals *kg, RNG *rng, int rng_offset, RNG *rng_congruential, int pass, float randv, float randp,
-		 ShaderData *sd, Ray ray, float distance, float *particle_isect_t, int path_flag, float *pdf, float *eval, float3 *throughput, float *omega_cache = NULL)
+	ShaderData *sd, Ray ray, float distance, float *particle_isect_t, int path_flag, float *pdf, float *eval, float3 *throughput, float *omega_cache = NULL)
 {
 	/* sample point on volumetric ray (return false - no hit, true - hit : fill new hit t value on path [start,end] */
 	float distance_magic_eps = 1e-4f;
@@ -625,8 +614,9 @@
 	}
 }
 
-/*volumetric shadows*/
-__device float3 kernel_volume_get_shadow_attenuation(KernelGlobals *kg, RNG *rng, int rng_offset, RNG *rng_congruential, int sample, Ray *light_ray, int media_volume_shader, float *volume_pdf)
+/* Volumetric shadows */
+__device float3 kernel_volume_get_shadow_attenuation(KernelGlobals *kg, RNG *rng, int rng_offset, RNG *rng_congruential, int sample,
+	Ray *light_ray, int media_volume_shader, float *volume_pdf)
 {
 	// helper for shadow probes, optimised for homogeneous volume, variable density other return 0 or 1.
 	// assume there are no objects inside light_ray, so it mus be preceded by shdow_blocked() or scene_intersect().
@@ -727,7 +717,8 @@
 
 
 
-__device bool shadow_blocked_new(KernelGlobals *kg, RNG *rng, int rng_offset, RNG *rng_congruential, int sample, PathState *state, Ray *ray, float3 *shadow, int media_volume_shader, float *volume_pdf, int bounces)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list