Example #1
0
        public BasicShader(Device device)
        {
            byte[] vspnctbytes     = File.ReadAllBytes("Shaders\\BasicVS_PNCT.cso");
            byte[] vspncttbytes    = File.ReadAllBytes("Shaders\\BasicVS_PNCTT.cso");
            byte[] vspncctbytes    = File.ReadAllBytes("Shaders\\BasicVS_PNCCT.cso");
            byte[] vspnccttbytes   = File.ReadAllBytes("Shaders\\BasicVS_PNCCTT.cso");
            byte[] vspncctttbytes  = File.ReadAllBytes("Shaders\\BasicVS_PNCCTTT.cso");
            byte[] vspnctxbytes    = File.ReadAllBytes("Shaders\\BasicVS_PNCTX.cso");
            byte[] vspncctxbytes   = File.ReadAllBytes("Shaders\\BasicVS_PNCCTX.cso");
            byte[] vspncttxbytes   = File.ReadAllBytes("Shaders\\BasicVS_PNCTTX.cso");
            byte[] vspnccttxbytes  = File.ReadAllBytes("Shaders\\BasicVS_PNCCTTX.cso");
            byte[] vspnctttxbytes  = File.ReadAllBytes("Shaders\\BasicVS_PNCTTTX.cso");
            byte[] vspncctttxbytes = File.ReadAllBytes("Shaders\\BasicVS_PNCCTTTX.cso");
            byte[] vsboxbytes      = File.ReadAllBytes("Shaders\\BasicVS_Box.cso");
            byte[] vsspherebytes   = File.ReadAllBytes("Shaders\\BasicVS_Sphere.cso");
            byte[] vscapsulebytes  = File.ReadAllBytes("Shaders\\BasicVS_Capsule.cso");
            byte[] vscylinderbytes = File.ReadAllBytes("Shaders\\BasicVS_Cylinder.cso");
            byte[] psbytes         = File.ReadAllBytes("Shaders\\BasicPS.cso");

            basicvspnct     = new VertexShader(device, vspnctbytes);
            basicvspnctt    = new VertexShader(device, vspncttbytes);
            basicvspncct    = new VertexShader(device, vspncctbytes);
            basicvspncctt   = new VertexShader(device, vspnccttbytes);
            basicvspnccttt  = new VertexShader(device, vspncctttbytes);
            basicvspnctx    = new VertexShader(device, vspnctxbytes);
            basicvspncctx   = new VertexShader(device, vspncctxbytes);
            basicvspncttx   = new VertexShader(device, vspncttxbytes);
            basicvspnccttx  = new VertexShader(device, vspnccttxbytes);
            basicvspnctttx  = new VertexShader(device, vspnctttxbytes);
            basicvspncctttx = new VertexShader(device, vspncctttxbytes);
            basicvsbox      = new VertexShader(device, vsboxbytes);
            basicvssphere   = new VertexShader(device, vsspherebytes);
            basicvscapsule  = new VertexShader(device, vscapsulebytes);
            basicvscylinder = new VertexShader(device, vscylinderbytes);
            basicps         = new PixelShader(device, psbytes);

            VSSceneVars    = new GpuVarsBuffer <BasicShaderVSSceneVars>(device);
            VSEntityVars   = new GpuVarsBuffer <BasicShaderVSEntityVars>(device);
            VSModelVars    = new GpuVarsBuffer <BasicShaderVSModelVars>(device);
            VSGeomVars     = new GpuVarsBuffer <BasicShaderVSGeomVars>(device);
            PSSceneVars    = new GpuVarsBuffer <BasicShaderPSSceneVars>(device);
            PSGeomVars     = new GpuVarsBuffer <BasicShaderPSGeomVars>(device);
            InstGlobalVars = new GpuVarsBuffer <BasicShaderInstGlobals>(device);
            InstLocalVars  = new GpuVarsBuffer <BasicShaderInstLocals>(device);

            InitInstGlobalVars();


            //supported layouts - requires Position, Normal, Colour, Texcoord
            layouts.Add(VertexType.Default, new InputLayout(device, vspnctbytes, VertexTypeDefault.GetLayout()));
            layouts.Add(VertexType.PNCH2, new InputLayout(device, vspnctbytes, VertexTypePNCH2.GetLayout()));
            layouts.Add(VertexType.PBBNCT, new InputLayout(device, vspnctbytes, VertexTypePBBNCT.GetLayout()));

            layouts.Add(VertexType.PNCTT, new InputLayout(device, vspncttbytes, VertexTypePNCTT.GetLayout()));
            layouts.Add(VertexType.PNCTTT, new InputLayout(device, vspncttbytes, VertexTypePNCTTT.GetLayout()));
            layouts.Add(VertexType.PBBNCTT, new InputLayout(device, vspncttbytes, VertexTypePBBNCTT.GetLayout()));
            layouts.Add(VertexType.PBBNCTTT, new InputLayout(device, vspncttbytes, VertexTypePBBNCTTT.GetLayout()));

            layouts.Add(VertexType.PNCCT, new InputLayout(device, vspncctbytes, VertexTypePNCCT.GetLayout()));
            layouts.Add(VertexType.PBBNCCT, new InputLayout(device, vspncctbytes, VertexTypePBBNCCT.GetLayout()));

            layouts.Add(VertexType.PNCCTT, new InputLayout(device, vspnccttbytes, VertexTypePNCCTT.GetLayout()));

            layouts.Add(VertexType.PNCCTTTT, new InputLayout(device, vspncctttbytes, VertexTypePNCCTTTT.GetLayout()));



            //normalmap layouts - requires Position, Normal, Colour, Texcoord, Tangent (X)
            layouts.Add(VertexType.DefaultEx, new InputLayout(device, vspnctxbytes, VertexTypeDefaultEx.GetLayout()));
            layouts.Add(VertexType.PCCH2H4, new InputLayout(device, vspnctxbytes, VertexTypePCCH2H4.GetLayout()));
            layouts.Add(VertexType.PBBNCTX, new InputLayout(device, vspnctxbytes, VertexTypePBBNCTX.GetLayout()));

            layouts.Add(VertexType.PNCCTX, new InputLayout(device, vspncctxbytes, VertexTypePNCCTX.GetLayout()));
            layouts.Add(VertexType.PBBNCCTX, new InputLayout(device, vspncctxbytes, VertexTypePBBNCCTX.GetLayout()));

            layouts.Add(VertexType.PNCTTX, new InputLayout(device, vspncttxbytes, VertexTypePNCTTX.GetLayout()));
            layouts.Add(VertexType.PBBNCTTX, new InputLayout(device, vspncttxbytes, VertexTypePBBNCTTX.GetLayout()));
            layouts.Add(VertexType.PBBNCTTTX, new InputLayout(device, vspncttxbytes, VertexTypePBBNCTTTX.GetLayout()));

            layouts.Add(VertexType.PNCCTTX, new InputLayout(device, vspnccttxbytes, VertexTypePNCCTTX.GetLayout()));
            layouts.Add(VertexType.PNCCTTX_2, new InputLayout(device, vspnccttxbytes, VertexTypePNCCTTX_2.GetLayout()));
            layouts.Add(VertexType.PNCTTTX, new InputLayout(device, vspnctttxbytes, VertexTypePNCTTTX.GetLayout()));
            layouts.Add(VertexType.PNCTTTX_2, new InputLayout(device, vspnctttxbytes, VertexTypePNCTTTX_2.GetLayout()));
            layouts.Add(VertexType.PNCTTTX_3, new InputLayout(device, vspnctttxbytes, VertexTypePNCTTTX_3.GetLayout()));
            layouts.Add(VertexType.PNCTTTTX, new InputLayout(device, vspnctttxbytes, VertexTypePNCTTTTX.GetLayout()));
            layouts.Add(VertexType.PNCCTTTX, new InputLayout(device, vspncctttxbytes, VertexTypePNCCTTTX.GetLayout()));
            layouts.Add(VertexType.PBBNCCTTX, new InputLayout(device, vspnccttxbytes, VertexTypePBBNCCTTX.GetLayout()));



            texsampler = new SamplerState(device, new SamplerStateDescription()
            {
                AddressU           = TextureAddressMode.Wrap,
                AddressV           = TextureAddressMode.Wrap,
                AddressW           = TextureAddressMode.Wrap,
                BorderColor        = Color.Black,
                ComparisonFunction = Comparison.Always,
                Filter             = Filter.MinMagMipLinear,
                MaximumAnisotropy  = 1,
                MaximumLod         = float.MaxValue,
                MinimumLod         = 0,
                MipLodBias         = 0,
            });
            texsampleranis = new SamplerState(device, new SamplerStateDescription()
            {
                AddressU           = TextureAddressMode.Wrap,
                AddressV           = TextureAddressMode.Wrap,
                AddressW           = TextureAddressMode.Wrap,
                BorderColor        = Color.Black,
                ComparisonFunction = Comparison.Always,
                Filter             = Filter.Anisotropic,
                MaximumAnisotropy  = 8,
                MaximumLod         = float.MaxValue,
                MinimumLod         = 0,
                MipLodBias         = 0,
            });
            texsamplertnt = new SamplerState(device, new SamplerStateDescription()
            {
                AddressU           = TextureAddressMode.Clamp,
                AddressV           = TextureAddressMode.Wrap,
                AddressW           = TextureAddressMode.Wrap,
                BorderColor        = Color.White,
                ComparisonFunction = Comparison.Always,
                Filter             = Filter.MinMagMipPoint,
                MaximumAnisotropy  = 1,
                MaximumLod         = float.MaxValue,
                MinimumLod         = 0,
                MipLodBias         = 0,
            });
            texsamplertntyft = new SamplerState(device, new SamplerStateDescription()
            {
                AddressU           = TextureAddressMode.Wrap,
                AddressV           = TextureAddressMode.Wrap,
                AddressW           = TextureAddressMode.Wrap,
                BorderColor        = Color.White,
                ComparisonFunction = Comparison.Always,
                Filter             = Filter.MinMagMipPoint,
                MaximumAnisotropy  = 1,
                MaximumLod         = float.MaxValue,
                MinimumLod         = 0,
                MipLodBias         = 0,
            });


            cube     = new UnitCube(device, vsboxbytes, false, false, true);
            sphere   = new UnitSphere(device, vsspherebytes, 4);
            capsule  = new UnitCapsule(device, vscapsulebytes, 4);
            cylinder = new UnitCylinder(device, vscylinderbytes, 8);
        }
