diff --git a/light.cpp b/light.cpp index f168857..d9d39d3 100755 --- a/light.cpp +++ b/light.cpp @@ -92,7 +92,7 @@ namespace vb01{ vec3 dir=vec3(direction.x,direction.y,direction.z); vec3 up=vec3(upDir.x,upDir.y,upDir.z); vec3 p=type==DIRECTIONAL?vec3(pos.x,pos.y,pos.z)-.5f*farPlane*dir:vec3(position.x,position.y,position.z); - view=lookAt(vec3(0,30,0),vec3(0,0,0),vec3(1,0,0)); + view=lookAt(p,p+dir,up); proj=ortho(-10.f,10.f,-10.f,10.f,nearPlane,farPlane); depthMapShader->use(); diff --git a/material.cpp b/material.cpp index eacc5b8..d20c5ff 100755 --- a/material.cpp +++ b/material.cpp @@ -49,10 +49,8 @@ namespace vb01{ shader->setVec4(diffuseColor,"diffuseColor"); } if(texturingEnabled){ - for(Texture *t : diffuseMapTextures){ - t->update(); + for(Texture *t : diffuseMapTextures) t->select(); - } for(Texture *t : normalMapTextures) t->select(); for(Texture *t : specularMapTextures) diff --git a/texture.cpp b/texture.cpp index 6816844..b6db7e4 100755 --- a/texture.cpp +++ b/texture.cpp @@ -77,35 +77,6 @@ namespace vb01{ stbi_image_free(data); } - Texture::Texture(string path[],int numFrames,s64 updateRate,bool flip){ - this->updateRate=updateRate; - this->numFrames=numFrames; - frames=new u32; - for(int i=0;itype=TextureType::TEXTURE_CUBEMAP; @@ -138,17 +109,8 @@ namespace vb01{ glDeleteTextures(1,&texture); } - void Texture::update(){ - if(numFrames>0){ - if(getTime()-lastUpdateTime>updateRate){ - currentFrame=(currentFrame==numFrames-1?0:currentFrame+1); - lastUpdateTime=getTime(); - } - } - } - void Texture::select(int id){ glActiveTexture(GL_TEXTURE0+id); - glBindTexture(type==TEXTURE_2D?GL_TEXTURE_2D:GL_TEXTURE_CUBE_MAP,numFrames==0?texture:frames[currentFrame]); + glBindTexture(type==TEXTURE_2D?GL_TEXTURE_2D:GL_TEXTURE_CUBE_MAP,texture); } } diff --git a/texture.frag b/texture.frag index 0cad3ba..cf6d20a 100755 --- a/texture.frag +++ b/texture.frag @@ -35,7 +35,7 @@ float getShadow(int id,int shadowId){ float closestDepth=texture(light[id].depthMap[shadowId],projCoords.xy).r; float currentDepth=projCoords.z; float bias=.005; - return (currentDepth-bias>closestDepth)&&projCoords.z<=1.?.7:0; + return currentDepth-bias>closestDepth?.7:0; } void main(){ diff --git a/texture.h b/texture.h index def2331..a38e9d6 100755 --- a/texture.h +++ b/texture.h @@ -3,7 +3,6 @@ #include #include -#include"util.h" #include FT_FREETYPE_H namespace vb01{ @@ -15,19 +14,16 @@ namespace vb01{ Texture(int,int,bool=true); Texture(FT_Face&,char); Texture(std::string,bool=false); - Texture(std::string[],int,s64,bool=false); Texture(std::string[6],bool=false); - void update(); void select(int=0); inline unsigned int* getTexture(){return &texture;} inline std::string getPath(){return path;} private: TextureType type=TextureType::TEXTURE_2D; - s64 updateRate=0,lastUpdateTime=0; - u32 texture,*frames; - int width,height,numChannels,numFrames=0,currentFrame=0; + unsigned int texture; + int width,height,numChannels; float weight; - u8 *data; + unsigned char *data; std::string path="",paths[6]; }; }