mirror of
https://github.com/devZoGok/vb01.git
synced 2026-08-26 19:43:30 +00:00
text texture animation
This commit is contained in:
@@ -4,16 +4,22 @@ in vec2 texCoords;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
struct Texture{
|
||||
float mixRatio;
|
||||
sampler2D pastTexture, nextTexture;
|
||||
bool animated;
|
||||
};
|
||||
|
||||
uniform bool texturingEnabled;
|
||||
uniform bool diffuseColorEnabled;
|
||||
uniform bool guiPlane;
|
||||
uniform vec4 diffuseColor;
|
||||
uniform sampler2D tex;
|
||||
uniform Texture diffuseMap;
|
||||
|
||||
void main(){
|
||||
vec4 c = (texturingEnabled ? texture(tex, texCoords) : diffuseColor);
|
||||
vec4 c = (texturingEnabled ? texture(diffuseMap.pastTexture, texCoords) : diffuseColor);
|
||||
if(diffuseColorEnabled){
|
||||
float alpha = texture(tex, texCoords).w;
|
||||
float alpha = texture(diffuseMap.pastTexture, texCoords).w;
|
||||
c = vec4(diffuseColor.xyz, alpha);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace vb01{
|
||||
currentValue = pastKeyframe.value;
|
||||
break;
|
||||
case Keyframe::LINEAR:
|
||||
currentValue = interpolateBezier(vector<float>({pastKeyframe.value, nextKeyframe.value}), ratio);
|
||||
break;
|
||||
case Keyframe::BEZIER:
|
||||
vector<float> points = vector<float>({pastKeyframe.value, pastKeyframe.rightHandleValue, nextKeyframe.leftHandleValue, nextKeyframe.value});
|
||||
currentValue = interpolateBezier(points, ratio);
|
||||
|
||||
+3
-2
@@ -107,8 +107,9 @@ namespace vb01{
|
||||
shader->setVec4(diffuseColor, "diffuseColor");
|
||||
}
|
||||
else if(type == MATERIAL_TEXT){
|
||||
shader->setInt(0, "textTex");
|
||||
//shader->setInt(1, "diffuseMap");
|
||||
shader->setInt(0, "textures[0].pastTexture");
|
||||
shader->setInt(1, "textures[0].nextTexture");
|
||||
shader->setInt(2, "textures[1].pastTexture");
|
||||
}
|
||||
|
||||
if(texturingEnabled){
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace vb01{
|
||||
glBindVertexArray(VAO);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
||||
glBufferSubData(GL_ARRAY_BUFFER, 0, dataSize, data);
|
||||
glyph.texture->select();
|
||||
glyph.texture->select(2);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,26 @@ in vec2 texCoords;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform sampler2D textTex, diffuseMap;
|
||||
struct Texture{
|
||||
float mixRatio;
|
||||
sampler2D pastTexture, nextTexture;
|
||||
bool animated;
|
||||
};
|
||||
|
||||
uniform Texture textures[2];
|
||||
uniform bool texturingEnabled;
|
||||
uniform vec4 diffuseColor;
|
||||
|
||||
void main(){
|
||||
float alpha = texture(textTex, texCoords).r;
|
||||
FragColor = vec4(diffuseColor.xyz, diffuseColor.w * alpha);
|
||||
vec4 diffCol;
|
||||
if(texturingEnabled){
|
||||
diffCol = texture(textures[0].pastTexture, texCoords);
|
||||
if(textures[0].animated)
|
||||
diffCol = mix(diffCol, texture(textures[0].nextTexture, texCoords), textures[0].mixRatio);
|
||||
}
|
||||
else
|
||||
diffCol = diffuseColor;
|
||||
|
||||
float alpha = texture(textures[1].pastTexture, texCoords).r;
|
||||
FragColor = vec4(diffCol.xyz, diffCol.w * alpha);
|
||||
}
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ void main(){
|
||||
vec4 finalColor = diffuseColor;
|
||||
if(texturingEnabled){
|
||||
vec4 textureColor = texture(textures[0].pastTexture, texCoords);
|
||||
finalColor = textures[0].animated ? mix(textureColor, texture(textures[0].nextTexture, texCoords), textures[0].mixRatio) : textureColor;
|
||||
finalColor = (textures[0].animated ? mix(textureColor, texture(textures[0].nextTexture, texCoords), textures[0].mixRatio) : textureColor);
|
||||
}
|
||||
|
||||
vec3 normal = norm;
|
||||
|
||||
Reference in New Issue
Block a user