@@ -106,7 +106,7 @@ static opengl_shader_type_t GL_shader_types[] = {
106106 { opengl_vert_attrib::POSITION, opengl_vert_attrib::TEXCOORD }, " Video Playback" },
107107
108108 { SDR_TYPE_PASSTHROUGH_RENDER, " passthrough-v.sdr" , " passthrough-f.sdr" , 0 ,
109- { " modelViewMatrix" , " projMatrix" , " baseMap" , " noTexturing" , " alphaTexture" , " srgb" , " intensity" , " color" , " alphaThreshold" },
109+ { " modelViewMatrix" , " projMatrix" , " baseMap" , " noTexturing" , " alphaTexture" , " srgb" , " intensity" , " color" , " alphaThreshold" , " clipEnabled " , " clipEquation " , " modelMatrix " },
110110 { opengl_vert_attrib::POSITION, opengl_vert_attrib::TEXCOORD, opengl_vert_attrib::COLOR }, " Passthrough" },
111111
112112 { SDR_TYPE_SHIELD_DECAL, " shield-impact-v.sdr" , " shield-impact-f.sdr" , 0 ,
@@ -788,7 +788,7 @@ void opengl_shader_compile_passthrough_shader()
788788 opengl_shader_set_current ();
789789}
790790
791- void opengl_shader_set_passthrough (bool textured, bool alpha, vec4 *clr, float color_scale)
791+ void opengl_shader_set_passthrough (bool textured, bool alpha, vec4 *clr, float color_scale, const material::clip_plane& clip_plane )
792792{
793793 opengl_shader_set_current (gr_opengl_maybe_create_shader (SDR_TYPE_PASSTHROUGH_RENDER, 0 ));
794794
@@ -820,6 +820,21 @@ void opengl_shader_set_passthrough(bool textured, bool alpha, vec4 *clr, float c
820820 Current_shader->program ->Uniforms .setUniform4f (" color" , 1 .0f , 1 .0f , 1 .0f , 1 .0f );
821821 }
822822
823+ if (clip_plane.enabled ) {
824+ Current_shader->program ->Uniforms .setUniformi (" clipEnabled" , 1 );
825+
826+ vec4 clip_equation;
827+ clip_equation.xyzw .x = clip_plane.normal .xyz .x ;
828+ clip_equation.xyzw .y = clip_plane.normal .xyz .y ;
829+ clip_equation.xyzw .z = clip_plane.normal .xyz .z ;
830+ clip_equation.xyzw .w = -vm_vec_dot (&clip_plane.normal , &clip_plane.position );
831+
832+ Current_shader->program ->Uniforms .setUniform4f (" clipEquation" , clip_equation);
833+ Current_shader->program ->Uniforms .setUniformMatrix4f (" modelMatrix" , GL_model_matrix_stack.get_transform ());
834+ } else {
835+ Current_shader->program ->Uniforms .setUniformi (" clipEnabled" , 0 );
836+ }
837+
823838 Current_shader->program ->Uniforms .setUniformMatrix4f (" modelViewMatrix" , GL_model_view_matrix);
824839 Current_shader->program ->Uniforms .setUniformMatrix4f (" projMatrix" , GL_projection_matrix);
825840}
0 commit comments