Esempio n. 1
0
/*
 * =================
 * R_Bloom_GeneratexCross - alternative bluring method
 * =================
 */
void R_Bloom_GeneratexCross(void)
{
    int        i;
    static int BLOOM_BLUR_RADIUS = 8;
    //static float	BLOOM_BLUR_INTENSITY = 2.5f;
    float        BLOOM_BLUR_INTENSITY;
    static float intensity;
    static float range;

    // set up sample size workspace
    glViewport(0, 0, sample_width, sample_height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, sample_width, sample_height, 0, -10, 100);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    // copy small scene into r_bloomeffecttexture
    GL_Bind(0, r_bloomeffecttexture);
    glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height);

    // start modifying the small scene corner
    GL_Enable(GL_BLEND);

    // darkening passes
    if (r_bloom_darken->value)
    {
        GL_BlendFunc(GL_DST_COLOR, GL_ZERO);
        GL_TexEnv(GL_MODULATE);

        R_Bloom_DrawStart
        for (i = 0; i < r_bloom_darken->value; i++)
        {
            R_Bloom_SamplePass(0, 0, 1.0f, 1.0f, 1.0f, 1.0f);
        }
        R_Bloom_DrawFinish
        glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height);
    }
Esempio n. 2
0
// =================
// R_Bloom_GeneratexDiamonds
//=================
void R_Bloom_GeneratexDiamonds( void )
{
	int         i, j;
	static float intensity;

	// Setup sample size workspace
	glViewport( 0, 0, sample_width, sample_height );
	glMatrixMode( GL_PROJECTION );
	glLoadIdentity ();
	glOrtho(0, sample_width, sample_height, 0, -10, 100);
	glMatrixMode( GL_MODELVIEW );
	glLoadIdentity ();

	// Copy small scene into r_bloomeffecttexture.
	GL_Bind(r_bloomeffecttexture);
	//glBindTexture(GL_TEXTURE_2D, r_bloomeffecttexture);
	glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height);

	// Start modifying the small scene corner.
	glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
	glEnable(GL_BLEND);

    // Darkening passes
	if( r_bloom_darken.value )
	{
		glBlendFunc(GL_DST_COLOR, GL_ZERO);
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

		for(i=0; i < r_bloom_darken.integer ;i++) 
		{
			R_Bloom_SamplePass( 0, 0 );
		}
		glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height);
	}

    // Bluring passes.
    //glBlendFunc(GL_ONE, GL_ONE);
    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
   
    if( r_bloom_diamond_size.value > 7 || r_bloom_diamond_size.value <= 3)
	{
		if( r_bloom_diamond_size.integer != 8 ) 
		{
			Cvar_SetValue( &r_bloom_diamond_size, 8 );
		}

		for(i = 0; i < r_bloom_diamond_size.integer; i++) 
		{
			for(j = 0; j < r_bloom_diamond_size.integer; j++) 
			{
				intensity = r_bloom_intensity.value * 0.3 * Diamond8x[i][j];
				if( intensity < 0.01f )
				{
					continue;
				}
				glColor4f( intensity, intensity, intensity, 1.0);
				R_Bloom_SamplePass( i - 4, j - 4 );
			}
		}
	} 
	else if( r_bloom_diamond_size.integer > 5 ) 
	{
		if( r_bloom_diamond_size.integer != 6 ) 
		{
			Cvar_SetValue( &r_bloom_diamond_size, 6 );
		}

		for(i = 0; i < r_bloom_diamond_size.integer; i++) 
		{
			for(j = 0; j < r_bloom_diamond_size.integer; j++) 
			{
				intensity = r_bloom_intensity.value * 0.5 * Diamond6x[i][j];
				if( intensity < 0.01f ) 
				{
					continue;
				}
				glColor4f( intensity, intensity, intensity, 1.0);
				R_Bloom_SamplePass( i - 3, j - 3 );
			}
		}
	} 
	else if( r_bloom_diamond_size.value > 3 ) 
	{
		if( r_bloom_diamond_size.integer != 4 )
		{
			Cvar_SetValue( &r_bloom_diamond_size, 4 );
		}

		for(i = 0; i < r_bloom_diamond_size.integer; i++) 
		{
			for(j = 0; j < r_bloom_diamond_size.integer; j++) 
			{
				intensity = r_bloom_intensity.value * 0.8f * Diamond4x[i][j];
				if( intensity < 0.01f ) continue;
				glColor4f( intensity, intensity, intensity, 1.0);
				R_Bloom_SamplePass( i-2, j-2 );
			}
		}
	}
   
	glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height);

	// Restore full screen workspace.
	glViewport( 0, 0, glwidth, glheight );
	glMatrixMode( GL_PROJECTION );
	glLoadIdentity ();
	glOrtho(0, glwidth, glheight, 0, -10, 100);
	glMatrixMode( GL_MODELVIEW );
	glLoadIdentity ();
}                                           
Esempio n. 3
0
// =================
// R_Bloom_GeneratexCross - alternative bluring method
// =================
void R_Bloom_GeneratexCross( void )
{
	int         i;
	static int      BLOOM_BLUR_RADIUS = 8;
	//static float  BLOOM_BLUR_INTENSITY = 2.5f;
	float   BLOOM_BLUR_INTENSITY;
	static float intensity;
	static float range;

	// Setup sample size workspace.
	glViewport( 0, 0, sample_width, sample_height );
	glMatrixMode( GL_PROJECTION );
	glLoadIdentity ();
	glOrtho(0, sample_width, sample_height, 0, -10, 100);
	glMatrixMode( GL_MODELVIEW );
	glLoadIdentity ();

	// Copy small scene into r_bloomeffecttexture.
	GL_Bind(r_bloomeffecttexture);
	//glBindTexture(GL_TEXTURE_2D, r_bloomeffecttexture);
	glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height);

	// Start modifying the small scene corner.
	glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
	glEnable(GL_BLEND);

	// Darkening passes.
	if( r_bloom_darken.value )
	{
		glBlendFunc(GL_DST_COLOR, GL_ZERO);
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

		for(i=0; i<r_bloom_darken.integer ;i++) 
		{
			R_Bloom_SamplePass( 0, 0 );
		}
		glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height);
	}

    // Bluring passes.
	if( BLOOM_BLUR_RADIUS ) 
	{
		glBlendFunc(GL_ONE, GL_ONE);

		range = (float)BLOOM_BLUR_RADIUS;

		BLOOM_BLUR_INTENSITY = r_bloom_intensity.value;
		//diagonal-cross draw 4 passes to add initial smooth
		glColor4f( 0.5f, 0.5f, 0.5f, 1.0);
		R_Bloom_SamplePass( 1, 1 );
		R_Bloom_SamplePass( -1, 1 );
		R_Bloom_SamplePass( -1, -1 );
		R_Bloom_SamplePass( 1, -1 );
		glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height);

		for(i =- (BLOOM_BLUR_RADIUS + 1); i <BLOOM_BLUR_RADIUS; i++) 
		{
			intensity = BLOOM_BLUR_INTENSITY/(range*2+1)*(1 - fabs(i*i)/(float)(range*range));
			if( intensity < 0.05f )
			{
				continue;
			}
			glColor4f( intensity, intensity, intensity, 1.0f);
			R_Bloom_SamplePass( i, 0 );
			//R_Bloom_SamplePass( -i, 0 );
		}

		glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height);

		//for(i = 0; i < BLOOM_BLUR_RADIUS; i++)
		for(i =- (BLOOM_BLUR_RADIUS + 1); i < BLOOM_BLUR_RADIUS; i++) 
		{
			intensity = BLOOM_BLUR_INTENSITY / (range*2+1) * (1 - fabs(i * i) / (float)(range * range));
			if( intensity < 0.05f )
			{
				continue;
			}
			glColor4f( intensity, intensity, intensity, 1.0f);
			R_Bloom_SamplePass( 0, i );
			//R_Bloom_SamplePass( 0, -i );
		}

		glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height);
	}

	// Restore full screen workspace.
	glViewport( 0, 0, glwidth, glheight );
	glMatrixMode( GL_PROJECTION );
	glLoadIdentity ();
	glOrtho(0, glwidth, glheight, 0, -10, 100);
	glMatrixMode( GL_MODELVIEW );
	glLoadIdentity ();
}
Esempio n. 4
0
/*
* R_Bloom_GeneratexDiamonds
*/
static void R_Bloom_GeneratexDiamonds( void )
{
	int i, j, k;
	float intensity, scale, *diamond;

	// set up sample size workspace
	GL_Scissor( 0, glState.height - sample_height, sample_width, sample_height );
	GL_Viewport( 0, glState.height - sample_height, sample_width, sample_height );
	qglMatrixMode( GL_PROJECTION );
	qglLoadIdentity();
	qglOrtho( 0, sample_width, sample_height, 0, -10, 100 );
	qglMatrixMode( GL_MODELVIEW );
	qglLoadIdentity();

	// copy small scene into r_bloomeffecttexture
	GL_Bind( 0, r_bloomeffecttexture );
	qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height );

	// start modifying the small scene corner
	qglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );

	// darkening passes
	if( r_bloom_darken->integer )
	{
		GL_TexEnv( GL_MODULATE );
		GL_SetState( GLSTATE_NO_DEPTH_TEST|GLSTATE_SRCBLEND_DST_COLOR|GLSTATE_DSTBLEND_ZERO );

		for( i = 0; i < r_bloom_darken->integer; i++ )
			R_Bloom_SamplePass( 0, 0 );
		qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height );
	}

	// bluring passes
	GL_SetState( GLSTATE_NO_DEPTH_TEST|GLSTATE_SRCBLEND_ONE|GLSTATE_DSTBLEND_ONE_MINUS_SRC_COLOR );

	if( r_bloom_diamond_size->integer > 7 || r_bloom_diamond_size->integer <= 3 )
	{
		if( r_bloom_diamond_size->integer != 8 )
			Cvar_ForceSet( "r_bloom_diamond_size", "8" );
	}
	else if( r_bloom_diamond_size->integer > 5 )
	{
		if( r_bloom_diamond_size->integer != 6 )
			Cvar_ForceSet( "r_bloom_diamond_size", "6" );
	}
	else if( r_bloom_diamond_size->integer > 3 )
	{
		if( r_bloom_diamond_size->integer != 4 )
			Cvar_ForceSet( "r_bloom_diamond_size", "4" );
	}

	switch( r_bloom_diamond_size->integer )
	{
	case 4:
		k = 2;
		diamond = &Diamond4x[0][0];
		scale = r_bloom_intensity->value * 0.8f;
		break;
	case 6:
		k = 3;
		diamond = &Diamond6x[0][0];
		scale = r_bloom_intensity->value * 0.5f;
		break;
	default:
//	case 8:
		k = 4;
		diamond = &Diamond8x[0][0];
		scale = r_bloom_intensity->value * 0.3f;
		break;
	}

	for( i = 0; i < r_bloom_diamond_size->integer; i++ )
	{
		for( j = 0; j < r_bloom_diamond_size->integer; j++, diamond++ )
		{
			intensity =  *diamond * scale;
			if( intensity < 0.01f )
				continue;

			qglColor4f( intensity, intensity, intensity, 1.0 );
			R_Bloom_SamplePass( i - k, j - k );
		}
	}

	qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height );

	// restore full screen workspace
	GL_Scissor( 0, 0, glState.width, glState.height );
	GL_Viewport( 0, 0, glState.width, glState.height );
	qglMatrixMode( GL_PROJECTION );
	qglLoadIdentity();
	qglOrtho( 0, glState.width, glState.height, 0, -10, 100 );
	qglMatrixMode( GL_MODELVIEW );
	qglLoadIdentity();
}
Esempio n. 5
0
/*
=================
R_Bloom_GeneratexDiamonds
=================
*/
static void R_Bloom_GeneratexDiamonds( void )
{
    int i, j;
    float intensity;

    // set up sample size workspace
    pglScissor( 0, 0, sample_width, sample_height );
    pglViewport( 0, 0, sample_width, sample_height );
    pglMatrixMode( GL_PROJECTION );
    pglLoadIdentity();
    pglOrtho( 0, sample_width, sample_height, 0, -10, 100 );
    pglMatrixMode( GL_MODELVIEW );
    pglLoadIdentity();

    // copy small scene into r_bloomeffecttexture
    GL_Bind( GL_TEXTURE0, r_bloomeffecttexture );
    pglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height );

    // start modifying the small scene corner
    pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
    pglEnable( GL_BLEND );

    // darkening passes
    if( r_bloom_darken->value )
    {
        pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
        pglBlendFunc( GL_DST_COLOR, GL_ZERO );

        for( i = 0; i < (int)r_bloom_darken->value; i++ )
            R_Bloom_SamplePass( 0, 0 );

        pglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height );
    }

    // bluring passes
    pglBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_COLOR );

    if( r_bloom_diamond_size->value > 7.0f || r_bloom_diamond_size->value <= 3.0f )
    {
        if( r_bloom_diamond_size->value != 8.0f )
            CVAR_SET_FLOAT( "r_bloom_diamond_size", 8.0f );

        for( i = 0; i < r_bloom_diamond_size->value; i++ )
        {
            for( j = 0; j < r_bloom_diamond_size->value; j++ )
            {
                intensity = r_bloom_intensity->value * 0.3f * Diamond8x[i][j];
                if( intensity < 0.01f ) continue;
                pglColor4f( intensity, intensity, intensity, 1.0f );
                R_Bloom_SamplePass( i-4, j-4 );
            }
        }
    }
    else if( r_bloom_diamond_size->value > 5.0f )
    {
        if( r_bloom_diamond_size->value != 6.0f )
            CVAR_SET_FLOAT( "r_bloom_diamond_size", 6.0f );

        for( i = 0; i < r_bloom_diamond_size->value; i++ )
        {
            for( j = 0; j < r_bloom_diamond_size->value; j++ )
            {
                intensity = r_bloom_intensity->value * 0.5f * Diamond6x[i][j];
                if( intensity < 0.01f ) continue;
                pglColor4f( intensity, intensity, intensity, 1.0f );
                R_Bloom_SamplePass( i-3, j-3 );
            }
        }
    }
    else if( r_bloom_diamond_size->value > 3.0f )
    {
        if( r_bloom_diamond_size->value != 4.0f )
            CVAR_SET_FLOAT( "r_bloom_diamond_size", 4.0f );

        for( i = 0; i < r_bloom_diamond_size->value; i++ )
        {
            for( j = 0; j < r_bloom_diamond_size->value; j++ )
            {
                intensity = r_bloom_intensity->value * 0.8f * Diamond4x[i][j];
                if( intensity < 0.01f ) continue;
                pglColor4f( intensity, intensity, intensity, 1.0f );
                R_Bloom_SamplePass( i-2, j-2 );
            }
        }
    }

    pglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height );

    // restore full screen workspace
    pglScissor( 0, 0, glState.width, glState.height );
    pglViewport( 0, 0, glState.width, glState.height );
    pglMatrixMode( GL_PROJECTION );
    pglLoadIdentity();
    pglOrtho( 0, glState.width, glState.height, 0, -10, 100 );
    pglMatrixMode( GL_MODELVIEW );
    pglLoadIdentity();
}
Esempio n. 6
0
/*
=================
R_Bloom_GeneratexDiamonds
=================
*/
void R_Bloom_GeneratexDiamonds( refdef_t *fd )
{
    int			i, j;
    static float intensity;

    //set up sample size workspace
    qglViewport( 0, 0, sample_width, sample_height );
    qglMatrixMode( GL_PROJECTION );
    qglLoadIdentity ();
    qglOrtho(0, sample_width, sample_height, 0, -10, 100);
    qglMatrixMode( GL_MODELVIEW );
    qglLoadIdentity ();

    //copy small scene into r_bloomeffecttexture
    GL_Bind(r_bloomeffecttexture->texnum);
    qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height);

    //start modifying the small scene corner
    qglColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
    GL_Enable(GL_BLEND);

    //Com_Printf("%d %d\n", r_bloom_darken->value, fd->bloomdarken);

    //darkening passes
    if( r_bloom_darken->value )
    {
        GL_BlendFunc(GL_DST_COLOR, GL_ZERO);
        GL_TexEnv(GL_MODULATE);

        for(i=0; i< r_bloom_darken->value  ; i++) {
            R_Bloom_SamplePass( 0, 0 );
        }
        qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height);
    }

    //bluring passes
    //GL_BlendFunc(GL_ONE, GL_ONE);
    GL_BlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);



    if( r_bloom_diamond_size->value > 7 || r_bloom_diamond_size->value <= 3)
    {
        if( (int)r_bloom_diamond_size->value != 8 ) Cvar_SetValue( "r_bloom_diamond_size", 8 );

        for(i=0; i<r_bloom_diamond_size->value; i++) {
            for(j=0; j<r_bloom_diamond_size->value; j++) {
                intensity = /*bc mod*/(fd->bloomintensity +  r_bloom_intensity->value) * 0.3 * Diamond8x[i][j];
                if( intensity < r_bloom_threshold->value ) continue;
                qglColor4f( intensity, intensity, intensity, 1.0);
                R_Bloom_SamplePass( i-4, j-4 );
            }
        }
    } else if( r_bloom_diamond_size->value > 5 ) {

        if( r_bloom_diamond_size->value != 6 ) Cvar_SetValue( "r_bloom_diamond_size", 6 );

        for(i=0; i<r_bloom_diamond_size->value; i++) {
            for(j=0; j<r_bloom_diamond_size->value; j++) {
                intensity = /*bc mod*/(fd->bloomintensity + r_bloom_intensity->value) * 0.5 * Diamond6x[i][j];
                if( intensity < r_bloom_threshold->value ) continue;
                qglColor4f( intensity, intensity, intensity, 1.0);
                R_Bloom_SamplePass( i-3, j-3 );
            }
        }
    } else if( r_bloom_diamond_size->value > 3 ) {

        if( (int)r_bloom_diamond_size->value != 4 ) Cvar_SetValue( "r_bloom_diamond_size", 4 );

        for(i=0; i<r_bloom_diamond_size->value; i++) {
            for(j=0; j<r_bloom_diamond_size->value; j++) {
                intensity = /*bc mod*/(fd->bloomintensity + r_bloom_intensity->value) * 0.8f * Diamond4x[i][j];
                if( intensity < r_bloom_threshold->value ) continue;
                qglColor4f( intensity, intensity, intensity, 1.0);
                R_Bloom_SamplePass( i-2, j-2 );
            }
        }
    }

    qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, sample_width, sample_height);

    //restore full screen workspace
    qglViewport( 0, 0, vid.width, vid.height );
    qglMatrixMode( GL_PROJECTION );
    qglLoadIdentity ();
    qglOrtho(0, vid.width, vid.height, 0, -10, 100);
    qglMatrixMode( GL_MODELVIEW );
    qglLoadIdentity ();
}