Esempio n. 1
0
 public void UpdateCloudsLocals(Clouds clouds, ShaderGlobalLights lights)
 {
     CloudsLocalVars.Vars.gSunDirection        = lights.CurrentSunDir;
     CloudsLocalVars.Vars.gSunColor            = ((Vector4)lights.Params.LightDirColour).XYZ();
     CloudsLocalVars.Vars.gUVOffset1           = clouds.AnimOverrides.UVOffset1;
     CloudsLocalVars.Vars.gUVOffset2           = clouds.AnimOverrides.UVOffset2;
     CloudsLocalVars.Vars.gUVOffset3           = clouds.AnimOverrides.UVOffset3;
     CloudsLocalVars.Vars.gRescaleUV1          = clouds.AnimOverrides.RescaleUV1;
     CloudsLocalVars.Vars.gRescaleUV2          = clouds.AnimOverrides.RescaleUV2;
     CloudsLocalVars.Vars.gRescaleUV3          = clouds.AnimOverrides.RescaleUV3;
     CloudsLocalVars.Vars.cloudLayerAnimScale1 = clouds.AnimOverrides.cloudLayerAnimScale1;
     CloudsLocalVars.Vars.cloudLayerAnimScale2 = clouds.AnimOverrides.cloudLayerAnimScale2;
     CloudsLocalVars.Vars.cloudLayerAnimScale3 = clouds.AnimOverrides.cloudLayerAnimScale3;
     CloudsLocalVars.Vars.gUVOffsetArr0        = Vector4.Zero;
     CloudsLocalVars.Vars.gUVOffsetArr1        = Vector4.Zero;
 }
Esempio n. 2
0
        public void RenderSun(DeviceContext context, Camera camera, Weather weather, ShaderGlobalLights lights)
        {
            context.VertexShader.Set(sunvs);
            context.PixelShader.Set(sunps);

            VSSunMoonVars.Vars.ViewProj = Matrix.Transpose(camera.ViewProjMatrix);
            VSSunMoonVars.Vars.ViewInv  = Matrix.Transpose(camera.ViewInvMatrix);
            VSSunMoonVars.Vars.CamRel   = new Vector4(lights.CurrentSunDir, 0);
            VSSunMoonVars.Vars.Size     = new Vector2(weather.CurrentValues.skySunDiscSize * 0.008f);
            VSSunMoonVars.Vars.Offset   = Vector2.Zero;
            VSSunMoonVars.Update(context);
            VSSunMoonVars.SetVSCBuffer(context, 0);

            PSSunMoonVars.Vars.Colour = new Vector4(weather.CurrentValues.skySunDiscCol * weather.CurrentValues.skySunHdr, 1);
            PSSunMoonVars.Update(context);
            PSSunMoonVars.SetPSCBuffer(context, 0);

            context.InputAssembler.InputLayout = sunlayout;
            sundisc.Draw(context);
        }
Esempio n. 3
0
        public void RenderLights(DeviceContext context, Camera camera, Shadowmap globalShadows, ShaderGlobalLights globalLights)
        {
            //first full-screen directional light pass, for sun/moon
            //discard pixels where scene depth is 0, since nothing was rendered there
            //blend mode: overwrite

            var ps = (MSAASampleCount > 1) ? DirLightMSPS : DirLightPS;

            context.VertexShader.Set(DirLightVS);
            context.PixelShader.Set(ps);

            LightVSVars.Vars.ViewProj  = Matrix.Identity;
            LightVSVars.Vars.CameraPos = Vector4.Zero;
            LightVSVars.Vars.LightType = 0;
            LightVSVars.Vars.IsLOD     = 0;
            LightVSVars.Vars.Pad0      = 0;
            LightVSVars.Vars.Pad1      = 0;
            LightVSVars.Update(context);
            LightVSVars.SetVSCBuffer(context, 0);

            LightPSVars.Vars.GlobalLights       = globalLights.Params;
            LightPSVars.Vars.ViewProjInv        = Matrix.Transpose(camera.ViewProjInvMatrix);
            LightPSVars.Vars.CameraPos          = Vector4.Zero;
            LightPSVars.Vars.EnableShadows      = (globalShadows != null) ? 1u : 0u;
            LightPSVars.Vars.RenderMode         = 0;
            LightPSVars.Vars.RenderModeIndex    = 1;
            LightPSVars.Vars.RenderSamplerCoord = 0;
            LightPSVars.Vars.LightType          = 0;
            LightPSVars.Vars.IsLOD       = 0;
            LightPSVars.Vars.SampleCount = (uint)MSAASampleCount;
            LightPSVars.Vars.SampleMult  = 1.0f / MSAASampleCount;
            LightPSVars.Update(context);
            LightPSVars.SetPSCBuffer(context, 0);

            context.PixelShader.SetShaderResources(0, GBuffers.DepthSRV);
            context.PixelShader.SetShaderResources(2, GBuffers.SRVs);

            if (globalShadows != null)
            {
                globalShadows.SetFinalRenderResources(context);
            }

            context.InputAssembler.InputLayout = LightQuadLayout;
            LightQuad.Draw(context);


            context.VertexShader.Set(null);
            context.PixelShader.Set(null);
            context.PixelShader.SetShaderResources(0, null, null, null);
            context.PixelShader.SetSamplers(0, null, null);
        }
