mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
VideoCommon: allow custom shaders to set the alpha value for use when blending is enabled
This commit is contained in:
@ -1315,6 +1315,23 @@ ShaderCode GeneratePixelShaderCode(APIType api_type, const ShaderHostConfig& hos
|
||||
|
||||
WriteFog(out, uid_data);
|
||||
|
||||
for (std::size_t i = 0; i < custom_details.shaders.size(); i++)
|
||||
{
|
||||
const auto& shader_details = custom_details.shaders[i];
|
||||
|
||||
if (!shader_details.custom_shader.empty())
|
||||
{
|
||||
out.Write("\t{{\n");
|
||||
out.Write("\t\tcustom_data.final_color = float4(prev.r / 255.0, prev.g / 255.0, prev.b "
|
||||
"/ 255.0, prev.a / 255.0);\n");
|
||||
out.Write("\t\tCustomShaderOutput custom_output = {}_{}(custom_data);\n",
|
||||
CUSTOM_PIXELSHADER_COLOR_FUNC, i);
|
||||
out.Write("\t\tprev = int4(custom_output.main_rt.r * 255, custom_output.main_rt.g * 255, "
|
||||
"custom_output.main_rt.b * 255, custom_output.main_rt.a * 255);\n");
|
||||
out.Write("\t}}\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (uid_data->logic_op_enable)
|
||||
WriteLogicOp(out, uid_data);
|
||||
else if (uid_data->emulate_logic_op_with_blend)
|
||||
@ -1325,31 +1342,6 @@ ShaderCode GeneratePixelShaderCode(APIType api_type, const ShaderHostConfig& hos
|
||||
const bool use_dual_source = !uid_data->no_dual_src || uid_data->blend_enable;
|
||||
WriteColor(out, api_type, uid_data, use_dual_source);
|
||||
|
||||
for (std::size_t i = 0; i < custom_details.shaders.size(); i++)
|
||||
{
|
||||
const auto& shader_details = custom_details.shaders[i];
|
||||
|
||||
if (!shader_details.custom_shader.empty())
|
||||
{
|
||||
out.Write("\t{{\n");
|
||||
if (uid_data->uint_output)
|
||||
{
|
||||
out.Write("\t\tcustom_data.final_color = float4(ocol0.x / 255.0, ocol0.y / 255.0, ocol0.z "
|
||||
"/ 255.0, ocol0.w / 255.0);\n");
|
||||
out.Write("\t\tfloat3 custom_output = {}_{}(custom_data).xyz;\n",
|
||||
CUSTOM_PIXELSHADER_COLOR_FUNC, i);
|
||||
out.Write("\t\tocol0.xyz = uint3(custom_output.x * 255, custom_output.y * 255, "
|
||||
"custom_output.z * 255);\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
out.Write("\t\tcustom_data.final_color = ocol0;\n");
|
||||
out.Write("\t\tocol0.xyz = {}_{}(custom_data).xyz;\n", CUSTOM_PIXELSHADER_COLOR_FUNC, i);
|
||||
}
|
||||
out.Write("\t}}\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (uid_data->blend_enable)
|
||||
WriteBlend(out, uid_data);
|
||||
else if (use_framebuffer_fetch)
|
||||
|
@ -379,6 +379,11 @@ void WriteCustomShaderStructDef(ShaderCode* out, u32 numtexgens)
|
||||
out->Write("const uint CUSTOM_SHADER_LIGHTING_ATTENUATION_TYPE_SPOT = {}u;\n",
|
||||
static_cast<u32>(AttenuationFunc::Spot));
|
||||
|
||||
out->Write("struct CustomShaderOutput\n");
|
||||
out->Write("{{\n");
|
||||
out->Write("\tfloat4 main_rt;\n");
|
||||
out->Write("}};\n\n");
|
||||
|
||||
out->Write("struct CustomShaderLightData\n");
|
||||
out->Write("{{\n");
|
||||
out->Write("\tfloat3 position;\n");
|
||||
|
@ -1506,6 +1506,24 @@ ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
|
||||
" }}\n"
|
||||
"\n");
|
||||
|
||||
for (std::size_t i = 0; i < custom_details.shaders.size(); i++)
|
||||
{
|
||||
const auto& shader_details = custom_details.shaders[i];
|
||||
|
||||
if (!shader_details.custom_shader.empty())
|
||||
{
|
||||
out.Write("\t{{\n");
|
||||
out.Write("\t\tcustom_data.final_color = float4(TevResult.r / 255.0, TevResult.g / 255.0, "
|
||||
"TevResult.b / 255.0, TevResult.a / 255.0);\n");
|
||||
out.Write("\t\tCustomShaderOutput custom_output = {}_{}(custom_data);\n",
|
||||
CUSTOM_PIXELSHADER_COLOR_FUNC, i);
|
||||
out.Write(
|
||||
"\t\tTevResult = int4(custom_output.main_rt.r * 255, custom_output.main_rt.g * 255, "
|
||||
"custom_output.main_rt.b * 255, custom_output.main_rt.a * 255);\n");
|
||||
out.Write("\t}}\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (use_framebuffer_fetch)
|
||||
{
|
||||
static constexpr std::array<const char*, 16> logic_op_mode{
|
||||
@ -1594,31 +1612,6 @@ ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
|
||||
}
|
||||
}
|
||||
|
||||
for (std::size_t i = 0; i < custom_details.shaders.size(); i++)
|
||||
{
|
||||
const auto& shader_details = custom_details.shaders[i];
|
||||
|
||||
if (!shader_details.custom_shader.empty())
|
||||
{
|
||||
out.Write("\t{{\n");
|
||||
if (uid_data->uint_output)
|
||||
{
|
||||
out.Write("\t\tcustom_data.final_color = float4(ocol0.x / 255.0, ocol0.y / 255.0, ocol0.z "
|
||||
"/ 255.0, ocol0.w / 255.0);\n");
|
||||
out.Write("\t\tfloat3 custom_output = {}_{}(custom_data).xyz;\n",
|
||||
CUSTOM_PIXELSHADER_COLOR_FUNC, i);
|
||||
out.Write("\t\tocol0.xyz = uint3(custom_output.x * 255, custom_output.y * 255, "
|
||||
"custom_output.z * 255);\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
out.Write("\t\tcustom_data.final_color = ocol0;\n");
|
||||
out.Write("\t\tocol0.xyz = {}_{}(custom_data).xyz;\n", CUSTOM_PIXELSHADER_COLOR_FUNC, i);
|
||||
}
|
||||
out.Write("\t}}\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (bounding_box)
|
||||
{
|
||||
out.Write(" if (bpmem_bounding_box) {{\n"
|
||||
|
Reference in New Issue
Block a user