6#include "zeroerr/assert.h"
28inline void lightSpotCosines(
float angleDeg,
float softness,
float &cosOuter,
float &cosInner) {
29 constexpr float kPi = 3.14159265358979323846f;
30 const float outerDeg = std::clamp(angleDeg, 0.1f, 89.f);
31 const float soft = std::clamp(softness, 0.f, 1.f);
32 const float outerRad = outerDeg * (kPi / 180.f);
33 const float innerRad = outerRad * (1.f -
soft);
34 cosOuter = std::cos(outerRad);
35 cosInner = std::cos(innerRad);
36 if (cosInner < cosOuter + 1e-4f) cosInner = cosOuter + 1e-4f;
40inline void light2dSpotCosines(
float angleDeg,
float softness,
float &cosOuter,
float &cosInner) {
49 glm::vec4
spot{0.f, 0.f, -2.f, -2.f};
55 glm::vec4
ambient{0.15f, 0.15f, 0.18f, 0.f};
74 std::string
type =
"point";
79 float r = 1.f,
g = 1.f,
b = 1.f;
80 float intensity = 1.f;
85 float spotSoftness = 0.35f;
88 bool volumetric =
false;
89 float volumetricIntensity = 1.f;
94 bool volumetricOnly =
false;
101 static Light2D *createLight(
const std::string &
type =
"point");
114 static Light2D *createEmissiveProxy(
float x,
float y,
float r,
float g,
float b,
115 float intensity = 1.f,
float radius = 200.f);
117 void setType(
const std::string &
type);
118 std::string getType();
120 void setPosition(
float x,
float y);
124 void setDirection(
float dx,
float dy);
128 void setColor(
float r,
float g,
float b,
float intensity = 1.f);
129 void setRadius(
float radius);
136 void setSpotAngle(
float degrees);
138 float getSpotAngle();
143 void setSpotSoftness(
float softness);
145 float getSpotSoftness();
150 void setVolumetric(
bool enabled);
151 bool getVolumetric();
152 void setVolumetricIntensity(
float intensity);
153 float getVolumetricIntensity();
154 void setVolumetricOnly(
bool enabled);
155 bool getVolumetricOnly();
157 void setCanvas(
Canvas *canvas);
168 glm::vec4
spot{0.f, 0.f, 0.f, -1.f};
202 float x = 0.f,
y = 0.f,
z = 0.f;
204 float r = 1.f,
g = 1.f,
b = 1.f;
205 float intensity = 1.f;
210 float spotSoftness = 0.35f;
212 bool castShadow =
false;
218 std::uint8_t shadowMethod = 0;
224 int shadowLocalSlot = -1;
225 float shadowBias = 0.f;
227 bool volumetric =
false;
228 float volumetricIntensity = 1.f;
233 bool volumetricOnly =
false;
237 COMPONENT(
Data, data)
239 static Light3D *createLight(
const std::string &
type =
"point");
247 static Light3D *createEmissiveProxy(
float x,
float y,
float z,
float r,
float g,
float b,
248 float intensity = 1.f,
float radius = 8.f);
250 void setType(
const std::string &
type);
251 std::string getType();
253 void setPosition(
float x,
float y,
float z);
258 void setDirection(
float dx,
float dy,
float dz);
263 void setColor(
float r,
float g,
float b,
float intensity = 1.f);
264 void setRadius(
float radius);
271 void setSpotAngle(
float degrees);
273 float getSpotAngle();
278 void setSpotSoftness(
float softness);
280 float getSpotSoftness();
285 void setCastShadow(
bool cast);
286 bool getCastShadow();
291 void setShadowMethod(
const std::string &
method);
293 std::string getShadowMethod();
294 void setShadowBias(
float bias);
295 float getShadowBias();
296 void setShadowStrength(
float strength);
297 float getShadowStrength();
299 void setVolumetric(
bool enabled);
300 bool getVolumetric();
301 void setVolumetricIntensity(
float intensity);
302 float getVolumetricIntensity();
303 void setVolumetricOnly(
bool enabled);
304 bool getVolumetricOnly();
#define EVENGINE_API_BACKENDS
std::function< eve::Result< void >()> release
Declarative 2D light. Collected by RenderSystem (max 8 per canvas/frame). type: "point" | "dir" | "sp...
Declarative 3D light. Collected by RenderSystem3D (max 8 per frame). type: "point" | "dir" | "spot" (...
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
void light2dSpotCosines(float angleDeg, float softness, float &cosOuter, float &cosInner)
Backward-compatible alias for lightSpotCosines.
void lightSpotCosines(float angleDeg, float softness, float &cosOuter, float &cosInner)
Convert spot angle/softness into GPU cosines (outer < inner). Shared by Light2D and Light3D flashligh...
GPU light packing for lit2d (std140-friendly).
glm::vec4 spot
Spot cone: xy = beam dir; z/w = cos(outer/inner half-angle). z <= -1.5 => off.
GPU light packing for mesh3d / PBR (std140-friendly).
glm::vec4 spot
Spot cone: xyz = world beam direction; w = spotScale (1/(cosInner-cosOuter)). w <= 0 means the light ...
Lighting2DUBO public API.
static constexpr int kMaxLights
Light2DGpu lights[kMaxLights]
Lighting3DPack public API.
std::array< glm::vec4, kMaxDiffuseVolumeProbes > diffuseVolumePosition
std::array< glm::vec4, kMaxDiffuseVolumeProbes > diffuseVolumeExtent
bool diffuseVolumeTrilinearCell
std::array< glm::vec4, kMaxDiffuseVolumeProbes *9 > diffuseVolumeSh
static constexpr int kMaxLights
static constexpr int kMaxDiffuseVolumeProbes
Light3DGpu lights[kMaxLights]
bool diffuseProbeShEnabled
int diffuseVolumeProbeCount
std::array< glm::vec4, 9 > diffuseProbeSh