Esempio n. 4
0
 public override void SetSceneVars(DeviceContext context, Camera camera, Shadowmap shadowmap, ShaderGlobalLights lights)
 {
     VSSceneVars.Vars.ViewProj    = Matrix.Transpose(camera.ViewProjMatrix);
     VSSceneVars.Vars.CameraPos   = new Vector4(camera.Position, 0.0f);
     VSSceneVars.Vars.LightColour = new Vector4(1.0f, 1.0f, 1.0f, lights.HdrIntensity * 2.0f);
     VSSceneVars.Update(context);
     VSSceneVars.SetVSCBuffer(context, 0);
 }
Esempio n. 5
0
        public void RenderLines(DeviceContext context, List <VertexTypePC> verts, Camera camera, ShaderGlobalLights lights)
        {
            UseDynamicVerts = true;
            SetShader(context);
            SetInputLayout(context, VertexType.PC);
            SetSceneVars(context, camera, null, lights);

            vertices.Clear();
            foreach (var vert in verts)
            {
                vertices.Add(vert);
            }
            vertices.Update(context);
            vertices.SetVSResource(context, 0);

            context.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.LineList;
            context.Draw(vertices.CurrentCount, 0);
        }
Esempio n. 6
0
        public void RenderBatches(DeviceContext context, List <RenderablePathBatch> batches, Camera camera, ShaderGlobalLights lights)
        {
            UseDynamicVerts = false;
            SetShader(context);
            SetInputLayout(context, VertexType.PC);
            SetSceneVars(context, camera, null, lights);

            context.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList;
            context.InputAssembler.SetIndexBuffer(null, Format.R16_UInt, 0);
            for (int i = 0; i < batches.Count; i++)
            {
                var pbatch = batches[i];

                if (pbatch.TriangleVertexBuffer == null)
                {
                    continue;
                }
                if (pbatch.TriangleVertexCount == 0)
                {
                    continue;
                }

                context.InputAssembler.SetVertexBuffers(0, pbatch.TriangleVBBinding);
                context.Draw(pbatch.TriangleVertexCount, 0);
            }

            context.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.LineList;
            context.InputAssembler.SetIndexBuffer(null, Format.R16_UInt, 0);
            for (int i = 0; i < batches.Count; i++)
            {
                var pbatch = batches[i];

                if (pbatch.PathVertexBuffer == null)
                {
                    continue;
                }
                if (pbatch.PathVertexCount == 0)
                {
                    continue;
                }

                context.InputAssembler.SetVertexBuffers(0, pbatch.PathVBBinding);
                context.Draw(pbatch.PathVertexCount, 0);
            }


            context.VertexShader.Set(boxvs);
            context.PixelShader.Set(boxps);

            VSSceneVars.SetVSCBuffer(context, 0);

            foreach (var batch in batches)
            {
                if (batch.NodeBuffer == null)
                {
                    continue;
                }

                context.VertexShader.SetShaderResource(0, batch.NodeBuffer.SRV);

                cube.DrawInstanced(context, batch.Nodes.Length);
            }

            UnbindResources(context);
        }
