2012-04-05 23:09:41 +00:00
|
|
|
//
|
|
|
|
|
// KRLight.h
|
|
|
|
|
// KREngine
|
|
|
|
|
//
|
|
|
|
|
// Created by Kearwood Gilbert on 12-04-05.
|
|
|
|
|
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
2012-12-07 08:22:20 +00:00
|
|
|
#ifndef KRLIGHT_H
|
|
|
|
|
#define KRLIGHT_H
|
2012-04-05 23:09:41 +00:00
|
|
|
|
2013-01-11 03:21:19 +00:00
|
|
|
#include "KRResource.h"
|
|
|
|
|
#include "KRNode.h"
|
|
|
|
|
#include "KRTexture.h"
|
2012-04-05 23:09:41 +00:00
|
|
|
|
2012-08-09 20:33:45 +00:00
|
|
|
static const float KRLIGHT_MIN_INFLUENCE = 0.15f; // 0.05f
|
2012-06-10 06:24:04 +00:00
|
|
|
|
2012-11-15 22:05:25 +00:00
|
|
|
// KRENGINE_MAX_SHADOW_BUFFERS must be at least 6 to allow omni-directional lights to render cube maps
|
|
|
|
|
|
|
|
|
|
#define KRENGINE_MAX_SHADOW_BUFFERS 6
|
2012-11-23 01:02:22 +00:00
|
|
|
#define KRENGINE_SHADOW_MAP_WIDTH 1024
|
|
|
|
|
#define KRENGINE_SHADOW_MAP_HEIGHT 1024
|
2012-11-15 22:05:25 +00:00
|
|
|
|
2012-04-12 00:43:53 +00:00
|
|
|
class KRLight : public KRNode {
|
2012-04-05 23:09:41 +00:00
|
|
|
public:
|
2012-06-10 06:24:04 +00:00
|
|
|
|
2012-04-26 09:06:45 +00:00
|
|
|
|
2012-04-12 00:43:53 +00:00
|
|
|
virtual ~KRLight();
|
|
|
|
|
virtual std::string getElementName() = 0;
|
|
|
|
|
virtual tinyxml2::XMLElement *saveXML( tinyxml2::XMLNode *parent);
|
2012-04-12 01:27:30 +00:00
|
|
|
virtual void loadXML(tinyxml2::XMLElement *e);
|
2012-04-12 00:43:53 +00:00
|
|
|
|
|
|
|
|
void setIntensity(float intensity);
|
|
|
|
|
float getIntensity();
|
|
|
|
|
void setDecayStart(float decayStart);
|
|
|
|
|
float getDecayStart();
|
|
|
|
|
const KRVector3 &getColor();
|
|
|
|
|
void setColor(const KRVector3 &color);
|
2012-04-05 23:09:41 +00:00
|
|
|
|
2012-06-15 00:05:56 +00:00
|
|
|
void setFlareTexture(std::string flare_texture);
|
|
|
|
|
void setFlareSize(float flare_size);
|
2013-03-14 14:29:12 -07:00
|
|
|
void setFlareOcclusionSize(float occlusion_size);
|
2012-11-15 22:05:25 +00:00
|
|
|
void deleteBuffers();
|
2012-12-28 06:25:57 +00:00
|
|
|
|
2013-04-25 16:21:28 -07:00
|
|
|
virtual void render(KRCamera *pCamera, std::vector<KRPointLight *> &point_lights, std::vector<KRDirectionalLight *> &directional_lights, std::vector<KRSpotLight *>&spot_lights, const KRViewport &viewport, KRNode::RenderPass renderPass);
|
2012-06-15 00:05:56 +00:00
|
|
|
|
2012-11-16 02:58:23 +00:00
|
|
|
int getShadowBufferCount();
|
|
|
|
|
GLuint *getShadowTextures();
|
|
|
|
|
KRViewport *getShadowViewports();
|
|
|
|
|
|
|
|
|
|
|
2012-04-05 23:09:41 +00:00
|
|
|
protected:
|
2012-08-29 21:43:11 +00:00
|
|
|
KRLight(KRScene &scene, std::string name);
|
2012-04-12 00:43:53 +00:00
|
|
|
|
|
|
|
|
float m_intensity;
|
|
|
|
|
float m_decayStart;
|
|
|
|
|
KRVector3 m_color;
|
2012-06-15 00:05:56 +00:00
|
|
|
|
|
|
|
|
std::string m_flareTexture;
|
|
|
|
|
KRTexture *m_pFlareTexture;
|
|
|
|
|
float m_flareSize;
|
2013-01-17 19:27:17 -08:00
|
|
|
float m_flareOcclusionSize;
|
2012-11-15 22:05:25 +00:00
|
|
|
|
2012-11-16 02:58:23 +00:00
|
|
|
bool m_casts_shadow;
|
|
|
|
|
bool m_light_shafts;
|
2012-11-23 01:02:22 +00:00
|
|
|
float m_dust_particle_density;
|
|
|
|
|
float m_dust_particle_size;
|
|
|
|
|
float m_dust_particle_intensity;
|
2012-11-16 02:58:23 +00:00
|
|
|
|
2013-01-17 19:27:17 -08:00
|
|
|
GLuint m_occlusionQuery; // Occlusion query for attenuating occluded flares
|
|
|
|
|
|
2012-11-15 22:05:25 +00:00
|
|
|
|
|
|
|
|
// Shadow Maps
|
|
|
|
|
int m_cShadowBuffers;
|
|
|
|
|
GLuint shadowFramebuffer[KRENGINE_MAX_SHADOW_BUFFERS], shadowDepthTexture[KRENGINE_MAX_SHADOW_BUFFERS];
|
|
|
|
|
bool shadowValid[KRENGINE_MAX_SHADOW_BUFFERS];
|
|
|
|
|
KRViewport m_shadowViewports[KRENGINE_MAX_SHADOW_BUFFERS];
|
|
|
|
|
|
|
|
|
|
void allocateShadowBuffers(int cBuffers);
|
|
|
|
|
void invalidateShadowBuffers();
|
|
|
|
|
|
|
|
|
|
virtual int configureShadowBufferViewports(const KRViewport &viewport);
|
|
|
|
|
void renderShadowBuffers(KRCamera *pCamera);
|
2012-04-05 23:09:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|