-#ifndef RENDER_H
-#define RENDER_H
-
#include "common.h"
#include "model.h"
+static void render_water_texture( m4x3f camera );
+static void render_water_surface( m4x4f pv, m4x3f camera );
+static void render_world( m4x4f projection, m4x3f camera );
+static void shader_link_standard_ub( GLuint shader, int texture_id );
+static void render_world_depth( m4x4f projection, m4x3f camera );
+
+#ifndef RENDER_H
+#define RENDER_H
+
static struct pipeline
{
float fov;
struct ub_world_lighting
{
/* v3f (padded) */
- v4f g_directional,
- g_sun_colour,
- g_shadow_colour;
+ v4f g_light_colours[3],
+ g_light_directions[3],
+ g_ambient_colour;
v4f g_water_plane,
g_depth_bounds;
+
float g_water_fog;
+ int g_light_count;
+ int g_light_preview;
}
ub_world_lighting;
+ struct light_widget
+ {
+ int enabled;
+ v2f dir;
+ v3f colour;
+ }
+ widgets[3];
+
+ float shadow_spread, shadow_length;
+
GLuint fb_depthmap, rgb_depthmap;
GLuint ubo_world_lighting,
ubo_world;
}
-gpipeline;
-
-static void render_water_texture( m4x3f camera );
-static void render_water_surface( m4x4f pv, m4x3f camera );
-static void render_world( m4x4f projection, m4x3f camera );
-static void render_world_depth( m4x4f projection, m4x3f camera );
+gpipeline =
+{
+ .widgets =
+ {
+ {
+ .enabled = 1,
+ .colour = { 1.36f, 1.35f, 1.01f },
+ .dir = { 0.63f, -0.08f }
+ },
+ {
+ .enabled = 1,
+ .colour = { 0.33f, 0.56f, 0.64f },
+ .dir = { -2.60f, -0.13f }
+ },
+ {
+ .enabled = 1,
+ .colour = { 0.05f, 0.05f, 0.23f },
+ .dir = { 2.60f, -0.84f }
+ }
+ },
+ .shadow_spread = 0.65f,
+ .shadow_length = 9.50f,
+
+ .ub_world_lighting =
+ {
+ .g_ambient_colour = { 0.09f, 0.03f, 0.07f }
+ }
+};
/*
* Matrix Projections
static void render_update_lighting_ub(void)
{
- glBindBuffer( GL_UNIFORM_BUFFER, gpipeline.ubo_world_lighting );
+ struct ub_world_lighting *winf = &gpipeline.ub_world_lighting;
+ int c = 0;
+ for( int i=0; i<3; i++ )
+ {
+ struct light_widget *lw = &gpipeline.widgets[i];
+
+ if( lw->enabled )
+ {
+ float pitch = lw->dir[0],
+ yaw = lw->dir[1],
+ xz = cosf( pitch );
+
+ v3_copy( (v3f){ xz*cosf(yaw), sinf(pitch), xz*sinf(yaw) },
+ winf->g_light_directions[c] );
+ v3_copy( lw->colour, winf->g_light_colours[c] );
+
+ c ++;
+ }
+ }
+
+ winf->g_light_count = c;
+ winf->g_light_directions[0][3] = gpipeline.shadow_length;
+ winf->g_light_colours[0][3] = gpipeline.shadow_spread;
+
+ glBindBuffer( GL_UNIFORM_BUFFER, gpipeline.ubo_world_lighting );
glBufferSubData( GL_UNIFORM_BUFFER, 0, sizeof(struct ub_world_lighting),
&gpipeline.ub_world_lighting );
}