smoot ltr animation? kinda
This commit is contained in:
parent
e94c476437
commit
f8f62312f9
2 changed files with 27 additions and 9 deletions
|
@ -8,8 +8,13 @@ in vec2 vsoTexCoord;
|
||||||
out vec4 fragColor;
|
out vec4 fragColor;
|
||||||
|
|
||||||
uniform sampler2D tex0;
|
uniform sampler2D tex0;
|
||||||
|
uniform sampler2D tex1;
|
||||||
uniform mat4 viewMatrix;
|
uniform mat4 viewMatrix;
|
||||||
uniform vec4 lumPos;
|
uniform vec4 lumPos;
|
||||||
|
uniform float fadeAmount;
|
||||||
|
|
||||||
|
const float fadeStart = 0;
|
||||||
|
const float fadeEnd = 1;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
const vec3 Vu = vec3(0, 0, -1);
|
const vec3 Vu = vec3(0, 0, -1);
|
||||||
|
@ -19,5 +24,10 @@ void main(void) {
|
||||||
float ispec = pow(clamp(dot(-Vu, reflexion), 0., 1.), 20);
|
float ispec = pow(clamp(dot(-Vu, reflexion), 0., 1.), 20);
|
||||||
float phongIL = clamp(dot(-Ld, vsoNormal), 0., 1.);
|
float phongIL = clamp(dot(-Ld, vsoNormal), 0., 1.);
|
||||||
|
|
||||||
fragColor = phongIL * texture(tex0, vsoTexCoord) + ispec * vec4(1);
|
vec4 color1 = texture(tex0, vsoTexCoord);
|
||||||
|
vec4 color2 = texture(tex1, vsoTexCoord);
|
||||||
|
float fadeFactor = smoothstep(fadeStart, fadeEnd, 1 - vsoTexCoord.x);
|
||||||
|
|
||||||
|
fragColor = phongIL * mix(color1, color2, fadeFactor * fadeAmount) + ispec * vec4(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
24
src/tag.c
24
src/tag.c
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
static GLuint _pId = 0;
|
static GLuint _pId = 0;
|
||||||
static GLuint _murId = 0;
|
static GLuint _murId = 0;
|
||||||
static GLuint _texId = 0;
|
static GLuint _texId[2] = {0};
|
||||||
|
|
||||||
static const char *matrix_proj = "proj";
|
static const char *matrix_proj = "proj";
|
||||||
static const char *matrix_model = "model";
|
static const char *matrix_model = "model";
|
||||||
|
@ -35,14 +35,15 @@ static void init(void) {
|
||||||
_murId = gl4dgGenGrid2df(100, 100);
|
_murId = gl4dgGenGrid2df(100, 100);
|
||||||
_pId = gl4duCreateProgram("<vs>shaders/tag.vs", "<fs>shaders/tag.fs", NULL);
|
_pId = gl4duCreateProgram("<vs>shaders/tag.vs", "<fs>shaders/tag.fs", NULL);
|
||||||
|
|
||||||
glGenTextures(1, &_texId);
|
glGenTextures(2, _texId);
|
||||||
load_img("images/wall.png", _texId);
|
load_img("images/wall.png", _texId[0]);
|
||||||
|
load_img("images/wall.png", _texId[1]);
|
||||||
|
|
||||||
TTF_Font *font = NULL;
|
TTF_Font *font = NULL;
|
||||||
if (initFont(&font, "fonts/Instrument.ttf", 100)) {
|
if (initFont(&font, "fonts/Instrument.ttf", 100)) {
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
if (writeText(&_texId, font, "macron = loser", (SDL_Color){0, 0, 0, 255},
|
if (writeText(&_texId[1], font, "macron = loser", (SDL_Color){0, 0, 0, 255},
|
||||||
GL_TRUE)) {
|
GL_TRUE)) {
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
|
@ -86,10 +87,17 @@ static void draw(void) {
|
||||||
gl4duSendMatrices();
|
gl4duSendMatrices();
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, _texId);
|
glBindTexture(GL_TEXTURE_2D, _texId[0]);
|
||||||
glUniform1f(glGetUniformLocation(_pId, "phase"), 0);
|
glUniform1f(glGetUniformLocation(_pId, "phase"), 0);
|
||||||
glUniform4fv(glGetUniformLocation(_pId, "lumPos"), 1, lum_pos);
|
glUniform4fv(glGetUniformLocation(_pId, "lumPos"), 1, lum_pos);
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE1);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, _texId[1]);
|
||||||
|
GLfloat fade_amout = (GLfloat)t0 / 7000.f;
|
||||||
|
glUniform1f(glGetUniformLocation(_pId, "fadeAmount"), fade_amout);
|
||||||
|
glUniform1i(glGetUniformLocation(_pId, "tex0"), 0);
|
||||||
|
glUniform1i(glGetUniformLocation(_pId, "tex1"), 1);
|
||||||
|
|
||||||
gl4dgDraw(_murId);
|
gl4dgDraw(_murId);
|
||||||
|
|
||||||
glUseProgram(0);
|
glUseProgram(0);
|
||||||
|
@ -97,8 +105,8 @@ static void draw(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deinit(void) {
|
static void deinit(void) {
|
||||||
if (_texId) {
|
if (_texId[0]) {
|
||||||
glDeleteTextures(1, &_texId);
|
glDeleteTextures(sizeof(_texId) / sizeof(*_texId), _texId);
|
||||||
_texId = 0;
|
_texId[0] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue