[Bf-blender-cvs] [f628b5f] openvdb: Merge branch 'master' into openvdb

Kévin Dietrich noreply at git.blender.org
Fri Sep 11 12:19:37 CEST 2015


Commit: f628b5f8436f6210569e7ed021e438f5be62d019
Author: Kévin Dietrich
Date:   Fri Sep 11 12:19:12 2015 +0200
Branches: openvdb
https://developer.blender.org/rBf628b5f8436f6210569e7ed021e438f5be62d019

Merge branch 'master' into openvdb

===================================================================



===================================================================

diff --cc intern/cycles/kernel/kernel_volume.h
index 64eecac,0a74a9d..269088c
--- a/intern/cycles/kernel/kernel_volume.h
+++ b/intern/cycles/kernel/kernel_volume.h
@@@ -477,115 -420,9 +477,115 @@@ ccl_device VolumeIntegrateResult kernel
  	return VOLUME_PATH_ATTENUATED;
  }
  
 +ccl_device_inline VolumeIntegrateResult kernel_volume_integrate_ray(
 +        KernelGlobals *kg, PathState *state, Ray *ray, ShaderData *sd,
 +        PathRadiance *L, float3 *throughput, float t, float new_t,
 +        float random_jitter_offset, bool has_scatter, float3 *accum_transmittance,
 +        int channel, const float tp_eps, float *xi)
 +{
 +	float dt = new_t - t;
 +	float3 tp = *throughput;
 +
 +	/* use random position inside this segment to sample shader */
 +	if(new_t == ray->t)
 +		random_jitter_offset = lcg_step_float(&state->rng_congruential) * dt;
 +
 +	float3 new_P = ray->P + ray->D * (t + random_jitter_offset);
 +	VolumeShaderCoefficients coeff;
 +
 +	/* compute segment */
 +	if(volume_shader_sample(kg, sd, state, new_P, &coeff)) {
 +		int closure_flag = sd->flag;
 +		float3 new_tp;
 +		float3 transmittance;
 +		bool scatter = false;
 +
 +		/* distance sampling */
 +#ifdef __VOLUME_SCATTER__
 +		if((closure_flag & SD_SCATTER) || (has_scatter && (closure_flag & SD_ABSORPTION))) {
 +			has_scatter = true;
 +
 +			float3 sigma_t = coeff.sigma_a + coeff.sigma_s;
 +			float3 sigma_s = coeff.sigma_s;
 +
 +			/* compute transmittance over full step */
 +			transmittance = volume_color_transmittance(sigma_t, dt);
 +
 +			/* decide if we will scatter or continue */
 +			float sample_transmittance = kernel_volume_channel_get(transmittance, channel);
 +
 +			if(1.0f - *xi >= sample_transmittance) {
 +				/* compute sampling distance */
 +				float sample_sigma_t = kernel_volume_channel_get(sigma_t, channel);
 +				float new_dt = -logf(1.0f - *xi)/sample_sigma_t;
 +				new_t = t + new_dt;
 +
 +				/* transmittance and pdf */
 +				float3 new_transmittance = volume_color_transmittance(sigma_t, new_dt);
 +				float3 pdf = sigma_t * new_transmittance;
 +
 +				/* throughput */
 +				new_tp = tp * sigma_s * new_transmittance / average(pdf);
 +				scatter = true;
 +			}
 +			else {
 +				/* throughput */
 +				float pdf = average(transmittance);
 +				new_tp = tp * transmittance / pdf;
 +
 +				/* remap xi so we can reuse it and keep thing stratified */
 +				*xi = 1.0f - (1.0f - *xi)/sample_transmittance;
 +			}
 +		}
 +		else
 +#endif
 +			if(closure_flag & SD_ABSORPTION) {
 +				/* absorption only, no sampling needed */
 +				float3 sigma_a = coeff.sigma_a;
 +
 +				transmittance = volume_color_transmittance(sigma_a, dt);
 +				new_tp = tp * transmittance;
 +			}
 +
 +		/* integrate emission attenuated by absorption */
 +		if(L && (closure_flag & SD_EMISSION)) {
 +			float3 emission = kernel_volume_emission_integrate(&coeff, closure_flag, transmittance, dt);
 +			path_radiance_accum_emission(L, tp, emission, state->bounce);
 +		}
 +
 +		/* modify throughput */
 +		if(closure_flag & (SD_ABSORPTION|SD_SCATTER)) {
 +			tp = new_tp;
 +
 +			/* stop if nearly all light blocked */
 +			if(tp.x < tp_eps && tp.y < tp_eps && tp.z < tp_eps) {
 +				tp = make_float3(0.0f, 0.0f, 0.0f);
 +				*throughput = tp;
 +				return VOLUME_PATH_ATTENUATED;
 +			}
 +		}
 +
 +		/* prepare to scatter to new direction */
 +		if(scatter) {
 +			/* adjust throughput and move to new location */
 +			sd->P = ray->P + new_t*ray->D;
 +			*throughput = tp;
 +
 +			return VOLUME_PATH_SCATTERED;
 +		}
 +		else {
 +			/* accumulate transmittance */
 +			*accum_transmittance *= transmittance;
 +		}
 +	}
 +
 +	*throughput = tp;
 +	return VOLUME_PATH_CONTINUE;
 +}
 +
  /* heterogeneous volume distance sampling: integrate stepping through the
   * volume until we reach the end, get absorbed entirely, or run out of
-  * iterations. this does probalistically scatter or get transmitted through
+  * iterations. this does probabilistically scatter or get transmitted through
   * for path tracing where we don't want to branch. */
  ccl_device VolumeIntegrateResult kernel_volume_integrate_heterogeneous_distance(KernelGlobals *kg,
  	PathState *state, Ray *ray, ShaderData *sd, PathRadiance *L, float3 *throughput, RNG *rng)
diff --cc source/blender/editors/space_view3d/CMakeLists.txt
index 1d1179e,059b384..41f3c64
--- a/source/blender/editors/space_view3d/CMakeLists.txt
+++ b/source/blender/editors/space_view3d/CMakeLists.txt
@@@ -90,11 -90,8 +90,15 @@@ if(WITH_FREESTYLE
  	add_definitions(-DWITH_FREESTYLE)
  endif()
  
+ if(WITH_LEGACY_DEPSGRAPH)
+ 	add_definitions(-DWITH_LEGACY_DEPSGRAPH)
+ endif()
+ 
 +if(WITH_OPENVDB)
 +	add_definitions(-DWITH_OPENVDB)
 +	list(APPEND INC
 +	     ../../../../intern/openvdb
 +	)
 +endif()
 +
  blender_add_lib(bf_editor_space_view3d "${SRC}" "${INC}" "${INC_SYS}")
diff --cc source/blender/editors/space_view3d/SConscript
index bb974d0,7fdccce..c25adeb
--- a/source/blender/editors/space_view3d/SConscript
+++ b/source/blender/editors/space_view3d/SConscript
@@@ -68,8 -68,7 +68,11 @@@ if env['WITH_BF_INTERNATIONAL']
  if env['WITH_BF_FREESTYLE']:
      defs.append('WITH_FREESTYLE')
  
+ if env['WITH_BF_LEGACY_DEPSGRAPH']:
+     defs.append('WITH_LEGACY_DEPSGRAPH')
+ 
 +if env['WITH_BF_OPENVDB']:
 +    incs.append('#intern/openvdb')
 +    defs.append('WITH_OPENVDB')
 +
  env.BlenderLib ( 'bf_editors_space_view3d', sources, incs, defines = defs, libtype=['core'], priority=[40] )




More information about the Bf-blender-cvs mailing list