lights use node position and orientation

This commit is contained in:
devZoGok
2021-10-19 19:06:41 +03:00
parent c241c6cac8
commit 3493f1b371
2 changed files with 3 additions and 4 deletions
+2
View File
@@ -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();
+1 -4
View File
@@ -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;
};