Merged in SL-16993 (pull request #910)

SL-16993

Approved-by: Euclid Linden
meow-7.2.2
Michael Pohoreski 2022-03-25 15:54:49 +00:00
commit c6da3dfd2f
5 changed files with 116 additions and 0 deletions

View File

@ -0,0 +1,42 @@
/**
* @file previewPhysicsF.glsl
*
* $LicenseInfo:firstyear=2022&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2022, 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 sampler2D diffuseMap;
uniform vec4 color;
VARYING vec2 vary_texcoord0;
//====================================================================================================
void main()
{
frag_color = texture2D(diffuseMap,vary_texcoord0.xy) * color;
}

View File

@ -0,0 +1,42 @@
/**
* @file previewPhysicsV.glsl
*
* $LicenseInfo:firstyear=2022&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2022, 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 texture_matrix0;
uniform mat4 modelview_matrix;
uniform mat4 modelview_projection_matrix;
ATTRIBUTE vec3 position;
ATTRIBUTE vec2 texcoord0;
VARYING vec2 vary_texcoord0;
//====================================================================================================
void main()
{
//transform vertex
gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy;
}

View File

@ -3285,6 +3285,14 @@ BOOL LLModelPreview::render()
if (!physics.mMesh.empty())
{ //render hull instead of mesh
// SL-16993 physics.mMesh[i].mNormals were being used to light the exploded
// analyzed physics shape but the drawArrays() interface changed
// causing normal data <0,0,0> to be passed to the shader.
// The Phyics Preview shader uses plain vertex coloring so the physics hull is full lit.
// We could also use interface/ui shaders.
gObjectPreviewProgram.unbind();
gPhysicsPreviewProgram.bind();
for (U32 i = 0; i < physics.mMesh.size(); ++i)
{
if (explode > 0.f)
@ -3312,6 +3320,9 @@ BOOL LLModelPreview::render()
gGL.popMatrix();
}
}
gPhysicsPreviewProgram.unbind();
gObjectPreviewProgram.bind();
}
}
}

View File

@ -102,6 +102,7 @@ LLGLSLShader gSkinnedObjectSimpleProgram;
LLGLSLShader gObjectSimpleImpostorProgram;
LLGLSLShader gSkinnedObjectSimpleImpostorProgram;
LLGLSLShader gObjectPreviewProgram;
LLGLSLShader gPhysicsPreviewProgram;
LLGLSLShader gObjectSimpleWaterProgram;
LLGLSLShader gSkinnedObjectSimpleWaterProgram;
LLGLSLShader gObjectSimpleAlphaMaskProgram;
@ -758,6 +759,7 @@ void LLViewerShaderMgr::unloadShaders()
gObjectSimpleImpostorProgram.unload();
gSkinnedObjectSimpleImpostorProgram.unload();
gObjectPreviewProgram.unload();
gPhysicsPreviewProgram.unload();
gImpostorProgram.unload();
gObjectSimpleAlphaMaskProgram.unload();
gSkinnedObjectSimpleAlphaMaskProgram.unload();
@ -3021,6 +3023,24 @@ BOOL LLViewerShaderMgr::loadShadersObject()
gObjectPreviewProgram.mFeatures.hasLighting = true;
}
if (success)
{
gPhysicsPreviewProgram.mName = "Preview Physics Shader";
gPhysicsPreviewProgram.mFeatures.calculatesLighting = false;
gPhysicsPreviewProgram.mFeatures.calculatesAtmospherics = false;
gPhysicsPreviewProgram.mFeatures.hasGamma = false;
gPhysicsPreviewProgram.mFeatures.hasAtmospherics = false;
gPhysicsPreviewProgram.mFeatures.hasLighting = false;
gPhysicsPreviewProgram.mFeatures.mIndexedTextureChannels = 0;
gPhysicsPreviewProgram.mFeatures.disableTextureIndex = true;
gPhysicsPreviewProgram.mShaderFiles.clear();
gPhysicsPreviewProgram.mShaderFiles.push_back(make_pair("objects/previewPhysicsV.glsl", GL_VERTEX_SHADER_ARB));
gPhysicsPreviewProgram.mShaderFiles.push_back(make_pair("objects/previewPhysicsF.glsl", GL_FRAGMENT_SHADER_ARB));
gPhysicsPreviewProgram.mShaderLevel = mShaderLevel[SHADER_OBJECT];
success = gPhysicsPreviewProgram.createShader(NULL, NULL);
gPhysicsPreviewProgram.mFeatures.hasLighting = false;
}
if (success)
{
gObjectSimpleProgram.mName = "Simple Shader";

View File

@ -181,6 +181,7 @@ extern LLGLSLShader gOneTextureNoColorProgram;
extern LLGLSLShader gObjectSimpleProgram;
extern LLGLSLShader gObjectSimpleImpostorProgram;
extern LLGLSLShader gObjectPreviewProgram;
extern LLGLSLShader gPhysicsPreviewProgram;
extern LLGLSLShader gObjectSimpleAlphaMaskProgram;
extern LLGLSLShader gObjectSimpleWaterProgram;
extern LLGLSLShader gObjectSimpleWaterAlphaMaskProgram;