Example #2
0
        public void Dispose()
        {
            DisposeBuffers();

            if (BlendState != null)
            {
                BlendState.Dispose();
                BlendState = null;
            }
            if (SampleStateLinear != null)
            {
                SampleStateLinear.Dispose();
                SampleStateLinear = null;
            }
            if (SampleStatePoint != null)
            {
                SampleStatePoint.Dispose();
                SampleStatePoint = null;
            }
            if (LightVSVars != null)
            {
                LightVSVars.Dispose();
                LightVSVars = null;
            }
            if (LightPSVars != null)
            {
                LightPSVars.Dispose();
                LightPSVars = null;
            }
            if (LightInstVars != null)
            {
                LightInstVars.Dispose();
                LightInstVars = null;
            }
            if (LightQuadLayout != null)
            {
                LightQuadLayout.Dispose();
                LightQuadLayout = null;
            }
            if (LightQuad != null)
            {
                LightQuad.Dispose();
                LightQuad = null;
            }
            if (LightCone != null)
            {
                LightCone.Dispose();
                LightCone = null;
            }
            if (LightSphere != null)
            {
                LightSphere.Dispose();
                LightSphere = null;
            }
            if (LightCapsule != null)
            {
                LightCapsule.Dispose();
                LightCapsule = null;
            }
            if (DirLightPS != null)
            {
                DirLightPS.Dispose();
                DirLightPS = null;
            }
            if (DirLightMSPS != null)
            {
                DirLightMSPS.Dispose();
                DirLightMSPS = null;
            }
            if (DirLightVS != null)
            {
                DirLightVS.Dispose();
                DirLightVS = null;
            }
            if (LodLightPS != null)
            {
                LodLightPS.Dispose();
                LodLightPS = null;
            }
            if (LodLightMSPS != null)
            {
                LodLightMSPS.Dispose();
                LodLightMSPS = null;
            }
            if (LodLightVS != null)
            {
                LodLightVS.Dispose();
                LodLightVS = null;
            }
            if (LightPS != null)
            {
                LightPS.Dispose();
                LightPS = null;
            }
            if (LightMSPS != null)
            {
                LightMSPS.Dispose();
                LightMSPS = null;
            }
            if (LightVS != null)
            {
                LightVS.Dispose();
                LightVS = null;
            }
            if (SSAAPSVars != null)
            {
                SSAAPSVars.Dispose();
                SSAAPSVars = null;
            }
            if (SSAAPS != null)
            {
                SSAAPS.Dispose();
                SSAAPS = null;
            }
            if (FinalVS != null)
            {
                FinalVS.Dispose();
                FinalVS = null;
            }
        }
