X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=source%2Fgles2rice%2Fsrc%2FOGLES2FragmentShaders.cpp;h=d43fcae9be78de5122e3bb24e2f0fab02cb1afa5;hb=ea03ad213a7c83970cdf11e64c769918274ebda2;hp=29b8e973460bb895f4f59a63511f62499f84e269;hpb=ad0f154dfe4248c7dd6b603b10f3a9a422ab1114;p=mupen64plus-pandora.git diff --git a/source/gles2rice/src/OGLES2FragmentShaders.cpp b/source/gles2rice/src/OGLES2FragmentShaders.cpp index 29b8e97..d43fcae 100755 --- a/source/gles2rice/src/OGLES2FragmentShaders.cpp +++ b/source/gles2rice/src/OGLES2FragmentShaders.cpp @@ -35,6 +35,7 @@ const char *vertexShader = "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"\ @@ -48,6 +49,7 @@ const char *vertexShader = "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"; @@ -71,7 +73,6 @@ const char *fragmentHeader = "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"\ @@ -80,7 +81,7 @@ const char *fragmentHeader = "{ \n"\ "vec4 comb,comb2; \n"\ " \n"\ -"#ifdef NEED_TEX0 \n"\ +"#ifdef NEED_TEX0 \n"\ "vec4 t0 = texture2D(uTex0,vTexCoord0); \n"\ "#endif \n"\ " \n"\ @@ -91,19 +92,15 @@ const char *fragmentHeader = 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 @@ -194,10 +191,10 @@ COGL_FragmentProgramCombiner::COGL_FragmentProgramCombiner(CRender *pRender) 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; @@ -328,6 +325,8 @@ void COGL_FragmentProgramCombiner::InitCombinerCycleCopy(void) 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 ) { @@ -573,6 +572,8 @@ int COGL_FragmentProgramCombiner::ParseDecodedMux() 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; @@ -650,6 +651,11 @@ void COGL_FragmentProgramCombiner::GenerateCombinerSetting(int index) 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)