Esempio n. 7
0
        public override void SetSceneVars(DeviceContext context, Camera camera, Shadowmap shadowmap, ShaderGlobalLights lights)
        {
            uint rendermode    = 0;
            uint rendermodeind = 1;

            switch (RenderMode)
            {
            case WorldRenderMode.VertexNormals:
                rendermode = 1;
                break;

            case WorldRenderMode.VertexTangents:
                rendermode = 2;
                break;

            case WorldRenderMode.VertexColour:
                rendermode    = 3;
                rendermodeind = (uint)RenderVertexColourIndex;
                break;

            case WorldRenderMode.TextureCoord:
                rendermode    = 4;
                rendermodeind = (uint)RenderTextureCoordIndex;
                break;

            case WorldRenderMode.SingleTexture:
                switch (RenderTextureSampler)
                {
                case MetaName.DiffuseSampler:
                    rendermode = 5;
                    break;

                case MetaName.BumpSampler:
                    rendermode = 6;
                    break;

                case MetaName.SpecSampler:
                    rendermode = 7;
                    break;

                default:
                    rendermode = 8;
                    break;
                }
                break;
            }


            VSSceneVars.Vars.ViewProj = Matrix.Transpose(camera.ViewProjMatrix);
            VSSceneVars.Update(context);
            VSSceneVars.SetVSCBuffer(context, 0);


            PSSceneVars.Vars.GlobalLights       = lights.Params;
            PSSceneVars.Vars.EnableShadows      = (shadowmap != null) ? 1u : 0u;
            PSSceneVars.Vars.RenderMode         = rendermode;
            PSSceneVars.Vars.RenderModeIndex    = rendermodeind;
            PSSceneVars.Vars.RenderSamplerCoord = (uint)RenderTextureSamplerCoord;
            PSSceneVars.Update(context);
            PSSceneVars.SetPSCBuffer(context, 0);

            if (shadowmap != null)
            {
                shadowmap.SetFinalRenderResources(context);
            }
        }
Esempio n. 8
0
        public void RenderLines(DeviceContext context, List <VertexTypePC> verts, Camera camera, ShaderGlobalLights lights)
        {
            UseDynamicVerts = true;
            SetShader(context);
            SetInputLayout(context, VertexType.PC);
            SetSceneVars(context, camera, null, lights);

            int drawn     = 0;
            int linecount = verts.Count / 2;
            int maxcount  = vertices.StructCount / 2;

            while (drawn < linecount)
            {
                vertices.Clear();

                int offset = drawn * 2;
                int bcount = Math.Min(linecount - drawn, maxcount);
                for (int i = 0; i < bcount; i++)
                {
                    int t = offset + (i * 2);
                    vertices.Add(verts[t + 0]);
                    vertices.Add(verts[t + 1]);
                }
                drawn += bcount;

                vertices.Update(context);
                vertices.SetVSResource(context, 0);

                context.InputAssembler.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.LineList;
                context.Draw(vertices.CurrentCount, 0);
            }
        }
Esempio n. 9
0
        public override void SetSceneVars(DeviceContext context, Camera camera, Shadowmap shadowmap, ShaderGlobalLights lights)
        {
            switch (mode)
            {
            default:
            case BoundsShaderMode.Sphere:
                VSSphereSceneVars.Vars.ViewProj     = Matrix.Transpose(camera.ViewProjMatrix);
                VSSphereSceneVars.Vars.ViewInv      = Matrix.Transpose(camera.ViewInvMatrix);
                VSSphereSceneVars.Vars.SegmentCount = (float)SegmentCount;
                VSSphereSceneVars.Vars.VertexCount  = (float)VertexCount;
                VSSphereSceneVars.Update(context);
                VSSphereSceneVars.SetVSCBuffer(context, 0);
                break;

            case BoundsShaderMode.Box:
                VSBoxSceneVars.Vars.ViewProj = Matrix.Transpose(camera.ViewProjMatrix);
                VSBoxSceneVars.Update(context);
                VSBoxSceneVars.SetVSCBuffer(context, 0);
                break;
            }
        }
Esempio n. 10
0
 public override void SetSceneVars(DeviceContext context, Camera camera, Shadowmap shadowmap, ShaderGlobalLights lights)
 {
 }
