Commit 2f0d30b7 authored by Frédéric Larue's avatar Frédéric Larue

Bug fixed in SelectionManagerMeshVertices and selection display performances improved.

parent 6f6326c8
......@@ -8,44 +8,19 @@ const char* SelectionManagerMeshVertices::s_DisplayShaderVSH =
"#version 330\n"
"uniform mat4 u_CameraMatrix;"
"uniform sampler2D u_SelectionTexture;"
"in vec3 vertexPosition;"
"out float idFloat;"
"void main()"
"{"
" idFloat = float( gl_VertexID );"
" gl_Position = u_CameraMatrix * vec4(vertexPosition,1.0f);"
"}";
const char* SelectionManagerMeshVertices::s_DisplayShaderGSH =
"#version 330\n"
"#extension GL_EXT_geometry_shader4 : enable\n"
"layout( points ) in;"
"layout( points, max_vertices = 1 ) out;"
" ivec2 bufferSize = textureSize( u_SelectionTexture, 0 );"
" float screenX = float( gl_VertexID % bufferSize.x ) + 0.5;"
" float screenY = float( gl_VertexID / bufferSize.x ) + 0.5;"
" vec2 texCoords = vec2(screenX,screenY) / vec2(bufferSize);"
"uniform sampler2D u_SelectionTexture;"
"in float idFloat[];"
"void main()"
"{"
" int id = int( idFloat[0] );"
" ivec2 bufferSize = textureSize( u_SelectionTexture, 0 );"
" float screenX = float( id % bufferSize.x ) + 0.5;"
" float screenY = float( id / bufferSize.x ) + 0.5;"
" vec2 texCoords = vec2(screenX,screenY) / vec2(bufferSize);"
" float selectionMask = texture(u_SelectionTexture,texCoords).x;"
" if( selectionMask != 0 )"
" {"
" gl_Position = gl_PositionIn[0];"
" EmitVertex();"
" EndPrimitive();"
" }"
" float selectionMask = texture( u_SelectionTexture, texCoords ).x;"
" gl_Position = mix( vec4(0,0,10,1), u_CameraMatrix*vec4(vertexPosition,1.0f), selectionMask );"
"}";
const char* SelectionManagerMeshVertices::s_DisplayShaderFSH =
......@@ -161,7 +136,6 @@ SelectionManagerMeshVertices::SelectionManagerMeshVertices( GPU::VBO &meshVBO,
GPU::CreateShaderFromSources(
m_DisplayShader,
s_DisplayShaderVSH,
s_DisplayShaderGSH,
s_DisplayShaderFSH
);
......
......@@ -10,7 +10,6 @@
class GLVIEWER_API SelectionManagerMeshVertices : public VertexSelectionManager
{
static const char* s_DisplayShaderVSH;
static const char* s_DisplayShaderGSH;
static const char* s_DisplayShaderFSH;
GPU::Shader m_DisplayShader;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment