public PhongShadowsVS() { Name = "PhongShadowsVS"; KeyPart = new TechniqueKey(vs: VertexShaderFlags.Position | VertexShaderFlags.Normal | VertexShaderFlags.TextureUV); Clear(); PhongVSOutputNode oldOutput = (PhongVSOutputNode)Result; InputStruct = Struct.VertexPositionNormalTexture; OutputStruct = VSOut; Add(CBStatic); Add(ConstantBuffer.CBPerFrame); Add(CBPerInstance); MatrixMultiplyNode mShadow = new MatrixMultiplyNode { Input1 = new ReferenceNode { Value = InputStruct[Param.SemanticVariables.Position] }, Input2 = MatrixMultiplyNode.LightWorldViewProjection }; Result = new PhongShadowsVSOutputNode { Position = oldOutput.Position, Normal = oldOutput.Normal, WorldPosition = oldOutput.WorldPosition, Texture = oldOutput.Texture, ShadowProjection = mShadow, Output = OutputStruct }; }
public ShapeVS() { Name = "ShapeVS"; Type = ShaderType.Vertex; FeatureLevel = FeatureLevel.VS_4_0_Level_9_1; KeyPart = new TechniqueKey(vs: VertexShaderFlags.Position | VertexShaderFlags.Color); EnableSeparators = true; InputStruct = Struct.VertexPositionColor; OutputStruct = VSOut; ConstantBuffer cbScene = CBPerFrame; ConstantBuffer cbInstance = CBPerInstance; Add(cbScene); Add(cbInstance); var nPosV3toV4 = CastNode.PositionV3toV4(InputStruct[Param.SemanticVariables.Position]); var mulPosWVP = new MatrixMultiplyNode { Input1 = nPosV3toV4, Input2 = MatrixMultiplyNode.WorldViewProjection, }; CustomOutputNode outputNode = new CustomOutputNode() { Output = OutputStruct }; outputNode.RegisterField(Vector.ClipPosition, mulPosWVP, Shaders.Type.Float4); outputNode.RegisterField(Vector.Color, new ReferenceNode { Value = InputStruct[Param.SemanticVariables.Color] }, Shaders.Type.Float4); Result = outputNode; }
public SkyboxVS() { Name = "SkyboxVS"; Type = ShaderType.Vertex; KeyPart = new TechniqueKey(vs: VertexShaderFlags.Position | VertexShaderFlags.Normal | VertexShaderFlags.TextureUVW); FeatureLevel = FeatureLevel.VS_4_0_Level_9_1; EnableSeparators = true; InputStruct = Struct.VertexPositionNormalTextureUVW; OutputStruct = VSOutput; Add(CBStatic); Add(Structs.ConstantBuffer.CBPerFrame); IVariable position = InputStruct[Param.SemanticVariables.ObjectPosition]; IVariable texture = InputStruct[Param.SemanticVariables.Texture]; CastNode nV3toV4 = new CastNode { Input = new SwizzleNode { Input = new ReferenceNode { Value = position }, Swizzle = new[] { Swizzle.X, Swizzle.Y, Swizzle.Z, Swizzle.Null } }, Output = new Vector { Type = Shaders.Type.Float4, Name = "vPosition" }, Mask = new[] { "0", "0", "0", "1" }, IsVerbose = true }; MatrixMultiplyNode mulPosWVP = new MatrixMultiplyNode { Input1 = nV3toV4, Input2 = MatrixMultiplyNode.WorldViewProjection, Output = new Vector { Type = Shaders.Type.Float4, Name = "vSkyBoxPosition", }, }; Result = new PhongVSOutputNode { Position = new SwizzleNode { Input = mulPosWVP, Swizzle = new[] { Swizzle.X, Swizzle.Y, Swizzle.W, Swizzle.W } }, Texture = new ReferenceNode { Value = texture }, Output = OutputStruct }; }
public WireframeVS() { Name = "WireframeVS"; Type = ShaderType.Vertex; KeyPart = new TechniqueKey(vs: VertexShaderFlags.Position | VertexShaderFlags.Normal | VertexShaderFlags.TextureUV | VertexShaderFlags.Barycentric); FeatureLevel = FeatureLevel.VS_4_0_Level_9_1; EnableSeparators = true; InputStruct = VertexPositionNormalBarycentric; OutputStruct = VertexPositionTextureIntensityBarycentricOut; ConstantBuffer cbFrame = CBPerFrame; ConstantBuffer cbInstance = CBPerInstance; Add(cbFrame); Add(cbInstance); IVariable position = InputStruct[Param.SemanticVariables.ObjectPosition]; IVariable lightDirection = cbFrame[Param.Vectors.LightDirection]; IVariable normal = InputStruct[Param.SemanticVariables.Normal]; IVariable texture = InputStruct[Param.SemanticVariables.Texture]; IVariable barycentric = InputStruct[Param.SemanticVariables.Barycentric]; CastNode nV3toV4 = new CastNode { Input = new SwizzleNode { Input = new ReferenceNode { Value = position }, Swizzle = new[] { Swizzle.X, Swizzle.Y, Swizzle.Z, Swizzle.Null } }, Output = new Vector { Type = Shaders.Type.Float4, Name = "vPosition" }, Mask = new[] { "0", "0", "0", "1" }, IsVerbose = true }; MatrixMultiplyNode mulPosWVP = new MatrixMultiplyNode { Input1 = nV3toV4, Input2 = MatrixMultiplyNode.WorldViewProjection, Output = new Vector() { Type = Shaders.Type.Float4, Name = "vClipPosition" }, IsVerbose = true }; MultiplyNode perspectiveCorrection = new MultiplyNode() { Input1 = new ReferenceNode() { Value = barycentric }, Input2 = new SwizzleNode() { Input = mulPosWVP, Swizzle = new Swizzle[] { Swizzle.W, } } }; BinaryFunctionNode dotLightNormal = new BinaryFunctionNode { Input1 = new ReferenceNode { Value = lightDirection }, Input2 = new ReferenceNode { Value = normal }, Function = HlslIntrinsics.Dot }; BinaryFunctionNode maxIntensity = new BinaryFunctionNode { Input1 = dotLightNormal, Input2 = new ScalarNode() { Value = 0.3f }, Function = HlslIntrinsics.Max }; CustomOutputNode outputNode = new CustomOutputNode() { Output = OutputStruct }; outputNode.RegisterField(Vector.ClipPosition, mulPosWVP, Shaders.Type.Float4); outputNode.RegisterField(Param.SemanticVariables.Intensity, Semantics.Intensity, maxIntensity, Shaders.Type.Float3); outputNode.RegisterField(Vector.TextureUV, new ReferenceNode { Value = texture }, Shaders.Type.Float2); outputNode.RegisterField(Param.SemanticVariables.Barycentric, Semantics.Barycentric, perspectiveCorrection, Shaders.Type.Float3); Result = outputNode; }
public PhongInstanceVS() { Name = "PhongInstanceVS"; Type = ShaderType.Vertex; KeyPart = new TechniqueKey(vs: VertexShaderFlags.Position | VertexShaderFlags.Normal | VertexShaderFlags.TextureUV | VertexShaderFlags.InstanceWorld); FeatureLevel = FeatureLevel.VS_4_0_Level_9_3; EnableSeparators = true; var instanceStruct = Struct.VertexPositionNormalTexture; instanceStruct.Add(Matrix.EntityInstanceWorld); InputStruct = instanceStruct; OutputStruct = Struct.VertexPositionNormalTextureOut; Structs.ConstantBuffer cbFrame = ConstantBuffer.CBPerFrame; Add(cbFrame); IVariable position = InputStruct[Param.SemanticVariables.ObjectPosition]; IVariable normal = InputStruct[Param.SemanticVariables.Normal]; IVariable texture = InputStruct[Param.SemanticVariables.Texture]; CastNode nV3toV4 = new CastNode { Input = new SwizzleNode { Input = new ReferenceNode { Value = position }, Swizzle = new[] { Swizzle.X, Swizzle.Y, Swizzle.Z, Swizzle.Null } }, Output = new Vector { Type = Shaders.Type.Float4, Name = "vPosition" }, Mask = new[] { "0", "0", "0", "1" }, IsVerbose = true }; ReferenceNode mWorld = new ReferenceNode { Value = InputStruct[Param.SemanticVariables.InstanceWorld], Output = new Matrix { Type = Shaders.Type.Matrix, Name = "mWorld", }, IsVerbose = true }; MatrixMultiplyNode m1m2 = new MatrixMultiplyNode { Input1 = mWorld, Input2 = new ReferenceNode { Value = Matrix.CameraView }, }; MatrixMultiplyNode mulWVP = new MatrixMultiplyNode { Input1 = m1m2, Input2 = new ReferenceNode { Value = Matrix.CameraProjection }, IsVerbose = true }; MatrixMultiplyNode mulPosWVP = new MatrixMultiplyNode { Input1 = nV3toV4, Input2 = mulWVP, }; MatrixMultiplyNode mulWP = new MatrixMultiplyNode { Input1 = nV3toV4, Input2 = mWorld, }; MatrixMultiplyNode mulNormal = new MatrixMultiplyNode { Input1 = new ReferenceNode { Value = normal }, Input2 = CastNode.CastWorldFloat3x3((Matrix)mWorld.Output, "mWorld3x3") }; Result = new PhongVSOutputNode { Position = mulPosWVP, WorldPosition = mulWP, Normal = mulNormal, Texture = new ReferenceNode { Value = texture }, Output = OutputStruct }; }
public PhongVS() { Name = "PhongVS"; Type = ShaderType.Vertex; KeyPart = new TechniqueKey(vs: VertexShaderFlags.Position | VertexShaderFlags.Normal | VertexShaderFlags.TextureUV); FeatureLevel = FeatureLevel.VS_4_0_Level_9_1; EnableSeparators = true; InputStruct = Struct.VertexPositionNormalTexture; OutputStruct = Struct.VertexPositionNormalTextureOut; Structs.ConstantBuffer cbFrame = ConstantBuffer.CBPerFrame; Structs.ConstantBuffer cbInstance = CBPerInstance; Add(cbFrame); Add(cbInstance); IVariable position = InputStruct[Param.SemanticVariables.ObjectPosition]; IVariable normal = InputStruct[Param.SemanticVariables.Normal]; IVariable texture = InputStruct[Param.SemanticVariables.Texture]; CastNode nV3toV4 = new CastNode { Input = new SwizzleNode { Input = new ReferenceNode { Value = position }, Swizzle = new[] { Swizzle.X, Swizzle.Y, Swizzle.Z, Swizzle.Null } }, Output = new Vector { Type = Shaders.Type.Float4, Name = "vPosition" }, Mask = new[] { "0", "0", "0", "1" }, IsVerbose = true }; MatrixMultiplyNode mulPosWVP = new MatrixMultiplyNode { Input1 = nV3toV4, Input2 = MatrixMultiplyNode.WorldViewProjection, }; MatrixMultiplyNode mulWP = new MatrixMultiplyNode { Input1 = nV3toV4, Input2 = new ReferenceNode { Value = Matrix.EntityWorld }, }; MatrixMultiplyNode mulNormal = new MatrixMultiplyNode { Input1 = new ReferenceNode { Value = normal }, Input2 = CastNode.WorldInverseTransposeFloat3x3 }; Result = new PhongVSOutputNode { Position = mulPosWVP, WorldPosition = mulWP, Normal = mulNormal, Texture = new ReferenceNode { Value = texture }, Output = OutputStruct }; }