Esempio n. 11
0
        public void RenderMoon(DeviceContext context, Camera camera, Weather weather, ShaderGlobalLights lights, RenderableTexture moontex)
        {
            context.VertexShader.Set(moonvs);
            context.PixelShader.Set(moonps);


            Quaternion ori  = Quaternion.Invert(Quaternion.LookAtRH(Vector3.Zero, lights.CurrentMoonDir, lights.MoonAxis));
            Matrix     omat = ori.ToMatrix();


            VSSunMoonVars.Vars.ViewProj = Matrix.Transpose(camera.ViewProjMatrix);
            VSSunMoonVars.Vars.ViewInv  = Matrix.Transpose(omat);// camera.ViewInvMatrix);
            VSSunMoonVars.Vars.CamRel   = new Vector4(lights.CurrentMoonDir, 0);
            VSSunMoonVars.Vars.Size     = new Vector2(weather.CurrentValues.skyMoonDiscSize * 0.008f);
            VSSunMoonVars.Vars.Offset   = Vector2.Zero;
            VSSunMoonVars.Update(context);
            VSSunMoonVars.SetVSCBuffer(context, 0);

            PSSunMoonVars.Vars.Colour = new Vector4(weather.CurrentValues.skyMoonCol * weather.CurrentValues.skyMoonIten, weather.CurrentValues.skyMoonIten);
            PSSunMoonVars.Update(context);
            PSSunMoonVars.SetPSCBuffer(context, 0);

            context.PixelShader.SetSampler(0, texsampler);
            moontex.SetPSResource(context, 0);

            context.InputAssembler.InputLayout = moonlayout;
            moonquad.Draw(context);
        }
