155 SLRay shadowRay(lightDist, L, ray);
157 root3D->
hitRec(&shadowRay);
159 return (shadowRay.
length < lightDist) ? 0.0f : 1.0f;
168 SLbool importantPointsAreLighting =
true;
180 isSampled[(
SLuint)iSP] =
false;
204 for (y = -hy; y <= hy; y += hy)
206 for (x = -hx; x <= hx; x += hx)
209 isSampled[(
SLuint)iSP] =
true;
214 SLRay shadowRay(SPDist, SP, ray);
216 root3D->
hitRec(&shadowRay);
218 if (shadowRay.
length >= SPDist - FLT_EPSILON)
219 lighted += invSamples;
221 importantPointsAreLighting =
false;
225 if (importantPointsAreLighting)
229 for (y = -hy; y <= hy; ++y)
231 for (x = -hx; x <= hx; ++x)
234 if (!isSampled[(
SLuint)iSP])
239 SLRay shadowRay(SPDist, SP, ray);
241 root3D->
hitRec(&shadowRay);
244 if (shadowRay.
length >= SPDist - FLT_EPSILON)
245 lighted += invSamples;
276 SLRay shadowRay(spDistWS, spWS, ray);
278 root3D->
hitRec(&shadowRay);
280 return (shadowRay.
length < spDistWS) ? 0.0f : 1.0f;
331 assert(x % 2 == 1 && y % 2 == 1);
#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
SLVec3< SLfloat > SLVec3f
Toplevel holder of the assets meshes, materials, textures and shaders.
Active or visible camera node class.
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
SLfloat spotExponent() const
SLfloat shadowTest(SLRay *ray, const SLVec3f &L, SLfloat lightDist, SLNode *root3D) override
void statsRec(SLNodeStats &stats) override
SLLightSpot::statsRec updates the statistic parameters.
SLLightRect(SLAssetManager *assetMgr, SLScene *s, SLfloat width=1, SLfloat height=1, SLbool hasMesh=true)
Construct a new SLLightRect::SLLightRect object.
SLfloat shadowTestMC(SLRay *ray, const SLVec3f &L, SLfloat lightDist, SLNode *root3D) override
void samples(SLVec2i samples)
SLVec2i _samples
Uneven NO. of samples in x and y dir.
void drawMesh(SLSceneView *sv) override
void createShadowMapAutoSize(SLCamera *camera, SLVec2i texSize=SLVec2i(1024, 1024), int numCascades=0) override
SLfloat _width
Width of square light in x direction.
SLfloat _height
Lenght of square light in y direction.
void samplesXY(SLint x, SLint y)
bool hitRec(SLRay *ray) override
void createShadowMap(float lightClipNear=0.1f, float lightClipFar=20.0f, SLVec2f size=SLVec2f(8, 8), SLVec2i texSize=SLVec2i(1024, 1024)) override
SLCol4f diffuse() override
Returns normally _diffuseColor * _diffusePower.
SLVec3< T > multVec(SLVec3< T > v) const
Defines a standard CG material with textures and a shader program.
void emissive(const SLCol4f &emis)
SLNode represents a node in a hierarchical scene graph.
virtual void drawMesh(SLSceneView *sv)
Draws the single mesh.
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)
SLPolygon creates a convex polyon mesh.
Ray class with ray and intersection properties.
SLRayType type
PRIMARY, REFLECTED, REFRACTED, SHADOW.
SLfloat length
length from origin to an intersection
SLVec3f hitPoint
Point of intersection.
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.
void set(const T X, const T Y)
void set(const T X, const T Y, const T Z)
Struct for scene graph statistics.
SLuint numBytes
NO. of bytes allocated.