Exemplo n.º 1
0
        public SkydomeShader(Device device)
        {
            byte[] skyvsbytes  = File.ReadAllBytes("Shaders\\SkydomeVS.cso");
            byte[] skypsbytes  = File.ReadAllBytes("Shaders\\SkydomePS.cso");
            byte[] sunvsbytes  = File.ReadAllBytes("Shaders\\SkySunVS.cso");
            byte[] sunpsbytes  = File.ReadAllBytes("Shaders\\SkySunPS.cso");
            byte[] moonvsbytes = File.ReadAllBytes("Shaders\\SkyMoonVS.cso");
            byte[] moonpsbytes = File.ReadAllBytes("Shaders\\SkyMoonPS.cso");

            skyvs  = new VertexShader(device, skyvsbytes);
            skyps  = new PixelShader(device, skypsbytes);
            sunvs  = new VertexShader(device, sunvsbytes);
            sunps  = new PixelShader(device, sunpsbytes);
            moonvs = new VertexShader(device, moonvsbytes);
            moonps = new PixelShader(device, moonpsbytes);

            SkyLocalVars = new GpuVarsBuffer <SkydomeShaderSkySystemLocals>(device);
            VSSceneVars  = new GpuVarsBuffer <SkydomeShaderVSSceneVars>(device);
            VSEntityVars = new GpuVarsBuffer <SkydomeShaderVSEntityVars>(device);
            VSModelVars  = new GpuVarsBuffer <SkydomeShaderVSModelVars>(device);
            PSSceneVars  = new GpuVarsBuffer <SkydomeShaderPSSceneVars>(device);

            VSSunMoonVars = new GpuVarsBuffer <SkydomeShaderVSSunMoonVars>(device);
            PSSunMoonVars = new GpuVarsBuffer <SkydomeShaderPSSunMoonVars>(device);

            sundisc   = new UnitDisc(device, 30, true);
            sunlayout = new InputLayout(device, sunvsbytes, sundisc.GetLayout());
            skylayout = new InputLayout(device, skyvsbytes, VertexTypeGTAV.GetLayout(VertexType.PTT));

            moonquad   = new UnitQuad(device, true);
            moonlayout = new InputLayout(device, moonvsbytes, moonquad.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,
            });
        }
Exemplo n.º 2
0
        public CloudsShader(Device device)
        {
            byte[] vsbytes = File.ReadAllBytes("Shaders\\CloudsVS.cso");
            byte[] psbytes = File.ReadAllBytes("Shaders\\CloudsPS.cso");

            vs = new VertexShader(device, vsbytes);
            ps = new PixelShader(device, psbytes);

            CloudsLocalVars = new GpuVarsBuffer <CloudsShaderCloudsLocals>(device);
            VSSceneVars     = new GpuVarsBuffer <CloudsShaderVSSceneVars>(device);
            VSEntityVars    = new GpuVarsBuffer <CloudsShaderVSEntityVars>(device);
            VSModelVars     = new GpuVarsBuffer <CloudsShaderVSModelVars>(device);
            PSSceneVars     = new GpuVarsBuffer <CloudsShaderPSSceneVars>(device);

            layout = new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.DefaultEx));

            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,
            });
        }
Exemplo n.º 3
0
        public CableShader(Device device)
        {
            byte[] vsbytes    = File.ReadAllBytes("Shaders\\CableVS.cso");
            byte[] psbytes    = File.ReadAllBytes("Shaders\\CablePS.cso");
            byte[] psdefbytes = File.ReadAllBytes("Shaders\\CablePS_Deferred.cso");

            vs    = new VertexShader(device, vsbytes);
            ps    = new PixelShader(device, psbytes);
            psdef = new PixelShader(device, psdefbytes);


            VSSceneVars  = new GpuVarsBuffer <CableShaderVSSceneVars>(device);
            VSEntityVars = new GpuVarsBuffer <CableShaderVSEntityVars>(device);
            VSModelVars  = new GpuVarsBuffer <CableShaderVSModelVars>(device);
            VSGeomVars   = new GpuVarsBuffer <CableShaderVSGeomVars>(device);
            PSSceneVars  = new GpuVarsBuffer <CableShaderPSSceneVars>(device);
            PSGeomVars   = new GpuVarsBuffer <CableShaderPSGeomVars>(device);


            //supported layout - requires Position, Normal, Colour, Texcoord
            layouts.Add(VertexType.Default, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.Default)));



            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,
            });
        }