Esempio n. 12
0
        public void UpdateSkyLocals(Weather weather, ShaderGlobalLights lights)
        {
            var wv = weather.CurrentValues;

            float   skyhdr    = EnableHDR ? wv.skyHdr : Math.Min(wv.skyHdr, 1.8f);
            float   sunhdr    = EnableHDR ? wv.skySunHdr : Math.Min(wv.skySunHdr, 4.8f); //NO HDR - turn it down!!!
            float   scathdr   = EnableHDR ? wv.skySunScatterInten : Math.Min(wv.skySunScatterInten, 1.8f);
            Vector3 suncolhdr = wv.skySunCol * sunhdr;
            Vector4 azecol    = wv.skyAzimuthEastCol;
            Vector4 azwcol    = wv.skyAzimuthWestCol;
            Vector4 aztcol    = wv.skyAzimuthTransitionCol;
            Vector4 zencol    = wv.skyZenithCol;
            Vector4 zetcol    = wv.skyZenithTransitionCol;
            Vector4 plncol    = wv.skyPlane;

            SkyLocalVars.Vars.azimuthEastColor          = azecol;
            SkyLocalVars.Vars.azimuthWestColor          = azwcol;
            SkyLocalVars.Vars.azimuthTransitionColor    = aztcol.XYZ();
            SkyLocalVars.Vars.azimuthTransitionPosition = wv.skyAzimuthTransition;
            SkyLocalVars.Vars.zenithColor           = zencol;
            SkyLocalVars.Vars.zenithTransitionColor = zetcol;
            SkyLocalVars.Vars.zenithConstants       = wv.skyZenithTransition;
            SkyLocalVars.Vars.skyPlaneColor         = plncol;
            SkyLocalVars.Vars.skyPlaneParams        = Vector4.Zero;
            SkyLocalVars.Vars.hdrIntensity          = skyhdr;
            SkyLocalVars.Vars.sunColor        = wv.skySunCol;
            SkyLocalVars.Vars.sunColorHdr     = new Vector4(suncolhdr, sunhdr);
            SkyLocalVars.Vars.sunDiscColorHdr = new Vector4(wv.skySunDiscCol, wv.skySunDiscSize);
            //SkyLocalVars.Vars.sunConstants = new Vector4(wv.skySunMie, scathdr);
            //SkyLocalVars.Vars.sunConstants.X = wv.skySunMie.X; //mie phase
            //SkyLocalVars.Vars.sunConstants.Y = wv.skySunMie.Y; //mie scatter
            //SkyLocalVars.Vars.sunConstants.Z = 0.5f / wv.skySunInfluenceRadius;// * 0.01f; // 0.0025f;  //mie size/"range"
            //SkyLocalVars.Vars.sunConstants.W = wv.skySunMie.Z;// * scathdr; //mie hdr intensity
            SkyLocalVars.Vars.sunConstants.X          = wv.skySunMie.X * wv.skySunMie.Y;       //mie phase
            SkyLocalVars.Vars.sunConstants.Y          = wv.skySunMie.Y;                        // 1.0f /wv.skySunMie.Y;// 1.7f;// wv.skySunMie.Y; //mie scatter
            SkyLocalVars.Vars.sunConstants.Z          = 0.00003f * wv.skySunInfluenceRadius;   // * wv.skySunMie.X;// wv.skySunMie.Z;///720.0f;// * 0.01f; // 0.0025f;  //mie size/"range"
            SkyLocalVars.Vars.sunConstants.W          = wv.skySunMie.Z;                        // * scathdr; //mie intensity multiplier
            SkyLocalVars.Vars.sunDirection            = new Vector4(-lights.CurrentSunDir, 0); // wv.sunDirection, 0);
            SkyLocalVars.Vars.sunPosition             = new Vector4(-lights.CurrentSunDir, 0); //not used
            SkyLocalVars.Vars.cloudBaseMinusMidColour = Vector4.Zero;
            SkyLocalVars.Vars.cloudMidColour          = Vector4.Zero;
            SkyLocalVars.Vars.cloudShadowMinusBaseColourTimesShadowStrength = Vector4.Zero;
            SkyLocalVars.Vars.cloudDetailConstants = Vector4.Zero;
            SkyLocalVars.Vars.cloudConstants1      = Vector4.Zero;
            SkyLocalVars.Vars.cloudConstants2      = Vector4.Zero;
            SkyLocalVars.Vars.smallCloudConstants  = Vector4.Zero;
            SkyLocalVars.Vars.smallCloudColorHdr   = Vector4.Zero;
            SkyLocalVars.Vars.effectsConstants     = Vector4.Zero;
            SkyLocalVars.Vars.horizonLevel         = 0;
            SkyLocalVars.Vars.speedConstants       = Vector3.Zero;
            SkyLocalVars.Vars.starfieldIntensity   = wv.skyStarsIten * 5.0f; //makes stars brighter....
            SkyLocalVars.Vars.moonDirection        = wv.moonDirection;
            SkyLocalVars.Vars.moonPosition         = Vector3.Zero;           //need to update this?
            SkyLocalVars.Vars.moonIntensity        = wv.skyMoonIten;
            SkyLocalVars.Vars.lunarCycle           = Vector4.Zero;
            SkyLocalVars.Vars.moonColor            = wv.skyMoonCol;
            SkyLocalVars.Vars.noiseFrequency       = 0;
            SkyLocalVars.Vars.noiseScale           = 0;
            SkyLocalVars.Vars.noiseThreshold       = 0;
            SkyLocalVars.Vars.noiseSoftness        = 0;
            SkyLocalVars.Vars.noiseDensityOffset   = 0;
            SkyLocalVars.Vars.noisePhase           = Vector4.Zero;
        }
