diff --git a/gui.frag b/gui.frag index f4bf50a..f977c2e 100755 --- a/gui.frag +++ b/gui.frag @@ -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); } diff --git a/keyframeChannel.cpp b/keyframeChannel.cpp index bb2998d..cd1ce86 100644 --- a/keyframeChannel.cpp +++ b/keyframeChannel.cpp @@ -10,6 +10,8 @@ namespace vb01{ currentValue = pastKeyframe.value; break; case Keyframe::LINEAR: + currentValue = interpolateBezier(vector({pastKeyframe.value, nextKeyframe.value}), ratio); + break; case Keyframe::BEZIER: vector points = vector({pastKeyframe.value, pastKeyframe.rightHandleValue, nextKeyframe.leftHandleValue, nextKeyframe.value}); currentValue = interpolateBezier(points, ratio); diff --git a/material.cpp b/material.cpp index bea5309..cab3b1b 100755 --- a/material.cpp +++ b/material.cpp @@ -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){ diff --git a/text.cpp b/text.cpp index a2a48c4..8f16c3c 100755 --- a/text.cpp +++ b/text.cpp @@ -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); } diff --git a/text.frag b/text.frag index e99f506..51ae864 100755 --- a/text.frag +++ b/text.frag @@ -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); } diff --git a/texture.frag b/texture.frag index 3a61aad..372e2f6 100755 --- a/texture.frag +++ b/texture.frag @@ -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;