2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2011-02-05 18:56:45 -07:00
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2011-02-05 18:56:45 -07:00
|
|
|
|
2020-07-24 11:46:13 -06:00
|
|
|
#include <string_view>
|
2016-01-17 14:54:31 -07:00
|
|
|
#include "Common/CommonTypes.h"
|
2017-01-31 21:29:29 -07:00
|
|
|
|
|
|
|
class ShaderCode;
|
2011-09-29 13:21:09 -06:00
|
|
|
|
2020-07-24 11:46:13 -06:00
|
|
|
#define LIGHT_COL "{}[{}].color.{}"
|
2014-05-30 08:17:30 -06:00
|
|
|
#define LIGHT_COL_PARAMS(index, swizzle) (I_LIGHTS), (index), (swizzle)
|
2013-04-10 05:38:31 -06:00
|
|
|
|
2020-07-24 11:46:13 -06:00
|
|
|
#define LIGHT_COSATT "{}[{}].cosatt"
|
2014-05-30 08:17:30 -06:00
|
|
|
#define LIGHT_COSATT_PARAMS(index) (I_LIGHTS), (index)
|
2013-04-10 05:38:31 -06:00
|
|
|
|
2020-07-24 11:46:13 -06:00
|
|
|
#define LIGHT_DISTATT "{}[{}].distatt"
|
2014-05-30 08:17:30 -06:00
|
|
|
#define LIGHT_DISTATT_PARAMS(index) (I_LIGHTS), (index)
|
2013-08-12 04:52:42 -06:00
|
|
|
|
2020-07-24 11:46:13 -06:00
|
|
|
#define LIGHT_POS "{}[{}].pos"
|
2014-05-30 08:17:30 -06:00
|
|
|
#define LIGHT_POS_PARAMS(index) (I_LIGHTS), (index)
|
2013-08-12 04:52:42 -06:00
|
|
|
|
2020-07-24 11:46:13 -06:00
|
|
|
#define LIGHT_DIR "{}[{}].dir"
|
2014-05-30 08:17:30 -06:00
|
|
|
#define LIGHT_DIR_PARAMS(index) (I_LIGHTS), (index)
|
2013-04-10 05:38:31 -06:00
|
|
|
|
2013-09-04 13:47:21 -06:00
|
|
|
/**
|
|
|
|
* Common uid data used for shader generators that use lighting calculations.
|
|
|
|
*/
|
|
|
|
struct LightingUidData
|
|
|
|
{
|
|
|
|
u32 matsource : 4; // 4x1 bit
|
|
|
|
u32 enablelighting : 4; // 4x1 bit
|
|
|
|
u32 ambsource : 4; // 4x1 bit
|
|
|
|
u32 diffusefunc : 8; // 4x2 bits
|
|
|
|
u32 attnfunc : 8; // 4x2 bits
|
|
|
|
u32 light_mask : 32; // 4x8 bits
|
|
|
|
};
|
|
|
|
|
2021-12-18 14:28:48 -07:00
|
|
|
constexpr char s_lighting_struct[] = "struct Light {\n"
|
|
|
|
"\tint4 color;\n"
|
|
|
|
"\tfloat4 cosatt;\n"
|
|
|
|
"\tfloat4 distatt;\n"
|
|
|
|
"\tfloat4 pos;\n"
|
|
|
|
"\tfloat4 dir;\n"
|
|
|
|
"};\n";
|
2013-04-10 05:38:31 -06:00
|
|
|
|
2017-01-29 05:38:48 -07:00
|
|
|
void GenerateLightingShaderCode(ShaderCode& object, const LightingUidData& uid_data,
|
2020-07-24 11:46:13 -06:00
|
|
|
std::string_view in_color_name, std::string_view dest);
|
2016-06-26 05:01:02 -06:00
|
|
|
void GetLightingShaderUid(LightingUidData& uid_data);
|
2022-11-11 19:20:04 -07:00
|
|
|
|
|
|
|
void GenerateCustomLightingHeaderDetails(ShaderCode* out, u32 enablelighting, u32 light_mask);
|
|
|
|
void GenerateCustomLightingImplementation(ShaderCode* out, const LightingUidData& uid_data,
|
|
|
|
std::string_view in_color_name);
|