Exemplo n.º 4
0
        GpuCBuffer <VertexTypePC> vertices; //for selection polys/lines use


        public PathShader(Device device)
        {
            byte[] boxvsbytes = File.ReadAllBytes("Shaders\\PathBoxVS.cso");
            byte[] boxpsbytes = File.ReadAllBytes("Shaders\\PathBoxPS.cso");
            byte[] dynvsbytes = File.ReadAllBytes("Shaders\\PathDynVS.cso");
            byte[] vsbytes    = File.ReadAllBytes("Shaders\\PathVS.cso");
            byte[] psbytes    = File.ReadAllBytes("Shaders\\PathPS.cso");


            boxvs = new VertexShader(device, boxvsbytes);
            boxps = new PixelShader(device, boxpsbytes);
            dynvs = new VertexShader(device, dynvsbytes);
            vs    = new VertexShader(device, vsbytes);
            ps    = new PixelShader(device, psbytes);

            VSSceneVars = new GpuVarsBuffer <PathShaderVSSceneVars>(device);

            layout = new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PC));

            cube = new UnitCube(device, boxvsbytes, true, false, true);

            vertices = new GpuCBuffer <VertexTypePC>(device, 1000); //should be more than needed....
        }
Exemplo n.º 5
0
        public TreesLodShader(Device device)
        {
            byte[] vsbytes    = File.ReadAllBytes("Shaders\\TreesLodVS.cso");
            byte[] psbytes    = File.ReadAllBytes("Shaders\\TreesLodPS.cso");
            byte[] psdefbytes = File.ReadAllBytes("Shaders\\TreesLodPS_Deferred.cso");

            vs    = new VertexShader(device, vsbytes);
            ps    = new PixelShader(device, psbytes);
            psdef = new PixelShader(device, psdefbytes);

            VSSceneVars  = new GpuVarsBuffer <TreesLodShaderVSSceneVars>(device);
            VSEntityVars = new GpuVarsBuffer <TreesLodShaderVSEntityVars>(device);
            VSModelVars  = new GpuVarsBuffer <TreesLodShaderVSModelVars>(device);
            VSGeomVars   = new GpuVarsBuffer <TreesLodShaderVSGeometryVars>(device);
            PSSceneVars  = new GpuVarsBuffer <TreesLodShaderPSSceneVars>(device);
            PSEntityVars = new GpuVarsBuffer <TreesLodShaderPSEntityVars>(device);

            //layouts.Add(VertexType.PNCCT, new InputLayout(device, vsbytes, VertexTypePNCCT.GetLayout()));
            layouts.Add(VertexType.PNCCTTTT, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTTTT)));



            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,
            });
        }
Exemplo n.º 6
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;
            }
        }
Exemplo n.º 7
0
        public TerrainShader(Device device)
        {
            byte[] vspncct    = File.ReadAllBytes("Shaders\\TerrainVS_PNCCT.cso");
            byte[] vspncctt   = File.ReadAllBytes("Shaders\\TerrainVS_PNCCTT.cso");
            byte[] vspnccttx  = File.ReadAllBytes("Shaders\\TerrainVS_PNCCTTX.cso");
            byte[] vspncctttx = File.ReadAllBytes("Shaders\\TerrainVS_PNCCTTTX.cso");
            byte[] vspncctx   = File.ReadAllBytes("Shaders\\TerrainVS_PNCCTX.cso");
            byte[] vspnctttx  = File.ReadAllBytes("Shaders\\TerrainVS_PNCTTTX.cso");
            byte[] vspncttx   = File.ReadAllBytes("Shaders\\TerrainVS_PNCTTX.cso");
            byte[] psbytes    = File.ReadAllBytes("Shaders\\TerrainPS.cso");
            byte[] psdefbytes = File.ReadAllBytes("Shaders\\TerrainPS_Deferred.cso");

            pncctvs      = new VertexShader(device, vspncct);
            pnccttvs     = new VertexShader(device, vspncctt);
            pnccttxvs    = new VertexShader(device, vspnccttx);
            pncctttxvs   = new VertexShader(device, vspncctttx);
            pncctxvs     = new VertexShader(device, vspncctx);
            pnctttxvs    = new VertexShader(device, vspnctttx);
            pncttxvs     = new VertexShader(device, vspncttx);
            terrainps    = new PixelShader(device, psbytes);
            terrainpsdef = new PixelShader(device, psdefbytes);

            VSSceneVars  = new GpuVarsBuffer <TerrainShaderVSSceneVars>(device);
            VSEntityVars = new GpuVarsBuffer <TerrainShaderVSEntityVars>(device);
            VSModelVars  = new GpuVarsBuffer <TerrainShaderVSModelVars>(device);
            VSGeomVars   = new GpuVarsBuffer <TerrainShaderVSGeomVars>(device);
            PSSceneVars  = new GpuVarsBuffer <TerrainShaderPSSceneVars>(device);
            PSGeomVars   = new GpuVarsBuffer <TerrainShaderPSGeomVars>(device);

            //supported layouts - requires Position, Normal, Colour, Texcoord
            layouts.Add(VertexType.PNCCT, new InputLayout(device, vspncct, VertexTypeGTAV.GetLayout(VertexType.PNCCT)));
            layouts.Add(VertexType.PNCCTT, new InputLayout(device, vspncctt, VertexTypeGTAV.GetLayout(VertexType.PNCCTT)));
            layouts.Add(VertexType.PNCTTX, new InputLayout(device, vspncttx, VertexTypeGTAV.GetLayout(VertexType.PNCTTX)));
            layouts.Add(VertexType.PNCTTTX_3, new InputLayout(device, vspnctttx, VertexTypeGTAV.GetLayout(VertexType.PNCTTTX_3)));
            layouts.Add(VertexType.PNCCTX, new InputLayout(device, vspncctx, VertexTypeGTAV.GetLayout(VertexType.PNCCTX)));
            layouts.Add(VertexType.PNCCTTX, new InputLayout(device, vspnccttx, VertexTypeGTAV.GetLayout(VertexType.PNCCTTX)));
            layouts.Add(VertexType.PNCCTTX_2, new InputLayout(device, vspnccttx, VertexTypeGTAV.GetLayout(VertexType.PNCCTTX_2)));
            layouts.Add(VertexType.PNCCTTTX, new InputLayout(device, vspncctttx, VertexTypeGTAV.GetLayout(VertexType.PNCCTTTX)));



            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.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,
            });
        }
