- m4x3f cam_new;
- m4x3_mul( gate->transport, camera, cam_new );
-
- vg_line_pt3( cam_new[3], 0.3f, 0xff00ff00 );
-
- m4x3f gate_xform;
- m4x3_copy( gate->to_world, gate_xform );
- m4x3_scalev( gate_xform, (v3f){ gate->dims[0], gate->dims[1], 1.0f } );
-
- m4x3f inverse;
- m4x3_invert_affine( cam_new, inverse );
-
- m4x4f view;
- m4x3_expand( inverse, view );
-
- v4f surface;
- m3x3_mulv( gate->recv_to_world, (v3f){0.0f,0.0f,-1.0f}, surface );
- surface[3] = v3_dot( surface, gate->co[1] );
-
- m4x4f projection;
- pipeline_projection( projection, 0.1f, 900.0f );
-
- m4x3_mulp( inverse, surface, surface );
- surface[3] = -fabsf(surface[3]);
- plane_clip_projection( projection, surface );
-
- m4x4_mul( projection, view, projection );
-
-#ifndef GATE_RENDER_PERFORMANCE
- fb_use( &grender.fb );
- glClearColor( 0.11f, 0.35f, 0.37f, 1.0f );
- glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
-#else
- shader_gatelq_use();
- shader_gatelq_uPv( vg.pv );
- shader_gatelq_uMdl( gate_xform );
- shader_gatelq_uCam( viewpos );
- shader_gatelq_uTime( vg.time*0.25f );
- shader_gatelq_uInvRes( (v2f){
- 1.0f / (float)vg.window_x,
- 1.0f / (float)vg.window_y });
-
- glEnable( GL_STENCIL_TEST );
- glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
- glStencilFunc( GL_ALWAYS, 1, 0xFF );
- glStencilMask( 0xFF );
-
- mesh_bind( &grender.mdl );
- mesh_draw( &grender.mdl );
-
- glClear( GL_DEPTH_BUFFER_BIT );
- glStencilFunc( GL_EQUAL, 1, 0xFF );
- glStencilMask( 0x00 );
-#endif
-
- render_world( projection, cam_new );
-
-#ifndef GATE_RENDER_PERFORMANCE
-
- /*
- * NOTE: Need to find a way to draw a stencil buffer into the water
- * rendering
- */
-
- render_water_texture( cam_new );
- fb_use( &grender.fb );
-
- render_water_surface( projection, cam_new );
- fb_use( NULL );
-
- shader_gate_use();
-
- shader_gate_uPv( vg_pv );
- shader_gate_uMdl( gate_xform );
-
- fb_bindtex( &grender.fb, 0 );
-
- shader_gate_uCam( viewpos );
- shader_gate_uTexMain( 0 );
- shader_gate_uTexWater( 1 );
- shader_gate_uTime( vg_time*0.25f );
- shader_gate_uInvRes( (v2f){
- 1.0f / (float)vg_window_x,
- 1.0f / (float)vg_window_y });
-
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- glBlendEquation(GL_FUNC_ADD);
-
- mesh_bind( &grender.mdl );
- mesh_draw( &grender.mdl );
-
- glDisable(GL_BLEND);
-#else
- glDisable( GL_STENCIL_TEST );
-
- render_water_texture( cam_new );
- fb_use( NULL );
- glEnable( GL_STENCIL_TEST );
-
- render_water_surface( projection, cam_new );
-
- glStencilMask( 0xFF );
- glStencilFunc( GL_ALWAYS, 1, 0xFF );
- glDisable( GL_STENCIL_TEST );
-#endif
-
- return 1;