private void DrawMask(PPDDevice device, AlphaBlendContext context, Matrix m, PrimitiveType primitiveType, int primitiveCount, int startIndex, int vertexCount) { using (var workspaceTexture = device.Workspace.Get()) { #if BENCHMARK using (var handler = Benchmark.Instance.Start("Copy")) { #endif device.StretchRectangle(device.GetRenderTarget(), workspaceTexture); #if BENCHMARK } #endif #if BENCHMARK using (var handler = Benchmark.Instance.Start("Effect Prepare")) { #endif effect.Technique = maskTechniqueNames[new Tuple <MaskType, bool>(MaskType, context.MaskTexture != null)]; effect.SetTexture(textureHandle, context.Texture); effect.SetTexture(lastRenderTargetTextureHandle, workspaceTexture.Texture); effect.SetTexture(maskTextureHandle, context.MaskTexture); effect.SetValue(drawInfoHandle, new DrawInfo { Matrix = m, Alpha = context.Alpha, OverlayColor = context.Overlay }); #if BENCHMARK } #endif #if BENCHMARK using (var handler = Benchmark.Instance.Start("Mask Draw")) { #endif var passCount = effect.Begin(); effect.BeginPass(0); effect.CommitChanges(); device.VertexDeclaration = effect.VertexDeclaration; device.SetStreamSource(context.Vertex.VertexBucket.VertexBuffer); device.DrawPrimitives(primitiveType, context.Vertex.Offset + startIndex, primitiveCount); effect.EndPass(); effect.End(); effect.SetTexture(textureHandle, null); #if BENCHMARK } #endif } }
private void Draw(PPDDevice device, WorkspaceTexture filterTexture, Border border, BorderType type, float thickness) { using (var workspaceTexture = device.Workspace.Get()) { #if BENCHMARK using (var handler = Benchmark.Instance.Start("Copy")) { #endif device.StretchRectangle(device.GetRenderTarget(), workspaceTexture); #if BENCHMARK } #endif effect.Technique = String.Format("{0}{1}Border", type, border.Blend); effect.SetTexture(filterTextureHandle, filterTexture.Texture); effect.SetTexture(lastRenderTargetTextureHandle, workspaceTexture.Texture); effect.SetValue(colorHandle, border.Color); var intThickness = (int)Math.Ceiling(thickness * 2 + 1); effect.SetValue(thicknessHandle, (float)intThickness); effect.SetValue(thickness2Handle, (int)Math.Pow(intThickness, 2)); effect.SetValue(actualThicknessHandle, thickness); var passCount = effect.Begin(); effect.BeginPass(0); effect.CommitChanges(); device.VertexDeclaration = effect.VertexDeclaration; var screenVertex = device.GetModule <ShaderCommon>().ScreenVertex; device.SetStreamSource(screenVertex.VertexBucket.VertexBuffer); device.DrawPrimitives(PrimitiveType.TriangleStrip, screenVertex.Offset, 2); effect.EndPass(); effect.End(); } }
private void DrawQuad(PPDDevice device) { effect.CommitChanges(); device.VertexDeclaration = effect.VertexDeclaration; var screenVertex = device.GetModule <ShaderCommon>().ScreenVertex; device.SetStreamSource(screenVertex.VertexBucket.VertexBuffer); device.DrawPrimitives(PrimitiveType.TriangleStrip, screenVertex.Offset, 2); }
/// <summary> /// コピーします。 /// </summary> /// <param name="device"></param> /// <param name="filterTexture"></param> /// <param name="size"></param> public void Draw(PPDDevice device, WorkspaceTexture filterTexture, int size) { using (var workspaceTexture = device.Workspace.Get()) using (var xTexture = device.Workspace.Get()) { #if BENCHMARK using (var handler = Benchmark.Instance.Start("Copy")) { #endif device.StretchRectangle(device.GetRenderTarget(), workspaceTexture); #if BENCHMARK } #endif var renderTarget = device.GetRenderTarget(); device.SetRenderTarget(xTexture); device.Clear(); effect.Technique = "Mosaic"; effect.SetTexture(filterTextureHandle, filterTexture.Texture); effect.SetTexture(lastRenderTargetTextureHandle, workspaceTexture.Texture); effect.SetValue(sizeHandle, size); var passCount = effect.Begin(); effect.BeginPass(0); effect.CommitChanges(); device.VertexDeclaration = effect.VertexDeclaration; var screenVertex = device.GetModule <ShaderCommon>().ScreenVertex; device.SetStreamSource(screenVertex.VertexBucket.VertexBuffer); device.DrawPrimitives(PrimitiveType.TriangleStrip, screenVertex.Offset, 2); effect.EndPass(); device.SetRenderTarget(renderTarget); effect.SetTexture(xTextureHandle, xTexture.Texture); effect.BeginPass(1); effect.CommitChanges(); device.DrawPrimitives(PrimitiveType.TriangleStrip, screenVertex.Offset, 2); effect.EndPass(); effect.End(); } }
/// <summary> /// コピーします。 /// </summary> /// <param name="device"></param> /// <param name="filterTexture"></param> /// <param name="lastRenderTargetTexture"></param> public void Draw(PPDDevice device, TextureBase filterTexture, TextureBase lastRenderTargetTexture) { effect.SetTexture(filterTextureHandle, filterTexture); effect.SetTexture(lastRenderTargetFilterTextureHandle, lastRenderTargetTexture); var passCount = effect.Begin(); effect.BeginPass(0); effect.CommitChanges(); device.VertexDeclaration = effect.VertexDeclaration; var screenVertex = device.GetModule <ShaderCommon>().ScreenVertex; device.SetStreamSource(screenVertex.VertexBucket.VertexBuffer); device.DrawPrimitives(PrimitiveType.TriangleStrip, screenVertex.Offset, 2); effect.EndPass(); effect.End(); }