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 ShaderDeviceData(DX11RenderContext context) { string basepath = "VVVV.DX11.Nodes.effects.DrawFullScreen.fx"; using (DX11Effect effect = DX11Effect.FromResource(Assembly.GetExecutingAssembly(), basepath)) { shaderInstance = new DX11ShaderInstance(context, effect); inputTextureVariable = shaderInstance.Effect.GetVariableBySemantic("INPUTTEXTURE").AsResource(); colorVariable = shaderInstance.Effect.GetVariableBySemantic("COLOR").AsVector(); samplerVariable = shaderInstance.Effect.GetVariableBySemantic("TEXTURESAMPLER").AsSampler(); texTransformVariable = shaderInstance.Effect.GetVariableBySemantic("TEXTUREMATRIX").AsMatrix(); pass = shaderInstance.CurrentTechnique.GetPassByIndex(0); } }
public static void CompareVariable(EffectVariable reflectionVariable, object variable) { EffectTypeDescription typeDesc = reflectionVariable.TypeInfo.Description; Assert.AreEqual(typeDesc.TypeName, typeDesc.TypeName); Assert.AreEqual(typeDesc.Class, typeDesc.Class); Assert.AreEqual(typeDesc.Type, typeDesc.Type); Assert.AreEqual(typeDesc.Elements, typeDesc.Elements); Assert.AreEqual(typeDesc.Members, typeDesc.Members); Assert.AreEqual(typeDesc.Rows, typeDesc.Rows); Assert.AreEqual(typeDesc.Columns, typeDesc.Columns); Assert.AreEqual(typeDesc.PackedSize, typeDesc.PackedSize); Assert.AreEqual(typeDesc.UnpackedSize, typeDesc.UnpackedSize); Assert.AreEqual(typeDesc.Stride, typeDesc.Stride); EffectVariableDescription variableDesc = reflectionVariable.Description; Assert.AreEqual(variableDesc.Name, variableDesc.Name); Assert.AreEqual(variableDesc.Semantic, variableDesc.Semantic); Assert.AreEqual(variableDesc.Flags, variableDesc.Flags); Assert.AreEqual(variableDesc.AnnotationCount, variableDesc.AnnotationCount); Assert.AreEqual(variableDesc.BufferOffset, variableDesc.BufferOffset); Assert.AreEqual(variableDesc.ExplicitBindPoint, variableDesc.ExplicitBindPoint); if (variable is EffectNumericVariable v1) { Assert.AreEqual(variableDesc.Name, v1.Name); Assert.AreEqual(0, v1.ExplicitBindPoint); } if (variable is EffectObjectVariable v2) { Assert.AreEqual(variableDesc.Name, v2.Name); } for (int i = 0; i < variableDesc.AnnotationCount; i++) { var annotation = reflectionVariable.GetAnnotationByIndex(i); } if (typeDesc.Type == ShaderVariableType.Sampler) { EffectSamplerVariable sampVariable = reflectionVariable.AsSampler(); SamplerState samplerState = sampVariable.GetSampler(); var sampDesc = samplerState.Description; } }
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 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 void Render(DX11RenderContext context) { if (this.lasthandle != this.Handle) { if (this.swapchain != null) { if (this.swapchain.Contains(context)) { this.swapchain.Dispose(context); } } this.lasthandle = this.Handle; } if (!this.swapchain.Contains(context)) { this.swapchain[context] = new DX11SwapChain(context, this.Handle, SlimDX.DXGI.Format.R8G8B8A8_UNorm, new SampleDescription(1, 0), 60, 1); } if (this.resized) { this.swapchain[context].Resize(); } if (this.FEnabled[0]) { context.CurrentDeviceContext.ClearRenderTargetView(this.swapchain[context].RTV, new SlimDX.Color4(0, 0, 0, 0)); } if (this.FIn.IsConnected && this.spreadMax > 0 && this.FEnabled[0]) { int id = this.FIndex[0]; if (this.FIn[id].Contains(context) && this.FIn[id][context] != null) { context.RenderTargetStack.Push(this.swapchain[context]); var rs = new DX11RenderState(); if (FAlpha[0]) { rs.Blend = DX11BlendStates.Instance.GetState("Blend"); context.CurrentDeviceContext.ClearRenderTargetView(this.swapchain[context].RTV, FInBgColor[0].Color); } context.RenderStateStack.Push(rs); context.CleanShaderStages(); context.Primitives.FullTriVS.GetVariableBySemantic("TEXTURE").AsResource().SetResource(this.FIn[id][context].SRV); EffectSamplerVariable samplervariable = context.Primitives.FullTriVS.GetVariableByName("linSamp").AsSampler(); SamplerState state = null; if (this.FInSamplerState.IsConnected) { state = SamplerState.FromDescription(context.Device, this.FInSamplerState[0]); samplervariable.SetSamplerState(0, state); } else { samplervariable.UndoSetSamplerState(0); } context.Primitives.FullScreenTriangle.Bind(null); context.Primitives.ApplyFullTri(); context.Primitives.FullScreenTriangle.Draw(); context.RenderStateStack.Pop(); context.RenderTargetStack.Pop(); context.CleanUpPS(); samplervariable.UndoSetSamplerState(0); //undo as can be used in other places if (state != null) { state.Dispose(); } } } }
/// <summary> /// Constructor /// </summary> /// <param name="variable">Internal effect sampler variable</param> public EngineEffectVariableSampler(EffectSamplerVariable variable) { this.variable = variable; }
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 EffectTextureVariable(Effect effect, string name) { _Effect = effect; _TextureVar = effect.GetVariableByName(name).AsShaderResource(); _SamplerVar = effect.GetVariableByName(name + "Sampler").AsSampler(); }