Example #1
0
        //--------------------------------------------------------------
        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 MarineSnow::draw(const ofCamera& cam)
 {
     // putting this here otherwise isn't working in VSE
     tex.bind();
     glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);
     tex.unbind();
     
     ofPushStyle();
     glPushAttrib(GL_ENABLE_BIT);
     glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
     glEnable(GL_POINT_SPRITE);
     ofEnableAlphaBlending();
     shader.begin();
     shader.setUniform1f("innerFogStart", innerFogStart);
     shader.setUniform1f("innerFogEnd", innerFogEnd);
     shader.setUniform1f("fogStart", fogStart);
     shader.setUniform1f("fogEnd", fogEnd);
     shader.setUniform1f("nearClip", cam.getNearClip());
     shader.setUniform1f("camZ", cam.getPosition().z);
     shader.setUniform1f("time", ofGetElapsedTimef());
     shader.setUniform1f("yMin", yMin);
     shader.setUniform1f("yRange", yMax - yMin);
     shader.setUniformTexture("tex", tex, 1);
     mesh.draw();
     shader.end();
     glPopAttrib();
     ofPopStyle();
 }
Example #3
0
        //--------------------------------------------------------------
        void ViewUbo::update(const ofCamera & camera)
        {
            const auto bounds = ofGetCurrentViewport();
            this->data.viewportSize = glm::vec2(bounds.width, bounds.height);
            this->data.rcpViewportSize = 1.0f / this->data.viewportSize;
            this->data.nearClip = camera.getNearClip();
            this->data.farClip = camera.getFarClip();
			this->data.viewMatrix = camera.getModelViewMatrix();
            this->data.inverseViewMatrix = glm::inverse(this->data.viewMatrix);

            this->ubo.updateData(sizeof(Data), &this->data);
        }
Example #4
0
void SecondCamera::setFromOtherCamera(ofCamera& other)
{
	setFarClip(other.getFarClip());
	setNearClip(other.getNearClip());
	setFov(other.getFov());
	
	matProjection = other.getProjectionMatrix();
	matModelView = other.getModelViewMatrix();
	
	matModelView.postMultTranslate(-_offset);
	
	isActive = true;
}
Example #5
0
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();
}
Example #6
0
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();
}