ProcessedVoxelVolume GetProcessedVolume() { var lightVoxel = ((LightVoxel)Light.Type); if (lightVoxel.Volume == null) { throw new ArgumentNullException("No Voxel Volume Component selected for voxel light."); } var voxelVolumeProcessor = lightVoxel.Volume.Entity.EntityManager.GetProcessor <VoxelVolumeProcessor>(); if (voxelVolumeProcessor == null) { return(null); } ProcessedVoxelVolume processedVolume = voxelVolumeProcessor.GetProcessedVolumeForComponent(lightVoxel.Volume); return(processedVolume); }
VoxelAttribute GetTraceAttr() { var lightVoxel = ((LightVoxel)Light.Type); ProcessedVoxelVolume processedVolume = GetProcessedVolume(); if (processedVolume == null) { return(null); } if (processedVolume.OutputAttributes.Count > lightVoxel.AttributeIndex) { return(processedVolume.OutputAttributes[lightVoxel.AttributeIndex]); } else { throw new ArgumentOutOfRangeException("Tried to access attribute index " + lightVoxel.AttributeIndex.ToString() + " (zero-indexed) when the Voxel Volume Component has only " + processedVolume.OutputAttributes.Count.ToString() + " attributes."); } }
public override void ApplyViewParameters(RenderDrawContext context, int viewIndex, ParameterCollection parameters) { base.ApplyViewParameters(context, viewIndex, parameters); var lightVoxel = (LightVoxel)Light.Type; if (lightVoxel.Volume is null) { return; } ProcessedVoxelVolume processedVolume = GetProcessedVolume(); if (processedVolume is null) { return; } var intensity = Light.Intensity; var intensityBounceScale = lightVoxel.BounceIntensityScale; var specularIntensity = lightVoxel.SpecularIntensityScale * intensity; var viewContext = new VoxelViewContext(processedVolume.passList, viewIndex); if (viewContext.IsVoxelView) { intensity *= intensityBounceScale / 3.141592f; specularIntensity = 0.0f; } parameters.Set(intensityKey, intensity); parameters.Set(specularIntensityKey, specularIntensity); if (traceAttribute != null) { lightVoxel.DiffuseMarcher?.ApplyMarchingParameters(parameters); lightVoxel.SpecularMarcher?.ApplyMarchingParameters(parameters); traceAttribute.ApplySamplingParameters(viewContext, parameters); } }
VoxelAttribute GetTraceAttr() { var lightVoxel = (LightVoxel)Light.Type; ProcessedVoxelVolume processedVolume = GetProcessedVolume(); if (processedVolume is null) { return(null); } if (processedVolume.OutputAttributes.Count > lightVoxel.AttributeIndex) { return(processedVolume.OutputAttributes[lightVoxel.AttributeIndex]); } else { throw new ArgumentOutOfRangeException( $"Tried to access attribute index {lightVoxel.AttributeIndex} (zero-indexed) when the " + $"Voxel Volume Component has only {processedVolume.OutputAttributes.Count} attributes."); } }