1 // Copyright 2008 Dolphin Emulator Project 2 // Licensed under GPLv2+ 3 // Refer to the license.txt file included. 4 5 #pragma once 6 7 #include "Common/CommonTypes.h" 8 9 class ShaderCode; 10 11 #define LIGHT_COL "%s[%d].color.%s" 12 #define LIGHT_COL_PARAMS(index, swizzle) (I_LIGHTS), (index), (swizzle) 13 14 #define LIGHT_COSATT "%s[%d].cosatt" 15 #define LIGHT_COSATT_PARAMS(index) (I_LIGHTS), (index) 16 17 #define LIGHT_DISTATT "%s[%d].distatt" 18 #define LIGHT_DISTATT_PARAMS(index) (I_LIGHTS), (index) 19 20 #define LIGHT_POS "%s[%d].pos" 21 #define LIGHT_POS_PARAMS(index) (I_LIGHTS), (index) 22 23 #define LIGHT_DIR "%s[%d].dir" 24 #define LIGHT_DIR_PARAMS(index) (I_LIGHTS), (index) 25 26 /** 27 * Common uid data used for shader generators that use lighting calculations. 28 */ 29 struct LightingUidData 30 { 31 u32 matsource : 4; // 4x1 bit 32 u32 enablelighting : 4; // 4x1 bit 33 u32 ambsource : 4; // 4x1 bit 34 u32 diffusefunc : 8; // 4x2 bits 35 u32 attnfunc : 8; // 4x2 bits 36 u32 light_mask : 32; // 4x8 bits 37 }; 38 39 static const char s_lighting_struct[] = "struct Light {\n" 40 "\tint4 color;\n" 41 "\tfloat4 cosatt;\n" 42 "\tfloat4 distatt;\n" 43 "\tfloat4 pos;\n" 44 "\tfloat4 dir;\n" 45 "};\n"; 46 47 void GenerateLightingShaderCode(ShaderCode& object, const LightingUidData& uid_data, int components, 48 const char* inColorName, const char* dest); 49 void GetLightingShaderUid(LightingUidData& uid_data); 50