m3x3_mulv( gate->transport, phys->m, phys->m );
m3x3_mulv( gate->transport, phys->bob, phys->bob );
+ /* Pre-emptively edit the camera matrices so that the motion vectors
+ * are correct */
+ m4x3f transport_i;
+ m4x4f transport_4;
+ m4x3_invert_affine( gate->transport, transport_i );
+ m4x3_expand( transport_i, transport_4 );
+ m4x4_mul( main_camera.mtx.pv, transport_4, main_camera.mtx.pv );
+ m4x4_mul( main_camera.mtx.v, transport_4, main_camera.mtx.v );
+
v4f transport_rotation;
m3x3_q( gate->transport, transport_rotation );
q_mul( transport_rotation, phys->rb.q, phys->rb.q );
/*
* The primary draw target
*/
- "Main",
+ "main",
.link = &gpipeline.fb_main,
.resolution_div = 1,
.attachments =
{
{
- "Colour", k_framebuffer_attachment_type_colour,
+ "colour", k_framebuffer_attachment_type_colour,
.internalformat = GL_RGB,
.format = GL_RGB,
.attachment = GL_COLOR_ATTACHMENT0
},
{
- "Motion Vectors", k_framebuffer_attachment_type_colour,
+ "motion", k_framebuffer_attachment_type_colour,
.quality = k_framebuffer_quality_high_only,
.internalformat = GL_RG16F,
.attachment = GL_COLOR_ATTACHMENT1
},
{
- "Depth/Stencil", k_framebuffer_attachment_type_renderbuffer,
+ "depth_stencil", k_framebuffer_attachment_type_renderbuffer,
.internalformat = GL_DEPTH24_STENCIL8,
.attachment = GL_DEPTH_STENCIL_ATTACHMENT
* Note: it does not have a render buffer attachement because it's
* intended to be drawn to in a MAX blending mode
*/
- "Heightmap",
+ "heightmap",
.link = &gpipeline.fb_heightmap,
.fixed_w = 1024,
.fixed_h = 1024,
.attachments =
{
{
- "Depth", k_framebuffer_attachment_type_colour,
+ "depth", k_framebuffer_attachment_type_colour,
.internalformat = GL_R32F,
.format = GL_RED,
/*
* Second rendered view from the perspective of the water reflection
*/
- "Water reflection",
+ "water_reflection",
.link = &gpipeline.fb_water_reflection,
.resolution_div = 3,
.attachments =
{
{
- "Colour", k_framebuffer_attachment_type_colour,
+ "colour", k_framebuffer_attachment_type_colour,
.internalformat = GL_RGB,
.format = GL_RGB,
.type = GL_UNSIGNED_BYTE,
.attachment = GL_COLOR_ATTACHMENT0
},
{
- "Depth/Stencil", k_framebuffer_attachment_type_renderbuffer,
+ "depth_stencil", k_framebuffer_attachment_type_renderbuffer,
.internalformat = GL_DEPTH24_STENCIL8,
.attachment = GL_DEPTH_STENCIL_ATTACHMENT
* Thid rendered view from the perspective of the camera, but just
* captures stuff thats under the water
*/
- "Water Beneath",
+ "water_beneath",
.link = &gpipeline.fb_water_beneath,
.resolution_div = 4,
.attachments =
{
{
- "Colour", k_framebuffer_attachment_type_colour,
+ "colour", k_framebuffer_attachment_type_colour,
.internalformat = GL_RGBA,
.format = GL_RGBA,
.type = GL_UNSIGNED_BYTE,
.attachment = GL_COLOR_ATTACHMENT0
},
{
- "Depth/Stencil", k_framebuffer_attachment_type_renderbuffer,
+ "depth_stencil", k_framebuffer_attachment_type_renderbuffer,
.internalformat = GL_DEPTH24_STENCIL8,
.attachment = GL_DEPTH_STENCIL_ATTACHMENT
0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,
0.2f, 0.0f, 0.8f, 1.0f, 0.2f, 1.0f,
- 0.2f, 0.0f, 0.8f, 0.0f, 0.8f, 1.0f};
+ 0.2f, 0.0f, 0.8f, 0.0f, 0.8f, 1.0f };
glGenVertexArrays( 1, &gpipeline.fsquad.vao );
glGenBuffers( 1, &gpipeline.fsquad.vbo );
glBufferData( GL_ARRAY_BUFFER, sizeof(quad), quad, GL_STATIC_DRAW );
glBindVertexArray( gpipeline.fsquad.vao );
glVertexAttribPointer( 0, 2, GL_FLOAT, GL_FALSE,
- sizeof(float)*2, (void*)0 );
+ sizeof(float)*2, (void*)0 );
glEnableVertexAttribArray( 0 );
VG_CHECK_GL_ERR();
"\n"
"#line 2 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n"
"{\n"
+" // This magically solves some artifacting errors!\n"
+" //\n"
" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n"
"\n"
" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n"
"\n"
"#line 13 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"#line 2 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n"
"{\n"
+" // This magically solves some artifacting errors!\n"
+" //\n"
" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n"
"\n"
" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n"
"\n"
"#line 2 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n"
"{\n"
+" // This magically solves some artifacting errors!\n"
+" //\n"
" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n"
"\n"
" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n"
-const float k_motion_lerp_amount = 0.05;
+const float k_motion_lerp_amount = 0.01;
void vs_motion_out( vec4 vproj0, vec4 vproj1 )
{
+ // This magically solves some artifacting errors!
+ //
vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;
aMotionVec0 = vec3( vproj0.xy, vproj0.w );
"\n"
"#line 2 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n"
"{\n"
+" // This magically solves some artifacting errors!\n"
+" //\n"
" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n"
"\n"
" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n"
"\n"
"#line 13 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"#line 2 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n"
"{\n"
+" // This magically solves some artifacting errors!\n"
+" //\n"
" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n"
"\n"
" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n"
"\n"
"#line 12 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"#line 2 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n"
"{\n"
+" // This magically solves some artifacting errors!\n"
+" //\n"
" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n"
"\n"
" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n"
"in vec3 aCo;\n"
"\n"
"#line 1 1 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"#line 2 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n"
"{\n"
+" // This magically solves some artifacting errors!\n"
+" //\n"
" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n"
"\n"
" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n"
"\n"
"#line 13 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"#line 2 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n"
"{\n"
+" // This magically solves some artifacting errors!\n"
+" //\n"
" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n"
"\n"
" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n"
"\n"
"#line 14 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"#line 2 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n"
"{\n"
+" // This magically solves some artifacting errors!\n"
+" //\n"
" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n"
"\n"
" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n"
"\n"
"#line 12 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"#line 2 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n"
"{\n"
+" // This magically solves some artifacting errors!\n"
+" //\n"
" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n"
"\n"
" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n"
"\n"
"#line 11 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"#line 2 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n"
"{\n"
+" // This magically solves some artifacting errors!\n"
+" //\n"
" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n"
"\n"
" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n"
"\n"
"#line 20 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"#line 2 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
"\n"
"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n"
"{\n"
+" // This magically solves some artifacting errors!\n"
+" //\n"
" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n"
"\n"
" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n"
"\n"
"#line 17 0 \n"
"#line 1 2 \n"
-"const float k_motion_lerp_amount = 0.05;\n"
+"const float k_motion_lerp_amount = 0.01;\n"
"\n"
"#line 2 0 \n"
"\n"
v3f v0;
v3_sub( cam->pos, gate->co[0], v0 );
- if( v3_dot(v0, gatedir) >= 0.0f )
+
+ float dist = v3_dot(v0, gatedir);
+
+ /* Hard cutoff */
+ if( dist > 3.0f )
return 0;
if( v3_dist( cam->pos, gate->co[0] ) > 100.0f )
static camera gate_view;
gate_view.fov = cam->fov;
gate_view.nearz = 0.1f;
- gate_view.farz = 900.0f;
+ gate_view.farz = 2000.0f;
m4x3_mul( gate->transport, cam->transform, gate_view.transform );
camera_update_view( &gate_view );
m4x3_mulp( gate_view.transform_inverse, surface, surface );
surface[3] = -fabsf(surface[3]);
- m4x4_clip_projection( gate_view.mtx.p, surface );
+
+ if( dist < -0.5f )
+ m4x4_clip_projection( gate_view.mtx.p, surface );
/* Ready to draw with new camrea */
camera_finalize( &gate_view );
mdl_node *mblob = mdl_node_from_name( mfoliage, "blob" );
mdl_submesh *sm_blob = mdl_node_submesh( mfoliage, mblob, 0 );
+ int count = 0;
+
for( int i=0;i<100000;i++ )
{
v3f pos;
ray_hit hit;
hit.dist = INFINITY;
- if( ray_world( pos, (v3f){0.0f,-1.0f,0.0f}, &hit ))
+ if( ray_world( pos, (v3f){0.0001f,-1.0f,0.0001f}, &hit ))
{
struct world_material *m1 = ray_hit_material( &hit );
if((hit.normal[1] > 0.8f) && (m1 == mat) && (hit.pos[1] > 0.0f+10.0f))
v3_copy( hit.pos, transform[3] );
scene_add_submesh( world.scene_no_collide, mfoliage,
sm_blob, transform);
+
+ count ++;
}
}
}
+
+ vg_info( "%d foliage models added\n", count );
}
VG_STATIC void world_ents_allocate(void)