コード例 #1
0
        public void DrawTransparent(Camera camera)
        {
            int     gameWidgetIndex = camera.GameWidget.GameWidgetIndex;
            Vector3 viewPosition    = camera.ViewPosition;
            Vector3 v     = new Vector3(MathUtils.Floor(viewPosition.X), 0f, MathUtils.Floor(viewPosition.Z));
            Matrix  value = Matrix.CreateTranslation(v - viewPosition) * camera.ViewMatrix.OrientationMatrix * camera.ProjectionMatrix;

            Display.BlendState        = BlendState.AlphaBlend;
            Display.DepthStencilState = DepthStencilState.Default;
            Display.RasterizerState   = ((m_subsystemSky.ViewUnderWaterDepth > 0f) ? RasterizerState.CullClockwiseScissor : RasterizerState.CullCounterClockwiseScissor);
            m_transparentShader.GetParameter("u_origin").SetValue(v.XZ);
            m_transparentShader.GetParameter("u_viewProjectionMatrix").SetValue(value);
            m_transparentShader.GetParameter("u_viewPosition").SetValue(viewPosition);
            m_transparentShader.GetParameter("u_texture").SetValue(m_subsystemAnimatedTextures.AnimatedBlocksTexture);
            m_transparentShader.GetParameter("u_samplerState").SetValue(SettingsManager.TerrainMipmapsEnabled ? m_samplerStateMips : m_samplerState);
            m_transparentShader.GetParameter("u_fogYMultiplier").SetValue(m_subsystemSky.VisibilityRangeYMultiplier);
            m_transparentShader.GetParameter("u_fogColor").SetValue(new Vector3(m_subsystemSky.ViewFogColor));
            ShaderParameter parameter = m_transparentShader.GetParameter("u_fogStartInvLength");

            for (int i = 0; i < m_chunksToDraw.Count; i++)
            {
                TerrainChunk terrainChunk = m_chunksToDraw[i];
                float        num          = MathUtils.Min(terrainChunk.FogEnds[gameWidgetIndex], m_subsystemSky.ViewFogRange.Y);
                float        num2         = MathUtils.Min(m_subsystemSky.ViewFogRange.X, num - 1f);
                parameter.SetValue(new Vector2(num2, 1f / (num - num2)));
                int subsetsMask = 64;
                DrawTerrainChunkGeometrySubsets(m_transparentShader, terrainChunk.Geometry, subsetsMask);
            }
        }
コード例 #2
0
        public override void Load()
        {
            color_shader     = Content.Get <ShaderProgram>("color_shader");
            scanlines_shader = Content.Get <ShaderProgram>("scanlines");

            current_shader = color_shader;

            colors_shader_tint_color = color_shader.GetParameter("tint_color");

            colors_shader_tint_color.SetValue(Color.White);

            scanlines_shader_params = scanlines_shader.GetParameter("params");

            scanlines_params = new Vector4(
                1.0f, // Amount
                0.5f, // Intensity
                0.0f, // Time
                0.0f
                );

            scanlines_shader_params.SetValue(scanlines_params);

            sprite = new Sprite(Content.Get <Texture2D>("cat"));

            sprite.SetOrigin(0.5f, 0.5f);

            sprite2 = new Sprite(Content.Get <Texture2D>("seiken"));

            sprite.SetOrigin(0.5f, 0.5f);

            timer = new Timer();

            timer.Every(20, UpdateColor);
        }
コード例 #3
0
 private void UpdateColor()
 {
     colors_shader_tint_color.SetValue(RandomEx.NextColor());
 }
コード例 #4
0
ファイル: ModelShader.cs プロジェクト: 1144822034/sc2.2mobile
 public override void PrepareForDrawingOverride()
 {
     Transforms.UpdateMatrices(m_instancesCount, worldView: false, viewProjection: false, worldViewProjection: true);
     m_worldViewProjectionMatrixParameter.SetValue(Transforms.WorldViewProjection, InstancesCount);
     m_worldMatrixParameter.SetValue(Transforms.World, InstancesCount);
 }