Example #1
0
        public TreesLodShader(Device device)
        {
            byte[] vsbytes = File.ReadAllBytes("Shaders\\TreesLodVS.cso");
            byte[] psbytes = File.ReadAllBytes("Shaders\\TreesLodPS.cso");

            basicvs = new VertexShader(device, vsbytes);
            basicps = new PixelShader(device, psbytes);

            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, VertexTypePNCCTTTT.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,
            });
        }
Example #2
0
        public MarkerShader(Device device)
        {
            byte[] vsbytes = File.ReadAllBytes("Shaders\\MarkerVS.cso");
            byte[] psbytes = File.ReadAllBytes("Shaders\\MarkerPS.cso");

            markervs = new VertexShader(device, vsbytes);
            markerps = new PixelShader(device, psbytes);

            VSSceneVars  = new GpuVarsBuffer <MarkerShaderVSSceneVars>(device);
            VSMarkerVars = new GpuVarsBuffer <MarkerShaderVSMarkerVars>(device);

            layout = new InputLayout(device, vsbytes, new[]
            {
                new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0),
                new InputElement("TEXCOORD", 0, Format.R32G32_Float, 16, 0),
            });

            texsampler = new SamplerState(device, new SamplerStateDescription()
            {
                AddressU           = TextureAddressMode.Clamp,
                AddressV           = TextureAddressMode.Clamp,
                AddressW           = TextureAddressMode.Clamp,
                BorderColor        = Color.Transparent,
                ComparisonFunction = Comparison.Always,
                Filter             = Filter.MinMagMipLinear,
                MaximumAnisotropy  = 1,
                MaximumLod         = float.MaxValue,
                MinimumLod         = 0,
                MipLodBias         = 0,
            });
        }
Example #3
0
        public WidgetShader(Device device)
        {
            byte[] vsbytes = File.ReadAllBytes("Shaders\\WidgetVS.cso");
            byte[] psbytes = File.ReadAllBytes("Shaders\\WidgetPS.cso");

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

            SceneVars = new GpuVarsBuffer <WidgetShaderSceneVars>(device);

            Vertices = new GpuCBuffer <WidgetShaderVertex>(device, 150); //should be more than needed....
        }
Example #4
0
        public Shadowmap(Device device)
        {
            TextureSize         = 1024;                                         //todo: make this a setting...
            CascadeCount        = Math.Min(Settings.Default.ShadowCascades, 8); // 6; //use setting
            PCFSize             = 3;
            PCFOffset           = 0.000125f;                                    //0.002f
            BlurBetweenCascades = 0.05f;

            ShadowVars = new GpuVarsBuffer <ShadowmapVars>(device);


            DepthTexture    = DXUtility.CreateTexture2D(device, TextureSize * CascadeCount, TextureSize, 1, 1, Format.R32_Typeless, 1, 0, ResourceUsage.Default, BindFlags.DepthStencil | BindFlags.ShaderResource, 0, 0);
            DepthTextureSS  = DXUtility.CreateSamplerState(device, TextureAddressMode.Border, new Color4(0.0f), Comparison.Less, Filter.ComparisonMinMagLinearMipPoint, 0, 0.0f, 0.0f, 0.0f);
            DepthTextureSRV = DXUtility.CreateShaderResourceView(device, DepthTexture, Format.R32_Float, ShaderResourceViewDimension.Texture2D, 1, 0, 0, 0);
            DepthTextureDSV = DXUtility.CreateDepthStencilView(device, DepthTexture, Format.D32_Float, DepthStencilViewDimension.Texture2D);

            Cascades = new List <ShadowmapCascade>(CascadeCount);
            for (int i = 0; i < CascadeCount; i++)
            {
                ShadowmapCascade c = new ShadowmapCascade();
                c.Owner         = this;
                c.Index         = i;
                c.ZNear         = 0.0f;
                c.ZFar          = 1.0f;
                c.IntervalNear  = 0.0f;
                c.IntervalFar   = 1.0f;
                c.DepthRenderVP = new ViewportF()
                {
                    Height   = (float)TextureSize,
                    Width    = (float)TextureSize,
                    MaxDepth = 1.0f,
                    MinDepth = 0.0f,
                    X        = (float)(TextureSize * i),
                    Y        = 0,
                };
                Cascades.Add(c);
            }

            DepthRenderRS = DXUtility.CreateRasterizerState(device, FillMode.Solid, CullMode.None, true, false, true, 0, 0.0f, 1.0f);
            DepthRenderDS = DXUtility.CreateDepthStencilState(device, true, DepthWriteMask.All);

            DepthRenderVP          = new ViewportF();
            DepthRenderVP.Height   = (float)TextureSize;
            DepthRenderVP.Width    = (float)TextureSize;
            DepthRenderVP.MaxDepth = 1.0f;
            DepthRenderVP.MinDepth = 0.0f;
            DepthRenderVP.X        = 0;
            DepthRenderVP.Y        = 0;

            graphicsMemoryUsage = (long)(TextureSize * TextureSize * CascadeCount * 4);
        }
