50 if (spotAngleDEG < 180.0f)
83 :
SLNode(
"LightSpot Node"),
84 SLLight(ambiPower, diffPower, specPower)
99 if (spotAngleDEG < 180.0f)
249 SLRay shadowRay(lightDist, L, ray);
250 root3D->
hitRec(&shadowRay);
273 SLbool outerCircleIsLighting =
true;
274 SLbool innerCircleIsNotLighting =
true;
277 if (fabs(L.
x) >= fabs(L.
y))
279 SLfloat invLength = 1.0f / sqrt(L.
x * L.
x + L.
z * L.
z);
280 LightX.
set(L.
z * invLength, 0, -L.
x * invLength);
284 SLfloat invLength = 1.0f / sqrt(L.
y * L.
y + L.
z * L.
z);
285 LightX.
set(0, L.
z * invLength, -L.
y * invLength);
287 LightY.
cross(L, LightX);
299 SLVec3f conePos(C + discPos.
x * LightX + discPos.
y * LightY);
303 SLRay shadowRay(lightDist, LDisc, ray);
305 root3D->
hitRec(&shadowRay);
307 if (shadowRay.
length < lightDist)
308 outerCircleIsLighting =
false;
311 lighted += invSamples;
312 innerCircleIsNotLighting =
false;
318 if (outerCircleIsLighting)
return 1.0f;
322 if (innerCircleIsNotLighting)
return lighted;
323 innerCircleIsNotLighting =
true;
342 SLRay shadowRay(lightDist, L, ray);
343 root3D->
hitRec(&shadowRay);
345 if (shadowRay.
length < lightDist)
366 SLbool outerCircleIsLighting =
true;
367 SLbool innerCircleIsNotLighting =
true;
370 if (fabs(L.
x) >= fabs(L.
y))
372 SLfloat invLength = 1.0f / sqrt(L.
x * L.
x + L.
z * L.
z);
373 LightX.
set(L.
z * invLength, 0, -L.
x * invLength);
377 SLfloat invLength = 1.0f / sqrt(L.
y * L.
y + L.
z * L.
z);
378 LightX.
set(0, L.
z * invLength, -L.
y * invLength);
380 LightY.
cross(L, LightX);
392 SLVec3f conePos(C + discPos.
x * LightX + discPos.
y * LightY);
396 SLRay shadowRay(lightDist, LDisc, ray);
398 root3D->
hitRec(&shadowRay);
400 if (shadowRay.
length < lightDist)
401 outerCircleIsLighting =
false;
404 lighted += invSamples;
405 innerCircleIsNotLighting =
false;
411 if (outerCircleIsLighting)
return 1.0f;
415 if (innerCircleIsNotLighting)
return lighted;
416 innerCircleIsNotLighting =
true;
#define SL_EXIT_MSG(message)
typedef void(SL_STDCALL *cbOnImGuiBuild)(SLScene *s
Callback function typedef for ImGui build function.
static const SLint SL_MAX_LIGHTS
max. number of used lights
Toplevel holder of the assets meshes, materials, textures and shaders.
Active or visible camera node class.
Abstract Light class for OpenGL light sources.
SLint _id
OpenGL light number (0-7)
SLShadowMap * _shadowMap
Used for shadow mapping.
SLfloat spotCutOffDEG() const
SLbool _isOn
Flag if light is on or off.
SLbool _createsShadows
flag if light creates shadows or not
bool hitRec(SLRay *ray) override
SLfloat shadowTestMC(SLRay *ray, const SLVec3f &L, SLfloat lightDist, SLNode *root3D) override
SLRaySamples2D _samples
2D sample points for soft shadows
void createShadowMapAutoSize(SLCamera *camera, SLVec2i texSize=SLVec2i(1024, 1024), int numCascades=0) override
void createShadowMap(float lightClipNear=0.1f, float lightClipFar=20.0f, SLVec2f size=SLVec2f(8, 8), SLVec2i texSize=SLVec2i(1024, 1024)) override
void drawMesh(SLSceneView *sv) override
void statsRec(SLNodeStats &stats) override
SLLightSpot::statsRec updates the statistic parameters.
SLfloat shadowTest(SLRay *ray, const SLVec3f &L, SLfloat lightDist, SLNode *root3D) override
SLfloat _radius
The sphere lights radius.
SLLightSpot(SLAssetManager *assetMgr, SLScene *s, SLfloat radius=0.3f, SLfloat spotAngleDEG=180.0f, SLbool hasMesh=true)
Construct a new SLLightSpot::SLLightSpot object.
Defines a standard CG material with textures and a shader program.
SLbool hasAlpha()
Returns true if there is any transparency in diffuse alpha or textures.
void emissive(const SLCol4f &emis)
virtual void preShade(SLRay *ray)
SLNode represents a node in a hierarchical scene graph.
virtual void drawMesh(SLSceneView *sv)
Draws the single mesh.
void translation(const SLVec3f &pos, SLTransformSpace relativeTo=TS_parent)
const SLMat4f & updateAndGetWM() const
bool _castsShadows
flag if meshes of node should cast shadows
virtual void addMesh(SLMesh *mesh)
virtual void statsRec(SLNodeStats &stats)
SLMesh * _mesh
pointer to a single mesh
virtual bool hitRec(SLRay *ray)
void translate(const SLVec3f &vec, SLTransformSpace relativeTo=TS_object)
Ray class with ray and intersection properties.
SLRayType type
PRIMARY, REFLECTED, REFRACTED, SHADOW.
SLMesh * hitMesh
Points to the intersected mesh.
SLVec3f dir
Direction vector of ray in WS.
SLfloat length
length from origin to an intersection
SLVec3f hitPoint
Point of intersection.
SLVec3f hitNormal
Surface normal at intersection point.
void samples(SLuint x, SLuint y, SLbool evenlyDistributed=true)
Resets the sample point array by the sqrt of the no. of samples.
void point(SLuint x, SLuint y, SLVec2f point)
The SLScene class represents the top level instance holding the scene structure.
SLNode * singleNodeSelected()
Returns the node if only one is selected. See also SLMesh::selectNodeMesh.
SceneView class represents a dynamic real time 3D view onto the scene.
Class for standard and cascaded shadow mapping.
void drawFrustum()
SLShadowMap::drawFrustum draws the volume affected by the shadow map.
SLSphere creates a sphere mesh based on SLSpheric w. 180 deg polar angle.
SLSphere creates a sphere mesh based on SLRevolver.
void cross(const SLVec3 &a, const SLVec3 &b)
void set(const T X, const T Y, const T Z)
T dot(const SLVec3 &v) const
Struct for scene graph statistics.
SLuint numBytes
NO. of bytes allocated.