public Material(Program a_shader, e_TransparencyMode a_transparencyMode, Pipeline a_pipeline, Graphics a_graphics) { m_shader = a_shader; m_transparencyMode = a_transparencyMode; m_bindings = new List <Binding>(); m_pipeline = a_pipeline; m_graphics = a_graphics; m_pipeline.AddObject(this); }
void DeferredPass(Vector3 a_cameraPosition, Vector3 a_cameraForward, Frustum a_cameraFrutrum, Camera a_camera, e_TransparencyMode a_transparencyMode) { foreach (DrawingContainer draw in m_drawingObjects) { Material material = draw.Material; if ((material.Transparency & a_transparencyMode) == 0) { continue; } Program program = material.Program; int progHandle = ((OpenTKProgram)program.InternalObject).Handle; GL.UseProgram(progHandle); if (program.DepthTest) { GL.Enable(EnableCap.DepthTest); } else { GL.Disable(EnableCap.DepthTest); } switch (program.CullingMode) { case e_CullingMode.None: { GL.Disable(EnableCap.CullFace); break; } case e_CullingMode.Front: { GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Front); break; } case e_CullingMode.Back: { GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Back); break; } case e_CullingMode.FrontAndBack: { GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.FrontAndBack); break; } } BindableContainer cont = BindMaterial(material); BindCamera(); BindTime(); if ((a_transparencyMode & e_TransparencyMode.Transparent) != 0) { GL.ActiveTexture(TextureUnit.Texture0 + cont.Textures); GL.BindTexture(TextureTarget.Texture2D, ((OpenTKTexture)m_renderTarget.DepthBuffer.InternalObject).Handle); GL.Uniform1(19, cont.Textures++); } foreach (DrawingContainer.RenderingContainer rend in draw.Renderers) { Renderer renderer = rend.Renderer; if (renderer.Visible) { Transform transform = renderer.Transform; if (transform != null) { lock (transform.GameObject) { Vector3 translation = transform.Translation; Vector3 scale = transform.Scale; float max = (float)Math.Max(scale.X, Math.Max(scale.Y, scale.Z)); float radius = renderer.Radius; float finalRadius = radius * max; if (radius != -1 && !a_cameraFrutrum.CompareSphere(translation, finalRadius)) { continue; } if (!transform.Static) { BindTransform(transform.ToMatrix(), transform.RotationMatrix); } else { int ubo = rend.TransformBuffer; BindTransform(transform, ref ubo); rend.TransformBuffer = ubo; } } } renderer.Draw(a_camera); #if DEBUG_INFO Pipeline.GLError("Graphics: Drawing: "); #endif } } } }