Example #5
0
        public PostProcessor(DXManager dxman)
        {
            var device = dxman.device;

            byte[] bReduceTo1DCS     = File.ReadAllBytes("Shaders\\PPReduceTo1DCS.cso");
            byte[] bReduceTo0DCS     = File.ReadAllBytes("Shaders\\PPReduceTo0DCS.cso");
            byte[] bLumBlendCS       = File.ReadAllBytes("Shaders\\PPLumBlendCS.cso");
            byte[] bBloomFilterBPHCS = File.ReadAllBytes("Shaders\\PPBloomFilterBPHCS.cso");
            byte[] bBloomFilterVCS   = File.ReadAllBytes("Shaders\\PPBloomFilterVCS.cso");
            byte[] bCopyPixelsPS     = File.ReadAllBytes("Shaders\\PPCopyPixelsPS.cso");
            byte[] bFinalPassVS      = File.ReadAllBytes("Shaders\\PPFinalPassVS.cso");
            byte[] bFinalPassPS      = File.ReadAllBytes("Shaders\\PPFinalPassPS.cso");

            ReduceTo1DCS     = new ComputeShader(device, bReduceTo1DCS);
            ReduceTo0DCS     = new ComputeShader(device, bReduceTo0DCS);
            LumBlendCS       = new ComputeShader(device, bLumBlendCS);
            BloomFilterBPHCS = new ComputeShader(device, bBloomFilterBPHCS);
            BloomFilterVCS   = new ComputeShader(device, bBloomFilterVCS);
            CopyPixelsPS     = new PixelShader(device, bCopyPixelsPS);
            FinalPassVS      = new VertexShader(device, bFinalPassVS);
            FinalPassPS      = new PixelShader(device, bFinalPassPS);
            FinalPassQuad    = new UnitQuad(device, true);
            FinalPassLayout  = new InputLayout(device, bFinalPassVS, new[]
            {
                new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0),
                new InputElement("TEXCOORD", 0, Format.R32G32_Float, 16, 0),
            });


            ReduceCSVars    = new GpuVarsBuffer <PostProcessorReduceCSVars>(device);
            LumBlendCSVars  = new GpuVarsBuffer <PostProcessorLumBlendCSVars>(device);
            FilterBPHCSVars = new GpuVarsBuffer <PostProcessorFilterBPHCSVars>(device);
            FilterVCSVars   = new GpuVarsBuffer <PostProcessorFilterVCSVars>(device);
            FinalPSVars     = new GpuVarsBuffer <PostProcessorFinalPSVars>(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);

            GetSampleWeights(ref FilterVCSVars.Vars.avSampleWeights, 3.0f, 1.25f); //init sample weights
            FilterBPHCSVars.Vars.avSampleWeights = FilterVCSVars.Vars.avSampleWeights;
        }
Example #6
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,
            });
        }
Example #7
0
        public BoundsShader(Device device)
        {
            byte[] spherevsbytes = File.ReadAllBytes("Shaders\\BoundingSphereVS.cso");
            byte[] boxvsbytes    = File.ReadAllBytes("Shaders\\BoundingBoxVS.cso");
            byte[] psbytes       = File.ReadAllBytes("Shaders\\BoundsPS.cso");

            spherevs = new VertexShader(device, spherevsbytes);
            boxvs    = new VertexShader(device, boxvsbytes);
            boundsps = new PixelShader(device, psbytes);

            VSSphereSceneVars = new GpuVarsBuffer <BoundingSphereVSSceneVars>(device);
            VSSphereVars      = new GpuVarsBuffer <BoundingSphereVSSphereVars>(device);
            VSBoxSceneVars    = new GpuVarsBuffer <BoundingBoxVSSceneVars>(device);
            VSBoxVars         = new GpuVarsBuffer <BoundingBoxVSBoxVars>(device);
            PSColourVars      = new GpuVarsBuffer <BoundsPSColourVars>(device);

            cube = new UnitCube(device, boxvsbytes, false, true, false);
        }
