public ImageEffectShader GetShader(RenderDrawContext context, VoxelAttribute attr) { VoxelViewContext viewContext = new VoxelViewContext(voxelView: false); Matrix ViewProjection = context.RenderContext.RenderView.ViewProjection; voxelDebugEffectShader.Parameters.Set(VoxelVisualizationViewShaderKeys.view, ViewProjection); voxelDebugEffectShader.Parameters.Set(VoxelVisualizationViewShaderKeys.viewInv, Matrix.Invert(ViewProjection)); voxelDebugEffectShader.Parameters.Set(VoxelVisualizationViewShaderKeys.background, (Vector4)Background); attr.UpdateSamplingLayout("AttributeSamplers[0]"); attr.ApplySamplingParameters(viewContext, voxelDebugEffectShader.Parameters); MarchMethod.UpdateMarchingLayout("marcher"); MarchMethod.ApplyMarchingParameters(voxelDebugEffectShader.Parameters); voxelDebugEffectShader.Parameters.Set(VoxelVisualizationViewShaderKeys.marcher, MarchMethod.GetMarchingShader(0)); ShaderSourceCollection collection = new ShaderSourceCollection { attr.GetSamplingShader() }; voxelDebugEffectShader.Parameters.Set(MarchAttributesKeys.AttributeSamplers, collection); return(voxelDebugEffectShader); }
public ImageEffectShader GetShader(RenderDrawContext context, VoxelAttribute attr) { VoxelViewContext viewContext = new VoxelViewContext(false); attr.UpdateSamplingLayout("Attribute"); attr.ApplySamplingParameters(viewContext, voxelDebugEffectShader.Parameters); voxelDebugEffectShader.Parameters.Set(VoxelVisualizationRawShaderKeys.Attribute, attr.GetSamplingShader()); voxelDebugEffectShader.Parameters.Set(VoxelVisualizationRawShaderKeys.mip, Mipmap); voxelDebugEffectShader.Parameters.Set(VoxelVisualizationRawShaderKeys.rangeOffset, RangeOffset); voxelDebugEffectShader.Parameters.Set(VoxelVisualizationRawShaderKeys.range, Range); return(voxelDebugEffectShader); }
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); } }