Exemplo n.º 1
0
        // --------------------------------------------------------------------

        private void PrepareMaterials(Scene scene, UBO <CameraUBufferData> camUBO, UBO <LightingUBufferData> lightUBO)
        {
            HashSet <Material> materials = GetMaterialsFromRenderers(scene);

            // TODO - improve this so we only check a template once!
            foreach (EntityRenderer er in scene.RenderData.EntityRenderers)
            {
                if (!er.SceneObject.Active)
                {
                    return;
                }

                foreach (MeshRenderer mr in er.Renderers)
                {
                    if (!mr.SceneObject.Active)
                    {
                        return;
                    }
                    materials.Add(mr.Material);
                }
            }

            foreach (Material m in materials)
            {
                if (m == null)
                {
                    return;
                }

                m.Shader.BindUBO(camUBO);
                m.Shader.BindUBO(lightUBO);
            }
        }
Exemplo n.º 2
0
 public Camera(string id, float near = 0.1f, float far = 1000) : base(id)
 {
     Near         = near;
     Far          = far;
     mUBufferData = new CameraUBufferData();
     mCameraUBO   = new UBO <CameraUBufferData>(mUBufferData, "CameraData");
 }
Exemplo n.º 3
0
        // --------------------------------------------------------------------

        public override void Dispose()
        {
            base.Dispose();

            mCameraUBO.Dispose();
            mCameraUBO = null;
        }
Exemplo n.º 4
0
        // --------------------------------------------------------------------

        public Lighting()
        {
            mUBufferData.PointLight       = new LightUBufferData[8];
            mUBufferData.SpotLight        = new LightUBufferData[8];
            mUBufferData.DirectionalLight = new LightUBufferData[2];

            mLightingUBO = new UBO <LightingUBufferData>(mUBufferData, "LightingData");
        }
Exemplo n.º 5
0
        public void BindUBO(UBO ubo)
        {
            int idx = GL.GetUniformBlockIndex(Program, ubo.BlockName);

            GL.UniformBlockBinding(Program, idx, ubo.BindingPoint);
        }
Exemplo n.º 6
0
        // --------------------------------------------------------------------

        public void Dispose()
        {
            mLightingUBO.Dispose();
            mLightingUBO = null;
        }
Exemplo n.º 7
0
 public void Dispose()
 {
     mSkyUBO.Dispose();
     mSkyUBO = null;
 }
Exemplo n.º 8
0
 public Sky()
 {
     mSkyUBO = new UBO <SkyUBufferData>(mUBufferData, "SkyData");
 }