Example #8
0
 public void Dispose()
 {
     graphicsMemoryUsage = 0;
     if (DepthTexture != null)
     {
         DepthTexture.Dispose();
         DepthTexture = null;
     }
     if (DepthTextureSS != null)
     {
         DepthTextureSS.Dispose();
         DepthTextureSS = null;
     }
     if (DepthTextureSRV != null)
     {
         DepthTextureSRV.Dispose();
         DepthTextureSRV = null;
     }
     if (DepthTextureDSV != null)
     {
         DepthTextureDSV.Dispose();
         DepthTextureDSV = null;
     }
     if (DepthRenderRS != null)
     {
         DepthRenderRS.Dispose();
         DepthRenderRS = null;
     }
     if (DepthRenderDS != null)
     {
         DepthRenderDS.Dispose();
         DepthRenderDS = null;
     }
     if (ShadowVars != null)
     {
         ShadowVars.Dispose();
         ShadowVars = null;
     }
     if (Cascades != null)
     {
         Cascades.Clear();
         Cascades = null;
     }
 }
Example #9
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, VertexTypeDefaultEx.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,
            });
        }
Example #10
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,
            });
        }
Example #11
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, VertexTypePC.GetLayout());

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

            vertices = new GpuCBuffer <VertexTypePC>(device, 1000); //should be more than needed....
        }
Example #12
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 #13
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);
        }
Example #14
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");

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

            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, VertexTypePNCCT.GetLayout()));
            layouts.Add(VertexType.PNCCTT, new InputLayout(device, vspncctt, VertexTypePNCCTT.GetLayout()));
            layouts.Add(VertexType.PNCTTX, new InputLayout(device, vspncttx, VertexTypePNCTTX.GetLayout()));
            layouts.Add(VertexType.PNCTTTX_3, new InputLayout(device, vspnctttx, VertexTypePNCTTTX_3.GetLayout()));
            layouts.Add(VertexType.PNCCTX, new InputLayout(device, vspncctx, VertexTypePNCCTX.GetLayout()));
            layouts.Add(VertexType.PNCCTTX, new InputLayout(device, vspnccttx, VertexTypePNCCTTX.GetLayout()));
            layouts.Add(VertexType.PNCCTTX_2, new InputLayout(device, vspnccttx, VertexTypePNCCTTX_2.GetLayout()));
            layouts.Add(VertexType.PNCCTTTX, new InputLayout(device, vspncctttx, VertexTypePNCCTTTX.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.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,
            });
        }
Example #15
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,
            });
        }
Example #16
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 (FinalPSVars != null)
            {
                FinalPSVars.Dispose();
                FinalPSVars = null;
            }
            if (FilterVCSVars != null)
            {
                FilterVCSVars.Dispose();
                FilterVCSVars = null;
            }
            if (FilterBPHCSVars != null)
            {
                FilterBPHCSVars.Dispose();
                FilterBPHCSVars = null;
            }
            if (LumBlendCSVars != null)
            {
                LumBlendCSVars.Dispose();
                LumBlendCSVars = null;
            }
            if (ReduceCSVars != null)
            {
                ReduceCSVars.Dispose();
                ReduceCSVars = null;
            }
            if (FinalPassLayout != null)
            {
                FinalPassLayout.Dispose();
                FinalPassLayout = null;
            }
            if (FinalPassQuad != null)
            {
                FinalPassQuad.Dispose();
                FinalPassQuad = null;
            }
            if (FinalPassPS != null)
            {
                FinalPassPS.Dispose();
                FinalPassPS = null;
            }
            if (FinalPassVS != null)
            {
                FinalPassVS.Dispose();
                FinalPassVS = null;
            }
            if (CopyPixelsPS != null)
            {
                CopyPixelsPS.Dispose();
                CopyPixelsPS = null;
            }
            if (BloomFilterVCS != null)
            {
                BloomFilterVCS.Dispose();
                BloomFilterVCS = null;
            }
            if (BloomFilterBPHCS != null)
            {
                BloomFilterBPHCS.Dispose();
                BloomFilterBPHCS = null;
            }
            if (LumBlendCS != null)
            {
                LumBlendCS.Dispose();
                LumBlendCS = null;
            }
            if (ReduceTo0DCS != null)
            {
                ReduceTo0DCS.Dispose();
                ReduceTo0DCS = null;
            }
            if (ReduceTo1DCS != null)
            {
                ReduceTo1DCS.Dispose();
                ReduceTo1DCS = null;
            }
        }
