<@include gpu/Config.slh@> <$VERSION_HEADER$> // Generated on <$_SCRIBE_DATE$> // // Draw and transform the fed vertex position with the standard MVP stack // and offset the vertices by a certain amount in the vertex direction // // Created by Olivier Prat on 11/02/2017 // Copyright 2017 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // <@include gpu/ShaderConstants.h@> <@include gpu/Transform.slh@> <$declareStandardTransform()$> struct ItemBound { vec4 id_boundPos; vec4 boundDim_s; }; #if !defined(GPU_SSBO_TRANSFORM_OBJECT) LAYOUT(binding=GPU_RESOURCE_BUFFER_SLOT0_TEXTURE) uniform samplerBuffer ssbo0Buffer; ItemBound getItemBound(int i) { int offset = 2 * i; ItemBound bound; bound.id_boundPos = texelFetch(ssbo0Buffer, offset); bound.boundDim_s = texelFetch(ssbo0Buffer, offset + 1); return bound; } #else LAYOUT_STD140(binding=GPU_RESOURCE_BUFFER_SLOT0_STORAGE) buffer ssbo0Buffer { ItemBound bounds[]; }; ItemBound getItemBound(int i) { ItemBound bound = bounds[i]; return bound; } #endif struct HighlightParameters { vec2 outlineWidth; }; LAYOUT_STD140(binding=0) uniform parametersBuffer { HighlightParameters _parameters; }; void main(void) { const vec3 UNIT_BOX_VERTICES[8] = vec3[8]( vec3(0.0, 1.0, 0.0), vec3(1.0, 1.0, 0.0), vec3(1.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), vec3(0.0, 1.0, 1.0), vec3(1.0, 1.0, 1.0), vec3(1.0, 0.0, 1.0), vec3(0.0, 0.0, 1.0) ); const vec3 UNIT_BOX_NORMALS[8] = vec3[8]( vec3(-1.0, 1.0, -1.0), vec3(1.0, 1.0, -1.0), vec3(1.0, -1.0, -1.0), vec3(-1.0, -1.0, -1.0), vec3(-1.0, 1.0, 1.0), vec3(1.0, 1.0, 1.0), vec3(1.0, -1.0, 1.0), vec3(-1.0, -1.0, 1.0) ); const int NUM_VERTICES_PER_CUBE = 36; const int UNIT_BOX_TRIANGLE_INDICES[NUM_VERTICES_PER_CUBE] = int[NUM_VERTICES_PER_CUBE]( 0, 1, 2, 0, 2, 3, 3, 2, 6, 3, 6, 7, 7, 6, 5, 7, 5, 4, 4, 5, 1, 4, 1, 0, 1, 5, 6, 1, 6, 2, 4, 0, 3, 4, 3, 7 ); int boundID = gl_VertexID / NUM_VERTICES_PER_CUBE; int vertexID = gl_VertexID - boundID * NUM_VERTICES_PER_CUBE; int triangleIndex = UNIT_BOX_TRIANGLE_INDICES[vertexID]; vec3 cubeVec = UNIT_BOX_VERTICES[triangleIndex]; ItemBound bound = getItemBound(boundID); vec3 boundPos = bound.id_boundPos.yzw; vec3 boundDim = bound.boundDim_s.xyz; vec4 pos = vec4(boundPos + boundDim * cubeVec.xyz, 1.0); // standard transform TransformCamera cam = getTransformCamera(); TransformObject obj = getTransformObject(); <$transformModelToMonoClipPos(cam, obj, pos, gl_Position)$> // Offset the vertex to take into account the outline width pos.xyz += UNIT_BOX_NORMALS[triangleIndex]; vec4 offsetPosition; <$transformModelToMonoClipPos(cam, obj, pos, offsetPosition)$> gl_Position.xy += normalize(offsetPosition.xy-gl_Position.xy) * _parameters.outlineWidth * gl_Position.w; <$transformStereoClipsSpace(cam, gl_Position)$> }