mirror of https://github.com/PCSX2/pcsx2.git
glsl: fix coordinate in channel depth effect
UV can't be used directly in channel effect Properly fix Urban Chaos smoke
This commit is contained in:
parent
b8b0a0d662
commit
7c430c9d3c
|
@ -176,14 +176,24 @@ mat4 sample_4p(vec4 u)
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
int fetch_raw_depth()
|
||||||
// Depth sampling
|
{
|
||||||
//////////////////////////////////////////////////////////////////////
|
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_c(ivec2 uv)
|
vec4 fetch_c(ivec2 uv)
|
||||||
{
|
{
|
||||||
return texelFetch(TextureSampler, ivec2(uv), 0);
|
return texelFetch(TextureSampler, ivec2(uv), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Depth sampling
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
ivec2 clamp_wrap_uv_depth(ivec2 uv)
|
ivec2 clamp_wrap_uv_depth(ivec2 uv)
|
||||||
{
|
{
|
||||||
ivec2 uv_out = uv;
|
ivec2 uv_out = uv;
|
||||||
|
@ -226,8 +236,14 @@ vec4 sample_depth(vec2 st)
|
||||||
|
|
||||||
vec4 t;
|
vec4 t;
|
||||||
#if PS_URBAN_CHAOS_HACK == 1
|
#if PS_URBAN_CHAOS_HACK == 1
|
||||||
// Convert a GL_FLOAT32 to a special color format expected by the game
|
// Depth buffer is read as a RGB5A1 texture. The game try to extract the green channel.
|
||||||
int depth = int(fetch_c(uv).r * exp2(32.0f));
|
// So it will do a first channel trick to extract lsb, value is right-shifted.
|
||||||
|
// Then a new channel trick to extract msb which will shifted to the left.
|
||||||
|
// OpenGL uses a FLOAT32 format for the depth so it requires a couple of conversion.
|
||||||
|
// To be faster both steps (msb&lsb) are done in a single pass.
|
||||||
|
|
||||||
|
// Warning: UV can't be used in channel effect
|
||||||
|
int depth = fetch_raw_depth();
|
||||||
|
|
||||||
// Convert lsb based on the palette
|
// Convert lsb based on the palette
|
||||||
t = texelFetch(PaletteSampler, ivec2((depth & 0xFF), 0), 0);
|
t = texelFetch(PaletteSampler, ivec2((depth & 0xFF), 0), 0);
|
||||||
|
@ -281,16 +297,6 @@ vec4 sample_depth(vec2 st)
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Fetch a Single Channel
|
// 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 fetch_red()
|
||||||
{
|
{
|
||||||
#if PS_DEPTH_FMT == 1 || PS_DEPTH_FMT == 2
|
#if PS_DEPTH_FMT == 1 || PS_DEPTH_FMT == 2
|
||||||
|
|
|
@ -1020,14 +1020,24 @@ static const char* const tfx_fs_all_glsl =
|
||||||
" return c;\n"
|
" return c;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
"//////////////////////////////////////////////////////////////////////\n"
|
"int fetch_raw_depth()\n"
|
||||||
"// Depth sampling\n"
|
"{\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_c(ivec2 uv)\n"
|
"vec4 fetch_c(ivec2 uv)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" return texelFetch(TextureSampler, ivec2(uv), 0);\n"
|
" return texelFetch(TextureSampler, ivec2(uv), 0);\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
"//////////////////////////////////////////////////////////////////////\n"
|
||||||
|
"// Depth sampling\n"
|
||||||
|
"//////////////////////////////////////////////////////////////////////\n"
|
||||||
"ivec2 clamp_wrap_uv_depth(ivec2 uv)\n"
|
"ivec2 clamp_wrap_uv_depth(ivec2 uv)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" ivec2 uv_out = uv;\n"
|
" ivec2 uv_out = uv;\n"
|
||||||
|
@ -1070,8 +1080,14 @@ static const char* const tfx_fs_all_glsl =
|
||||||
"\n"
|
"\n"
|
||||||
" vec4 t;\n"
|
" vec4 t;\n"
|
||||||
"#if PS_URBAN_CHAOS_HACK == 1\n"
|
"#if PS_URBAN_CHAOS_HACK == 1\n"
|
||||||
" // Convert a GL_FLOAT32 to a special color format expected by the game\n"
|
" // Depth buffer is read as a RGB5A1 texture. The game try to extract the green channel.\n"
|
||||||
" int depth = int(fetch_c(uv).r * exp2(32.0f));\n"
|
" // So it will do a first channel trick to extract lsb, value is right-shifted.\n"
|
||||||
|
" // Then a new channel trick to extract msb which will shifted to the left.\n"
|
||||||
|
" // OpenGL uses a FLOAT32 format for the depth so it requires a couple of conversion.\n"
|
||||||
|
" // To be faster both steps (msb&lsb) are done in a single pass.\n"
|
||||||
|
"\n"
|
||||||
|
" // Warning: UV can't be used in channel effect\n"
|
||||||
|
" int depth = fetch_raw_depth();\n"
|
||||||
"\n"
|
"\n"
|
||||||
" // Convert lsb based on the palette\n"
|
" // Convert lsb based on the palette\n"
|
||||||
" t = texelFetch(PaletteSampler, ivec2((depth & 0xFF), 0), 0);\n"
|
" t = texelFetch(PaletteSampler, ivec2((depth & 0xFF), 0), 0);\n"
|
||||||
|
@ -1125,16 +1141,6 @@ static const char* const tfx_fs_all_glsl =
|
||||||
"//////////////////////////////////////////////////////////////////////\n"
|
"//////////////////////////////////////////////////////////////////////\n"
|
||||||
"// Fetch a Single Channel\n"
|
"// Fetch a Single Channel\n"
|
||||||
"//////////////////////////////////////////////////////////////////////\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"
|
"vec4 fetch_red()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"#if PS_DEPTH_FMT == 1 || PS_DEPTH_FMT == 2\n"
|
"#if PS_DEPTH_FMT == 1 || PS_DEPTH_FMT == 2\n"
|
||||||
|
|
Loading…
Reference in New Issue