Example #17
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 #18
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);


            //supported layouts - requires Position, Normal, Colour, Texcoord
            layouts.Add(VertexType.Default, new InputLayout(device, vsbytes, VertexTypeDefault.GetLayout()));
            layouts.Add(VertexType.DefaultEx, new InputLayout(device, vsbytes, VertexTypeDefaultEx.GetLayout()));
            layouts.Add(VertexType.PNCCT, new InputLayout(device, vsbytes, VertexTypePNCCT.GetLayout()));
            layouts.Add(VertexType.PNCCTTTT, new InputLayout(device, vsbytes, VertexTypePNCCTTTT.GetLayout()));
            layouts.Add(VertexType.PNCTTTX, new InputLayout(device, vsbytes, VertexTypePNCTTTX.GetLayout()));
            layouts.Add(VertexType.PNCTTTX_2, new InputLayout(device, vsbytes, VertexTypePNCTTTX_2.GetLayout()));
            layouts.Add(VertexType.PNCTTTX_3, new InputLayout(device, vsbytes, VertexTypePNCTTTX_3.GetLayout()));
            layouts.Add(VertexType.PNCTTTTX, new InputLayout(device, vsbytes, VertexTypePNCTTTTX.GetLayout()));
            layouts.Add(VertexType.PNCTTX, new InputLayout(device, vsbytes, VertexTypePNCTTX.GetLayout()));
            layouts.Add(VertexType.PNCCTTX, new InputLayout(device, vsbytes, VertexTypePNCCTTX.GetLayout()));
            layouts.Add(VertexType.PNCCTTX_2, new InputLayout(device, vsbytes, VertexTypePNCCTTX_2.GetLayout()));
            layouts.Add(VertexType.PNCCTTTX, new InputLayout(device, vsbytes, VertexTypePNCCTTTX.GetLayout()));
            layouts.Add(VertexType.PNCCTT, new InputLayout(device, vsbytes, VertexTypePNCCTT.GetLayout()));
            layouts.Add(VertexType.PNCCTX, new InputLayout(device, vsbytes, VertexTypePNCCTX.GetLayout()));
            layouts.Add(VertexType.PNCH2, new InputLayout(device, vsbytes, VertexTypePNCH2.GetLayout()));
            layouts.Add(VertexType.PCCH2H4, new InputLayout(device, vsbytes, VertexTypePCCH2H4.GetLayout()));
            layouts.Add(VertexType.PNCTT, new InputLayout(device, vsbytes, VertexTypePNCTT.GetLayout()));
            layouts.Add(VertexType.PNCTTT, new InputLayout(device, vsbytes, VertexTypePNCTTT.GetLayout()));

            layouts.Add(VertexType.PBBNCT, new InputLayout(device, vssbytes, VertexTypePBBNCT.GetLayout()));
            layouts.Add(VertexType.PBBNCTX, new InputLayout(device, vssbytes, VertexTypePBBNCTX.GetLayout()));
            layouts.Add(VertexType.PBBNCTT, new InputLayout(device, vssbytes, VertexTypePBBNCTT.GetLayout()));
            layouts.Add(VertexType.PBBNCTTT, new InputLayout(device, vssbytes, VertexTypePBBNCTTT.GetLayout()));
            layouts.Add(VertexType.PBBNCCT, new InputLayout(device, vssbytes, VertexTypePBBNCCT.GetLayout()));
            layouts.Add(VertexType.PBBNCCTT, new InputLayout(device, vssbytes, VertexTypePBBNCCTT.GetLayout()));//TODO
            layouts.Add(VertexType.PBBNCCTX, new InputLayout(device, vssbytes, VertexTypePBBNCCTX.GetLayout()));
            layouts.Add(VertexType.PBBNCTTX, new InputLayout(device, vssbytes, VertexTypePBBNCTTX.GetLayout()));
            layouts.Add(VertexType.PBBNCTTTX, new InputLayout(device, vssbytes, VertexTypePBBNCTTTX.GetLayout())); //TODO
            layouts.Add(VertexType.PBBNCCTTX, new InputLayout(device, vssbytes, VertexTypePBBNCCTTX.GetLayout())); //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;
            }
        }