Esempio n. 13
0
        public override void SetSceneVars(DeviceContext context, Camera camera, Shadowmap shadowmap, ShaderGlobalLights lights)
        {
            uint rendermode    = 0;
            uint rendermodeind = 1;

            SpecularEnable = lights.SpecularEnabled;

            switch (RenderMode)
            {
            case WorldRenderMode.VertexNormals:
                rendermode = 1;
                break;

            case WorldRenderMode.VertexTangents:
                rendermode = 2;
                break;

            case WorldRenderMode.VertexColour:
                rendermode    = 3;
                rendermodeind = (uint)RenderVertexColourIndex;
                break;

            case WorldRenderMode.TextureCoord:
                rendermode    = 4;
                rendermodeind = (uint)RenderTextureCoordIndex;
                break;

            case WorldRenderMode.SingleTexture:
                rendermode = 8;    //direct mode
                break;
            }


            float phspd  = 4.0f;
            float phspdi = 1.0f / phspd;
            float phspdh = phspd * 0.5f;
            float t      = (float)(CurrentRealTime - (Math.Floor(CurrentRealTime * 0.001) * 1000.0)) * 1.0f;
            float ta     = t * 2.0f;
            float tb     = ta + (phspdh);
            float t1     = (ta * phspdi - (float)Math.Floor(ta * phspdi)) * phspd;
            float t2     = (tb * phspdi - (float)Math.Floor(tb * phspdi)) * phspd;
            float s1     = ((t1 < phspdh) ? t1 : phspd - t1) * phspdi * 1.0f;
            float s2     = ((t2 < phspdh) ? t2 : phspd - t2) * phspdi * 1.0f;
            //float s1 = ((float)Math.Cos(t1 * phspdi * Math.PI * 2) + 1.0f) * 0.5f;
            //float s2 = ((float)Math.Cos(t2 * phspdi * Math.PI * 2) + 1.0f) * 0.5f;

            float gFlowX = t1 * 0.5f;
            float gFlowY = t2 * 0.5f;
            float gFlowZ = s1;
            float gFlowW = s2;


            Vector2 fogtexMin = new Vector2(-4000.0f, -4000.0f); //aka water quads min/max
            Vector2 fogtexMax = new Vector2(4500.0f, 8000.0f);
            Vector2 fogtexInv = 1.0f / (fogtexMax - fogtexMin);


            bool usewaterbumps = (waterbump != null) && (waterbump.ShaderResourceView != null) && (waterbump2 != null) && (waterbump2.ShaderResourceView != null);
            bool usefogtex     = (waterfog != null) && (waterfog.ShaderResourceView != null);

            VSSceneVars.Vars.ViewProj    = Matrix.Transpose(camera.ViewProjMatrix);
            VSSceneVars.Vars.WaterVector = Vector4.Zero;
            VSSceneVars.Vars.ScaledTime  = t * 0.1f;
            VSSceneVars.Update(context);
            VSSceneVars.SetVSCBuffer(context, 0);

            PSSceneVars.Vars.GlobalLights       = lights.Params;
            PSSceneVars.Vars.EnableShadows      = (shadowmap != null) ? 1u : 0u;
            PSSceneVars.Vars.RenderMode         = rendermode;
            PSSceneVars.Vars.RenderModeIndex    = rendermodeind;
            PSSceneVars.Vars.RenderSamplerCoord = (uint)RenderTextureSamplerCoord;
            PSSceneVars.Vars.EnableWaterbumps   = usewaterbumps ? 1u : 0u;
            PSSceneVars.Vars.EnableFogtex       = usefogtex ? 1u : 0u;
            PSSceneVars.Vars.gFlowParams        = new Vector4(gFlowX, gFlowY, gFlowZ, gFlowW);
            PSSceneVars.Vars.CameraPos          = new Vector4(camera.Position, 0.0f);
            PSSceneVars.Vars.WaterFogParams     = new Vector4(fogtexMin, fogtexInv.X, fogtexInv.Y);
            PSSceneVars.Update(context);
            PSSceneVars.SetPSCBuffer(context, 0);

            if (shadowmap != null)
            {
                shadowmap.SetFinalRenderResources(context);
            }
            if (usewaterbumps)
            {
                context.PixelShader.SetShaderResource(4, waterbump.ShaderResourceView);
                context.PixelShader.SetShaderResource(5, waterbump2.ShaderResourceView);
            }
            if (usefogtex)
            {
                context.PixelShader.SetShaderResource(6, waterfog.ShaderResourceView);
            }
        }
Esempio n. 14
0
 public override void SetSceneVars(DeviceContext context, Camera camera, Shadowmap shadowmap, ShaderGlobalLights lights)
 {
     VSSceneVars.Vars.ViewProj    = Matrix.Transpose(camera.ViewProjMatrix);
     VSSceneVars.Vars.ViewInv     = Matrix.Transpose(camera.ViewInvMatrix);
     VSSceneVars.Vars.ScreenScale = new Vector4(0.5f / camera.Width, 0.5f / camera.Height, camera.Width, camera.Height);
     VSSceneVars.Update(context);
     VSSceneVars.SetVSCBuffer(context, 0);
 }
