27inline void lightSpotCosines(
float angleDeg,
float softness,
float &cosOuter,
float &cosInner) {
28 constexpr float kPi = 3.14159265358979323846f;
29 const float outerDeg = std::clamp(angleDeg, 0.1f, 89.f);
30 const float soft = std::clamp(softness, 0.f, 1.f);
31 const float outerRad = outerDeg * (kPi / 180.f);
32 const float innerRad = outerRad * (1.f -
soft);
33 cosOuter = std::cos(outerRad);
34 cosInner = std::cos(innerRad);
35 if (cosInner < cosOuter + 1e-4f) cosInner = cosOuter + 1e-4f;
39inline void light2dSpotCosines(
float angleDeg,
float softness,
float &cosOuter,
float &cosInner) {
48 glm::vec4
spot{0.f, 0.f, -2.f, -2.f};
54 glm::vec4
ambient{0.15f, 0.15f, 0.18f, 0.f};
69 void release()
override {}
73 std::string
type =
"point";
78 float r = 1.f,
g = 1.f,
b = 1.f;
79 float intensity = 1.f;
84 float spotSoftness = 0.35f;
87 bool volumetric =
false;
88 float volumetricIntensity = 1.f;
93 bool volumetricOnly =
false;
100 static Light2D *createLight(
const std::string &
type =
"point");
113 static Light2D *createEmissiveProxy(
float x,
float y,
float r,
float g,
float b,
114 float intensity = 1.f,
float radius = 200.f);
116 void setType(
const std::string &
type);
117 std::string getType();
119 void setPosition(
float x,
float y);
123 void setDirection(
float dx,
float dy);
127 void setColor(
float r,
float g,
float b,
float intensity = 1.f);
128 void setRadius(
float radius);
135 void setSpotAngle(
float degrees);
137 float getSpotAngle();
142 void setSpotSoftness(
float softness);
144 float getSpotSoftness();
149 void setVolumetric(
bool enabled);
150 bool getVolumetric();
151 void setVolumetricIntensity(
float intensity);
152 float getVolumetricIntensity();
153 void setVolumetricOnly(
bool enabled);
154 bool getVolumetricOnly();
156 void setCanvas(
Canvas *canvas);
167 glm::vec4
spot{0.f, 0.f, 0.f, -1.f};
196 void release()
override {}
201 float x = 0.f,
y = 0.f,
z = 0.f;
203 float r = 1.f,
g = 1.f,
b = 1.f;
204 float intensity = 1.f;
209 float spotSoftness = 0.35f;
211 bool castShadow =
false;
217 std::uint8_t shadowMethod = 0;
223 int shadowLocalSlot = -1;
224 float shadowBias = 0.f;
226 bool volumetric =
false;
227 float volumetricIntensity = 1.f;
232 bool volumetricOnly =
false;
236 COMPONENT(
Data, data)
238 static Light3D *createLight(
const std::string &
type =
"point");
246 static Light3D *createEmissiveProxy(
float x,
float y,
float z,
float r,
float g,
float b,
247 float intensity = 1.f,
float radius = 8.f);
249 void setType(
const std::string &
type);
250 std::string getType();
252 void setPosition(
float x,
float y,
float z);
257 void setDirection(
float dx,
float dy,
float dz);
262 void setColor(
float r,
float g,
float b,
float intensity = 1.f);
263 void setRadius(
float radius);
270 void setSpotAngle(
float degrees);
272 float getSpotAngle();
277 void setSpotSoftness(
float softness);
279 float getSpotSoftness();
284 void setCastShadow(
bool cast);
285 bool getCastShadow();
290 void setShadowMethod(
const std::string &
method);
292 std::string getShadowMethod();
293 void setShadowBias(
float bias);
294 float getShadowBias();
295 void setShadowStrength(
float strength);
296 float getShadowStrength();
298 void setVolumetric(
bool enabled);
299 bool getVolumetric();
300 void setVolumetricIntensity(
float intensity);
301 float getVolumetricIntensity();
302 void setVolumetricOnly(
bool enabled);
303 bool getVolumetricOnly();
#define EVENGINE_API_BACKENDS
const EntityFact * entity
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