Example #19
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 #20
0
        public ShadowShader(Device device)
        {
            byte[] vsbytes = File.ReadAllBytes("Shaders\\ShadowVS.cso");
            byte[] psbytes = File.ReadAllBytes("Shaders\\ShadowPS.cso");

            shadowvs = new VertexShader(device, vsbytes);
            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);


            //supported layouts - requires Position, Normal, Colour, Texcoord
            layouts.Add(VertexType.Default, new InputLayout(device, vsbytes, VertexTypeDefault.GetLayout()));
            layouts.Add(VertexType.DefaultEx, new InputLayout(device, vsbytes, VertexTypeDefaultEx.GetLayout()));
            layouts.Add(VertexType.PNCCT, new InputLayout(device, vsbytes, VertexTypePNCCT.GetLayout()));
            layouts.Add(VertexType.PNCCTTTT, new InputLayout(device, vsbytes, VertexTypePNCCTTTT.GetLayout()));
            layouts.Add(VertexType.PCCNCCTTX, new InputLayout(device, vsbytes, VertexTypePCCNCCTTX.GetLayout()));
            layouts.Add(VertexType.PCCNCCT, new InputLayout(device, vsbytes, VertexTypePCCNCCT.GetLayout()));
            layouts.Add(VertexType.PNCTTTX, new InputLayout(device, vsbytes, VertexTypePNCTTTX.GetLayout()));
            layouts.Add(VertexType.PNCTTTX_2, new InputLayout(device, vsbytes, VertexTypePNCTTTX_2.GetLayout()));
            layouts.Add(VertexType.PNCTTTX_3, new InputLayout(device, vsbytes, VertexTypePNCTTTX_3.GetLayout()));
            layouts.Add(VertexType.PNCTTTTX, new InputLayout(device, vsbytes, VertexTypePNCTTTTX.GetLayout()));
            layouts.Add(VertexType.PNCTTX, new InputLayout(device, vsbytes, VertexTypePNCTTX.GetLayout()));
            layouts.Add(VertexType.PNCCTTX, new InputLayout(device, vsbytes, VertexTypePNCCTTX.GetLayout()));
            layouts.Add(VertexType.PNCCTTX_2, new InputLayout(device, vsbytes, VertexTypePNCCTTX_2.GetLayout()));
            layouts.Add(VertexType.PNCCTTTX, new InputLayout(device, vsbytes, VertexTypePNCCTTTX.GetLayout()));
            layouts.Add(VertexType.PCCNCCTX, new InputLayout(device, vsbytes, VertexTypePCCNCCTX.GetLayout()));
            layouts.Add(VertexType.PCCNCTX, new InputLayout(device, vsbytes, VertexTypePCCNCTX.GetLayout()));
            layouts.Add(VertexType.PCCNCT, new InputLayout(device, vsbytes, VertexTypePCCNCT.GetLayout()));
            layouts.Add(VertexType.PNCCTT, new InputLayout(device, vsbytes, VertexTypePNCCTT.GetLayout()));
            layouts.Add(VertexType.PNCCTX, new InputLayout(device, vsbytes, VertexTypePNCCTX.GetLayout()));
            layouts.Add(VertexType.PNCH2, new InputLayout(device, vsbytes, VertexTypePNCH2.GetLayout()));
            layouts.Add(VertexType.PCCH2H4, new InputLayout(device, vsbytes, VertexTypePCCH2H4.GetLayout()));
            layouts.Add(VertexType.PCCNCTT, new InputLayout(device, vsbytes, VertexTypePCCNCTT.GetLayout()));
            layouts.Add(VertexType.PCCNCTTX, new InputLayout(device, vsbytes, VertexTypePCCNCTTX.GetLayout()));
            layouts.Add(VertexType.PCCNCTTT, new InputLayout(device, vsbytes, VertexTypePCCNCTTT.GetLayout()));
            layouts.Add(VertexType.PNCTT, new InputLayout(device, vsbytes, VertexTypePNCTT.GetLayout()));
            layouts.Add(VertexType.PNCTTT, new InputLayout(device, vsbytes, VertexTypePNCTTT.GetLayout()));
            layouts.Add(VertexType.PCCNCTTTX, new InputLayout(device, vsbytes, VertexTypePCCNCTTTX.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,
            });
            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,
            });
        }