コード例 #1
0
ファイル: Sprite.cs プロジェクト: ajmd17/apexengine-sharp
 public override void Render(Rendering.Environment environment, Camera cam)
 {
     SpriteRenderer spriteRenderer = renderManager.SpriteRenderer;
     spriteRenderer.Render(texture, WorldTransform, WorldTransform.GetTranslation().x,
            WorldTransform.GetTranslation().y,
             texture.Width * WorldTransform.GetScale().x, texture.Height * WorldTransform.GetScale().y, white);
 }
コード例 #2
0
ファイル: Game.cs プロジェクト: ajmd17/apexengine-sharp
 public Game(Renderer renderer)
 {
     cam = new DefaultCamera(inputManager, 55);
     renderManager = new RenderManager(renderer, cam, new Action(() => { Render(); }));
     renderManager.SpriteRenderer = new SpriteRenderer(this);
     physicsWorld = new PhysicsWorld(new PhysicsDebugDraw(cam));
 }
コード例 #3
0
ファイル: Populator.cs プロジェクト: ajmd17/apexengine-sharp
 public Populator(Camera cam, bool batchGeometry, int seed, float probability)
 {
     this.cam = cam;
     this.batchGeometry = batchGeometry;
     rand = new Random(12345);
     this.probability = probability;
 }
コード例 #4
0
 public RenderManager(Renderer renderer, Camera cam, Action userRender)
 {
     RenderManager.renderer = renderer;
     this.userRender = userRender;
     postProcessor = new PostProcessor(this, cam);
     depthFbo = new Framebuffer(cam.Width, cam.Height);
 }
コード例 #5
0
ファイル: SkyShader.cs プロジェクト: ajmd17/apexengine-sharp
        public override void Update(Rendering.Environment environment, Camera cam, Mesh mesh)
        {
            base.Update(environment, cam, mesh);

            if (environment.DirectionalLight != null)
            {
                sunDirNor.Set(environment.DirectionalLight.Direction);
                sunDirNor.NormalizeStore();
            }

            skyTransform.SetTranslation(cam.Translation);
            skyTransform.SetScale(skydomeScale);

            if (currentMaterial != null)
            {
                Texture noiseMap;
                if ((noiseMap = currentMaterial.GetTexture("noise_map")) != null)
                {
                    Texture.ActiveTextureSlot(0);
                    noiseMap.Use();
                    SetUniform("u_noiseMap", 0);
                }
            }

            SetUniform("u_globalTime", environment.ElapsedTime);

            SetUniform("u_world", skyTransform.GetMatrix());
            SetUniform("u_view", cam.ViewMatrix);
            SetUniform("u_proj", cam.ProjectionMatrix);
            SetUniform("v3LightPos", sunDirNor);
            SetUniform("v3InvWavelength", invWavelength4);
            SetUniform("fKrESun", KrESun);
            SetUniform("fKmESun", KmESun);
            SetUniform("fOuterRadius", innerRadius * 1.025f);
            SetUniform("fInnerRadius", innerRadius);
            SetUniform("fOuterRadius2", (innerRadius * 1.025f)* (innerRadius * 1.025f));
            SetUniform("fInnerRadius2", innerRadius * innerRadius);
            SetUniform("fKr4PI", Kr4PI);
            SetUniform("fKm4PI", Km4PI);
            SetUniform("fScale", scale);
            SetUniform("fScaleDepth", scaleDepth);
            SetUniform("fScaleOverScaleDepth", scaleOverScaleDepth);
            SetUniform("fSamples", fSamples);
            SetUniform("nSamples", nSamples);
            SetUniform("fg", G);
            SetUniform("fg2", G * G);
            SetUniform("fExposure", exposure);
            SetUniform("v3CameraPos", cam.Translation);
            SetUniform("fCameraHeight2", cam.Height * cam.Height);
            SetUniform("u_sunColor", this.sunColor);
        }
