mirror of https://github.com/PCSX2/pcsx2.git
glsl: support channel effect on depth texture too
This commit is contained in:
parent
e0581ee771
commit
5676acaef9
|
@ -129,6 +129,7 @@ GSTextureCache::Source* GSTextureCache::LookupDepthSource(const GIFRegTEX0& TEX0
|
|||
src->m_texture = dst->m_texture;
|
||||
src->m_shared_texture = true;
|
||||
src->m_target = true; // So renderer can check if a conversion is required
|
||||
src->m_from_target = dst->m_texture; // avoid complex condition on the renderer
|
||||
src->m_32_bits_fmt = dst->m_32_bits_fmt;
|
||||
|
||||
// Insert the texture in the hash set to keep track of it. But don't bother with
|
||||
|
|
|
@ -281,27 +281,47 @@ vec4 sample_depth(vec2 st)
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
// Fetch a Single Channel
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
int fetch_raw_depth()
|
||||
{
|
||||
return int(texelFetch(RawTextureSampler, ivec2(gl_FragCoord.xy), 0).r * exp2(32.0f));
|
||||
}
|
||||
|
||||
vec4 fetch_raw_color()
|
||||
{
|
||||
return texelFetch(RawTextureSampler, ivec2(gl_FragCoord.xy), 0);
|
||||
}
|
||||
|
||||
vec4 fetch_red()
|
||||
{
|
||||
vec4 rt = texelFetch(RawTextureSampler, ivec2(gl_FragCoord.xy), 0);
|
||||
#if PS_DEPTH_FMT == 1 || PS_DEPTH_FMT == 2
|
||||
int depth = (fetch_raw_depth()) & 0xFF;
|
||||
vec4 rt = vec4(depth) / 255.0f;
|
||||
#else
|
||||
vec4 rt = fetch_raw_color();
|
||||
#endif
|
||||
return sample_p(rt.r) * 255.0f;
|
||||
}
|
||||
|
||||
vec4 fetch_blue()
|
||||
{
|
||||
vec4 rt = texelFetch(RawTextureSampler, ivec2(gl_FragCoord.xy), 0);
|
||||
#if PS_DEPTH_FMT == 1 || PS_DEPTH_FMT == 2
|
||||
int depth = (fetch_raw_depth() >> 16) & 0xFF;
|
||||
vec4 rt = vec4(depth) / 255.0f;
|
||||
#else
|
||||
vec4 rt = fetch_raw_color();
|
||||
#endif
|
||||
return sample_p(rt.b) * 255.0f;
|
||||
}
|
||||
|
||||
vec4 fetch_green()
|
||||
{
|
||||
vec4 rt = texelFetch(RawTextureSampler, ivec2(gl_FragCoord.xy), 0);
|
||||
vec4 rt = fetch_raw_color();
|
||||
return sample_p(rt.g) * 255.0f;
|
||||
}
|
||||
|
||||
vec4 fetch_alpha()
|
||||
{
|
||||
vec4 rt = texelFetch(RawTextureSampler, ivec2(gl_FragCoord.xy), 0);
|
||||
vec4 rt = fetch_raw_color();
|
||||
return sample_p(rt.a) * 255.0f;
|
||||
}
|
||||
|
||||
|
|
|
@ -1125,27 +1125,47 @@ static const char* const tfx_fs_all_glsl =
|
|||
"//////////////////////////////////////////////////////////////////////\n"
|
||||
"// Fetch a Single Channel\n"
|
||||
"//////////////////////////////////////////////////////////////////////\n"
|
||||
"int fetch_raw_depth()\n"
|
||||
"{\n"
|
||||
" return int(texelFetch(RawTextureSampler, ivec2(gl_FragCoord.xy), 0).r * exp2(32.0f));\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"vec4 fetch_raw_color()\n"
|
||||
"{\n"
|
||||
" return texelFetch(RawTextureSampler, ivec2(gl_FragCoord.xy), 0);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"vec4 fetch_red()\n"
|
||||
"{\n"
|
||||
" vec4 rt = texelFetch(RawTextureSampler, ivec2(gl_FragCoord.xy), 0);\n"
|
||||
"#if PS_DEPTH_FMT == 1 || PS_DEPTH_FMT == 2\n"
|
||||
" int depth = (fetch_raw_depth()) & 0xFF;\n"
|
||||
" vec4 rt = vec4(depth) / 255.0f;\n"
|
||||
"#else\n"
|
||||
" vec4 rt = fetch_raw_color();\n"
|
||||
"#endif\n"
|
||||
" return sample_p(rt.r) * 255.0f;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"vec4 fetch_blue()\n"
|
||||
"{\n"
|
||||
" vec4 rt = texelFetch(RawTextureSampler, ivec2(gl_FragCoord.xy), 0);\n"
|
||||
"#if PS_DEPTH_FMT == 1 || PS_DEPTH_FMT == 2\n"
|
||||
" int depth = (fetch_raw_depth() >> 16) & 0xFF;\n"
|
||||
" vec4 rt = vec4(depth) / 255.0f;\n"
|
||||
"#else\n"
|
||||
" vec4 rt = fetch_raw_color();\n"
|
||||
"#endif\n"
|
||||
" return sample_p(rt.b) * 255.0f;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"vec4 fetch_green()\n"
|
||||
"{\n"
|
||||
" vec4 rt = texelFetch(RawTextureSampler, ivec2(gl_FragCoord.xy), 0);\n"
|
||||
" vec4 rt = fetch_raw_color();\n"
|
||||
" return sample_p(rt.g) * 255.0f;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"vec4 fetch_alpha()\n"
|
||||
"{\n"
|
||||
" vec4 rt = texelFetch(RawTextureSampler, ivec2(gl_FragCoord.xy), 0);\n"
|
||||
" vec4 rt = fetch_raw_color();\n"
|
||||
" return sample_p(rt.a) * 255.0f;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
|
|
Loading…
Reference in New Issue