Exemplo n.º 8
0
        //check dt1_21_reflproxy and dt1_05_reflproxy


        public WaterShader(Device device)
        {
            byte[] vsptbytes    = File.ReadAllBytes("Shaders\\WaterVS_PT.cso");
            byte[] vspctbytes   = File.ReadAllBytes("Shaders\\WaterVS_PCT.cso");
            byte[] vspnctbytes  = File.ReadAllBytes("Shaders\\WaterVS_PNCT.cso");
            byte[] vspnctxbytes = File.ReadAllBytes("Shaders\\WaterVS_PNCTX.cso");
            byte[] psbytes      = File.ReadAllBytes("Shaders\\WaterPS.cso");
            byte[] psdefbytes   = File.ReadAllBytes("Shaders\\WaterPS_Deferred.cso");


            vspt    = new VertexShader(device, vsptbytes);
            vspct   = new VertexShader(device, vspctbytes);
            vspnct  = new VertexShader(device, vspnctbytes);
            vspnctx = new VertexShader(device, vspnctxbytes);
            ps      = new PixelShader(device, psbytes);
            psdef   = new PixelShader(device, psdefbytes);

            VSSceneVars  = new GpuVarsBuffer <WaterShaderVSSceneVars>(device);
            VSEntityVars = new GpuVarsBuffer <WaterShaderVSEntityVars>(device);
            VSGeomVars   = new GpuVarsBuffer <WaterShaderVSGeomVars>(device);
            PSSceneVars  = new GpuVarsBuffer <WaterShaderPSSceneVars>(device);
            PSGeomVars   = new GpuVarsBuffer <WaterShaderPSGeomVars>(device);

            layouts.Add(VertexType.PT, new InputLayout(device, vsptbytes, VertexTypeGTAV.GetLayout(VertexType.PT)));
            layouts.Add(VertexType.PCT, new InputLayout(device, vspctbytes, VertexTypeGTAV.GetLayout(VertexType.PCT)));
            layouts.Add(VertexType.Default, new InputLayout(device, vspnctbytes, VertexTypeGTAV.GetLayout(VertexType.Default)));
            layouts.Add(VertexType.DefaultEx, new InputLayout(device, vspnctxbytes, VertexTypeGTAV.GetLayout(VertexType.DefaultEx)));

            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,
            });
            texsamplerflow = 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,
            });
        }
