//-------------------------------------------------------------- void ClusterGrid::setup(const ofCamera & camera) { this->clear(); this->projInfo.fov = ofDegToRad(camera.getFov()); this->projInfo.aspectRatio = camera.getAspectRatio(); this->projInfo.nearZ = camera.getNearClip(); this->projInfo.farZ = camera.getFarClip(); memset(this->culledPointLightIndices, 0, sizeof(this->culledPointLightIndices[0]) * MAX_POINT_LIGHTS); this->numCulledLightIndices = 0; memset(this->lightIndices, 0, sizeof(this->lightIndices[0]) * MAX_CLUSTERED_LIGHTS); memset(this->lightSortKeys, 0, sizeof(this->lightSortKeys[0]) * MAX_CLUSTERED_LIGHTS); memset(this->tempLightSortKeys, 0, sizeof(this->tempLightSortKeys[0]) * MAX_CLUSTERED_LIGHTS); memset(this->tempLightIndices, 0, sizeof(this->tempLightIndices[0]) * MAX_CLUSTERED_LIGHTS); memset(this->clusterLightPointerList, 0, sizeof(this->clusterLightPointerList[0]) * NUM_CLUSTERS); this->createLightIndexTextures(); this->planesX = new util::Plane[NUM_PLANES_X]; this->planesY = new util::Plane[NUM_PLANES_Y]; this->planesZ = new util::Plane[NUM_PLANES_Z]; this->createPlanes(); }
void lb::LightSystem::Init( const ofCamera& _camera ) { lb::ProjInfo projInfo; projInfo.fov = ofDegToRad( _camera.getFov() ); projInfo.aspectRatio = _camera.getAspectRatio(); projInfo.nearZ = _camera.getNearClip(); projInfo.farZ = _camera.getFarClip(); m_pointLights.reserve( lb::ClusterGrid::MAX_POINT_LIGHTS ); m_clusterGrid.Init( projInfo ); m_clusterGridDebug.CreateClusterMesh( m_clusterGrid, projInfo ); // Create point light uniform buffer m_pointLightUbo.allocate( lb::ClusterGrid::MAX_POINT_LIGHTS * sizeof( lb::PointLight ), nullptr, GL_DYNAMIC_DRAW ); assert( true == m_pointLightUbo.isAllocated() ); m_debugSphere = ofSpherePrimitive( 1.0f, 8 ); m_pointLights.clear(); }
void lb::LightSystem::Init( const ofCamera& _camera ) { lb::ProjInfo projInfo; projInfo.fov = ofDegToRad( _camera.getFov() ); projInfo.aspectRatio = _camera.getAspectRatio(); projInfo.nearZ = _camera.getNearClip(); projInfo.farZ = _camera.getFarClip(); m_directionalLights.reserve( skMaxDirectionalLights ); m_pointLights.reserve( skMaxPointLights ); m_clusterGrid.Init( projInfo ); m_clusterGridDebug.CreateClusterMesh( m_clusterGrid, projInfo ); // Create point light uniform buffer size_t numBytes = sizeof( LightUbo ); ofLogNotice() << numBytes << endl; m_pointLightUbo.allocate( numBytes, nullptr, GL_DYNAMIC_DRAW ); assert( true == m_pointLightUbo.isAllocated() ); m_debugSphere = ofSpherePrimitive( 1.0f, 8 ); m_pointLights.clear(); }