public override void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings) { Vector2 v = new Vector2(settings.RenderWidth, settings.RenderHeight); v.X = 1.0f / v.X; v.Y = 1.0f / v.Y; shaderinstance.SetByName(this.Name, v); }
public void ApplyGlobal(DX11ShaderInstance instance) { //this.globalsettings = settings; this.rendervariables.Apply(instance, this.globalsettings); this.shaderpins.Preprocess(instance); }
public TextureArraySetSlice(DX11RenderContext context) { this.context = context; this.shader = ShaderUtils.GetShader(context, "SetSlice"); this.quad = context.Primitives.FullScreenQuad; this.quad.ValidateLayout(this.shader.GetPass(0), out this.layout); }
public override void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings, DX11ObjectRenderSettings obj) { if (obj.Geometry != null) { if (obj.Geometry.HasBoundingBox) { shaderinstance.SetByName(this.Name,obj.Geometry.BoundingBox.Minimum); } else { shaderinstance.SetByName(this.Name, vec); } } else { shaderinstance.SetByName(this.Name, vec); } }
public void Update(IPluginIO pin, DX11RenderContext context) { if (this.FOutGeom.SliceCount == 0) { return; } if (this.generateShader == null) { this.generateShader = ShaderUtils.GetShader(context, "GenerateDispatch1D"); this.dispatchBuffer = new DispatchIndirectBuffer(context); this.countBuffer = new DX11RawBuffer(context.Device, 16); } if (!this.FOutGeom[0].Contains(context)) { this.indirectDispatch = new DX11NullIndirectDispatcher(); this.indirectDispatch.IndirectArgs = this.dispatchBuffer; DX11NullGeometry nullgeom = new DX11NullGeometry(context); nullgeom.AssignDrawer(this.indirectDispatch); this.FOutGeom[0][context] = nullgeom; this.FOutCounter[0][context] = this.dispatchBuffer.RWBuffer; } var countuav = this.FInArgBuffer[0][context]; context.CurrentDeviceContext.CopyStructureCount(countuav.UAV, this.countBuffer.Buffer, 0); this.generateShader.SetBySemantic("WARPSIZE", this.FInWarpX[0]); this.generateShader.SetBySemantic("COUNTERBUFFER", this.countBuffer.SRV); this.generateShader.SetBySemantic("RWDISPATCHBUFFER", this.dispatchBuffer.UAV); this.generateShader.ApplyPass(0); context.CurrentDeviceContext.Dispatch(1, 1, 1); this.generateShader.CleanUp(); this.dispatchBuffer.UpdateBuffer(); }
public override void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings, DX11ObjectRenderSettings obj) { if (obj.Geometry != null) { if (obj.Geometry.HasBoundingBox) { Vector3 scale = obj.Geometry.BoundingBox.Maximum - obj.Geometry.BoundingBox.Minimum; scale.X = scale.X != 0.0f ? 1.0f / scale.X : 1.0f; scale.Y = scale.Y != 0.0f ? 1.0f / scale.Y : 1.0f; scale.Z = scale.Z != 0.0f ? 1.0f / scale.Z : 1.0f; Matrix m = Matrix.Scaling(scale); shaderinstance.SetByName(this.Name, m); } else { shaderinstance.SetByName(this.Name, m); } } else { shaderinstance.SetByName(this.Name, m); } }
public abstract void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings);
public void SetEffect(DX11Effect shader) { //Create if (this.shader == null) { this.shader = shader; if (shader.IsCompiled) { this.shaderinstance = new DX11ShaderInstance(this.context, shader.ByteCode); this.UpdateTechnique(); } } else { if (shader.IsCompiled) { //Update shader if (shader != this.shader) { //Dispose old effect if applicable this.shader = shader; if (this.shaderinstance != null) { this.shaderinstance.Dispose(); } this.shaderinstance = new DX11ShaderInstance(this.context, shader.ByteCode); this.UpdateTechnique(); this.DisposeLayouts(); } } } }
public override void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings, DX11ObjectRenderSettings obj) { shaderinstance.SetByName(this.Name, (float)obj.DrawCallIndex); }
public override void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings, DX11ObjectRenderSettings obj) { shaderinstance.SetByName(this.Name, Matrix.Transpose(obj.WorldTransform)); }
public override void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings) { shaderinstance.SetByName(this.Name, Matrix.Invert(settings.ViewProjection)); }
public override void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings) { shaderinstance.SetByName(this.Name, Matrix.Transpose(settings.View)); }
public void ApplyPerObject(DX11RenderContext context, DX11ShaderInstance instance, DX11ObjectRenderSettings objectsettings, int slice) { this.worldvariables.Apply(instance, this.globalsettings, objectsettings); this.shaderpins.ApplySlice(instance, slice); }
public void Update(IPluginIO pin, DX11RenderContext context) { Device device = context.Device; DeviceContext ctx = context.CurrentDeviceContext; if ( !this.FOutPointcloudRingBuffer[0].Contains(context) || !this.FOutUpdatedBuffer[0].Contains(context) || !this.bCounter.Contains(context) || !this.bOffset.Contains(context) || this.FInPointcloudRingBufferSize.IsChanged || this.FInEleCount.IsChanged) { this.FOutPointcloudRingBuffer[0].Dispose(context); DX11RWStructuredBuffer brPointcloud = new DX11RWStructuredBuffer(device, FInPointcloudRingBufferSize[0], FInStride[0], eDX11BufferMode.Counter); this.FOutPointcloudRingBuffer[0][context] = brPointcloud; this.FOutUpdatedBuffer[0].Dispose(context); DX11RWStructuredBuffer brUpdated = new DX11RWStructuredBuffer(device, FInPointcloudRingBufferSize[0], 4, eDX11BufferMode.Counter); this.FOutUpdatedBuffer[0][context] = brUpdated; this.bOffset.Dispose(context); this.bOffset[context] = new DX11RawBuffer(device, 16); this.bCounter.Dispose(context); this.bCounter[context] = new DX11RWStructuredBuffer(device, FInEleCount[0], 4, eDX11BufferMode.Counter); } // load shader if (this.shader == null) { string basepath = "RingBuffer.effects.RingBuffer.fx"; DX11Effect effect = DX11Effect.FromResource(Assembly.GetExecutingAssembly(), basepath); this.shader = new DX11ShaderInstance(context, effect); } if (this.FInPointcloudBuffer.PluginIO.IsConnected && FInSet[0] && currentFrame != FHDEHost.FrameTime) { currentFrame = FHDEHost.FrameTime; // prevents to execute this a second time int[] mask = new int[4] { 0, 0, 0, 0 }; ctx.ClearUnorderedAccessView(FOutUpdatedBuffer[0][context].UAV, mask); shader.SelectTechnique("AddPoints"); shader.SetBySemantic("POINTCLOUDBUFFER", FInPointcloudBuffer[0][context].SRV); shader.SetBySemantic("POINTCLOUDCOUNTBUFFER", FInCountBuffer[0][context].SRV); shader.SetBySemantic("POINTCLOUDRINGBUFFER", FOutPointcloudRingBuffer[0][context].UAV, FInPointcloudRingBufferSize[0]); shader.SetBySemantic("UPDATEDRINGBUFFER", FOutUpdatedBuffer[0][context].UAV, FInPointcloudRingBufferSize[0]); shader.SetBySemantic("POINTCLOUDRINGBUFFERSIZE", FInPointcloudRingBufferSize[0]); shader.SetBySemantic("OFFSETBUFFER", this.bOffset[context].SRV); shader.SetBySemantic("COUNTERBUFFER", this.bCounter[context].UAV, 0); shader.ApplyPass(0); ctx.Dispatch((FInEleCount[0] + 63) / 64, 1, 1); ctx.CopyStructureCount(this.bCounter[context].UAV, this.bOffset[context].Buffer, 0); shader.SelectTechnique("CalcOffset"); shader.ApplyPass(0); ctx.Dispatch(1, 1, 1); context.CleanUp(); context.CleanUpCS(); } }
public void Update(IPluginIO pin, DX11RenderContext context) { if (quadshader == null) { string basepath = "VVVV.DX11.Nodes.effects.quad.fx"; DX11Effect effect = DX11Effect.FromResource(Assembly.GetExecutingAssembly(), basepath); quadshader = new DX11ShaderInstance(context, effect); texturevariable = quadshader.Effect.GetVariableBySemantic("INPUTTEXTURE").AsResource(); samplervariable = quadshader.Effect.GetVariableBySemantic("SAMPLERSTATE").AsSampler(); Quad quad = new Quad(); quad.Size = new Vector2(1.0f); quadgeometry = context.Primitives.QuadNormals(quad); quadlayouts = new List<InputLayout>(); for (int i = 0; i < 4; i++) { InputLayout layout; quadshader.SelectTechnique(i); bool res = quadgeometry.ValidateLayout(quadshader.GetPass(0), out layout); quadlayouts.Add(layout); } } if (this.spmax > 0) { if (!this.FOutLayer[0].Contains(context)) { this.FOutLayer[0][context] = new DX11Layer(); this.FOutLayer[0][context].Render = this.Render; } } }
public override void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings) { shaderinstance.SetByName(this.Name, settings.View); }
public bool SetGlobalSettings(DX11ShaderInstance instance, DX11RenderSettings settings) { this.globalsettings = settings; return settings.ApplySemantics(instance, this.customvariables); }
public override void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings) { Matrix iv = Matrix.Invert(settings.View); shaderinstance.SetByName(this.Name, new Vector3(iv.M41, iv.M42, iv.M43)); }
public override void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings) { float val = 1.0f / (float)settings.DrawCallCount; shaderinstance.SetByName(this.Name, val); }
public QuadShaderDeviceData(DX11RenderContext context) { string basepath = "VVVV.DX11.Nodes.effects.quad.fx"; DX11Effect effect = DX11Effect.FromResource(Assembly.GetExecutingAssembly(), basepath); quadshader = new DX11ShaderInstance(context, effect); texturevariable = quadshader.Effect.GetVariableBySemantic("INPUTTEXTURE").AsResource(); samplervariable = quadshader.Effect.GetVariableBySemantic("SAMPLERSTATE").AsSampler(); Quad quad = new Quad(); quad.Size = new Vector2(1.0f); quadgeometry = context.Primitives.QuadNormals(quad); quadlayouts = new List<InputLayout>(); for (int i = 0; i < 4; i++) { InputLayout layout; quadshader.SelectTechnique(i); bool res = quadgeometry.ValidateLayout(quadshader.GetPass(0), out layout); quadlayouts.Add(layout); } }
public override void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings) { if (settings.ReadBuffer != null) { shaderinstance.SetByName(this.Name, settings.ReadBuffer.SRV); } }
public override void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings, DX11ObjectRenderSettings obj) { shaderinstance.SetByName(this.Name, obj.WorldTransform * settings.View); }
public override void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings) { if (settings.BackBuffer != null) { EffectVariable counter = this.variable.GetAnnotationByName("counter"); if (counter != null) { float cnt = counter.AsScalar().GetFloat(); shaderinstance.SetByName(this.Name, settings.BackBuffer.UAV,(int)cnt); } else { if (settings.ResetCounter) { shaderinstance.SetByName(this.Name, settings.BackBuffer.UAV, settings.CounterValue); } else { shaderinstance.SetByName(this.Name, settings.BackBuffer.UAV); } } } }
public override void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings, DX11ObjectRenderSettings obj) { shaderinstance.SetByName(this.Name, obj.IterationIndex); }
public override void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings) { shaderinstance.SetByName(this.Name, new Vector3(settings.RenderWidth, settings.RenderHeight, settings.RenderDepth)); }
public abstract void Apply(DX11ShaderInstance shaderinstance, DX11RenderSettings settings, DX11ObjectRenderSettings obj);
public void Update(IPluginIO pin, DX11RenderContext context) { Device device = context.Device; DeviceContext ctx = context.CurrentDeviceContext; if (!this.FOutLinkBuffer[0].Contains(context) || !this.FOutOffsetBuffer[0].Contains(context) || FInGridcellCount.IsChanged) { this.FOutLinkBuffer[0].Dispose(context); this.FOutOffsetBuffer[0].Dispose(context); DX11RWStructuredBuffer lb = new DX11RWStructuredBuffer(device, FInEleCount[0], 8, eDX11BufferMode.Counter); DX11RWStructuredBuffer ob = new DX11RWStructuredBuffer(device, FInGridcellCount[0] * FInGridcellCount[0] * FInGridcellCount[0], 4, eDX11BufferMode.Counter); this.FOutLinkBuffer[0][context] = lb; this.FOutOffsetBuffer[0][context] = ob; } // clear offsetbuffer int[] mask = new int[4] { -1, -1, -1, -1 }; ctx.ClearUnorderedAccessView(FOutOffsetBuffer[0][context].UAV,mask); // load shader if (this.shader == null) { string basepath = "LinkedList.effects.LinkedList.fx"; DX11Effect effect = DX11Effect.FromResource(Assembly.GetExecutingAssembly(), basepath); this.shader = new DX11ShaderInstance(context, effect); } if (this.FInPcBuffer.PluginIO.IsConnected) { shader.SelectTechnique("BuildHash"); shader.SetBySemantic("POINTCLOUDBUFFER", FInPcBuffer[0][context].SRV); shader.SetBySemantic("POINTTRANSFORM", FInTransform[0]); shader.SetBySemantic("RWLINKBUFFER", FOutLinkBuffer[0][context].UAV, 0); shader.SetBySemantic("RWOFFSETBUFFER", FOutOffsetBuffer[0][context].UAV); shader.SetBySemantic("GRIDCELLSIZE", FInGridcellCount[0]); shader.ApplyPass(0); ctx.Dispatch((FInEleCount[0] + 63) / 64, 1, 1); context.CleanUp(); context.CleanUpCS(); } }
public bool ApplySemantics(DX11ShaderInstance instance, List<IDX11CustomRenderVariable> variables) { foreach (IDX11RenderSemantic semantic in this.CustomSemantics) { if (!semantic.Apply(instance, variables)) { return false; } } foreach (DX11Resource<IDX11RenderSemantic> semantic in this.ResourceSemantics) { if (semantic[instance.RenderContext] != null) { if (!semantic[instance.RenderContext].Apply(instance, variables)) { return false; } } } return true; }
public void Update(IPluginIO pin, DX11RenderContext context) { Device device = context.Device; DeviceContext ctx = context.CurrentDeviceContext; if (!this.FOutPointcloudBuffer[0].Contains(context) || !this.FOutIndexBuffer[0].Contains(context) || this.FInEleCount.IsChanged ) { this.FOutPointcloudBuffer[0].Dispose(context); this.FOutIndexBuffer[0].Dispose(context); DX11RWStructuredBuffer pcBuffer = new DX11RWStructuredBuffer(device, FInEleCount[0], FInStride[0], eDX11BufferMode.Counter); DX11RWStructuredBuffer idBuffer = new DX11RWStructuredBuffer(device, FInEleCount[0], 4, eDX11BufferMode.Counter); this.FOutPointcloudBuffer[0][context] = pcBuffer; this.FOutIndexBuffer[0][context] = idBuffer; } // clear offsetbuffer int[] mask = new int[4] { -1, -1, -1, -1 }; ctx.ClearUnorderedAccessView(FOutIndexBuffer[0][context].UAV,mask); // load shader if (this.shader == null) { string basepath = "RingBufferIndexing.effects.RingBufferIndexing.fx"; DX11Effect effect = DX11Effect.FromResource(Assembly.GetExecutingAssembly(), basepath); this.shader = new DX11ShaderInstance(context, effect); } if (this.FInPointcloudBuffer.PluginIO.IsConnected /* && currentFrame != FHDEHost.FrameTime*/) { currentFrame = FHDEHost.FrameTime; // prevents to execute this a second time shader.SelectTechnique("BuildHash"); shader.SetBySemantic("POINTCLOUDBUFFERIN", FInPointcloudBuffer[0][context].SRV); shader.SetBySemantic("POINTCLOUDBUFFEROUT", FOutPointcloudBuffer[0][context].UAV, 0); shader.SetBySemantic("INDEXBUFFER", FOutIndexBuffer[0][context].UAV); shader.ApplyPass(0); ctx.Dispatch((FInEleCount[0] + 63) / 64, 1, 1); context.CleanUp(); context.CleanUpCS(); } }