MAINT-74 Fix "show cross sections" crashing and not working in general.

meow-7.2.2
Dave Parks 2012-04-10 17:13:28 -05:00
parent d8b80cdbb6
commit f96a6aad6b
5 changed files with 121 additions and 4 deletions

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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();
@ -2655,6 +2657,16 @@ BOOL LLViewerShaderMgr::loadShadersInterface()
success = gDebugProgram.createShader(NULL, NULL);
}
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";

View File

@ -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]