rsx: Preserve fog coordinate across shader stages

- The x value contains the VP output value interpolated across primitive surface
- The y coordinate contains the fog fraction according to the selected fog formula
This commit is contained in:
kd-11 2018-09-05 22:32:15 +03:00 committed by kd-11
parent 343656f66d
commit 346b97f871

View File

@ -34,38 +34,37 @@ namespace program_common
template_body += "$T fetch_fog_value(uint mode, $T $I)\n";
template_body += "{\n";
template_body += " $T result = $T(0., 0., 0., 0.);\n";
template_body += " $T result = $T($I.x, 0., 0., 0.);\n";
template_body += " switch(mode)\n";
template_body += " {\n";
template_body += " default:\n";
template_body += " return result;\n";
template_body += " case 0:\n";
template_body += " //linear\n";
template_body += " result = $T(fog_param1 * $I.x + (fog_param0 - 1.), fog_param1 * $I.x + (fog_param0 - 1.), 0., 0.);\n";
template_body += " result.y = fog_param1 * $I.x + (fog_param0 - 1.);\n";
template_body += " break;\n";
template_body += " case 1:\n";
template_body += " //exponential\n";
template_body += " result = $T(11.084 * (fog_param1 * $I.x + fog_param0 - 1.5), exp(11.084 * (fog_param1 * $I.x + fog_param0 - 1.5)), 0., 0.);\n";
template_body += " result.y = exp(11.084 * (fog_param1 * $I.x + fog_param0 - 1.5));\n";
template_body += " break;\n";
template_body += " case 2:\n";
template_body += " //exponential2\n";
template_body += " result = $T(4.709 * (fog_param1 * $I.x + fog_param0 - 1.5), exp(-pow(4.709 * (fog_param1 * $I.x + fog_param0 - 1.5), 2.)), 0., 0.);\n";
template_body += " result.y = exp(-pow(4.709 * (fog_param1 * $I.x + fog_param0 - 1.5), 2.));\n";
template_body += " break;\n";
template_body += " case 3:\n";
template_body += " //exponential_abs\n";
template_body += " result = $T(11.084 * (fog_param1 * abs($I.x) + fog_param0 - 1.5), exp(11.084 * (fog_param1 * abs($I.x) + fog_param0 - 1.5)), 0., 0.);\n";
template_body += " result.y = exp(11.084 * (fog_param1 * abs($I.x) + fog_param0 - 1.5));\n";
template_body += " break;\n";
template_body += " case 4:\n";
template_body += " //exponential2_abs\n";
template_body += " result = $T(4.709 * (fog_param1 * abs($I.x) + fog_param0 - 1.5), exp(-pow(4.709 * (fog_param1 * abs($I.x) + fog_param0 - 1.5), 2.)), 0., 0.);\n";
template_body += " result.y = exp(-pow(4.709 * (fog_param1 * abs($I.x) + fog_param0 - 1.5), 2.));\n";
template_body += " break;\n";
template_body += " case 5:\n";
template_body += " //linear_abs\n";
template_body += " result = $T(fog_param1 * abs($I.x) + (fog_param0 - 1.), fog_param1 * abs($I.x) + (fog_param0 - 1.), 0., 0.);\n";
template_body += " result.y = fog_param1 * abs($I.x) + (fog_param0 - 1.);\n";
template_body += " break;\n";
template_body += " }\n";
template_body += "\n";
template_body += " result.x = max(result.x, 0.);\n";
template_body += " result.y = clamp(result.y, 0., 1.);\n";
template_body += " return result;\n";
template_body += "}\n\n";