Beispiel #1
0
        public void SaveScreenToTexture(Camera cam, Texture toSaveTo)
        {
            toSaveTo.Use();

            Renderer.CopyScreenToTexture2D(cam.Width, cam.Height);

            Texture2D.Clear();
        }
 public override void Update(Environment environment, Camera cam, Mesh mesh)
 {
     if (this.currentMaterial.GetTexture(Material.TEXTURE_DIFFUSE) != null)
     {
         Texture diffuse = this.currentMaterial.GetTexture(Material.TEXTURE_DIFFUSE);
         Texture.ActiveTextureSlot(0);
         diffuse.Use();
         this.SetUniform("u_texture", 0);
         this.SetUniform("B_hasTexture", 1);
     }
     else
     {
         this.SetUniform("B_hasTexture", 0);
     }
     ctransform.SetTranslation(ctrans);
     ctransform.SetRotation(crot);
     ctransform.SetScale(cscale);
     this.SetUniform("u_color", currentColor);
     this.SetUniform("u_world", ctransform.GetMatrix());
     this.SetUniform("u_view", mycam.ViewMatrix);
     this.SetUniform("u_proj", mycam.ProjectionMatrix);
 }
        public override void Update()
        {
            this.shadowMap0 = parent.ShadowCams[0].ShadowMap;
            this.shadowMap1 = parent.ShadowCams[1].ShadowMap;
            this.shadowMap2 = parent.ShadowCams[2].ShadowMap;
            this.shadowMap3 = parent.ShadowCams[3].ShadowMap;
            this.shadowMapViewProjTrans0 = parent.ShadowCams[0].ViewProjectionMatrix;
            this.shadowMapViewProjTrans1 = parent.ShadowCams[1].ViewProjectionMatrix;
            this.shadowMapViewProjTrans2 = parent.ShadowCams[2].ViewProjectionMatrix;
            this.shadowMapViewProjTrans3 = parent.ShadowCams[3].ViewProjectionMatrix;
            this.splits = parent.Splits;

            camMat.SetToLookAt(cam.Translation, cam.Translation.Add(new Vector3f(0, 0, -1)), cam.Up);
            camMat.MultiplyStore(cam.ProjectionMatrix);
            shader.SetUniform("u_camMat", camMat);
            Texture.ActiveTextureSlot(0);
            shadowMap0.Use();
            Texture.ActiveTextureSlot(1);
            shadowMap1.Use();
            Texture.ActiveTextureSlot(2);
            shadowMap2.Use();
            Texture.ActiveTextureSlot(3);
            shadowMap3.Use();
            Texture.ActiveTextureSlot(4);
            depthTexture.Use();
            Texture.ActiveTextureSlot(5);
            colorTexture.Use();
            Texture.ActiveTextureSlot(6);
            noiseMap.Use();

            shader.SetUniform("u_shadowMap0", 0);
            shader.SetUniform("u_shadowMap1", 1);
            shader.SetUniform("u_shadowMap2", 2);
            shader.SetUniform("u_shadowMap3", 3);
            shader.SetUniform("u_depthTexture", 4);
            shader.SetUniform("u_sceneTexture", 5);
            shader.SetUniform("u_noiseTexture", 6);
            shader.SetUniform("u_shadowMapViewProjTrans0", shadowMapViewProjTrans0);
            shader.SetUniform("u_shadowMapViewProjTrans1", shadowMapViewProjTrans1);
            shader.SetUniform("u_shadowMapViewProjTrans2", shadowMapViewProjTrans2);
            shader.SetUniform("u_shadowMapViewProjTrans3", shadowMapViewProjTrans3);
            shader.SetUniform("u_cameraPosition", cam.Translation);
            shader.SetUniform("u_invViewProj", cam.InverseViewProjectionMatrix);
            shader.SetUniform("u_view", cam.ViewMatrix);
            shader.SetUniform("u_proj", cam.ProjectionMatrix);

            if (debugMode)
            {
                shader.SetUniform("B_debugMode", 1);
            }
            else
            {
                shader.SetUniform("B_debugMode", 0);
            }
            for (int i = 0; i < splits.Length; i++)
            {
                shader.SetUniform("splits[" + i + "]", splits[i]);
            }
        }
        public void SaveScreenToTexture(Camera cam, Texture toSaveTo)
        {
            toSaveTo.Use();

            Renderer.CopyScreenToTexture2D(cam.Width, cam.Height);

            Texture2D.Clear();
        }