Esempio n. 15
0
 public abstract void SetSceneVars(DeviceContext context, Camera camera, Shadowmap shadowmap, ShaderGlobalLights lights);
Esempio n. 16
0
        public override void SetSceneVars(DeviceContext context, Camera camera, Shadowmap shadowmap, ShaderGlobalLights lights)
        {
            CloudsLocalVars.Update(context);
            CloudsLocalVars.SetVSCBuffer(context, 0);
            CloudsLocalVars.SetPSCBuffer(context, 0);

            VSSceneVars.Vars.ViewProj = Matrix.Transpose(camera.ViewProjMatrix);
            VSSceneVars.Vars.ViewInv  = Matrix.Transpose(camera.ViewInvMatrix);
            VSSceneVars.Update(context);
            VSSceneVars.SetVSCBuffer(context, 1);

            PSSceneVars.Vars.LightDirection = new Vector4(lights.Params.LightDir, 0.0f);
            PSSceneVars.Vars.EnableHDR      = EnableHDR ? 1u : 0u;
            PSSceneVars.Update(context);
            PSSceneVars.SetPSCBuffer(context, 1);
        }
Esempio n. 17
0
        public override void SetSceneVars(DeviceContext context, Camera camera, Shadowmap shadowmap, ShaderGlobalLights lights)
        {
            VSSceneVars.Vars.ViewProj = Matrix.Transpose(camera.ViewProjMatrix);
            VSSceneVars.Update(context);
            VSSceneVars.SetVSCBuffer(context, 0);

            PSSceneVars.Vars.GlobalLights = lights.Params;
            PSSceneVars.Update(context);
            PSSceneVars.SetPSCBuffer(context, 0);
        }
Esempio n. 18
0
        public override void SetSceneVars(DeviceContext context, Camera camera, Shadowmap shadowmap, ShaderGlobalLights lights)
        {
            uint rendermode    = 0;
            uint rendermodeind = 1;

            SpecularEnable = lights.SpecularEnabled;

            switch (RenderMode)
            {
            case WorldRenderMode.VertexNormals:
                rendermode = 1;
                break;

            case WorldRenderMode.VertexTangents:
                rendermode = 2;
                break;

            case WorldRenderMode.VertexColour:
                rendermode    = 3;
                rendermodeind = (uint)RenderVertexColourIndex;
                break;

            case WorldRenderMode.TextureCoord:
                rendermode    = 4;
                rendermodeind = (uint)RenderTextureCoordIndex;
                break;

            case WorldRenderMode.SingleTexture:
                rendermode = 8;    //direct mode
                break;
            }


            VSSceneVars.Vars.ViewProj   = Matrix.Transpose(camera.ViewProjMatrix);
            VSSceneVars.Vars.WindVector = WindVector;
            VSSceneVars.Update(context);
            VSSceneVars.SetVSCBuffer(context, 0);

            PSSceneVars.Vars.GlobalLights       = lights.Params;
            PSSceneVars.Vars.EnableShadows      = (shadowmap != null) ? 1u : 0u;
            PSSceneVars.Vars.RenderMode         = rendermode;
            PSSceneVars.Vars.RenderModeIndex    = rendermodeind;
            PSSceneVars.Vars.RenderSamplerCoord = (uint)RenderTextureSamplerCoord;
            PSSceneVars.Update(context);
            PSSceneVars.SetPSCBuffer(context, 0);

            if (shadowmap != null)
            {
                shadowmap.SetFinalRenderResources(context);
            }

            if (!InstGlobalVars.Flag) //on the first frame, update the instance globals
            {
                InstGlobalVars.Update(context);
                InstGlobalVars.Flag = true;
            }
        }
Esempio n. 19
0
 public override void SetSceneVars(DeviceContext context, Camera camera, Shadowmap shadowmap, ShaderGlobalLights lights)
 {
     VSSceneVars.Vars.ViewProj = Matrix.Transpose(camera.ViewProjMatrix);
     VSSceneVars.Vars.ViewInv  = Matrix.Transpose(camera.ViewInvMatrix);
     VSSceneVars.Vars.CamPos   = camera.Position;
     VSSceneVars.Update(context);
     VSSceneVars.SetVSCBuffer(context, 0);
 }