Exemplo n.º 1
0
 /// <summary>
 /// Static constructor.
 /// </summary>
 static SceneObject()
 {
     // Static initialization
     SceneGraph.Touch();
     SceneObjectCamera.Touch();
     SceneObjectGeometry.Touch();
     SceneObjectLight.Touch();
     SceneObjectLightZone.Touch();
 }
Exemplo n.º 2
0
        private void ManageObject(GraphicsContext ctx, SceneGraphContext ctxScene, SceneObjectLight sceneObject)
        {
            if (sceneObject == null)
            {
                throw new ArgumentNullException("sceneObject");
            }

            State.LightsState.Light lightObject = sceneObject.ToLight(ctx, ctxScene);

            CurrentZone.Lights.Add(lightObject);

            if (sceneObject.HasShadowMap)
            {
                lightObject.ShadowMapIndex = ShadowLights.Count;
                if (ShadowLights.Contains(sceneObject) == false)
                {
                    ShadowLights.Add(sceneObject);
                }
            }
        }
Exemplo n.º 3
0
        private void DisplayShadowMaps(GraphicsContext ctx)
        {
            State.ViewportState   viewportState   = new State.ViewportState(ctx);
            OrthoProjectionMatrix orthoProjection = new OrthoProjectionMatrix(0.0f, viewportState.Width, 0.0f, viewportState.Height);
            ModelMatrix           model           = new ModelMatrix();

            // No depth test
            State.DepthTestState.DefaultState.Apply(ctx, null);

            ctx.Bind(_ShadowMapDebugProgram);

            for (int i = 0; i < _LightManager.ShadowLights.Count; i++)
            {
                SceneObjectLight     shadowLight     = _LightManager.ShadowLights[i];
                SceneObjectLightSpot shadowSpotLight = shadowLight as SceneObjectLightSpot;
                if (shadowSpotLight == null)
                {
                    continue;
                }

                Texture2d shadowTex = shadowSpotLight._ShadowMap;
                shadowTex.SamplerParams.CompareMode = false;

                ModelMatrix quadModel = new ModelMatrix(model);
                quadModel.Scale(shadowTex.Width / 4, shadowTex.Height / 4);

                _ShadowMapDebugProgram.SetUniform(ctx, "glo_ModelViewProjection", orthoProjection * quadModel);
                _ShadowMapDebugProgram.SetUniform(ctx, "glo_NearFar", new Vertex2f(0.1f, 100.0f));
                _ShadowMapDebugProgram.SetUniform(ctx, "glo_Texture", shadowTex);

                _ShadowMapQuad.Draw(ctx, _ShadowMapDebugProgram);

                shadowTex.SamplerParams.CompareMode = true;

                // Stride right
                model.Translate(shadowTex.Width, 0.0f);
            }
        }