コード例 #6
0
        public override void Update(Environment environment, Camera cam, Mesh mesh)
        {
            base.Update(environment, cam, mesh);

            if (currentMaterial != null)
            {
                Texture2D tex = (Texture2D)currentMaterial.GetTexture(Material.TEXTURE_DIFFUSE);
                if (tex != null)
                {
                    Texture.ActiveTextureSlot(0);
                    tex.Use();
                    SetUniform("u_texture", 0);
                    SetUniform("u_imgWidth", tex.Width);
                    SetUniform("u_imgHeight", tex.Height);
                }
                SetUniform("u_delta", currentMaterial.GetFloat("delta_value"));
            }
        }
コード例 #7
0
ファイル: Shader.cs プロジェクト: ajmd17/apexengine-sharp
 public virtual void Update(Environment environment, Camera cam, Mesh mesh)
 {
     SetDefaultValues();
     SetUniform(APEX_WORLDMATRIX, worldMatrix);
     SetUniform(APEX_VIEWMATRIX, viewMatrix);
     SetUniform(APEX_PROJECTIONMATRIX, projectionMatrix);
     SetUniform(APEX_CAMERAPOSITION, cam.Translation);
     SetUniform(APEX_CAMERADIRECTION, cam.Direction);
 }
コード例 #8
0
        public void SaveScreenToTexture(Camera cam, Texture toSaveTo)
        {
            toSaveTo.Use();

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

            Texture2D.Clear();
        }
コード例 #9
0
        public override void Update(Rendering.Environment environment, Camera cam, Mesh mesh)
        {
            base.Update(environment, cam, mesh);

            environment.DirectionalLight.BindLight(0, this);
            environment.AmbientLight.BindLight(0, this);

            SetUniform(ENV_FOGSTART, environment.FogStart);
            SetUniform(ENV_FOGEND, environment.FogEnd);
            SetUniform(ENV_FOGCOLOR, environment.FogColor);

            if (currentMaterial != null)
            {

                Texture diffuseTex0 = currentMaterial.GetTexture(TerrainMaterial.TEXTURE_DIFFUSE0);
                if (diffuseTex0 != null)
                {
                    Texture.ActiveTextureSlot(0);
                    diffuseTex0.Use();
                    SetUniform("terrainTexture0", 0);

                    float scale = 16f;
                   /* if (currentMaterial.GetFloat(TerrainMaterial.TEXTURE_SCALE_0) > 0)
                    {
                        scale = currentMaterial.GetFloat(TerrainMaterial.TEXTURE_SCALE_0);
                    }*/
                    SetUniform("terrainTexture0Scale", scale);
                }

                Texture normalTex0 = currentMaterial.GetTexture(TerrainMaterial.TEXTURE_NORMAL0);
                if (normalTex0 != null)
                {
                    Texture.ActiveTextureSlot(1);
                    normalTex0.Use();
                    SetUniform("terrainTexture0Normal", 1);
                    SetUniform("terrainTexture0HasNormal", 1);
                }
                else
                {
                    SetUniform("terrainTexture0HasNormal", 0);
                }

                Texture slopeTex = currentMaterial.GetTexture(TerrainMaterial.TEXTURE_DIFFUSE_SLOPE);
                if (slopeTex != null)
                {
                    Texture.ActiveTextureSlot(9);
                    slopeTex.Use();
                    SetUniform("slopeTexture", 9);

                    float scale = 16f;
                  /*  if (currentMaterial.GetFloat(TerrainMaterial.TEXTURE_SCALE_SLOPE) > 0)
                    {
                        scale = currentMaterial.GetFloat(TerrainMaterial.TEXTURE_SCALE_SLOPE);
                    }*/
                    SetUniform("slopeScale", scale);
                }

                Texture slopeNormalTex = currentMaterial.GetTexture(TerrainMaterial.TEXTURE_NORMAL_SLOPE);
                if (slopeNormalTex != null)
                {
                    Texture.ActiveTextureSlot(10);
                    slopeNormalTex.Use();
                    SetUniform("slopeTextureNormal", 10);
                    SetUniform("slopeTextureHasNormal", 1);
                }
                else
                {
                    SetUniform("slopeTextureHasNormal", 0);
                }

                Texture splatTex = currentMaterial.GetTexture(TerrainMaterial.TEXTURE_SPLAT);
                if (splatTex != null)
                {
                    Texture.ActiveTextureSlot(11);
                    splatTex.Use();
                    SetUniform("splatTexture", 11);
                    SetUniform("hasSplatMap", 1);
                }
                else
                {
                    SetUniform("hasSplatMap", 0);
                }
            }
            if (environment.ShadowsEnabled)
            {
                SetUniform("Env_ShadowsEnabled", 1);
                for (int i = 0; i < 4; i++)
                {
                    Texture.ActiveTextureSlot(3 + i);
                    environment.ShadowMaps[i].Use();
                    SetUniform("Env_ShadowMap" + i.ToString(), 3 + i);
                    SetUniform("Env_ShadowMatrix" + i.ToString(), environment.ShadowMatrices[i]);
                    SetUniform("Env_ShadowMapSplits[" + i.ToString() + "]", environment.ShadowMapSplits[i]);
                }
            }
        }
