summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2012-04-10 17:13:28 -0500
committerDave Parks <davep@lindenlab.com>2012-04-10 17:13:28 -0500
commitf96a6aad6b266c8cd4b1a117510fd4cacb6413c8 (patch)
tree6e858c0ac1d385c0b00accc9e77f4bb3d26b9225
parentd8b80cdbb635360d36fb374b76edc5d7ab32fad8 (diff)
MAINT-74 Fix "show cross sections" crashing and not working in general.
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/clipF.glsl46
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/clipV.glsl38
-rw-r--r--indra/newview/llmaniptranslate.cpp28
-rw-r--r--indra/newview/llviewershadermgr.cpp12
-rw-r--r--indra/newview/llviewershadermgr.h1
5 files changed, 121 insertions, 4 deletions
diff --git a/indra/newview/app_settings/shaders/class1/interface/clipF.glsl b/indra/newview/app_settings/shaders/class1/interface/clipF.glsl
new file mode 100644
index 0000000000..ac2bc8703b
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/interface/clipF.glsl
@@ -0,0 +1,46 @@
+/**
+ * @file debugF.glsl
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2011, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+#ifdef DEFINE_GL_FRAGCOLOR
+out vec4 frag_color;
+#else
+#define frag_color gl_FragColor
+#endif
+
+uniform vec4 color;
+uniform vec4 clip_plane;
+
+VARYING vec3 vary_position;
+
+
+void main()
+{
+ if (dot(vary_position,clip_plane.xyz)+clip_plane.w < 0.0)
+ {
+ discard;
+ }
+
+ frag_color = color;
+}
diff --git a/indra/newview/app_settings/shaders/class1/interface/clipV.glsl b/indra/newview/app_settings/shaders/class1/interface/clipV.glsl
new file mode 100644
index 0000000000..e376b25a71
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/interface/clipV.glsl
@@ -0,0 +1,38 @@
+/**
+ * @file debugV.glsl
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2011, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+uniform mat4 modelview_projection_matrix;
+uniform mat4 modelview_matrix;
+
+ATTRIBUTE vec3 position;
+
+VARYING vec3 vary_position;
+
+void main()
+{
+ vary_position = (modelview_matrix*vec4(position.xyz,1.0)).xyz;
+ gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
+}
+
diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp
index 3a88fbd96d..4dd3fa1722 100644
--- a/indra/newview/llmaniptranslate.cpp
+++ b/indra/newview/llmaniptranslate.cpp
@@ -60,6 +60,7 @@
#include "llworld.h"
#include "llui.h"
#include "pipeline.h"
+#include "llviewershadermgr.h"
const S32 NUM_AXES = 3;
const S32 MOUSE_DRAG_SLOP = 2; // pixels
@@ -1645,17 +1646,28 @@ void LLManipTranslate::highlightIntersection(LLVector3 normal,
LLQuaternion grid_rotation,
LLColor4 inner_color)
{
- if (!gSavedSettings.getBOOL("GridCrossSections"))
+ if (!gSavedSettings.getBOOL("GridCrossSections") || !LLGLSLShader::sNoFixedFunction)
{
return;
}
+
+ LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr;
+
+
U32 types[] = { LLRenderPass::PASS_SIMPLE, LLRenderPass::PASS_ALPHA, LLRenderPass::PASS_FULLBRIGHT, LLRenderPass::PASS_SHINY };
U32 num_types = LL_ARRAY_SIZE(types);
GLuint stencil_mask = 0xFFFFFFFF;
//stencil in volumes
+
gGL.flush();
+
+ if (shader)
+ {
+ gClipProgram.bind();
+ }
+
{
glStencilMask(stencil_mask);
glClearStencil(1);
@@ -1666,6 +1678,7 @@ void LLManipTranslate::highlightIntersection(LLVector3 normal,
glStencilFunc(GL_ALWAYS, 0, stencil_mask);
gGL.setColorMask(false, false);
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+
gGL.diffuseColor4f(1,1,1,1);
//setup clip plane
@@ -1675,10 +1688,12 @@ void LLManipTranslate::highlightIntersection(LLVector3 normal,
normal = -normal;
}
F32 d = -(selection_center * normal);
- F64 plane[] = { normal.mV[0], normal.mV[1], normal.mV[2], d };
- LLGLEnable clip(GL_CLIP_PLANE0);
- glClipPlane(GL_CLIP_PLANE0, plane);
+ glh::vec4f plane(normal.mV[0], normal.mV[1], normal.mV[2], d );
+ gGL.getModelviewMatrix().inverse().mult_vec_matrix(plane);
+
+ gClipProgram.uniform4fv("clip_plane", 1, plane.v);
+
BOOL particles = gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES);
BOOL clouds = gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS);
@@ -1729,6 +1744,11 @@ void LLManipTranslate::highlightIntersection(LLVector3 normal,
F32 sz = mGridSizeMeters;
F32 tiles = sz;
+ if (shader)
+ {
+ shader->bind();
+ }
+
//draw volume/plane intersections
{
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp
index 10c61c01d5..ec3a7f901e 100644
--- a/indra/newview/llviewershadermgr.cpp
+++ b/indra/newview/llviewershadermgr.cpp
@@ -72,6 +72,7 @@ LLGLSLShader gGlowCombineFXAAProgram;
LLGLSLShader gTwoTextureAddProgram;
LLGLSLShader gOneTextureNoColorProgram;
LLGLSLShader gDebugProgram;
+LLGLSLShader gClipProgram;
LLGLSLShader gAlphaMaskProgram;
//object shaders
@@ -601,6 +602,7 @@ void LLViewerShaderMgr::unloadShaders()
{
gOcclusionProgram.unload();
gDebugProgram.unload();
+ gClipProgram.unload();
gAlphaMaskProgram.unload();
gUIProgram.unload();
gCustomAlphaProgram.unload();
@@ -2657,6 +2659,16 @@ BOOL LLViewerShaderMgr::loadShadersInterface()
if (success)
{
+ gClipProgram.mName = "Clip Shader";
+ gClipProgram.mShaderFiles.clear();
+ gClipProgram.mShaderFiles.push_back(make_pair("interface/clipV.glsl", GL_VERTEX_SHADER_ARB));
+ gClipProgram.mShaderFiles.push_back(make_pair("interface/clipF.glsl", GL_FRAGMENT_SHADER_ARB));
+ gClipProgram.mShaderLevel = mVertexShaderLevel[SHADER_INTERFACE];
+ success = gClipProgram.createShader(NULL, NULL);
+ }
+
+ if (success)
+ {
gAlphaMaskProgram.mName = "Alpha Mask Shader";
gAlphaMaskProgram.mShaderFiles.clear();
gAlphaMaskProgram.mShaderFiles.push_back(make_pair("interface/alphamaskV.glsl", GL_VERTEX_SHADER_ARB));
diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h
index 95eb551bf1..d10aba85c7 100644
--- a/indra/newview/llviewershadermgr.h
+++ b/indra/newview/llviewershadermgr.h
@@ -216,6 +216,7 @@ extern LLGLSLShader gGlowCombineProgram;
extern LLGLSLShader gSplatTextureRectProgram;
extern LLGLSLShader gGlowCombineFXAAProgram;
extern LLGLSLShader gDebugProgram;
+extern LLGLSLShader gClipProgram;
extern LLGLSLShader gAlphaMaskProgram;
//output tex0[tc0] + tex1[tc1]