Example #3
0
        public BasicShader(Device device)
        {
            byte[] vspnctbytes     = File.ReadAllBytes("Shaders\\BasicVS_PNCT.cso");
            byte[] vspncttbytes    = File.ReadAllBytes("Shaders\\BasicVS_PNCTT.cso");
            byte[] vspnctttbytes   = File.ReadAllBytes("Shaders\\BasicVS_PNCTTT.cso");
            byte[] vspncctbytes    = File.ReadAllBytes("Shaders\\BasicVS_PNCCT.cso");
            byte[] vspnccttbytes   = File.ReadAllBytes("Shaders\\BasicVS_PNCCTT.cso");
            byte[] vspncctttbytes  = File.ReadAllBytes("Shaders\\BasicVS_PNCCTTT.cso");
            byte[] vspnctxbytes    = File.ReadAllBytes("Shaders\\BasicVS_PNCTX.cso");
            byte[] vspncctxbytes   = File.ReadAllBytes("Shaders\\BasicVS_PNCCTX.cso");
            byte[] vspncttxbytes   = File.ReadAllBytes("Shaders\\BasicVS_PNCTTX.cso");
            byte[] vspnccttxbytes  = File.ReadAllBytes("Shaders\\BasicVS_PNCCTTX.cso");
            byte[] vspnctttxbytes  = File.ReadAllBytes("Shaders\\BasicVS_PNCTTTX.cso");
            byte[] vspncctttxbytes = File.ReadAllBytes("Shaders\\BasicVS_PNCCTTTX.cso");

            byte[] vspbbnctbytes    = File.ReadAllBytes("Shaders\\BasicVS_PBBNCT.cso");
            byte[] vspbbnctxbytes   = File.ReadAllBytes("Shaders\\BasicVS_PBBNCTX.cso");
            byte[] vspbbncttbytes   = File.ReadAllBytes("Shaders\\BasicVS_PBBNCTT.cso");
            byte[] vspbbnctttbytes  = File.ReadAllBytes("Shaders\\BasicVS_PBBNCTTT.cso");
            byte[] vspbbncctbytes   = File.ReadAllBytes("Shaders\\BasicVS_PBBNCCT.cso");
            byte[] vspbbncctxbytes  = File.ReadAllBytes("Shaders\\BasicVS_PBBNCCTX.cso");
            byte[] vspbbnccttxbytes = File.ReadAllBytes("Shaders\\BasicVS_PBBNCCTTX.cso");
            byte[] vspbbncttxbytes  = File.ReadAllBytes("Shaders\\BasicVS_PBBNCTTX.cso");

            byte[] vsboxbytes      = File.ReadAllBytes("Shaders\\BasicVS_Box.cso");
            byte[] vsspherebytes   = File.ReadAllBytes("Shaders\\BasicVS_Sphere.cso");
            byte[] vscapsulebytes  = File.ReadAllBytes("Shaders\\BasicVS_Capsule.cso");
            byte[] vscylinderbytes = File.ReadAllBytes("Shaders\\BasicVS_Cylinder.cso");
            byte[] psbytes         = File.ReadAllBytes("Shaders\\BasicPS.cso");
            byte[] psdefbytes      = File.ReadAllBytes("Shaders\\BasicPS_Deferred.cso");

            basicvspnct      = new VertexShader(device, vspnctbytes);
            basicvspnctt     = new VertexShader(device, vspncttbytes);
            basicvspncttt    = new VertexShader(device, vspnctttbytes);
            basicvspncct     = new VertexShader(device, vspncctbytes);
            basicvspncctt    = new VertexShader(device, vspnccttbytes);
            basicvspnccttt   = new VertexShader(device, vspncctttbytes);
            basicvspnctx     = new VertexShader(device, vspnctxbytes);
            basicvspncctx    = new VertexShader(device, vspncctxbytes);
            basicvspncttx    = new VertexShader(device, vspncttxbytes);
            basicvspnccttx   = new VertexShader(device, vspnccttxbytes);
            basicvspnctttx   = new VertexShader(device, vspnctttxbytes);
            basicvspncctttx  = new VertexShader(device, vspncctttxbytes);
            basicvspbbnct    = new VertexShader(device, vspbbnctbytes);
            basicvspbbnctx   = new VertexShader(device, vspbbnctxbytes);
            basicvspbbnctt   = new VertexShader(device, vspbbncttbytes);
            basicvspbbncttt  = new VertexShader(device, vspbbnctttbytes);
            basicvspbbncct   = new VertexShader(device, vspbbncctbytes);
            basicvspbbncctx  = new VertexShader(device, vspbbncctxbytes);
            basicvspbbnccttx = new VertexShader(device, vspbbnccttxbytes);
            basicvspbbncttx  = new VertexShader(device, vspbbncttxbytes);
            basicvsbox       = new VertexShader(device, vsboxbytes);
            basicvssphere    = new VertexShader(device, vsspherebytes);
            basicvscapsule   = new VertexShader(device, vscapsulebytes);
            basicvscylinder  = new VertexShader(device, vscylinderbytes);
            basicps          = new PixelShader(device, psbytes);
            basicpsdef       = new PixelShader(device, psdefbytes);

            VSSceneVars    = new GpuVarsBuffer <BasicShaderVSSceneVars>(device);
            VSEntityVars   = new GpuVarsBuffer <BasicShaderVSEntityVars>(device);
            VSModelVars    = new GpuVarsBuffer <BasicShaderVSModelVars>(device);
            VSGeomVars     = new GpuVarsBuffer <BasicShaderVSGeomVars>(device);
            PSSceneVars    = new GpuVarsBuffer <BasicShaderPSSceneVars>(device);
            PSGeomVars     = new GpuVarsBuffer <BasicShaderPSGeomVars>(device);
            InstGlobalVars = new GpuVarsBuffer <BasicShaderInstGlobals>(device);
            InstLocalVars  = new GpuVarsBuffer <BasicShaderInstLocals>(device);
            BoneMatrices   = new GpuABuffer <Matrix3_s>(device, 255);
            ClothVertices  = new GpuABuffer <Vector4>(device, 254);

            InitInstGlobalVars();


            //supported layouts - requires Position, Normal, Colour, Texcoord
            layouts.Add(VertexType.Default, new InputLayout(device, vspnctbytes, VertexTypeGTAV.GetLayout(VertexType.Default)));
            layouts.Add(VertexType.PNCH2, new InputLayout(device, vspnctbytes, VertexTypeGTAV.GetLayout(VertexType.PNCH2, VertexDeclarationTypes.GTAV3)));//TODO?
            layouts.Add(VertexType.PNCTT, new InputLayout(device, vspncttbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTT)));
            layouts.Add(VertexType.PNCTTT, new InputLayout(device, vspnctttbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTTT)));
            layouts.Add(VertexType.PNCCT, new InputLayout(device, vspncctbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCT)));
            layouts.Add(VertexType.PNCCTT, new InputLayout(device, vspnccttbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTT)));
            layouts.Add(VertexType.PNCCTTTT, new InputLayout(device, vspncctttbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTTTT)));//TODO..?



            //normalmap layouts - requires Position, Normal, Colour, Texcoord, Tangent (X)
            layouts.Add(VertexType.DefaultEx, new InputLayout(device, vspnctxbytes, VertexTypeGTAV.GetLayout(VertexType.DefaultEx)));
            layouts.Add(VertexType.PCCH2H4, new InputLayout(device, vspnctxbytes, VertexTypeGTAV.GetLayout(VertexType.PCCH2H4, VertexDeclarationTypes.GTAV2)));
            layouts.Add(VertexType.PNCCTX, new InputLayout(device, vspncctxbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTX)));
            layouts.Add(VertexType.PNCTTX, new InputLayout(device, vspncttxbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTTX)));
            layouts.Add(VertexType.PNCCTTX, new InputLayout(device, vspnccttxbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTTX)));
            layouts.Add(VertexType.PNCCTTX_2, new InputLayout(device, vspnccttxbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTTX_2)));
            layouts.Add(VertexType.PNCTTTX, new InputLayout(device, vspnctttxbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTTTX)));
            layouts.Add(VertexType.PNCTTTX_2, new InputLayout(device, vspnctttxbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTTTX_2)));
            layouts.Add(VertexType.PNCTTTX_3, new InputLayout(device, vspnctttxbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTTTX_3)));
            layouts.Add(VertexType.PNCTTTTX, new InputLayout(device, vspnctttxbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTTTTX)));//TODO
            layouts.Add(VertexType.PNCCTTTX, new InputLayout(device, vspncctttxbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTTTX)));



            //skinned layouts
            layouts.Add(VertexType.PBBNCT, new InputLayout(device, vspbbnctbytes, VertexTypeGTAV.GetLayout(VertexType.PBBNCT)));
            layouts.Add(VertexType.PBBNCTX, new InputLayout(device, vspbbnctxbytes, VertexTypeGTAV.GetLayout(VertexType.PBBNCTX)));
            layouts.Add(VertexType.PBBNCTT, new InputLayout(device, vspbbncttbytes, VertexTypeGTAV.GetLayout(VertexType.PBBNCTT)));
            layouts.Add(VertexType.PBBNCTTT, new InputLayout(device, vspbbnctttbytes, VertexTypeGTAV.GetLayout(VertexType.PBBNCTTT)));
            layouts.Add(VertexType.PBBNCCT, new InputLayout(device, vspbbncctbytes, VertexTypeGTAV.GetLayout(VertexType.PBBNCCT)));
            layouts.Add(VertexType.PBBNCCTT, new InputLayout(device, vspbbncctbytes, VertexTypeGTAV.GetLayout(VertexType.PBBNCCTT)));//TODO
            layouts.Add(VertexType.PBBNCCTX, new InputLayout(device, vspbbncctxbytes, VertexTypeGTAV.GetLayout(VertexType.PBBNCCTX)));
            layouts.Add(VertexType.PBBNCTTX, new InputLayout(device, vspbbncttxbytes, VertexTypeGTAV.GetLayout(VertexType.PBBNCTTX)));
            layouts.Add(VertexType.PBBNCTTTX, new InputLayout(device, vspbbncttxbytes, VertexTypeGTAV.GetLayout(VertexType.PBBNCTTTX)));//TODO
            layouts.Add(VertexType.PBBNCCTTX, new InputLayout(device, vspbbnccttxbytes, VertexTypeGTAV.GetLayout(VertexType.PBBNCCTTX)));
            //PBBCCT todo
            //PBBNC todo



            texsampler = new SamplerState(device, new SamplerStateDescription()
            {
                AddressU           = TextureAddressMode.Wrap,
                AddressV           = TextureAddressMode.Wrap,
                AddressW           = TextureAddressMode.Wrap,
                BorderColor        = Color.Black,
                ComparisonFunction = Comparison.Always,
                Filter             = Filter.MinMagMipLinear,
                MaximumAnisotropy  = 1,
                MaximumLod         = float.MaxValue,
                MinimumLod         = 0,
                MipLodBias         = 0,
            });
            texsampleranis = new SamplerState(device, new SamplerStateDescription()
            {
                AddressU           = TextureAddressMode.Wrap,
                AddressV           = TextureAddressMode.Wrap,
                AddressW           = TextureAddressMode.Wrap,
                BorderColor        = Color.Black,
                ComparisonFunction = Comparison.Always,
                Filter             = Filter.Anisotropic,
                MaximumAnisotropy  = 8,
                MaximumLod         = float.MaxValue,
                MinimumLod         = 0,
                MipLodBias         = 0,
            });
            texsamplertnt = new SamplerState(device, new SamplerStateDescription()
            {
                AddressU           = TextureAddressMode.Clamp,
                AddressV           = TextureAddressMode.Wrap,
                AddressW           = TextureAddressMode.Wrap,
                BorderColor        = Color.White,
                ComparisonFunction = Comparison.Always,
                Filter             = Filter.MinMagMipPoint,
                MaximumAnisotropy  = 1,
                MaximumLod         = float.MaxValue,
                MinimumLod         = 0,
                MipLodBias         = 0,
            });
            texsamplertntyft = new SamplerState(device, new SamplerStateDescription()
            {
                AddressU           = TextureAddressMode.Wrap,
                AddressV           = TextureAddressMode.Wrap,
                AddressW           = TextureAddressMode.Wrap,
                BorderColor        = Color.White,
                ComparisonFunction = Comparison.Always,
                Filter             = Filter.MinMagMipPoint,
                MaximumAnisotropy  = 1,
                MaximumLod         = float.MaxValue,
                MinimumLod         = 0,
                MipLodBias         = 0,
            });


            cube     = new UnitCube(device, vsboxbytes, false, false, true);
            sphere   = new UnitSphere(device, vsspherebytes, 4);
            capsule  = new UnitCapsule(device, vscapsulebytes, 4);
            cylinder = new UnitCylinder(device, vscylinderbytes, 8);

            defaultBoneMatrices = new Matrix3_s[255];
            for (int i = 0; i < 255; i++)
            {
                defaultBoneMatrices[i].Row1 = Vector4.UnitX;
                defaultBoneMatrices[i].Row2 = Vector4.UnitY;
                defaultBoneMatrices[i].Row3 = Vector4.UnitZ;
            }
        }