コード例 #10
0
ファイル: Populator.cs プロジェクト: ajmd17/apexengine-sharp
 public Populator(Camera cam, bool batchGeometry)
     : this(cam, batchGeometry, 12345)
 {
 }
コード例 #11
0
ファイル: Populator.cs プロジェクト: ajmd17/apexengine-sharp
 public Populator(Camera cam, bool batchGeometry, int seed)
     : this(cam, batchGeometry, seed, 0.5f)
 {
 }
コード例 #12
0
ファイル: Renderer.cs プロジェクト: ajmd17/apexengine-sharp
 public abstract void DrawTriangle(Camera cam, float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3);
コード例 #13
0
ファイル: Geometry.cs プロジェクト: ajmd17/apexengine-sharp
 public virtual void Render(Rendering.Environment environment, Camera cam)
 {
     if (shader == null)
     {
         SetDefaultShader();
     }
     if (mesh != null)
     {
         shader.Use();
         shader.ApplyMaterial(Material);
         shader.SetTransforms(GetWorldMatrix(), cam.ViewMatrix, cam.ProjectionMatrix);
         shader.Update(environment, cam, mesh);
         shader.Render(mesh);
         shader.End();
         Shader.Clear();
     }
 }
コード例 #14
0
 public PhysicsDebugDraw(Camera cam)
 {
     this.cam = cam;
 }
コード例 #15
0
ファイル: Renderer.cs プロジェクト: ajmd17/apexengine-sharp
 public abstract void SetAudioListenerValues(Camera cam);
コード例 #16
0
 public NormalMapRenderer(Environment env, Camera cam)
 {
     this.cam = cam;
     this.env = env;
 }
コード例 #17
0
 public RockPopulator(PhysicsWorld physicsWorld, Camera cam)
     : base(cam, true, 0.42f)
 {
     this.physicsWorld = physicsWorld;
 }
コード例 #18
0
ファイル: Populator.cs プロジェクト: ajmd17/apexengine-sharp
 public Populator(Camera cam, bool batchGeometry, int seed)
 {
     this.cam = cam;
     this.batchGeometry = batchGeometry;
     rand = new Random(seed);
 }
コード例 #19
0
        public void Render(Environment env, Camera cam)
        {
            renderer.Viewport(0, 0, cam.Width, cam.Height);

               // RenderDepthTexture(env, cam);

            renderer.ClearColor(backgroundColor.x, backgroundColor.y, backgroundColor.z, backgroundColor.w);
            renderer.Clear(true, true, false);

            foreach (RenderComponent rc in components)
            {
                rc.Render();
                rc.Update();
            }
            postProcessor.Capture();

            RenderBucket(env, cam, Bucket.Sky);
            RenderBucket(env, cam, Bucket.Opaque);
            RenderBucket(env, cam, Bucket.Transparent);
            RenderBucket(env, cam, Bucket.Particle);
            userRender();

            postProcessor.Release();
        }
コード例 #20
0
ファイル: Renderer.cs プロジェクト: ajmd17/apexengine-sharp
 public abstract void DrawLine(Camera cam, float x1, float y1, float z1, float x2, float y2, float z2);
コード例 #21
0
 public GrassPopulator(PhysicsWorld physicsWorld, Camera cam)
     : base(cam, true)
 {
     this.physicsWorld = physicsWorld;
 }
