"attribute lowp vec2 aTexCoord0; \n"\
"attribute lowp vec2 aTexCoord1; \n"\
"attribute lowp vec2 aAtlasTransform; \n"\
+"attribute mediump float aFogCoord; \n"\
" \n"\
"varying lowp float vFactor; \n"\
"varying lowp vec4 vShadeColor; \n"\
"vShadeColor = aColor; \n"\
"vTexCoord0 = aTexCoord0; \n"\
"vTexCoord1 = aTexCoord1; \n"\
+"vFog = clamp((FogMinMax[1] - aFogCoord)/(FogMinMax[1]-FogMinMax[0]),0.0,1.0); \n"\
" \n"\
"} \n"\
" \n";
"uniform vec4 FogColor; \n"\
"uniform vec2 FogMinMax; \n"\
" \n"\
-"varying lowp float vFactor; \n"\
"varying lowp vec4 vShadeColor; \n"\
"varying mediump vec2 vTexCoord0; \n"\
"varying lowp vec2 vTexCoord1; \n"\
"{ \n"\
"vec4 comb,comb2; \n"\
" \n"\
-"#ifdef NEED_TEX0 \n"\
+"#ifdef NEED_TEX0 \n"\
"vec4 t0 = texture2D(uTex0,vTexCoord0); \n"\
"#endif \n"\
" \n"\
const char *fragmentFooter =
" \n"\
"#ifdef FOG \n"\
-" float z = gl_FragCoord.z * 2.0 - 1.0; \n"\
-" float FogFactor = (FogMinMax[1] - z) / (FogMinMax[1] - FogMinMax[0]); \n"\
-" FogFactor = clamp(FogFactor, 0.0, 1.0); \n"\
-" \n"\
-" gl_FragColor.rgb = mix(FogColor.rgb, comb.rgb, FogFactor ); \n"\
-" gl_FragColor.a = comb.a; \n"\
-"#else \n"\
-" gl_FragColor = comb; \n"\
-"#endif \n"\
-" \n"\
-"#ifdef ALPHA_TEST \n"\
+"gl_FragColor.rgb = mix(FogColor.rgb,comb.rgb,vFog); \n"\
+"gl_FragColor.a = comb.a; \n"\
+"#else \n"\
+"gl_FragColor = comb; \n"\
+"#endif \n"\
+" \n"\
+"#ifdef ALPHA_TEST \n"\
ALPHA_TEST
-"#endif \n"\
+"#endif \n"\
"} \n";
//Fragment shader for InitCycleCopy
m_pDecodedMux = new DecodedMuxForPixelShader;
m_bFragmentProgramIsSupported = true;
m_AlphaRef = 0.0f;
- bAlphaTestState = DISABLE;
- bAlphaTestPreviousState = DISABLE;
- bFogState = DISABLE;
- bFogPreviousState = DISABLE;
+ bAlphaTestState = false;
+ bAlphaTestPreviousState = false;
+ bFogState = false;
+ bFogPreviousState = false;
//Create shaders for fill and copy
GLint success;
OPENGL_CHECK_ERRORS;
glDisableVertexAttribArray(VS_TEXCOORD1);
OPENGL_CHECK_ERRORS;
+ glDisableVertexAttribArray(VS_FOG);
+ OPENGL_CHECK_ERRORS;
COGLTexture* pTexture = g_textures[gRSP.curTile].m_pCOGLTexture;
if( pTexture )
{
OPENGL_CHECK_ERRORS;
glBindAttribLocation(res.programID,VS_POSITION,"aPosition");
OPENGL_CHECK_ERRORS;
+ glBindAttribLocation(res.programID,VS_FOG,"aFogCoord");
+ OPENGL_CHECK_ERRORS;
glLinkProgram(res.programID);
OPENGL_CHECK_ERRORS;
OPENGL_CHECK_ERRORS;
glVertexAttribPointer(VS_COLOR, 4, GL_UNSIGNED_BYTE,GL_TRUE, sizeof(uint8)*4, &(g_oglVtxColors[0][0]) );
OPENGL_CHECK_ERRORS;
+
+ glEnableVertexAttribArray(VS_FOG);
+ OPENGL_CHECK_ERRORS;
+ glVertexAttribPointer(VS_FOG,1,GL_FLOAT,GL_FALSE,sizeof(float)*5,&(g_vtxProjected5[0][4]));
+ OPENGL_CHECK_ERRORS;
}
void COGL_FragmentProgramCombiner::GenerateCombinerSettingConstants(int index)