public PostProcessor(Device device, ShaderCache shaderCache, Size2 size) { ResultTexture = new Texture2D(device, new Texture2DDescription() { Format = ColorFormat, Width = size.Width, Height = size.Height, ArraySize = 1, SampleDescription = new SampleDescription(1, 0), MipLevels = 1, Usage = ResourceUsage.Default, BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource }); ResultTargetView = new RenderTargetView(device, ResultTexture); ResultSourceView = new ShaderResourceView(device, ResultTexture); constantsBuffer = new ConstantBufferManager <PostProcessorConstants>(device); StateDescriptions postProcessingStateDesc = StateDescriptions.Common.Clone(); postProcessingStateDesc.rasterizer.CullMode = CullMode.None; postProcessingStates = new States(device, postProcessingStateDesc); fullScreenVertexShader = shaderCache.GetVertexShader <RenderPassController>("game/rendering/FullScreenVertexShader"); postProcessingShader = shaderCache.GetPixelShader <RenderPassController>("game/rendering/postprocess/PostProcessingShader"); }
public GpuOcclusionCalculator(Device device, ShaderCache shaderCache, QuadTopology topology, float[] faceTransparencies, uint[] faceMasks, uint[] vertexMasks) { if (topology.Faces.Length != faceTransparencies.Length) { throw new ArgumentException("face count mismatch"); } if (topology.Faces.Length != faceMasks.Length) { throw new ArgumentException("face count mismatch"); } if (topology.VertexCount != vertexMasks.Length) { throw new ArgumentException("vertex count mismatch"); } shader = shaderCache.GetComputeShader <GpuOcclusionCalculator>("occlusion/HemisphericalRasterizingComputeShader"); segmentBufferManager = new ConstantBufferManager <ArraySegment>(device); SetupHemispherePointsAndWeights(device); SetupRasterTable(device, shaderCache); SetupTopologyBuffers(device, topology, faceTransparencies); faceMasksView = BufferUtilities.ToStructuredBufferView(device, faceMasks); vertexMasksView = BufferUtilities.ToStructuredBufferView(device, vertexMasks); }
public ImageBasedLightingEnvironment(Device device, StandardSamplers standardSamplers, IArchiveDirectory dataDir, string environmentName, float rotation) { this.device = device; this.standardSamplers = standardSamplers; this.dataDir = dataDir; constantBufferManager = new ConstantBufferManager <ShaderConstants>(device); EnvironmentName = environmentName; Rotation = rotation; }
public CompanionWindow(Device device, ShaderCache shaderCache, StandardSamplers standardSamplers, string title, IArchiveDirectory dataDir) { this.device = device; this.standardSamplers = standardSamplers; form = new RenderForm(title); // SwapChain description var desc = new SwapChainDescription() { BufferCount = 1, ModeDescription = new ModeDescription(form.ClientSize.Width, form.ClientSize.Height, default(Rational), Format.R8G8B8A8_UNorm_SRgb), IsWindowed = true, OutputHandle = form.Handle, SampleDescription = new SampleDescription(1, 0), SwapEffect = SwapEffect.Discard, //TODO: consider using flip Usage = Usage.RenderTargetOutput }; using (var factory = new Factory1()) { factory.MakeWindowAssociation(form.Handle, WindowAssociationFlags.IgnoreAll); swapChain = new SwapChain(factory, device, desc); } form.UserResized += OnUserResized; SetupBackbufferAndViewport(); copyFromSourceVertexShader = shaderCache.GetVertexShader <CompanionWindow>("viewer/companion-window/CopyFromSource"); copyFromSourcePixelShader = shaderCache.GetPixelShader <CompanionWindow>("viewer/companion-window/CopyFromSource"); uiBlendState = MakeUiBlendState(device); aspectRatiosBufferManager = new ConstantBufferManager <AspectRatios>(device); overlay = Overlay.Load(device, shaderCache, dataDir.Subdirectory("ui").File("put-on-headset-overlay.dds")); form.KeyPress += OnKeyPress; form.MouseDown += OnMouseDown; form.MouseUp += OnMouseUp; form.MouseMove += OnMouseMove; DebugInitialize(); }
public PlayspaceFloor(Device device, ShaderCache shaderCache) { vertexShader = shaderCache.GetVertexShader <Backdrop>("backdrop/PlayspaceFloor"); pixelShader = shaderCache.GetPixelShader <Backdrop>("backdrop/PlayspaceFloor"); playAreaRectBuffer = new ConstantBufferManager <PlayAreaRect>(device); }