コード例 #22
0
 public void RenderBucket(Environment env, Camera cam, Bucket bucket)
 {
     for (int i = 0; i < geometries.Count; i++)
     {
         if (geometries[i].AttachedToRoot && geometries[i].Material.Bucket == bucket)
         {
             geometries[i].Render(env, cam);
         }
     }
 }
コード例 #23
0
        public void RenderBucketDepth(Environment env, Camera cam, Bucket bucket, DepthRenderMode renderMode)
        {
            for (int i = 0; i < geometries.Count; i++)
            {
                if (geometries[i].AttachedToRoot && geometries[i].Material.Bucket == bucket)
                {
                    if (geometries[i].DepthShader == null)
                    {
                        if (geometries[i].GetShader() == null)
                            geometries[i].SetDefaultShader();
                        ShaderProperties p = new ShaderProperties(geometries[i].ShaderProperties);
                        p.SetProperty("DEPTH", true);
                        geometries[i].DepthShader = ShaderManager.GetShader(typeof(Shaders.DepthShader), p);
                    }
                    if (renderMode == DepthRenderMode.Shadow && geometries[i].Material.GetBool(Material.MATERIAL_CASTSHADOWS))
                    {
                        geometries[i].DepthShader.Use();
                        geometries[i].DepthShader.ApplyMaterial(geometries[i].Material);
                        geometries[i].DepthShader.SetTransforms(geometries[i].GetWorldMatrix(), cam.ViewMatrix, cam.ProjectionMatrix);
                        geometries[i].DepthShader.Update(env, cam, geometries[i].Mesh);
                        geometries[i].DepthShader.Render(geometries[i].Mesh);
                        geometries[i].DepthShader.End();
                    }

                    Shader.Clear();
                    Texture2D.Clear();
                }
            }
        }
コード例 #24
0
        public void RenderBucketNormals(Environment env, Camera cam, Bucket bucket)
        {
            for (int i = 0; i < geometries.Count; i++)
            {
                if (geometries[i].AttachedToRoot && geometries[i].Material.Bucket == bucket)
                {
                    if (geometries[i].NormalsShader == null)
                    {
                        if (geometries[i].GetShader() == null)
                            geometries[i].SetDefaultShader();
                        ShaderProperties p = new ShaderProperties(geometries[i].ShaderProperties);
                        p.SetProperty("NORMALS", true);
                        geometries[i].NormalsShader = ShaderManager.GetShader(typeof(Shaders.NormalsShader), p);

                    }

                    geometries[i].NormalsShader.Use();
                    geometries[i].NormalsShader.ApplyMaterial(geometries[i].Material);
                    geometries[i].NormalsShader.SetTransforms(geometries[i].GetWorldMatrix(), cam.ViewMatrix, cam.ProjectionMatrix);
                    geometries[i].NormalsShader.Update(env, cam, geometries[i].Mesh);
                    geometries[i].NormalsShader.Render(geometries[i].Mesh);
                    geometries[i].NormalsShader.End();

                    Shader.Clear();
                }
            }
        }
コード例 #25
0
ファイル: Populator.cs プロジェクト: ajmd17/apexengine-sharp
 public Populator(Camera cam, bool batchGeometry, float probability)
     : this(cam, batchGeometry, 12345, probability)
 {
 }
コード例 #26
0
        public void RenderDepthTexture(Environment env, Camera cam)
        {
            if (depthFbo.Width != cam.Width || depthFbo.Height != cam.Height)
            {
                depthFbo.Width = cam.Width;
                depthFbo.Height = cam.Height;
                depthFbo.Init();
            }
            depthFbo.Capture();

            renderer.Clear(true, true, false);

            RenderBucketDepth(env, cam, Bucket.Opaque, DepthRenderMode.Depth);
            RenderBucketDepth(env, cam, Bucket.Transparent, DepthRenderMode.Depth);

            depthFbo.Release();
            depthTexture = depthFbo.ColorTexture;
        }
コード例 #27
0
ファイル: Populator.cs プロジェクト: ajmd17/apexengine-sharp
 public Populator(Camera cam)
     : this(cam, true)
 {
 }
コード例 #28
0
 public TreePopulator(PhysicsWorld physicsWorld, Camera cam)
     : base(cam, false, 0.4f)
 {
     this.physicsWorld = physicsWorld;
 }