// -------------------------------------------------------------------- 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); } }
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"); }
// -------------------------------------------------------------------- public override void Dispose() { base.Dispose(); mCameraUBO.Dispose(); mCameraUBO = null; }
// -------------------------------------------------------------------- public Lighting() { mUBufferData.PointLight = new LightUBufferData[8]; mUBufferData.SpotLight = new LightUBufferData[8]; mUBufferData.DirectionalLight = new LightUBufferData[2]; mLightingUBO = new UBO <LightingUBufferData>(mUBufferData, "LightingData"); }
public void BindUBO(UBO ubo) { int idx = GL.GetUniformBlockIndex(Program, ubo.BlockName); GL.UniformBlockBinding(Program, idx, ubo.BindingPoint); }
// -------------------------------------------------------------------- public void Dispose() { mLightingUBO.Dispose(); mLightingUBO = null; }
public void Dispose() { mSkyUBO.Dispose(); mSkyUBO = null; }
public Sky() { mSkyUBO = new UBO <SkyUBufferData>(mUBufferData, "SkyData"); }