Revert "animatable textures"

This reverts commit 8226a9479ce8ab45bed5bc6acbba63eaaf0e6330.
This commit is contained in:
devZoGok
2021-10-19 19:06:40 +03:00
parent 89c25c5bd9
commit 0193216ebb
5 changed files with 7 additions and 51 deletions
+1 -1
View File
@@ -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();
+1 -3
View File
@@ -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)
+1 -39
View File
@@ -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;i<numFrames;i++){
bool png=false;
int length=path[i].length();
if(path[i].substr(length-4,string::npos)==".png")
png=true;
glGenTextures(1,&(frames[i]));
glBindTexture(GL_TEXTURE_2D,frames[i]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
stbi_set_flip_vertically_on_load(flip);
data=stbi_load(path[i].c_str(),&width,&height,&numChannels,0);
glTexImage2D(GL_TEXTURE_2D,0,png?GL_RGBA:GL_RGB,width,height,0,png?GL_RGBA:GL_RGB,GL_UNSIGNED_BYTE,data);
//glGenerateMipmap(GL_TEXTURE_2D);
stbi_image_free(data);
}
}
Texture::Texture(string paths[6],bool flip){
this->type=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);
}
}
+1 -1
View File
@@ -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(){
+3 -7
View File
@@ -3,7 +3,6 @@
#include<string>
#include<ft2build.h>
#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];
};
}