mirror of
https://github.com/devZoGok/vb01.git
synced 2026-08-26 19:43:30 +00:00
lights use node position and orientation
This commit is contained in:
@@ -104,6 +104,7 @@ namespace vb01{
|
||||
|
||||
void Light::renderShadow(std::vector<Node*> descendants, mat4 &proj, mat4 &view){
|
||||
Root *root = Root::getSingleton();
|
||||
Vector3 position = node->getPosition(), direction = node->getGlobalAxis(2);
|
||||
|
||||
glViewport(0, 0, depthMapSize, depthMapSize);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, depthmapFBO);
|
||||
@@ -172,6 +173,7 @@ namespace vb01{
|
||||
}
|
||||
|
||||
void Light::updateShader(vector<Material*> materials, int thisId, mat4 &proj, mat4 &view){
|
||||
Vector3 position = node->localToGlobalPosition(Vector3::VEC_ZERO), direction = node->getGlobalAxis(2);
|
||||
for(Material *m : materials){
|
||||
Shader *shader = m->getShader();
|
||||
shader->use();
|
||||
|
||||
@@ -22,9 +22,7 @@ namespace vb01{
|
||||
~Light();
|
||||
void update();
|
||||
inline void setNode(Node *node){this->node = node;}
|
||||
inline void setPosition(Vector3 pos){this->position = pos;}
|
||||
inline void setColor(Vector3 color){this->color = color;}
|
||||
inline void setDirection(Vector3 dir){this->direction = dir;}
|
||||
inline void setAttenuationValues(float a, float b, float c){
|
||||
attenuationValues.x = a;
|
||||
attenuationValues.y = b;
|
||||
@@ -34,7 +32,6 @@ namespace vb01{
|
||||
inline void setOuterAngle(float outerAngle){this->outerAngle = outerAngle;}
|
||||
inline void setShadowNearPlane(float nearPlane){this->nearPlane = nearPlane;}
|
||||
inline void setShadowFarPlane(float farPlane){this->farPlane = farPlane;}
|
||||
inline Vector3 getDirection(){return direction;}
|
||||
inline Vector3 getAttenuationValues(){return attenuationValues;}
|
||||
inline float getInnerAngle(){return innerAngle;}
|
||||
inline float getOuterAngle(){return outerAngle;}
|
||||
@@ -51,7 +48,7 @@ namespace vb01{
|
||||
Shader *depthMapShader;
|
||||
Texture *depthMap = nullptr;
|
||||
Node *node = nullptr;
|
||||
Vector3 position = Vector3::VEC_ZERO, color, attenuationValues = Vector3(1.8, .7, 1), direction;
|
||||
Vector3 color, attenuationValues = Vector3(1.8, .7, 1);
|
||||
float innerAngle = .707, outerAngle = .714, nearPlane = .1, farPlane = 100;
|
||||
unsigned int depthmapFBO, depthMapSize = 1024;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user