From 208d3c8413579611e1b6f01a39d046ab82d451cb Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 11 Dec 2014 13:59:21 -0800 Subject: [PATCH] remove old unused shaders --- interface/resources/shaders/passthrough.vert | 21 --- interface/resources/shaders/point_size.vert | 174 ------------------- interface/resources/shaders/voxel.geom | 87 ---------- 3 files changed, 282 deletions(-) delete mode 100644 interface/resources/shaders/passthrough.vert delete mode 100644 interface/resources/shaders/point_size.vert delete mode 100644 interface/resources/shaders/voxel.geom diff --git a/interface/resources/shaders/passthrough.vert b/interface/resources/shaders/passthrough.vert deleted file mode 100644 index bb0a18eefa..0000000000 --- a/interface/resources/shaders/passthrough.vert +++ /dev/null @@ -1,21 +0,0 @@ -#version 120 - -// -// passthrough.vert -// vertex shader -// -// Copyright 2013 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 -// - -attribute float voxelSizeIn; -varying float voxelSize; - -void main(void) { - gl_FrontColor = gl_Color; - gl_Position = gl_Vertex; // don't call ftransform(), because we do projection in geometry shader - voxelSize = voxelSizeIn; -} \ No newline at end of file diff --git a/interface/resources/shaders/point_size.vert b/interface/resources/shaders/point_size.vert deleted file mode 100644 index 88c56bf0c4..0000000000 --- a/interface/resources/shaders/point_size.vert +++ /dev/null @@ -1,174 +0,0 @@ -#version 120 - -// -// point_size.vert -// vertex shader -// -// Copyright 2013 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 -// - -attribute float voxelSizeIn; -varying float voxelSize; - -uniform float viewportWidth; -uniform float viewportHeight; -uniform vec3 cameraPosition; - -// Bit codes for faces -const int NONE = 0; -const int RIGHT = 1; -const int LEFT = 2; -const int BOTTOM = 4; -const int BOTTOM_RIGHT = BOTTOM + RIGHT; -const int BOTTOM_LEFT = BOTTOM + LEFT; -const int TOP = 8; -const int TOP_RIGHT = TOP + RIGHT; -const int TOP_LEFT = TOP + LEFT; -const int NEAR = 16; -const int NEAR_RIGHT = NEAR + RIGHT; -const int NEAR_LEFT = NEAR + LEFT; -const int NEAR_BOTTOM = NEAR + BOTTOM; -const int NEAR_BOTTOM_RIGHT = NEAR + BOTTOM + RIGHT; -const int NEAR_BOTTOM_LEFT = NEAR + BOTTOM + LEFT; -const int NEAR_TOP = NEAR + TOP; -const int NEAR_TOP_RIGHT = NEAR + TOP + RIGHT; -const int NEAR_TOP_LEFT = NEAR + TOP + LEFT; -const int FAR = 32; -const int FAR_RIGHT = FAR + RIGHT; -const int FAR_LEFT = FAR + LEFT; -const int FAR_BOTTOM = FAR + BOTTOM; -const int FAR_BOTTOM_RIGHT = FAR + BOTTOM + RIGHT; -const int FAR_BOTTOM_LEFT = FAR + BOTTOM + LEFT; -const int FAR_TOP = FAR + TOP; -const int FAR_TOP_RIGHT = FAR + TOP + RIGHT; -const int FAR_TOP_LEFT = FAR + TOP + LEFT; - -// If we know the position of the camera relative to the voxel, we can a priori know the vertices that make the visible hull -// polygon. This also tells us which two vertices are known to make the longest possible distance between any pair of these -// vertices for the projected polygon. This is a visibleFaces table based on this knowledge. - -void main(void) { - // Note: the gl_Vertex in this case are in "world coordinates" meaning they've already been scaled to TREE_SCALE - // this is also true for voxelSizeIn. - vec4 bottomNearRight = gl_Vertex; - vec4 topFarLeft = (gl_Vertex + vec4(voxelSizeIn, voxelSizeIn, voxelSizeIn, 0.0)); - - int visibleFaces = NONE; - - // In order to use our visibleFaces "table" (implemented as if statements) below, we need to encode the 6-bit code to - // orient camera relative to the 6 defining faces of the voxel. Based on camera position relative to the bottomNearRight - // corner and the topFarLeft corner, we can calculate which hull and therefore which two vertices are furthest apart - // linearly once projected - if (cameraPosition.x < bottomNearRight.x) { - visibleFaces += RIGHT; - } - if (cameraPosition.x > topFarLeft.x) { - visibleFaces += LEFT; - } - if (cameraPosition.y < bottomNearRight.y) { - visibleFaces += BOTTOM; - } - if (cameraPosition.y > topFarLeft.y) { - visibleFaces += TOP; - } - if (cameraPosition.z < bottomNearRight.z) { - visibleFaces += NEAR; - } - if (cameraPosition.z > topFarLeft.z) { - visibleFaces += FAR; - } - - vec4 cornerAdjustOne; - vec4 cornerAdjustTwo; - - if (visibleFaces == RIGHT) { - cornerAdjustOne = vec4(0,0,0,0) * voxelSizeIn; - cornerAdjustTwo = vec4(0,1,1,0) * voxelSizeIn; - } else if (visibleFaces == LEFT) { - cornerAdjustOne = vec4(1,0,0,0) * voxelSizeIn; - cornerAdjustTwo = vec4(1,1,1,0) * voxelSizeIn; - } else if (visibleFaces == BOTTOM) { - cornerAdjustOne = vec4(0,0,0,0) * voxelSizeIn; - cornerAdjustTwo = vec4(1,0,1,0) * voxelSizeIn; - } else if (visibleFaces == TOP) { - cornerAdjustOne = vec4(0,1,0,0) * voxelSizeIn; - cornerAdjustTwo = vec4(1,1,1,0) * voxelSizeIn; - } else if (visibleFaces == NEAR) { - cornerAdjustOne = vec4(0,0,0,0) * voxelSizeIn; - cornerAdjustTwo = vec4(1,1,0,0) * voxelSizeIn; - } else if (visibleFaces == FAR) { - cornerAdjustOne = vec4(0,0,1,0) * voxelSizeIn; - cornerAdjustTwo = vec4(1,1,1,0) * voxelSizeIn; - } else if (visibleFaces == NEAR_BOTTOM_LEFT || - visibleFaces == FAR_TOP || - visibleFaces == FAR_TOP_RIGHT) { - cornerAdjustOne = vec4(0,1,0,0) * voxelSizeIn; - cornerAdjustTwo = vec4(1,0,1,0) * voxelSizeIn; - } else if (visibleFaces == FAR_TOP_LEFT || - visibleFaces == NEAR_RIGHT || - visibleFaces == NEAR_BOTTOM || - visibleFaces == NEAR_BOTTOM_RIGHT) { - cornerAdjustOne = vec4(0,0,1,0) * voxelSizeIn; - cornerAdjustTwo = vec4(1,1,0,0) * voxelSizeIn; - } else if (visibleFaces == NEAR_TOP_RIGHT || - visibleFaces == FAR_LEFT || - visibleFaces == FAR_BOTTOM_LEFT || - visibleFaces == BOTTOM_RIGHT || - visibleFaces == TOP_LEFT) { - cornerAdjustOne = vec4(1,0,0,0) * voxelSizeIn; - cornerAdjustTwo = vec4(0,1,1,0) * voxelSizeIn; - - // Everything else... - //} else if (visibleFaces == BOTTOM_LEFT || - // visibleFaces == TOP_RIGHT || - // visibleFaces == NEAR_LEFT || - // visibleFaces == FAR_RIGHT || - // visibleFaces == NEAR_TOP || - // visibleFaces == NEAR_TOP_LEFT || - // visibleFaces == FAR_BOTTOM || - // visibleFaces == FAR_BOTTOM_RIGHT) { - } else { - cornerAdjustOne = vec4(0,0,0,0) * voxelSizeIn; - cornerAdjustTwo = vec4(1,1,1,0) * voxelSizeIn; - } - - // Determine our corners - vec4 cornerOne = gl_Vertex + cornerAdjustOne; - vec4 cornerTwo = gl_Vertex + cornerAdjustTwo; - - // Find their model view projections - vec4 cornerOneMVP = gl_ModelViewProjectionMatrix * cornerOne; - vec4 cornerTwoMVP = gl_ModelViewProjectionMatrix * cornerTwo; - - // Map to x, y screen coordinates - vec2 cornerOneScreen = vec2(cornerOneMVP.x / cornerOneMVP.w, cornerOneMVP.y / cornerOneMVP.w); - if (cornerOneMVP.w < 0) { - cornerOneScreen.x = -cornerOneScreen.x; - cornerOneScreen.y = -cornerOneScreen.y; - } - - vec2 cornerTwoScreen = vec2(cornerTwoMVP.x / cornerTwoMVP.w, cornerTwoMVP.y / cornerTwoMVP.w); - if (cornerTwoMVP.w < 0) { - cornerTwoScreen.x = -cornerTwoScreen.x; - cornerTwoScreen.y = -cornerTwoScreen.y; - } - - // Find the distance between them in pixels - float voxelScreenWidth = abs(cornerOneScreen.x - cornerTwoScreen.x) * viewportWidth / 2.0; - float voxelScreenHeight = abs(cornerOneScreen.y - cornerTwoScreen.y) * viewportHeight / 2.0; - float voxelScreenLength = sqrt(voxelScreenHeight * voxelScreenHeight + voxelScreenWidth * voxelScreenWidth); - - // Find the center of the voxel - vec4 centerVertex = gl_Vertex; - float halfSizeIn = voxelSizeIn / 2; - centerVertex += vec4(halfSizeIn, halfSizeIn, halfSizeIn, 0.0); - vec4 center = gl_ModelViewProjectionMatrix * centerVertex; - - // Finally place the point at the center of the voxel, with a size equal to the maximum screen length - gl_Position = center; - gl_PointSize = voxelScreenLength; - gl_FrontColor = gl_Color; -} \ No newline at end of file diff --git a/interface/resources/shaders/voxel.geom b/interface/resources/shaders/voxel.geom deleted file mode 100644 index 4c850ed608..0000000000 --- a/interface/resources/shaders/voxel.geom +++ /dev/null @@ -1,87 +0,0 @@ -#version 120 -#extension GL_ARB_geometry_shader4 : enable - -// -// voxel.geom -// geometry shader -// -// Copyright 2013 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 -// - -// -// VOXEL GEOMETRY SHADER -// -// Input: gl_VerticesIn/gl_PositionIn -// GL_POINTS -// Assumes vertex shader has not transformed coordinates -// Each gl_PositionIn is the corner of voxel -// varying voxelSize - which is the voxel size -// -// Note: In vertex shader doesn't do any transform. Therefore passing the 3D world coordinates xyz to us -// -// Output: GL_TRIANGLE_STRIP -// -// Issues: -// how do we need to handle lighting of these colors?? -// how do we handle normals? -// check for size=0 and don't output the primitive -// - -varying in float voxelSize[1]; - -const int VERTICES_PER_FACE = 4; -const int COORD_PER_VERTEX = 3; -const int COORD_PER_FACE = COORD_PER_VERTEX * VERTICES_PER_FACE; - -void faceOfVoxel(vec4 corner, float scale, float[COORD_PER_FACE] facePoints, vec4 color, vec4 normal) { - for (int v = 0; v < VERTICES_PER_FACE; v++ ) { - vec4 vertex = corner; - for (int c = 0; c < COORD_PER_VERTEX; c++ ) { - int cIndex = c + (v * COORD_PER_VERTEX); - vertex[c] += (facePoints[cIndex] * scale); - } - - gl_FrontColor = color * (gl_LightModel.ambient + gl_LightSource[0].ambient + - gl_LightSource[0].diffuse * max(0.0, dot(normal, gl_LightSource[0].position))); - - gl_Position = gl_ModelViewProjectionMatrix * vertex; - EmitVertex(); - } - EndPrimitive(); -} - - -void main() { - //increment variable - int i; - vec4 corner; - float scale; - - float bottomFace[COORD_PER_FACE] = float[COORD_PER_FACE]( 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1 ); - float topFace[COORD_PER_FACE] = float[COORD_PER_FACE]( 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1 ); - float rightFace[COORD_PER_FACE] = float[COORD_PER_FACE]( 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1 ); - float leftFace[COORD_PER_FACE] = float[COORD_PER_FACE]( 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1 ); - float frontFace[COORD_PER_FACE] = float[COORD_PER_FACE]( 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0 ); - float backFace[COORD_PER_FACE] = float[COORD_PER_FACE]( 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1 ); - - vec4 bottomNormal = vec4(0.0, -1, 0.0, 0.0); - vec4 topNormal = vec4(0.0, 1, 0.0, 0.0); - vec4 rightNormal = vec4( -1, 0.0, 0.0, 0.0); - vec4 leftNormal = vec4( 1, 0.0, 0.0, 0.0); - vec4 frontNormal = vec4(0.0, 0.0, -1, 0.0); - vec4 backNormal = vec4(0.0, 0.0, 1, 0.0); - - for(i = 0; i < gl_VerticesIn; i++) { - corner = gl_PositionIn[i]; - scale = voxelSize[i]; - faceOfVoxel(corner, scale, bottomFace, gl_FrontColorIn[i], bottomNormal); - faceOfVoxel(corner, scale, topFace, gl_FrontColorIn[i], topNormal ); - faceOfVoxel(corner, scale, rightFace, gl_FrontColorIn[i], rightNormal ); - faceOfVoxel(corner, scale, leftFace, gl_FrontColorIn[i], leftNormal ); - faceOfVoxel(corner, scale, frontFace, gl_FrontColorIn[i], frontNormal ); - faceOfVoxel(corner, scale, backFace, gl_FrontColorIn[i], backNormal ); - } -} \ No newline at end of file