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); }
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)); }
public Populator(Camera cam, bool batchGeometry, int seed, float probability) { this.cam = cam; this.batchGeometry = batchGeometry; rand = new Random(12345); this.probability = probability; }
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); }
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); }
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")); } }
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); }
public void SaveScreenToTexture(Camera cam, Texture toSaveTo) { toSaveTo.Use(); Renderer.CopyScreenToTexture2D(cam.Width, cam.Height); Texture2D.Clear(); }
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]); } } }
public Populator(Camera cam, bool batchGeometry) : this(cam, batchGeometry, 12345) { }
public Populator(Camera cam, bool batchGeometry, int seed) : this(cam, batchGeometry, seed, 0.5f) { }
public abstract void DrawTriangle(Camera cam, float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3);
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(); } }
public PhysicsDebugDraw(Camera cam) { this.cam = cam; }
public abstract void SetAudioListenerValues(Camera cam);
public NormalMapRenderer(Environment env, Camera cam) { this.cam = cam; this.env = env; }
public RockPopulator(PhysicsWorld physicsWorld, Camera cam) : base(cam, true, 0.42f) { this.physicsWorld = physicsWorld; }
public Populator(Camera cam, bool batchGeometry, int seed) { this.cam = cam; this.batchGeometry = batchGeometry; rand = new Random(seed); }
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(); }
public abstract void DrawLine(Camera cam, float x1, float y1, float z1, float x2, float y2, float z2);
public GrassPopulator(PhysicsWorld physicsWorld, Camera cam) : base(cam, true) { this.physicsWorld = physicsWorld; }
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); } } }
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(); } } }
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(); } } }
public Populator(Camera cam, bool batchGeometry, float probability) : this(cam, batchGeometry, 12345, probability) { }
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; }
public Populator(Camera cam) : this(cam, true) { }
public TreePopulator(PhysicsWorld physicsWorld, Camera cam) : base(cam, false, 0.4f) { this.physicsWorld = physicsWorld; }