예제 #1
0
Point3f RealisticCamera::SampleExitPupil(const Point2f &pFilm,
        const Point2f &lensSample,
        Float *sampleBoundsArea) const {
    // Find exit pupil bound for sample distance from film center
    Float rFilm = std::sqrt(pFilm.x * pFilm.x + pFilm.y * pFilm.y);
    int rIndex = rFilm / (film->diagonal / 2) * exitPupilBounds.size();
    rIndex = std::min((int)exitPupilBounds.size() - 1, rIndex);
    Bounds2f pupilBounds = exitPupilBounds[rIndex];
    if (sampleBoundsArea) *sampleBoundsArea = pupilBounds.Area();

    // Generate sample point inside exit pupil bound
    Point2f pLens = pupilBounds.Lerp(lensSample);

    // Return sample point rotated by angle of _pFilm_ with $+x$ axis
    Float sinTheta = (rFilm != 0) ? pFilm.y / rFilm : 0;
    Float cosTheta = (rFilm != 0) ? pFilm.x / rFilm : 1;
    return Point3f(cosTheta * pLens.x - sinTheta * pLens.y,
                   sinTheta * pLens.x + cosTheta * pLens.y, LensRearZ());
}
예제 #2
0
파일: mlt.cpp 프로젝트: syoyo/pbrt-v3
// MLT Method Definitions
Spectrum MLTIntegrator::L(const Scene &scene, MemoryArena &arena,
                          const std::unique_ptr<Distribution1D> &lightDistr,
                          const std::unordered_map<const Light *, size_t> &lightToIndex,
                          MLTSampler &sampler, int depth, Point2f *pRaster) {
    sampler.StartStream(cameraStreamIndex);
    // Determine the number of available strategies and pick a specific one
    int s, t, nStrategies;
    if (depth == 0) {
        nStrategies = 1;
        s = 0;
        t = 2;
    } else {
        nStrategies = depth + 2;
        s = std::min((int)(sampler.Get1D() * nStrategies), nStrategies - 1);
        t = nStrategies - s;
    }

    // Generate a camera subpath with exactly _t_ vertices
    Vertex *cameraVertices = arena.Alloc<Vertex>(t);
    Bounds2f sampleBounds = (Bounds2f)camera->film->GetSampleBounds();
    *pRaster = sampleBounds.Lerp(sampler.Get2D());
    if (GenerateCameraSubpath(scene, sampler, arena, t, *camera, *pRaster,
                              cameraVertices) != t)
        return Spectrum(0.f);

    // Generate a light subpath with exactly _s_ vertices
    sampler.StartStream(lightStreamIndex);
    Vertex *lightVertices = arena.Alloc<Vertex>(s);
    if (GenerateLightSubpath(scene, sampler, arena, s, cameraVertices[0].time(),
                             *lightDistr, lightToIndex, lightVertices) != s)
        return Spectrum(0.f);

    // Execute connection strategy and return the radiance estimate
    sampler.StartStream(connectionStreamIndex);
    return ConnectBDPT(scene, lightVertices, cameraVertices, s, t, *lightDistr,
                       lightToIndex, *camera, sampler, pRaster) *
           nStrategies;
}
예제 #3
0
	void Console::Draw() {
		if ( font == NULL ) {
			font = r3::CreateStbFont( con_font.GetVal(), con_fontSize.GetVal() ); 			
		}
		if ( ! IsActive() ) {
			return;
		}
		
		int border = 10;
		
		int w = r_windowWidth.GetVal();
		int h = r_windowHeight.GetVal();
		int conW = w - 2 * border;
		int conH = ( h - ( h >> 2 ) ) - border;
		float s = con_fontScale.GetVal();

		static Bounds2f bO;
		static float yAdvance = 0;
		static float sCache = 0;
		if ( s != sCache ) {
			bO = font->GetStringDimensions( "O", s );
			Bounds2f bb = font->GetStringDimensions( "|", s );
			sCache = s;
			yAdvance = std::max( bO.Height(), bb.Height() );
		}
		
		int x0 = border;
		int y = ( h >> 2) + border;
		
		ImColor( 16, 16, 16, con_opacity.GetVal() * 255 );
		BlendFunc( BlendFunc_SrcAlpha, BlendFunc_OneMinusSrcAlpha );
		BlendEnable();

		DrawQuad( x0, y, x0 + conW, y + conH );
		
		string cl = "> " + commandLine;
		int cp = cursorPos + 2;

		Bounds2f b = font->GetStringDimensions( cl, s );
		Bounds2f b2 = font->GetStringDimensions( cl.substr(0, cp ), s );
		
		ImColor( 255, 255, 255, 192 );
		font->Print( cl, x0, y, s );
		
		ImColor( 255, 255, 255, 64 );
		DrawQuad( x0 + b2.Width(), y, x0 + b2.Width() + bO.Width(), y + bO.Height() );
		
		y += yAdvance;

		ImColor( 255, 255, 255, 128 );
		for ( int i = outputBuffer.size() - 1; i >= 0 && y < h; i-- ) {
			string & line = outputBuffer[ i ];
			font->Print( line, x0, y, s );
			y += yAdvance;
		}

		BlendDisable();
	}
예제 #4
0
파일: console.cpp 프로젝트: nyotis/r3
void Console::Draw() {
    if ( font == NULL ) {
        font = r3::CreateStbFont( con_font.GetVal(), "", con_fontSize.GetVal() );
    }

    ScopedMutex scm( conMutex, R3_LOC );

    if ( ! IsActive() ) {
        return;
    }

    int border = 10;

    int w = r_windowWidth.GetVal();
    int h = r_windowHeight.GetVal();
    int conW = w - 2 * border;
    int conH = ( h - ( h >> 2 ) ) - border;
    float s = con_fontScale.GetVal();

    static Bounds2f bO;
    static float yAdvance = 0;
    static float sCache = 0;
    if ( s != sCache ) {
        bO = font->GetStringDimensions( "O", s );
        Bounds2f bb = font->GetStringDimensions( "|", s );
        sCache = s;
        yAdvance = std::max<int>( bO.Height(), bb.Height() );
    }

    int x0 = border;
    int y = ( h >> 2) + border;

    glColor4ub( 16, 16, 16, con_opacity.GetVal() * 255 );
    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
    glEnable( GL_BLEND );

    DrawQuad( x0, y, x0 + conW, y + conH );

    string cl = "> " + commandLine;
    int cp = cursorPos + 2;

    //Bounds2f b = font->GetStringDimensions( cl, s );
    Bounds2f b2 = font->GetStringDimensions( cl.substr(0, cp ), s );

    glColor4ub( 255, 255, 255, 192 );
    font->Print( cl, x0, y, s );


    glColor4ub( 255, 255, 255, 64 );
    DrawQuad( x0 + b2.Width(), y, x0 + b2.Width() + bO.Width(), y + bO.Height() );

    y += yAdvance;

    glColor4ub( 255, 255, 255, 128 );
    for ( int i = (int)outputBuffer.size() - 1 - outputBufferPos; i >= 0 && y < h; i-- ) {
        string & line = outputBuffer[ i ];
        font->Print( line, x0, y, s );
        y += yAdvance;
    }
    glDisable( GL_BLEND );
}