add EffectMode_ColorBurn
This commit is contained in:
@@ -341,6 +341,58 @@ void InitScalingScript()
|
|||||||
GLExt.glVertexAttrib2fARB( ATTRIB_TEXTURE_MATRIX_SCALE, 1, 1 );
|
GLExt.glVertexAttrib2fARB( ATTRIB_TEXTURE_MATRIX_SCALE, 1, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const GLcharARB *g_ColorBurnFragmentShader = " \
|
||||||
|
uniform sampler2D Texture1; \
|
||||||
|
uniform sampler2D Texture2; \
|
||||||
|
void main(void) \
|
||||||
|
{ \
|
||||||
|
vec4 color1 = texture2DProj( Texture1, gl_TexCoord[0] ); \
|
||||||
|
vec4 color2 = texture2DProj( Texture2, gl_TexCoord[0] ); \
|
||||||
|
\
|
||||||
|
/* Threshold to prevent division by zero: */ \
|
||||||
|
vec4 threshold = vec4(0.00001, 0.00001, 0.00001, 0.00001); \
|
||||||
|
vec4 color = 1-((1-color1) / max(color2, threshold)); \
|
||||||
|
color = (color * color1[3]) + (color2 * (1-color1[3]) ); \
|
||||||
|
color[3] = color2[3]; \
|
||||||
|
gl_FragColor = color; \
|
||||||
|
} \
|
||||||
|
";
|
||||||
|
|
||||||
|
static GLhandleARB g_bColorBurnShader = 0;
|
||||||
|
void InitColorBurnScript()
|
||||||
|
{
|
||||||
|
g_bColorBurnShader = 0;
|
||||||
|
|
||||||
|
if( !GLExt.m_bGL_ARB_shader_objects ||
|
||||||
|
!GLExt.m_bGL_ARB_fragment_shader ||
|
||||||
|
!GLExt.m_bGL_ARB_shading_language_100 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
GLhandleARB FragmentShader = CompileShader( GL_FRAGMENT_SHADER_ARB, g_ColorBurnFragmentShader );
|
||||||
|
if( FragmentShader == 0 )
|
||||||
|
{
|
||||||
|
GLExt.glDeleteObjectARB( FragmentShader );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AssertNoGLError();
|
||||||
|
|
||||||
|
g_bColorBurnShader = GLExt.glCreateProgramObjectARB();
|
||||||
|
GLExt.glAttachObjectARB( g_bColorBurnShader, FragmentShader );
|
||||||
|
GLExt.glDeleteObjectARB( FragmentShader );
|
||||||
|
|
||||||
|
// Link the program.
|
||||||
|
GLExt.glLinkProgramARB( g_bColorBurnShader );
|
||||||
|
GLint bLinkStatus = false;
|
||||||
|
GLExt.glGetObjectParameterivARB( g_bColorBurnShader, GL_OBJECT_LINK_STATUS_ARB, &bLinkStatus );
|
||||||
|
|
||||||
|
if( !bLinkStatus )
|
||||||
|
{
|
||||||
|
LOG->Trace( "Color burn shader link failed: %s", GetInfoLog(g_bColorBurnShader).c_str() );
|
||||||
|
GLExt.glDeleteObjectARB( g_bColorBurnShader );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static LocalizedString OBTAIN_AN_UPDATED_VIDEO_DRIVER ( "RageDisplay_OGL", "Obtain an updated driver from your video card manufacturer." );
|
static LocalizedString OBTAIN_AN_UPDATED_VIDEO_DRIVER ( "RageDisplay_OGL", "Obtain an updated driver from your video card manufacturer." );
|
||||||
static LocalizedString GLDIRECT_IS_NOT_COMPATIBLE ( "RageDisplay_OGL", "GLDirect was detected. GLDirect is not compatible with this game and should be disabled." );
|
static LocalizedString GLDIRECT_IS_NOT_COMPATIBLE ( "RageDisplay_OGL", "GLDirect was detected. GLDirect is not compatible with this game and should be disabled." );
|
||||||
RString RageDisplay_OGL::Init( const VideoModeParams &p, bool bAllowUnacceleratedRenderer )
|
RString RageDisplay_OGL::Init( const VideoModeParams &p, bool bAllowUnacceleratedRenderer )
|
||||||
@@ -602,6 +654,7 @@ RString RageDisplay_OGL::TryVideoMode( const VideoModeParams &p, bool &bNewDevic
|
|||||||
InvalidateAllGeometry();
|
InvalidateAllGeometry();
|
||||||
|
|
||||||
InitScalingScript();
|
InitScalingScript();
|
||||||
|
InitColorBurnScript();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set vsync the Windows way, if we can. (What other extensions are there
|
/* Set vsync the Windows way, if we can. (What other extensions are there
|
||||||
@@ -1445,6 +1498,42 @@ void RageDisplay_OGL::SetTextureFiltering( TextureUnit tu, bool b )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RageDisplay_OGL::SetEffectMode( EffectMode effect )
|
||||||
|
{
|
||||||
|
switch( effect )
|
||||||
|
{
|
||||||
|
case EffectMode_Normal:
|
||||||
|
if( GLExt.glUseProgramObjectARB != NULL )
|
||||||
|
GLExt.glUseProgramObjectARB( 0 );
|
||||||
|
break;
|
||||||
|
case EffectMode_ColorBurn:
|
||||||
|
if( !g_bColorBurnShader )
|
||||||
|
break; // unsupported
|
||||||
|
|
||||||
|
FlushGLErrors();
|
||||||
|
GLExt.glUseProgramObjectARB( g_bColorBurnShader );
|
||||||
|
GLint g_bColorBurnShaderTexture1 = GLExt.glGetUniformLocationARB( g_bColorBurnShader, "Texture1" );
|
||||||
|
GLint g_bColorBurnShaderTexture2 = GLExt.glGetUniformLocationARB( g_bColorBurnShader, "Texture2" );
|
||||||
|
GLExt.glUniform1iARB( g_bColorBurnShaderTexture1, 0 );
|
||||||
|
GLExt.glUniform1iARB( g_bColorBurnShaderTexture2, 1 );
|
||||||
|
AssertNoGLError();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RageDisplay_OGL::IsEffectModeSupported( EffectMode effect )
|
||||||
|
{
|
||||||
|
switch( effect )
|
||||||
|
{
|
||||||
|
case EffectMode_Normal:
|
||||||
|
return true;
|
||||||
|
case EffectMode_ColorBurn:
|
||||||
|
return g_bColorBurnShader != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void RageDisplay_OGL::SetBlendMode( BlendMode mode )
|
void RageDisplay_OGL::SetBlendMode( BlendMode mode )
|
||||||
{
|
{
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ public:
|
|||||||
void SetTextureWrapping( TextureUnit tu, bool b );
|
void SetTextureWrapping( TextureUnit tu, bool b );
|
||||||
int GetMaxTextureSize() const;
|
int GetMaxTextureSize() const;
|
||||||
void SetTextureFiltering( TextureUnit tu, bool b );
|
void SetTextureFiltering( TextureUnit tu, bool b );
|
||||||
|
void SetEffectMode( EffectMode effect );
|
||||||
|
bool IsEffectModeSupported( EffectMode effect );
|
||||||
bool SupportsRenderToTexture() const;
|
bool SupportsRenderToTexture() const;
|
||||||
unsigned CreateRenderTarget( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut );
|
unsigned CreateRenderTarget( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut );
|
||||||
void SetRenderTarget( unsigned iHandle, bool bPreserveTexture );
|
void SetRenderTarget( unsigned iHandle, bool bPreserveTexture );
|
||||||
|
|||||||
@@ -95,6 +95,9 @@ static const char *EffectModeNames[] =
|
|||||||
{
|
{
|
||||||
/* Normal blending. All supported texture modes have their standard effects. */
|
/* Normal blending. All supported texture modes have their standard effects. */
|
||||||
"Normal",
|
"Normal",
|
||||||
|
|
||||||
|
/* Color burn blending. */
|
||||||
|
"ColorBurn",
|
||||||
};
|
};
|
||||||
XToString( EffectMode );
|
XToString( EffectMode );
|
||||||
LuaXType( EffectMode );
|
LuaXType( EffectMode );
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ LuaDeclareType( TextureMode );
|
|||||||
enum EffectMode
|
enum EffectMode
|
||||||
{
|
{
|
||||||
EffectMode_Normal,
|
EffectMode_Normal,
|
||||||
|
EffectMode_ColorBurn,
|
||||||
NUM_EffectMode,
|
NUM_EffectMode,
|
||||||
EffectMode_Invalid
|
EffectMode_Invalid
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user