Exemplo n.º 9
0
        public ShadowShader(Device device)
        {
            byte[] vsbytes  = File.ReadAllBytes("Shaders\\ShadowVS.cso");
            byte[] vssbytes = File.ReadAllBytes("Shaders\\ShadowVS_Skin.cso");
            byte[] psbytes  = File.ReadAllBytes("Shaders\\ShadowPS.cso");

            shadowvs      = new VertexShader(device, vsbytes);
            shadowvs_skin = new VertexShader(device, vssbytes);
            shadowps      = new PixelShader(device, psbytes);


            VSSceneVars   = new GpuVarsBuffer <ShadowShaderVSSceneVars>(device);
            VSEntityVars  = new GpuVarsBuffer <ShadowShaderVSEntityVars>(device);
            VSModelVars   = new GpuVarsBuffer <ShadowShaderVSModelVars>(device);
            GeomVars      = new GpuVarsBuffer <ShadowShaderGeomVars>(device);
            BoneMatrices  = new GpuABuffer <Matrix3_s>(device, 255);
            ClothVertices = new GpuABuffer <Vector4>(device, 254);


            //supported layouts - requires Position, Normal, Colour, Texcoord
            layouts.Add(VertexType.Default, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.Default)));
            layouts.Add(VertexType.DefaultEx, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.DefaultEx)));
            layouts.Add(VertexType.PNCCT, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCT)));
            layouts.Add(VertexType.PNCCTTTT, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTTTT)));
            layouts.Add(VertexType.PNCTTTX, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTTTX)));
            layouts.Add(VertexType.PNCTTTX_2, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTTTX_2)));
            layouts.Add(VertexType.PNCTTTX_3, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTTTX_3)));
            layouts.Add(VertexType.PNCTTTTX, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTTTTX)));
            layouts.Add(VertexType.PNCTTX, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTTX)));
            layouts.Add(VertexType.PNCCTTX, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTTX)));
            layouts.Add(VertexType.PNCCTTX_2, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTTX_2)));
            layouts.Add(VertexType.PNCCTTTX, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTTTX)));
            layouts.Add(VertexType.PNCCTT, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTT)));
            layouts.Add(VertexType.PNCCTX, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCCTX)));
            layouts.Add(VertexType.PNCH2, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCH2, VertexDeclarationTypes.Types3)));
            layouts.Add(VertexType.PCCH2H4, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PCCH2H4, VertexDeclarationTypes.Types2)));
            layouts.Add(VertexType.PNCTT, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTT)));
            layouts.Add(VertexType.PNCTTT, new InputLayout(device, vsbytes, VertexTypeGTAV.GetLayout(VertexType.PNCTTT)));

            layouts.Add(VertexType.PBBNCT, new InputLayout(device, vssbytes, VertexTypeGTAV.GetLayout(VertexType.PBBNCT)));
            layouts.Add(VertexType.PBBNCTX, new InputLayout(device, vssbytes, VertexTypeGTAV.GetLayout(VertexType.PBBNCTX)));
            layouts.Add(VertexType.PBBNCTT, new InputLayout(device, vssbytes, VertexTypeGTAV.GetLayout(VertexType.PBBNCTT)));
            layouts.Add(VertexType.PBBNCTTT, new InputLayout(device, vssbytes, VertexTypeGTAV.GetLayout(VertexType.PBBNCTTT)));
            layouts.Add(VertexType.PBBNCCT, new InputLayout(device, vssbytes, VertexTypeGTAV.GetLayout(VertexType.PBBNCCT)));
            layouts.Add(VertexType.PBBNCCTT, new InputLayout(device, vssbytes, VertexTypeGTAV.GetLayout(VertexType.PBBNCCTT)));//TODO
            layouts.Add(VertexType.PBBNCCTX, new InputLayout(device, vssbytes, VertexTypeGTAV.GetLayout(VertexType.PBBNCCTX)));
            layouts.Add(VertexType.PBBNCTTX, new InputLayout(device, vssbytes, VertexTypeGTAV.GetLayout(VertexType.PBBNCTTX)));
            layouts.Add(VertexType.PBBNCTTTX, new InputLayout(device, vssbytes, VertexTypeGTAV.GetLayout(VertexType.PBBNCTTTX))); //TODO
            layouts.Add(VertexType.PBBNCCTTX, new InputLayout(device, vssbytes, VertexTypeGTAV.GetLayout(VertexType.PBBNCCTTX))); //TODO
            //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,
            });
            texsamplerc = new SamplerState(device, new SamplerStateDescription()
            {
                AddressU           = TextureAddressMode.Clamp,
                AddressV           = TextureAddressMode.Clamp,
                AddressW           = TextureAddressMode.Clamp,
                BorderColor        = Color.Black,
                ComparisonFunction = Comparison.Always,
                Filter             = Filter.MinMagMipPoint,
                MaximumAnisotropy  = 1,
                MaximumLod         = float.MaxValue,
                MinimumLod         = 0,
                MipLodBias         = 0,
            });



            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;
            }
        }