2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:09:55 +00:00
|
|
|
// Refer to the license.txt file included.
|
2011-02-06 01:56:45 +00:00
|
|
|
|
2014-02-10 18:54:46 +00:00
|
|
|
#pragma once
|
2011-02-06 01:56:45 +00:00
|
|
|
|
2016-01-17 21:54:31 +00:00
|
|
|
#include "Common/Assert.h"
|
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/NativeVertexFormat.h"
|
2014-02-19 01:27:20 +00:00
|
|
|
#include "VideoCommon/ShaderGenCommon.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/XFMemory.h"
|
2011-09-29 19:21:09 +00:00
|
|
|
|
2014-05-30 14:17:30 +00:00
|
|
|
#define LIGHT_COL "%s[%d].color.%s"
|
|
|
|
#define LIGHT_COL_PARAMS(index, swizzle) (I_LIGHTS), (index), (swizzle)
|
2013-04-10 11:38:31 +00:00
|
|
|
|
2014-05-30 14:17:30 +00:00
|
|
|
#define LIGHT_COSATT "%s[%d].cosatt"
|
|
|
|
#define LIGHT_COSATT_PARAMS(index) (I_LIGHTS), (index)
|
2013-04-10 11:38:31 +00:00
|
|
|
|
2014-05-30 14:17:30 +00:00
|
|
|
#define LIGHT_DISTATT "%s[%d].distatt"
|
|
|
|
#define LIGHT_DISTATT_PARAMS(index) (I_LIGHTS), (index)
|
2013-08-12 10:52:42 +00:00
|
|
|
|
2014-05-30 14:17:30 +00:00
|
|
|
#define LIGHT_POS "%s[%d].pos"
|
|
|
|
#define LIGHT_POS_PARAMS(index) (I_LIGHTS), (index)
|
2013-08-12 10:52:42 +00:00
|
|
|
|
2014-05-30 14:17:30 +00:00
|
|
|
#define LIGHT_DIR "%s[%d].dir"
|
|
|
|
#define LIGHT_DIR_PARAMS(index) (I_LIGHTS), (index)
|
2013-04-10 11:38:31 +00:00
|
|
|
|
2013-09-04 19:47:21 +00:00
|
|
|
/**
|
|
|
|
* Common uid data used for shader generators that use lighting calculations.
|
|
|
|
*/
|
|
|
|
struct LightingUidData
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
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
|
2013-09-04 19:47:21 +00:00
|
|
|
};
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
static const 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 11:38:31 +00:00
|
|
|
|
2016-06-26 11:01:02 +00:00
|
|
|
void GenerateLightingShaderCode(ShaderCode& object, const LightingUidData& uid_data, int components,
|
|
|
|
const char* inColorName, const char* dest);
|
|
|
|
void GetLightingShaderUid(LightingUidData& uid_data);
|