Example #4
0
        public DeferredScene(DXManager dxman)
        {
            var device = dxman.device;

            byte[] bDirLightVS   = File.ReadAllBytes("Shaders\\DirLightVS.cso");
            byte[] bDirLightPS   = File.ReadAllBytes("Shaders\\DirLightPS.cso");
            byte[] bDirLightMSPS = File.ReadAllBytes("Shaders\\DirLightPS_MS.cso");
            byte[] bLodLightVS   = File.ReadAllBytes("Shaders\\LodLightsVS.cso");
            byte[] bLodLightPS   = File.ReadAllBytes("Shaders\\LodLightsPS.cso");
            byte[] bLodLightMSPS = File.ReadAllBytes("Shaders\\LodLightsPS_MS.cso");
            byte[] bLightVS      = File.ReadAllBytes("Shaders\\LightVS.cso");
            byte[] bLightPS      = File.ReadAllBytes("Shaders\\LightPS.cso");
            byte[] bLightMSPS    = File.ReadAllBytes("Shaders\\LightPS_MS.cso");
            byte[] bFinalVS      = File.ReadAllBytes("Shaders\\PPFinalPassVS.cso");
            byte[] bSSAAPS       = File.ReadAllBytes("Shaders\\PPSSAAPS.cso");

            DirLightVS = new VertexShader(device, bDirLightVS);
            DirLightPS = new PixelShader(device, bDirLightPS);
            LodLightVS = new VertexShader(device, bLodLightVS);
            LodLightPS = new PixelShader(device, bLodLightPS);
            LightVS    = new VertexShader(device, bLightVS);
            LightPS    = new PixelShader(device, bLightPS);

            try
            {
                //error could happen here if the device isn't supporting feature level 10.1
                DirLightMSPS = new PixelShader(device, bDirLightMSPS);
                LodLightMSPS = new PixelShader(device, bLodLightMSPS);
                LightMSPS    = new PixelShader(device, bLightMSPS);
            }
            catch
            {
                MSAASampleCount = 1; //can't do MSAA without at least 10.1 support
            }


            LightCone       = new UnitCone(device, bLodLightVS, 4, false);
            LightSphere     = new UnitSphere(device, bLodLightVS, 4, true);
            LightCapsule    = new UnitCapsule(device, bLodLightVS, 4, false);
            LightQuad       = new UnitQuad(device, true);
            LightQuadLayout = new InputLayout(device, bDirLightVS, new[]
            {
                new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0),
                new InputElement("TEXCOORD", 0, Format.R32G32_Float, 16, 0),
            });

            LightVSVars   = new GpuVarsBuffer <DeferredLightVSVars>(device);
            LightPSVars   = new GpuVarsBuffer <DeferredLightPSVars>(device);
            LightInstVars = new GpuVarsBuffer <DeferredLightInstVars>(device);


            FinalVS = new VertexShader(device, bFinalVS);
            SSAAPS  = new PixelShader(device, bSSAAPS);

            SSAAPSVars = new GpuVarsBuffer <DeferredSSAAPSVars>(device);

            TextureAddressMode a = TextureAddressMode.Clamp;
            Color4             b = new Color4(0.0f, 0.0f, 0.0f, 0.0f);
            Comparison         c = Comparison.Always;

            SampleStatePoint  = DXUtility.CreateSamplerState(device, a, b, c, Filter.MinMagMipPoint, 0, 1.0f, 1.0f, 0.0f);
            SampleStateLinear = DXUtility.CreateSamplerState(device, a, b, c, Filter.MinMagMipLinear, 0, 1.0f, 1.0f, 0.0f);

            BlendState = DXUtility.CreateBlendState(device, false, BlendOperation.Add, BlendOption.One, BlendOption.Zero, BlendOperation.Add, BlendOption.One, BlendOption.Zero, ColorWriteMaskFlags.All);
        }