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 = ...@@ -8,44 +8,19 @@ const char* SelectionManagerMeshVertices::s_DisplayShaderVSH =
"#version 330\n" "#version 330\n"
"uniform mat4 u_CameraMatrix;" "uniform mat4 u_CameraMatrix;"
"uniform sampler2D u_SelectionTexture;"
"in vec3 vertexPosition;" "in vec3 vertexPosition;"
"out float idFloat;"
"void main()" "void main()"
"{" "{"
" idFloat = float( gl_VertexID );" " ivec2 bufferSize = textureSize( u_SelectionTexture, 0 );"
" gl_Position = u_CameraMatrix * vec4(vertexPosition,1.0f);" " 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);"
const char* SelectionManagerMeshVertices::s_DisplayShaderGSH =
"#version 330\n"
"#extension GL_EXT_geometry_shader4 : enable\n"
"layout( points ) in;"
"layout( points, max_vertices = 1 ) out;"
"uniform sampler2D u_SelectionTexture;" " float selectionMask = texture( u_SelectionTexture, texCoords ).x;"
" gl_Position = mix( vec4(0,0,10,1), u_CameraMatrix*vec4(vertexPosition,1.0f), selectionMask );"
"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();"
" }"
"}"; "}";
const char* SelectionManagerMeshVertices::s_DisplayShaderFSH = const char* SelectionManagerMeshVertices::s_DisplayShaderFSH =
...@@ -161,7 +136,6 @@ SelectionManagerMeshVertices::SelectionManagerMeshVertices( GPU::VBO &meshVBO, ...@@ -161,7 +136,6 @@ SelectionManagerMeshVertices::SelectionManagerMeshVertices( GPU::VBO &meshVBO,
GPU::CreateShaderFromSources( GPU::CreateShaderFromSources(
m_DisplayShader, m_DisplayShader,
s_DisplayShaderVSH, s_DisplayShaderVSH,
s_DisplayShaderGSH,
s_DisplayShaderFSH s_DisplayShaderFSH
); );
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
class GLVIEWER_API SelectionManagerMeshVertices : public VertexSelectionManager class GLVIEWER_API SelectionManagerMeshVertices : public VertexSelectionManager
{ {
static const char* s_DisplayShaderVSH; static const char* s_DisplayShaderVSH;
static const char* s_DisplayShaderGSH;
static const char* s_DisplayShaderFSH; static const char* s_DisplayShaderFSH;
GPU::Shader m_DisplayShader; 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