Cloud shader fix, entity waving effect
This commit is contained in:
@@ -13,5 +13,5 @@ void main ()
|
||||
discard;
|
||||
}
|
||||
|
||||
gl_FragColor = texture2D (texture, f_uv);
|
||||
gl_FragColor = vec4 (0.7, 0.7, 0.7, 1.0);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ varying vec2 f_uv;
|
||||
|
||||
void main ()
|
||||
{
|
||||
f_uv = (uv * 20.0) + (time * 20.0);
|
||||
/* Because the UVs go from 0 to 1, and I CBA to wrap textures, we
|
||||
gotta mod it. */
|
||||
f_uv = (uv * 20.0) + vec2 (mod(time * 0.000003, 1.0), mod(time * 0.000002, 1.0));
|
||||
gl_Position = projection * view * model * position;
|
||||
}
|
||||
|
||||
@@ -7,10 +7,27 @@ uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
uniform mat4 model;
|
||||
|
||||
uniform float time;
|
||||
uniform bool wavy;
|
||||
|
||||
varying vec2 f_uv;
|
||||
|
||||
void main ()
|
||||
{
|
||||
f_uv = uv;
|
||||
gl_Position = projection * view * model * position;
|
||||
|
||||
vec4 pos = position;
|
||||
|
||||
if (wavy)
|
||||
{
|
||||
vec2 center = vec2 (0.5, 0.5);
|
||||
vec2 local = pos.xz - center;
|
||||
|
||||
local.x += sin(local.x * time * 0.001) / 64.0;
|
||||
local.y += cos(local.y * time * 0.001) / 64.0;
|
||||
|
||||
pos.xz = local + center;
|
||||
}
|
||||
|
||||
gl_Position = projection * view * model * pos;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "../entity/entman.h"
|
||||
#include "../entity/templates.h"
|
||||
|
||||
#define RENDER_DISTANCE 6
|
||||
#define RENDER_DISTANCE 4
|
||||
|
||||
void chunkman_init ();
|
||||
void chunkman_update (vec3 camera_position);
|
||||
|
||||
@@ -12,6 +12,7 @@ typedef struct Entity
|
||||
enum { RENDER_NORMAL, RENDER_BILLBOARD_Y, RENDER_BILLBOARD } render_type;
|
||||
bool visible;
|
||||
bool dont_cull;
|
||||
bool wavy;
|
||||
|
||||
void *userdata;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
extern vec3 camera_position;
|
||||
extern int last_time;
|
||||
|
||||
Entity *player_entity;
|
||||
Entity *player_entity, *sky_entity;
|
||||
|
||||
static GSequence *entities;
|
||||
static EntityMesh mesh_quad1, mesh_quad2, mesh_quad_x;
|
||||
@@ -40,8 +40,8 @@ entman_init ()
|
||||
|
||||
ENTADD (player_entity);
|
||||
|
||||
Entity *sky = malloc (sizeof (Entity));
|
||||
*sky = (Entity) {
|
||||
sky_entity = malloc (sizeof (Entity));
|
||||
*sky_entity = (Entity) {
|
||||
.mesh_type = MESH_QUAD1,
|
||||
.origin = ORIGIN_CENTER,
|
||||
.visible = true,
|
||||
@@ -53,7 +53,7 @@ entman_init ()
|
||||
.program = RESPRG ("clouds")
|
||||
};
|
||||
|
||||
ENTADD (sky);
|
||||
ENTADD (sky_entity);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -184,6 +184,15 @@ entman_render_internal (gpointer data, gpointer userdata)
|
||||
program_set_mat4 (entity->program, "model", model);
|
||||
program_set_float (entity->program, "time", last_time);
|
||||
|
||||
if (entity->wavy)
|
||||
{
|
||||
program_set_float (entity->program, "wavy", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
program_set_float (entity->program, "wavy", false);
|
||||
}
|
||||
|
||||
if (entity->texture != last_texture)
|
||||
{
|
||||
glActiveTexture (GL_TEXTURE0);
|
||||
|
||||
@@ -23,6 +23,7 @@ ent_templates_init ()
|
||||
*tree = (Entity) {
|
||||
.mesh_type = MESH_QUAD_X,
|
||||
.visible = true,
|
||||
.wavy = true,
|
||||
.origin = ORIGIN_BOTTOM,
|
||||
.position = { 0.0 },
|
||||
.scale = { 3.0, 8.0, 3.0 },
|
||||
@@ -38,6 +39,7 @@ ent_templates_init ()
|
||||
.mesh_type = MESH_QUAD1,
|
||||
.render_type = RENDER_BILLBOARD_Y,
|
||||
.visible = true,
|
||||
.wavy = true,
|
||||
.origin = ORIGIN_BOTTOM,
|
||||
.position = { 0.0 },
|
||||
.scale = { 1.0, 0.5, 1.0 },
|
||||
|
||||
+3
-1
@@ -1,7 +1,7 @@
|
||||
#include "state.h"
|
||||
|
||||
extern vec3 camera_position;
|
||||
extern Entity *player_entity;
|
||||
extern Entity *player_entity, *sky_entity;
|
||||
|
||||
float delta_time;
|
||||
int last_time;
|
||||
@@ -21,6 +21,8 @@ game_state_tick (int ticks)
|
||||
|
||||
glm_vec3_copy (player_entity->position, camera_position);
|
||||
camera_position[1] += player_entity->scale[1] - 0.2;
|
||||
sky_entity->position[0] = camera_position[0];
|
||||
sky_entity->position[2] = camera_position[2];
|
||||
|
||||
if (flags_get ("moving_forward"))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user