mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 13:57:57 -07:00
51724c1ccd
Cel-damage depends on lighting being calculated for the first channel even though there is no color in the vertex format (defaults to the material color). If lighting for the channel is not enabled, the vertex will use the default color as before. The default value of the color is determined by the number of elements in the vertex format. This fixes the grey cubes in Super Mario Sunshine. If the color channel count is zero, we set the color to black before the end of the vertex shader. It's possible that this would be undefined behavior on hardware if a vertex color index that was greater than the channel count was used within TEV.
51 lines
1.6 KiB
C++
51 lines
1.6 KiB
C++
// Copyright 2008 Dolphin Emulator Project
|
|
// Licensed under GPLv2+
|
|
// Refer to the license.txt file included.
|
|
|
|
#pragma once
|
|
|
|
#include <string_view>
|
|
#include "Common/CommonTypes.h"
|
|
|
|
class ShaderCode;
|
|
|
|
#define LIGHT_COL "{}[{}].color.{}"
|
|
#define LIGHT_COL_PARAMS(index, swizzle) (I_LIGHTS), (index), (swizzle)
|
|
|
|
#define LIGHT_COSATT "{}[{}].cosatt"
|
|
#define LIGHT_COSATT_PARAMS(index) (I_LIGHTS), (index)
|
|
|
|
#define LIGHT_DISTATT "{}[{}].distatt"
|
|
#define LIGHT_DISTATT_PARAMS(index) (I_LIGHTS), (index)
|
|
|
|
#define LIGHT_POS "{}[{}].pos"
|
|
#define LIGHT_POS_PARAMS(index) (I_LIGHTS), (index)
|
|
|
|
#define LIGHT_DIR "{}[{}].dir"
|
|
#define LIGHT_DIR_PARAMS(index) (I_LIGHTS), (index)
|
|
|
|
/**
|
|
* 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
|
|
};
|
|
|
|
constexpr inline char s_lighting_struct[] = "struct Light {\n"
|
|
"\tint4 color;\n"
|
|
"\tfloat4 cosatt;\n"
|
|
"\tfloat4 distatt;\n"
|
|
"\tfloat4 pos;\n"
|
|
"\tfloat4 dir;\n"
|
|
"};\n";
|
|
|
|
void GenerateLightingShaderCode(ShaderCode& object, const LightingUidData& uid_data,
|
|
std::string_view in_color_name, std::string_view dest);
|
|
void GetLightingShaderUid(LightingUidData& uid_data);
|