Massive deferred update...

Plus renamed setupViewport to setup[2|3]DViewport.
Migrated mWindowRect to mWindowRectRaw, mVirtualWindowRect to mWindowRectScaled.
Slowly updating getwindow/getworldview calls to new v2 variants as I run across them.
Cleaned up ascent-related code in llmanip.cpp.
Impostor update tweaks.
Edgepatch water occlusion changes. (no patch flickering on edges of screen while moving camera)
This commit is contained in:
Shyotl
2011-08-11 03:16:17 -05:00
parent ca328aec72
commit c9860f7b66
38 changed files with 1053 additions and 560 deletions

View File

@@ -357,7 +357,8 @@ void LLGLSLShader::mapUniform(GLint index, const vector<string> * uniforms)
GLint LLGLSLShader::mapUniformTextureChannel(GLint location, GLenum type)
{
if (type >= GL_SAMPLER_1D_ARB && type <= GL_SAMPLER_2D_RECT_SHADOW_ARB)
if (type >= GL_SAMPLER_1D_ARB && type <= GL_SAMPLER_2D_RECT_SHADOW_ARB /*||
type == GL_SAMPLER_2D_MULTISAMPLE*/)
{ //this here is a texture
glUniform1iARB(location, mActiveTextureChannels);
LL_DEBUGS("ShaderLoading") << "Assigned to texture channel " << mActiveTextureChannels << LL_ENDL;

View File

@@ -1,8 +1,8 @@
/**
* @file avatarAlphaV.glsl
*
* Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
* $License$
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* $/LicenseInfo$
*/
@@ -35,19 +35,24 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
//get distance
float d = length(lv);
//normalize light vector
lv *= 1.0/d;
float da = 0.0;
if (d > 0.0 && la > 0.0 && fa > 0.0)
{
//normalize light vector
lv *= 1.0/d;
//distance attenuation
float dist2 = d*d/(la*la);
float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
//distance attenuation
float dist2 = d*d/(la*la);
da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
// spotlight coefficient.
float spot = max(dot(-ln, lv), is_pointlight);
da *= spot*spot; // GL_SPOT_EXPONENT=2
// spotlight coefficient.
float spot = max(dot(-ln, lv), is_pointlight);
da *= spot*spot; // GL_SPOT_EXPONENT=2
//angular attenuation
da *= calcDirectionalLight(n, lv);
//angular attenuation
da *= calcDirectionalLight(n, lv);
}
return da;
}

View File

@@ -1,18 +1,21 @@
/**
* @file avatarShadowF.glsl
*
* Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
* $License$
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* $/LicenseInfo$
*/
uniform sampler2D diffuseMap;
varying vec4 post_pos;
void main()
{
//gl_FragColor = vec4(1,1,1,gl_Color.a * texture2D(diffuseMap, gl_TexCoord[0].xy).a);
gl_FragColor = vec4(1,1,1,1);
gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0);
}

View File

@@ -1,8 +1,8 @@
/**
* @file avatarShadowV.glsl
*
* Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
* $License$
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* $/LicenseInfo$
*/
@@ -11,6 +11,8 @@ mat4 getSkinnedTransform();
attribute vec4 weight;
varying vec4 post_pos;
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
@@ -30,8 +32,9 @@ void main()
norm = normalize(norm);
pos = gl_ProjectionMatrix * pos;
pos.z = max(pos.z, -pos.w+0.01);
gl_Position = pos;
post_pos = pos;
gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w);
gl_FrontColor = gl_Color;
}

View File

@@ -1,8 +1,8 @@
/**
* @file blurLightF.glsl
*
* Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
* $License$
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* $/LicenseInfo$
*/
@@ -26,7 +26,7 @@ uniform vec2 screen_res;
vec4 getPosition(vec2 pos_screen)
{
float depth = texture2DRect(depthMap, pos_screen.xy).a;
float depth = texture2DRect(depthMap, pos_screen.xy).r;
vec2 sc = pos_screen.xy*2.0;
sc /= screen_res;
sc -= vec2(1.0,1.0);
@@ -39,7 +39,7 @@ vec4 getPosition(vec2 pos_screen)
void main()
{
vec2 tc = vary_fragcoord.xy;
vec2 tc = vary_fragcoord.xy;
vec3 norm = texture2DRect(normalMap, tc).xyz;
norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
vec3 pos = getPosition(tc).xyz;
@@ -55,8 +55,7 @@ void main()
float pointplanedist_tolerance_pow2 = pos.z*pos.z*0.00005;
// perturb sampling origin slightly in screen-space to hide edge-ghosting artifacts where smoothing radius is quite large
//This causes some pretty nasty artifacting, so disabling for now.
//tc += ( (mod(tc.x+tc.y,2) - 0.5) * kern[1].z * dlt * 0.5 );
tc += ( (mod(tc.x+tc.y,2) - 0.5) * kern[1].z * dlt * 0.5 );
for (int i = 1; i < 4; i++)
{

View File

@@ -0,0 +1,79 @@
/**
* @file WLCloudsF.glsl
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* $/LicenseInfo$
*/
/////////////////////////////////////////////////////////////////////////
// The fragment shader for the sky
/////////////////////////////////////////////////////////////////////////
varying vec4 vary_CloudColorSun;
varying vec4 vary_CloudColorAmbient;
varying float vary_CloudDensity;
uniform sampler2D cloud_noise_texture;
uniform vec4 cloud_pos_density1;
uniform vec4 cloud_pos_density2;
uniform vec4 gamma;
/// Soft clips the light with a gamma correction
vec3 scaleSoftClip(vec3 light) {
//soft clip effect:
light = 1. - clamp(light, vec3(0.), vec3(1.));
light = 1. - pow(light, gamma.xxx);
return light;
}
void main()
{
// Set variables
vec2 uv1 = gl_TexCoord[0].xy;
vec2 uv2 = gl_TexCoord[1].xy;
vec4 cloudColorSun = vary_CloudColorSun;
vec4 cloudColorAmbient = vary_CloudColorAmbient;
float cloudDensity = vary_CloudDensity;
vec2 uv3 = gl_TexCoord[2].xy;
vec2 uv4 = gl_TexCoord[3].xy;
// Offset texture coords
uv1 += cloud_pos_density1.xy; //large texture, visible density
uv2 += cloud_pos_density1.xy; //large texture, self shadow
uv3 += cloud_pos_density2.xy; //small texture, visible density
uv4 += cloud_pos_density2.xy; //small texture, self shadow
// Compute alpha1, the main cloud opacity
float alpha1 = (texture2D(cloud_noise_texture, uv1).x - 0.5) + (texture2D(cloud_noise_texture, uv3).x - 0.5) * cloud_pos_density2.z;
alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10. * cloud_pos_density1.z, 1.);
// And smooth
alpha1 = 1. - alpha1 * alpha1;
alpha1 = 1. - alpha1 * alpha1;
// Compute alpha2, for self shadowing effect
// (1 - alpha2) will later be used as percentage of incoming sunlight
float alpha2 = (texture2D(cloud_noise_texture, uv2).x - 0.5);
alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.);
// And smooth
alpha2 = 1. - alpha2;
alpha2 = 1. - alpha2 * alpha2;
// Combine
vec4 color;
color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient);
color *= 2.;
/// Gamma correct for WL (soft clip effect).
gl_FragData[0] = vec4(scaleSoftClip(color.rgb), alpha1);
gl_FragData[1] = vec4(0.0,0.0,0.0,0.0);
gl_FragData[2] = vec4(0,0,1,0);
}

View File

@@ -0,0 +1,165 @@
/**
* @file WLCloudsV.glsl
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* $/LicenseInfo$
*/
//////////////////////////////////////////////////////////////////////////
// The vertex shader for creating the atmospheric sky
///////////////////////////////////////////////////////////////////////////////
// Output parameters
varying vec4 vary_CloudColorSun;
varying vec4 vary_CloudColorAmbient;
varying float vary_CloudDensity;
// Inputs
uniform vec3 camPosLocal;
uniform vec4 lightnorm;
uniform vec4 sunlight_color;
uniform vec4 ambient;
uniform vec4 blue_horizon;
uniform vec4 blue_density;
uniform vec4 haze_horizon;
uniform vec4 haze_density;
uniform vec4 cloud_shadow;
uniform vec4 density_multiplier;
uniform vec4 max_y;
uniform vec4 glow;
uniform vec4 cloud_color;
uniform vec4 cloud_scale;
void main()
{
// World / view / projection
gl_Position = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;
// Get relative position
vec3 P = gl_Vertex.xyz - camPosLocal.xyz + vec3(0,50,0);
// Set altitude
if (P.y > 0.)
{
P *= (max_y.x / P.y);
}
else
{
P *= (-32000. / P.y);
}
// Can normalize then
vec3 Pn = normalize(P);
float Plen = length(P);
// Initialize temp variables
vec4 temp1 = vec4(0.);
vec4 temp2 = vec4(0.);
vec4 blue_weight;
vec4 haze_weight;
vec4 sunlight = sunlight_color;
vec4 light_atten;
// Sunlight attenuation effect (hue and brightness) due to atmosphere
// this is used later for sunlight modulation at various altitudes
light_atten = (blue_density * 1.0 + haze_density.x * 0.25) * (density_multiplier.x * max_y.x);
// Calculate relative weights
temp1 = blue_density + haze_density.x;
blue_weight = blue_density / temp1;
haze_weight = haze_density.x / temp1;
// Compute sunlight from P & lightnorm (for long rays like sky)
temp2.y = max(0., max(0., Pn.y) * 1.0 + lightnorm.y );
temp2.y = 1. / temp2.y;
sunlight *= exp( - light_atten * temp2.y);
// Distance
temp2.z = Plen * density_multiplier.x;
// Transparency (-> temp1)
// ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati
// compiler gets confused.
temp1 = exp(-temp1 * temp2.z);
// Compute haze glow
temp2.x = dot(Pn, lightnorm.xyz);
temp2.x = 1. - temp2.x;
// temp2.x is 0 at the sun and increases away from sun
temp2.x = max(temp2.x, .001);
// Set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot)
temp2.x *= glow.x;
// Higher glow.x gives dimmer glow (because next step is 1 / "angle")
temp2.x = pow(temp2.x, glow.z);
// glow.z should be negative, so we're doing a sort of (1 / "angle") function
// Add "minimum anti-solar illumination"
temp2.x += .25;
// Increase ambient when there are more clouds
vec4 tmpAmbient = ambient;
tmpAmbient += (1. - tmpAmbient) * cloud_shadow.x * 0.5;
// Dim sunlight by cloud shadow percentage
sunlight *= (1. - cloud_shadow.x);
// Haze color below cloud
vec4 additiveColorBelowCloud = ( blue_horizon * blue_weight * (sunlight + tmpAmbient)
+ (haze_horizon.r * haze_weight) * (sunlight * temp2.x + tmpAmbient)
);
// CLOUDS
sunlight = sunlight_color;
temp2.y = max(0., lightnorm.y * 2.);
temp2.y = 1. / temp2.y;
sunlight *= exp( - light_atten * temp2.y);
// Cloud color out
vary_CloudColorSun = (sunlight * temp2.x) * cloud_color;
vary_CloudColorAmbient = tmpAmbient * cloud_color;
// Attenuate cloud color by atmosphere
temp1 = sqrt(temp1); //less atmos opacity (more transparency) below clouds
vary_CloudColorSun *= temp1;
vary_CloudColorAmbient *= temp1;
vec4 oHazeColorBelowCloud = additiveColorBelowCloud * (1. - temp1);
// Make a nice cloud density based on the cloud_shadow value that was passed in.
vary_CloudDensity = 2. * (cloud_shadow.x - 0.25);
// Texture coords
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[0].xy -= 0.5;
gl_TexCoord[0].xy /= cloud_scale.x;
gl_TexCoord[0].xy += 0.5;
gl_TexCoord[1] = gl_TexCoord[0];
gl_TexCoord[1].x += lightnorm.x * 0.0125;
gl_TexCoord[1].y += lightnorm.z * 0.0125;
gl_TexCoord[2] = gl_TexCoord[0] * 16.;
gl_TexCoord[3] = gl_TexCoord[1] * 16.;
// Combine these to minimize register use
vary_CloudColorAmbient += oHazeColorBelowCloud;
// needs this to compile on mac
//vary_AtmosAttenuation = vec3(0.0,0.0,0.0);
// END CLOUDS
}

View File

@@ -1,8 +1,8 @@
/**
* @file multiPointLightF.glsl
*
* Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
* $License$
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* $/LicenseInfo$
*/
@@ -36,7 +36,7 @@ uniform mat4 inv_proj;
vec4 getPosition(vec2 pos_screen)
{
float depth = texture2DRect(depthMap, pos_screen.xy).a;
float depth = texture2DRect(depthMap, pos_screen.xy).r;
vec2 sc = pos_screen.xy*2.0;
sc /= screen_res;
sc -= vec2(1.0,1.0);
@@ -123,4 +123,6 @@ void main()
gl_FragColor.rgb = out_col;
gl_FragColor.a = 0.0;
//gl_FragColor = vec4(0.1, 0.025, 0.025/4.0, 0.0);
}

View File

@@ -30,7 +30,7 @@ uniform vec4 viewport;
vec4 getPosition(vec2 pos_screen)
{
float depth = texture2DRect(depthMap, pos_screen.xy).a;
float depth = texture2DRect(depthMap, pos_screen.xy).r;
vec2 sc = (pos_screen.xy-viewport.xy)*2.0;
sc /= viewport.zw;
sc -= vec2(1.0,1.0);

View File

@@ -29,7 +29,7 @@ varying vec2 vary_fragcoord;
float getDepth(vec2 pos_screen)
{
float z = texture2DRect(depthMap, pos_screen.xy).a;
float z = texture2DRect(depthMap, pos_screen.xy).r;
z = z*2.0-1.0;
vec4 ndc = vec4(0.0, 0.0, z, 1.0);
vec4 p = inv_proj*ndc;

View File

@@ -0,0 +1,44 @@
/**
* @file WLSkyF.glsl
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* $/LicenseInfo$
*/
/////////////////////////////////////////////////////////////////////////
// The fragment shader for the sky
/////////////////////////////////////////////////////////////////////////
varying vec4 vary_HazeColor;
uniform sampler2D cloud_noise_texture;
uniform vec4 gamma;
/// Soft clips the light with a gamma correction
vec3 scaleSoftClip(vec3 light) {
//soft clip effect:
light = 1. - clamp(light, vec3(0.), vec3(1.));
light = 1. - pow(light, gamma.xxx);
return light;
}
void main()
{
// Potential Fill-rate optimization. Add cloud calculation
// back in and output alpha of 0 (so that alpha culling kills
// the fragment) if the sky wouldn't show up because the clouds
// are fully opaque.
vec4 color;
color = vary_HazeColor;
color *= 2.;
/// Gamma correct for WL (soft clip effect).
gl_FragData[0] = vec4(scaleSoftClip(color.rgb), 1.0);
gl_FragData[1] = vec4(0.0,0.0,0.0,0.0);
gl_FragData[2] = vec4(0,0,1,0);
}

View File

@@ -0,0 +1,140 @@
/**
* @file WLSkyV.glsl
*
* $LicenseInfo:firstyear=2005&license=viewerlgpl$
* $/LicenseInfo$
*/
// SKY ////////////////////////////////////////////////////////////////////////
// The vertex shader for creating the atmospheric sky
///////////////////////////////////////////////////////////////////////////////
// Output parameters
varying vec4 vary_HazeColor;
// Inputs
uniform vec3 camPosLocal;
uniform vec4 lightnorm;
uniform vec4 sunlight_color;
uniform vec4 ambient;
uniform vec4 blue_horizon;
uniform vec4 blue_density;
uniform vec4 haze_horizon;
uniform vec4 haze_density;
uniform vec4 cloud_shadow;
uniform vec4 density_multiplier;
uniform vec4 max_y;
uniform vec4 glow;
uniform vec4 cloud_color;
uniform vec4 cloud_scale;
void main()
{
// World / view / projection
gl_Position = ftransform();
gl_TexCoord[0] = gl_MultiTexCoord0;
// Get relative position
vec3 P = gl_Vertex.xyz - camPosLocal.xyz + vec3(0,50,0);
//vec3 P = gl_Vertex.xyz + vec3(0,50,0);
// Set altitude
if (P.y > 0.)
{
P *= (max_y.x / P.y);
}
else
{
P *= (-32000. / P.y);
}
// Can normalize then
vec3 Pn = normalize(P);
float Plen = length(P);
// Initialize temp variables
vec4 temp1 = vec4(0.);
vec4 temp2 = vec4(0.);
vec4 blue_weight;
vec4 haze_weight;
vec4 sunlight = sunlight_color;
vec4 light_atten;
// Sunlight attenuation effect (hue and brightness) due to atmosphere
// this is used later for sunlight modulation at various altitudes
light_atten = (blue_density * 1.0 + haze_density.x * 0.25) * (density_multiplier.x * max_y.x);
// Calculate relative weights
temp1 = blue_density + haze_density.x;
blue_weight = blue_density / temp1;
haze_weight = haze_density.x / temp1;
// Compute sunlight from P & lightnorm (for long rays like sky)
temp2.y = max(0., max(0., Pn.y) * 1.0 + lightnorm.y );
temp2.y = 1. / temp2.y;
sunlight *= exp( - light_atten * temp2.y);
// Distance
temp2.z = Plen * density_multiplier.x;
// Transparency (-> temp1)
// ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati
// compiler gets confused.
temp1 = exp(-temp1 * temp2.z);
// Compute haze glow
temp2.x = dot(Pn, lightnorm.xyz);
temp2.x = 1. - temp2.x;
// temp2.x is 0 at the sun and increases away from sun
temp2.x = max(temp2.x, .001);
// Set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot)
temp2.x *= glow.x;
// Higher glow.x gives dimmer glow (because next step is 1 / "angle")
temp2.x = pow(temp2.x, glow.z);
// glow.z should be negative, so we're doing a sort of (1 / "angle") function
// Add "minimum anti-solar illumination"
temp2.x += .25;
// Haze color above cloud
vary_HazeColor = ( blue_horizon * blue_weight * (sunlight + ambient)
+ (haze_horizon.r * haze_weight) * (sunlight * temp2.x + ambient)
);
// Increase ambient when there are more clouds
vec4 tmpAmbient = ambient;
tmpAmbient += (1. - tmpAmbient) * cloud_shadow.x * 0.5;
// Dim sunlight by cloud shadow percentage
sunlight *= (1. - cloud_shadow.x);
// Haze color below cloud
vec4 additiveColorBelowCloud = ( blue_horizon * blue_weight * (sunlight + tmpAmbient)
+ (haze_horizon.r * haze_weight) * (sunlight * temp2.x + tmpAmbient)
);
// Final atmosphere additive
vary_HazeColor *= (1. - temp1);
// Attenuate cloud color by atmosphere
temp1 = sqrt(temp1); //less atmos opacity (more transparency) below clouds
// At horizon, blend high altitude sky color towards the darker color below the clouds
vary_HazeColor += (additiveColorBelowCloud - vary_HazeColor) * (1. - sqrt(temp1));
// won't compile on mac without this being set
//vary_AtmosAttenuation = vec3(0.0,0.0,0.0);
}

View File

@@ -1,8 +1,8 @@
/**
* @file softenLightF.glsl
*
* Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
* $License$
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* $/LicenseInfo$
*/
@@ -11,9 +11,12 @@
uniform sampler2DRect diffuseRect;
uniform sampler2DRect specularRect;
uniform sampler2DRect positionMap;
uniform sampler2DRect normalMap;
uniform sampler2DRect lightMap;
uniform sampler2DRect depthMap;
uniform sampler2D noiseMap;
uniform samplerCube environmentMap;
uniform sampler2D lightFunc;
uniform float blur_size;
@@ -256,7 +259,7 @@ vec3 scaleSoftClip(vec3 light)
void main()
{
vec2 tc = vary_fragcoord.xy;
float depth = texture2DRect(depthMap, tc.xy).a;
float depth = texture2DRect(depthMap, tc.xy).r;
vec3 pos = getPosition_d(tc, depth).xyz;
vec3 norm = texture2DRect(normalMap, tc).xyz;
norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
@@ -267,74 +270,41 @@ void main()
vec4 diffuse = texture2DRect(diffuseRect, tc);
vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
float scol = max(scol_ambocc.r, diffuse.a);
float ambocc = scol_ambocc.g;
calcAtmospherics(pos.xyz, ambocc);
vec3 col = atmosAmbient(vec3(0));
col += atmosAffectDirectionalLight(max(min(da, scol), diffuse.a));
col *= diffuse.rgb;
if (spec.a > 0.0) // specular reflection
vec3 col;
float bloom = 0.0;
if (diffuse.a < 0.9)
{
// the old infinite-sky shiny reflection
//
vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
float sa = dot(refnormpersp, vary_light.xyz);
vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
/*
// screen-space cheap fakey reflection map
//
vec3 refnorm = normalize(reflect(vec3(0,0,-1), norm.xyz));
depth -= 0.5; // unbias depth
// first figure out where we'll make our 2D guess from
vec2 ref2d = (0.25 * screen_res.y) * (refnorm.xy) * abs(refnorm.z) / depth;
// Offset the guess source a little according to a trivial
// checkerboard dither function and spec.a.
// This is meant to be similar to sampling a blurred version
// of the diffuse map. LOD would be better in that regard.
// The goal of the blur is to soften reflections in surfaces
// with low shinyness, and also to disguise our lameness.
float checkerboard = floor(mod(tc.x+tc.y, 2.0)); // 0.0, 1.0
float checkoffset = (3.0 + (7.0*(1.0-spec.a)))*(checkerboard-0.5);
ref2d += vec2(checkoffset, checkoffset);
ref2d += tc.xy; // use as offset from destination
// Get attributes from the 2D guess point.
// We average two samples of diffuse (not of anything else) per
// pixel to try to reduce aliasing some more.
vec3 refcol = 0.5 * (texture2DRect(diffuseRect, ref2d + vec2(0.0, -checkoffset)).rgb +
texture2DRect(diffuseRect, ref2d + vec2(-checkoffset, 0.0)).rgb);
float refdepth = texture2DRect(depthMap, ref2d).a;
vec3 refpos = getPosition_d(ref2d, refdepth).xyz;
vec3 refn = texture2DRect(normalMap, ref2d).rgb;
refn = normalize(vec3((refn.xy-0.5)*2.0,refn.z)); // unpack norm
// figure out how appropriate our guess actually was
float refapprop = max(0.0, dot(-refnorm, normalize(pos - refpos)));
// darken reflections from points which face away from the reflected ray - our guess was a back-face
//refapprop *= step(dot(refnorm, refn), 0.0);
refapprop = min(refapprop, max(0.0, -dot(refnorm, refn))); // more conservative variant
// get appropriate light strength for guess-point.
// reflect light direction to increase the illusion that
// these are reflections.
vec3 reflight = reflect(lightnorm.xyz, norm.xyz);
float reflit = max(dot(refn, reflight.xyz), 0.0);
// apply sun color to guess-point, dampen according to inappropriateness of guess
float refmod = min(refapprop, reflit);
vec3 refprod = vary_SunlitColor * refcol.rgb * refmod;
vec3 ssshiny = (refprod * spec.a);
ssshiny *= 0.3; // dampen it even more
*/
vec3 ssshiny = vec3(0,0,0);
// add the two types of shiny together
col += (ssshiny + dumbshiny) * spec.rgb;
}
calcAtmospherics(pos.xyz, 1.0);
col = atmosLighting(col);
col = scaleSoftClip(col);
col = atmosAmbient(vec3(0));
col += atmosAffectDirectionalLight(max(min(da, 1.0), diffuse.a));
col *= diffuse.rgb;
if (spec.a > 0.0) // specular reflection
{
// the old infinite-sky shiny reflection
//
vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
float sa = dot(refnormpersp, vary_light.xyz);
vec3 dumbshiny = vary_SunlitColor*texture2D(lightFunc, vec2(sa, spec.a)).a;
// add the two types of shiny together
vec3 spec_contrib = dumbshiny * spec.rgb;
bloom = dot(spec_contrib, spec_contrib);
col += spec_contrib;
}
col = atmosLighting(col);
col = scaleSoftClip(col);
col = mix(col.rgb, diffuse.rgb, diffuse.a);
}
else
{
col = diffuse.rgb;
}
gl_FragColor.rgb = col;
gl_FragColor.a = 0.0;
gl_FragColor.a = bloom;
}

View File

@@ -0,0 +1,19 @@
/**
* @file starsF.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* $/LicenseInfo$
*/
uniform sampler2D diffuseMap;
void main()
{
vec4 col = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy);
gl_FragData[0] = col;
gl_FragData[1] = vec4(0,0,0,0);
gl_FragData[2] = vec4(0,0,1,0);
}

View File

@@ -0,0 +1,17 @@
/**
* @file starsV.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
* $/LicenseInfo$
*/
void main()
{
//transform vertex
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_FrontColor = gl_Color;
}

View File

@@ -35,22 +35,27 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
//get distance
float d = length(lv);
//normalize light vector
lv *= 1.0/d;
//distance attenuation
float dist2 = d*d/(la*la);
float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
float da = 0.0;
// spotlight coefficient.
float spot = max(dot(-ln, lv), is_pointlight);
da *= spot*spot; // GL_SPOT_EXPONENT=2
if (d > 0.0 && la > 0.0 && fa > 0.0)
{
//normalize light vector
lv *= 1.0/d;
//angular attenuation
da *= calcDirectionalLight(n, lv);
//distance attenuation
float dist2 = d*d/(la*la);
da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
return da;
// spotlight coefficient.
float spot = max(dot(-ln, lv), is_pointlight);
da *= spot*spot; // GL_SPOT_EXPONENT=2
//angular attenuation
da *= calcDirectionalLight(n, lv);
}
return da;
}
void main()

View File

@@ -71,7 +71,7 @@ vec4 getPosition_d(vec2 pos_screen, float depth)
vec4 getPosition(vec2 pos_screen)
{ //get position in screen space (world units) given window coordinate and depth map
float depth = texture2DRect(depthMap, pos_screen.xy).a;
float depth = texture2DRect(depthMap, pos_screen.xy).r;
return getPosition_d(pos_screen, depth);
}
@@ -258,7 +258,7 @@ vec3 scaleSoftClip(vec3 light)
void main()
{
vec2 tc = vary_fragcoord.xy;
float depth = texture2DRect(depthMap, tc.xy).a;
float depth = texture2DRect(depthMap, tc.xy).r;
vec3 pos = getPosition_d(tc, depth).xyz;
vec3 norm = texture2DRect(normalMap, tc).xyz;
norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
@@ -267,34 +267,49 @@ void main()
float da = max(dot(norm.xyz, vary_light.xyz), 0.0);
vec4 diffuse = texture2DRect(diffuseRect, tc);
vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
float scol = max(scol_ambocc.r, diffuse.a);
float ambocc = scol_ambocc.g;
calcAtmospherics(pos.xyz, ambocc);
vec3 col = atmosAmbient(vec3(0));
col += atmosAffectDirectionalLight(max(min(da, scol), diffuse.a));
col *= diffuse.rgb;
if (spec.a > 0.0) // specular reflection
{
// the old infinite-sky shiny reflection
//
vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
float sa = dot(refnormpersp, vary_light.xyz);
vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
// add the two types of shiny together
col += dumbshiny * spec.rgb;
}
vec3 col;
float bloom = 0.0;
if (diffuse.a < 0.9)
{
vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
float scol = max(scol_ambocc.r, diffuse.a);
float ambocc = scol_ambocc.g;
col = atmosLighting(col);
col = scaleSoftClip(col);
calcAtmospherics(pos.xyz, ambocc);
col = atmosAmbient(vec3(0));
col += atmosAffectDirectionalLight(max(min(da, scol), diffuse.a));
col *= diffuse.rgb;
if (spec.a > 0.0) // specular reflection
{
// the old infinite-sky shiny reflection
//
vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
float sa = dot(refnormpersp, vary_light.xyz);
vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*texture2D(lightFunc, vec2(sa, spec.a)).a;
// add the two types of shiny together
vec3 spec_contrib = dumbshiny * spec.rgb;
bloom = dot(spec_contrib, spec_contrib);
col += spec_contrib;
}
col = atmosLighting(col);
col = scaleSoftClip(col);
col = mix(col, diffuse.rgb, diffuse.a);
}
else
{
col = diffuse.rgb;
}
gl_FragColor.rgb = col;
gl_FragColor.a = 0.0;
gl_FragColor.a = bloom;
}

View File

@@ -45,7 +45,7 @@ uniform float spot_shadow_offset;
vec4 getPosition(vec2 pos_screen)
{
float depth = texture2DRect(depthMap, pos_screen.xy).a;
float depth = texture2DRect(depthMap, pos_screen.xy).r;
vec2 sc = pos_screen.xy*2.0;
sc /= screen_res;
sc -= vec2(1.0,1.0);
@@ -60,9 +60,7 @@ vec4 getPosition(vec2 pos_screen)
float calcAmbientOcclusion(vec4 pos, vec3 norm)
{
float ret = 1.0;
float dist = dot(pos.xyz,pos.xyz);
vec2 kern[8];
// exponentially (^2) distant occlusion samples spread around origin
kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
@@ -70,13 +68,13 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm)
kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
vec2 pos_screen = vary_fragcoord.xy;
vec3 pos_world = pos.xyz;
vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
vec2 pos_screen = vary_fragcoord.xy;
vec3 pos_world = pos.xyz;
vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
float angle_hidden = 0.0;
int points = 0;
@@ -106,7 +104,6 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm)
angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
ret = (1.0 - (float(points != 0) * angle_hidden));
ret += max((dist-32.0*32.0)/(32.0*32.0), 0.0);
return min(ret, 1.0);
}
@@ -237,7 +234,7 @@ void main()
gl_FragColor[0] = shadow;
gl_FragColor[1] = calcAmbientOcclusion(pos, norm);
spos.xyz = shadow_pos+offset*spot_shadow_offset;
spos.xyz = shadow_pos+norm*spot_shadow_offset;
//spotlight shadow 1
vec4 lpos = shadow_matrix[4]*spos;

View File

@@ -431,7 +431,6 @@ void LLDrawPoolAvatar::endShadowPass(S32 pass)
sVertexProgram->unbind();
disable_vertex_weighting(sVertexProgram->mAttribute[LLViewerShaderMgr::AVATAR_WEIGHT]);
}
gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
}
#if MESH_ENABLED

View File

@@ -117,6 +117,17 @@ void LLDrawPoolWLSky::endRenderPass( S32 pass )
{
}
void LLDrawPoolWLSky::beginDeferredPass(S32 pass)
{
sky_shader = &gDeferredWLSkyProgram;
cloud_shader = &gDeferredWLCloudProgram;
}
void LLDrawPoolWLSky::endDeferredPass(S32 pass)
{
}
void LLDrawPoolWLSky::renderDome(F32 camHeightLocal, LLGLSLShader * shader) const
{
LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin();
@@ -296,6 +307,53 @@ void LLDrawPoolWLSky::renderHeavenlyBodies()
}
}
void LLDrawPoolWLSky::renderDeferred(S32 pass)
{
if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY))
{
return;
}
LLFastTimer ftm(LLFastTimer::FTM_RENDER_WL_SKY);
const F32 camHeightLocal = LLWLParamManager::instance()->getDomeOffset() * LLWLParamManager::instance()->getDomeRadius();
LLGLSNoFog disableFog;
LLGLDepthTest depth(GL_TRUE, GL_FALSE);
LLGLDisable clip(GL_CLIP_PLANE0);
gGL.setColorMask(true, false);
LLGLSquashToFarClip far_clip(glh_get_current_projection());
renderSkyHaze(camHeightLocal);
LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin();
glPushMatrix();
glTranslatef(origin.mV[0], origin.mV[1], origin.mV[2]);
gDeferredStarProgram.bind();
// *NOTE: have to bind a texture here since register combiners blending in
// renderStars() requires something to be bound and we might as well only
// bind the moon's texture once.
gGL.getTexUnit(0)->bind(gSky.mVOSkyp->mFace[LLVOSky::FACE_MOON]->getTexture());
renderHeavenlyBodies();
renderStars();
gDeferredStarProgram.unbind();
glPopMatrix();
renderSkyClouds(camHeightLocal);
gGL.setColorMask(true, true);
//gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
}
void LLDrawPoolWLSky::render(S32 pass)
{
if (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY))

View File

@@ -50,10 +50,10 @@ public:
/*virtual*/ BOOL isDead() { return FALSE; }
/*virtual*/ S32 getNumPostDeferredPasses() { return getNumPasses(); }
/*virtual*/ void beginPostDeferredPass(S32 pass) { beginRenderPass(pass); }
/*virtual*/ void endPostDeferredPass(S32 pass) { endRenderPass(pass); }
/*virtual*/ void renderPostDeferred(S32 pass) { render(pass); }
/*virtual*/ S32 getNumDeferredPasses() { return 1; }
/*virtual*/ void beginDeferredPass(S32 pass);
/*virtual*/ void endDeferredPass(S32 pass);
/*virtual*/ void renderDeferred(S32 pass);
/*virtual*/ LLViewerTexture *getDebugTexture();
/*virtual*/ void beginRenderPass( S32 pass );

View File

@@ -123,7 +123,7 @@ void LLViewerDynamicTexture::preRender(BOOL clear_depth)
// force rendering to on-screen portion of frame buffer
LLCoordScreen window_pos;
gViewerWindow->getWindow()->getPosition( &window_pos );
mOrigin.set(0, gViewerWindow->getWindowDisplayHeight() - mFullHeight); // top left corner
mOrigin.set(0, gViewerWindow->getWindowHeightRaw() - mFullHeight); // top left corner
if (window_pos.mX < 0)
{
@@ -178,7 +178,7 @@ void LLViewerDynamicTexture::postRender(BOOL success)
}
// restore viewport
gViewerWindow->setupViewport();
gViewerWindow->setup2DViewport();
// restore camera
LLViewerCamera* camera = LLViewerCamera::getInstance();

View File

@@ -543,7 +543,7 @@ void LLHUDEffectLookAt::render()
const LLFontGL* font = LLResMgr::getInstance()->getRes(LLFONT_SANSSERIF);
LLGLEnable gl_blend(GL_BLEND);
glPushMatrix();
gViewerWindow->setupViewport();
gViewerWindow->setup2DViewport();
hud_render_utf8text(text,
target + shadow_offset,
*font,

View File

@@ -75,8 +75,8 @@ void hud_render_text(const LLWString &wstr, const LLVector3 &pos_agent,
LLVector3 up_axis;
if (orthographic)
{
right_axis.setVec(0.f, -1.f / gViewerWindow->getWindowHeight(), 0.f);
up_axis.setVec(0.f, 0.f, 1.f / gViewerWindow->getWindowHeight());
right_axis.setVec(0.f, -1.f / gViewerWindow->getWorldViewHeightScaled(), 0.f);
up_axis.setVec(0.f, 0.f, 1.f / gViewerWindow->getWorldViewHeightScaled());
}
else
{

View File

@@ -70,11 +70,7 @@ S32 LLManip::sMaxTimesShowHelpText = 5;
F32 LLManip::sGridMaxSubdivisionLevel = 32.f;
F32 LLManip::sGridMinSubdivisionLevel = 1.f;
LLVector2 LLManip::sTickLabelSpacing(60.f, 25.f);
bool LLManip::sActualRoot = false;// going to set these up in the main entry
bool LLManip::sPivotPerc = false;
F32 LLManip::sPivotX = 0.f;
F32 LLManip::sPivotY = 0.f;
F32 LLManip::sPivotZ = 0.f;
//static
void LLManip::rebuild(LLViewerObject* vobj)
@@ -106,53 +102,6 @@ LLManip::LLManip( const std::string& name, LLToolComposite* composite )
mHighlightedPart(LL_NO_PART),
mManipPart(LL_NO_PART)
{
initPivot();
gSavedSettings.getControl("AscentBuildPrefs_ActualRoot")->getSignal()->connect(boost::bind(&updateActualRoot));
gSavedSettings.getControl("AscentBuildPrefs_PivotIsPercent")->getSignal()->connect(boost::bind(&updatePivotIsPercent));
gSavedSettings.getControl("AscentBuildPrefs_PivotX")->getSignal()->connect(boost::bind(&updatePivotX));
gSavedSettings.getControl("AscentBuildPrefs_PivotY")->getSignal()->connect(boost::bind(&updatePivotY));
gSavedSettings.getControl("AscentBuildPrefs_PivotZ")->getSignal()->connect(boost::bind(&updatePivotZ));
}
//static
void LLManip::initPivot()
{
sActualRoot = (bool)gSavedSettings.getBOOL("AscentBuildPrefs_ActualRoot");
sPivotPerc = (bool)gSavedSettings.getBOOL("AscentBuildPrefs_PivotIsPercent");
sPivotX = gSavedSettings.getF32("AscentBuildPrefs_PivotX");
sPivotY = gSavedSettings.getF32("AscentBuildPrefs_PivotY");
sPivotZ = gSavedSettings.getF32("AscentBuildPrefs_PivotZ");
}
//static
bool LLManip::updateActualRoot()
{
//sActualRoot = (bool)data.asBoolean();
sActualRoot = gSavedSettings.getBOOL("AscentBuildPrefs_ActualRoot");
return true;
}
//static
bool LLManip::updatePivotIsPercent()
{
sPivotPerc = gSavedSettings.getBOOL("AscentBuildPrefs_PivotIsPercent");
return true;
}
//static
bool LLManip::updatePivotX()
{
sPivotX = gSavedSettings.getF32("AscentBuildPrefs_PivotX");
return true;
}
//static
bool LLManip::updatePivotY()
{
sPivotY = gSavedSettings.getF32("AscentBuildPrefs_PivotY");
return true;
}
//static
bool LLManip::updatePivotZ()
{
sPivotZ = gSavedSettings.getF32("AscentBuildPrefs_PivotZ");
return true;
}
void LLManip::getManipNormal(LLViewerObject* object, EManipPart manip, LLVector3 &normal)
@@ -317,8 +266,8 @@ BOOL LLManip::getMousePointOnPlaneGlobal(LLVector3d& point, S32 x, S32 y, LLVect
if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
BOOL result = FALSE;
F32 mouse_x = ((F32)x / gViewerWindow->getWindowWidth() - 0.5f) * LLViewerCamera::getInstance()->getAspect() / gAgentCamera.mHUDCurZoom;
F32 mouse_y = ((F32)y / gViewerWindow->getWindowHeight() - 0.5f) / gAgentCamera.mHUDCurZoom;
F32 mouse_x = ((F32)x / gViewerWindow->getWorldViewWidthScaled() - 0.5f) * LLViewerCamera::getInstance()->getAspect() / gAgentCamera.mHUDCurZoom;
F32 mouse_y = ((F32)y / gViewerWindow->getWorldViewHeightScaled() - 0.5f) / gAgentCamera.mHUDCurZoom;
LLVector3 origin_agent = gAgent.getPosAgentFromGlobal(origin);
LLVector3 mouse_pos = LLVector3(0.f, -mouse_x, mouse_y);
@@ -356,8 +305,8 @@ BOOL LLManip::nearestPointOnLineFromMouse( S32 x, S32 y, const LLVector3& b1, co
if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
F32 mouse_x = (((F32)x / gViewerWindow->getWindowWidth()) - 0.5f) * LLViewerCamera::getInstance()->getAspect() / gAgentCamera.mHUDCurZoom;
F32 mouse_y = (((F32)y / gViewerWindow->getWindowHeight()) - 0.5f) / gAgentCamera.mHUDCurZoom;
F32 mouse_x = (((F32)x / gViewerWindow->getWindowWidthScaled()) - 0.5f) * LLViewerCamera::getInstance()->getAspect() / gAgentCamera.mHUDCurZoom;
F32 mouse_y = (((F32)y / gViewerWindow->getWindowHeightScaled()) - 0.5f) / gAgentCamera.mHUDCurZoom;
a1 = LLVector3(llmin(b1.mV[VX] - 0.1f, b2.mV[VX] - 0.1f, 0.f), -mouse_x, mouse_y);
a2 = a1 + LLVector3(1.f, 0.f, 0.f);
}
@@ -404,43 +353,22 @@ LLVector3 LLManip::getSavedPivotPoint() const
LLVector3 LLManip::getPivotPoint()
{
LLVector3 pos;
LLVector3 scale;
LLQuaternion rot;// = mObjectSelection->getFirstObject()->getRotation();
if (mObjectSelection->getFirstRootObject(TRUE) && (mObjectSelection->getObjectCount() == 1 || sActualRoot) && mObjectSelection->getSelectType() != SELECT_TYPE_HUD)
static LLCachedControl<bool> actual_root("AscentBuildPrefs_ActualRoot");
static LLCachedControl<bool> pivot_as_percent("AscentBuildPrefs_PivotIsPercent");
static LLCachedControl<F32> pivot_x("AscentBuildPrefs_PivotX");
static LLCachedControl<F32> pivot_y("AscentBuildPrefs_PivotY");
static LLCachedControl<F32> pivot_z("AscentBuildPrefs_PivotZ");
LLVector3 offset(pivot_x,pivot_y,pivot_z);
if (mObjectSelection->getFirstRootObject(TRUE) && (mObjectSelection->getObjectCount() == 1 || actual_root) && mObjectSelection->getSelectType() != SELECT_TYPE_HUD)
{
pos = mObjectSelection->getFirstRootObject(TRUE)->getPivotPositionAgent();
scale = mObjectSelection->getFirstRootObject(TRUE)->getScale();
rot = mObjectSelection->getFirstRootObject(TRUE)->getRotation();
}else
{
pos = LLSelectMgr::getInstance()->getBBoxOfSelection().getCenterAgent();
scale = LLSelectMgr::getInstance()->getBBoxOfSelection().getExtentLocal();
rot = LLSelectMgr::getInstance()->getBBoxOfSelection().getRotation();
if(pivot_as_percent)
offset = ((offset * .01f) - LLVector3(.5f,.5f,.5f)).scaleVec(mObjectSelection->getFirstRootObject(TRUE)->getScale());
return mObjectSelection->getFirstObject()->getPivotPositionAgent() + offset * mObjectSelection->getFirstRootObject(TRUE)->getRotation();
}
if(sPivotPerc)
{
LLVector3 add(
(-scale[VX]*0.5) + (scale[VX]*(sPivotX*0.01)),
(-scale[VY]*0.5) + (scale[VY]*(sPivotY*0.01)),
(-scale[VZ]*0.5) + (scale[VZ]*(sPivotZ*0.01)));
add = add * rot;
pos = pos + add;
}else
{
//pos[VX] = pos[VX] + gSavedSettings.getF32("EmeraldBuildPrefs_PivotX");
//pos[VY] = pos[VY] + gSavedSettings.getF32("EmeraldBuildPrefs_PivotY");
//pos[VZ] = pos[VZ] + gSavedSettings.getF32("EmeraldBuildPrefs_PivotZ");
LLVector3 add(
sPivotX,
sPivotY,
sPivotZ);
add = add * rot;
pos = pos + add;
}
//pos = pos * rot;
return pos;
if(pivot_as_percent)
offset = ((offset * .01f) - LLVector3(.5f,.5f,.5f)).scaleVec(LLSelectMgr::getInstance()->getBBoxOfSelection().getExtentLocal());
return LLSelectMgr::getInstance()->getBBoxOfSelection().getCenterAgent() + offset * LLSelectMgr::getInstance()->getBBoxOfSelection().getRotation();
}
@@ -514,17 +442,17 @@ void LLManip::renderXYZ(const LLVector3 &vec)
const S32 PAD = 10;
std::string feedback_string;
LLVector3 camera_pos = LLViewerCamera::getInstance()->getOrigin() + LLViewerCamera::getInstance()->getAtAxis();
S32 window_center_x = gViewerWindow->getWindowWidth() / 2;
S32 window_center_y = gViewerWindow->getWindowHeight() / 2;
S32 vertical_offset = window_center_y - VERTICAL_OFFSET;
S32 window_center_x = gViewerWindow->getWorldViewRectScaled().getWidth() / 2;
S32 window_center_y = gViewerWindow->getWorldViewRectScaled().getHeight() / 2;
S32 vertical_offset = window_center_y - VERTICAL_OFFSET;
glPushMatrix();
gGL.pushMatrix();
{
LLUIImagePtr imagep = LLUI::getUIImage("rounded_square.tga");
gViewerWindow->setup2DRender();
const LLVector2& display_scale = gViewerWindow->getDisplayScale();
glScalef(display_scale.mV[VX], display_scale.mV[VY], 1.f);
gGL.scalef(display_scale.mV[VX], display_scale.mV[VY], 1.f);
gGL.color4f(0.f, 0.f, 0.f, 0.7f);
imagep->draw(
@@ -534,7 +462,7 @@ void LLManip::renderXYZ(const LLVector3 &vec)
PAD * 2 + 10,
LLColor4(0.f, 0.f, 0.f, 0.7f) );
}
glPopMatrix();
gGL.popMatrix();
gViewerWindow->setup3DRender();
@@ -586,9 +514,9 @@ void LLManip::renderTickText(const LLVector3& pos, const std::string& text, cons
// render shadow first
LLColor4 shadow_color = LLColor4::black;
shadow_color.mV[VALPHA] = color.mV[VALPHA] * 0.5f;
gViewerWindow->setupViewport(1, -1);
gViewerWindow->setup3DViewport(1, -1);
hud_render_utf8text(text, render_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(text), 3.f, shadow_color, mObjectSelection->getSelectType() == SELECT_TYPE_HUD);
gViewerWindow->setupViewport();
gViewerWindow->setup3DViewport();
hud_render_utf8text(text, render_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(text), 3.f, color, mObjectSelection->getSelectType() == SELECT_TYPE_HUD);
glPopMatrix();
@@ -648,19 +576,19 @@ void LLManip::renderTickValue(const LLVector3& pos, F32 value, const std::string
{
fraction_string = llformat("%c%02d%s", LLResMgr::getInstance()->getDecimalPoint(), fractional_portion, suffix.c_str());
gViewerWindow->setupViewport(1, -1);
gViewerWindow->setup3DViewport(1, -1);
hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, -1.f * big_fontp->getWidthF32(val_string), 3.f, shadow_color, hud_selection);
hud_render_utf8text(fraction_string, render_pos, *small_fontp, LLFontGL::NORMAL, 1.f, 3.f, shadow_color, hud_selection);
gViewerWindow->setupViewport();
gViewerWindow->setup3DViewport();
hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, -1.f * big_fontp->getWidthF32(val_string), 3.f, color, hud_selection);
hud_render_utf8text(fraction_string, render_pos, *small_fontp, LLFontGL::NORMAL, 1.f, 3.f, color, hud_selection);
}
else
{
gViewerWindow->setupViewport(1, -1);
gViewerWindow->setup3DViewport(1, -1);
hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(val_string), 3.f, shadow_color, hud_selection);
gViewerWindow->setupViewport();
gViewerWindow->setup3DViewport();
hud_render_utf8text(val_string, render_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(val_string), 3.f, color, hud_selection);
}
glPopMatrix();
@@ -679,14 +607,14 @@ LLColor4 LLManip::setupSnapGuideRenderPass(S32 pass)
{
case 0:
// shadow
gViewerWindow->setupViewport(1, -1);
gViewerWindow->setup3DViewport(1, -1);
line_color = grid_color_shadow;
line_color.mV[VALPHA] *= line_alpha;
LLUI::setLineWidth(2.f);
break;
case 1:
// hidden lines
gViewerWindow->setupViewport();
gViewerWindow->setup3DViewport();
line_color = grid_color_bg;
line_color.mV[VALPHA] *= line_alpha;
LLUI::setLineWidth(1.f);

View File

@@ -151,13 +151,6 @@ protected:
BOOL getMousePointOnPlaneAgent(LLVector3& point, S32 x, S32 y, LLVector3 origin, LLVector3 normal);
BOOL nearestPointOnLineFromMouse( S32 x, S32 y, const LLVector3& b1, const LLVector3& b2, F32 &a_param, F32 &b_param );
LLColor4 setupSnapGuideRenderPass(S32 pass);
private:
static void initPivot();
static bool updateActualRoot();
static bool updatePivotIsPercent();
static bool updatePivotX();
static bool updatePivotY();
static bool updatePivotZ();
protected:
LLFrameTimer mHelpTextTimer;
BOOL mInSnapRegime;
@@ -172,11 +165,6 @@ protected:
static F32 sGridMaxSubdivisionLevel;
static F32 sGridMinSubdivisionLevel;
static LLVector2 sTickLabelSpacing;
static bool sActualRoot;
static bool sPivotPerc;
static F32 sPivotX;
static F32 sPivotY;
static F32 sPivotZ;
};

View File

@@ -516,8 +516,9 @@ void LLManipScale::highlightManipulators(S32 x, S32 y)
mProjectedManipulators.insert(projManipulator);
}
F32 half_width = (F32)gViewerWindow->getWindowWidth() / 2.f;
F32 half_height = (F32)gViewerWindow->getWindowHeight() / 2.f;
LLRect world_view_rect = gViewerWindow->getWorldViewRectScaled();
F32 half_width = (F32)world_view_rect.getWidth() / 2.f;
F32 half_height = (F32)world_view_rect.getHeight() / 2.f;
LLVector2 manip2d;
LLVector2 mousePos((F32)x - half_width, (F32)y - half_height);
LLVector2 delta;

View File

@@ -106,6 +106,16 @@ const U32 ARROW_TO_AXIS[4] =
VZ
};
// Sort manipulator handles by their screen-space projection
struct ClosestToCamera
{
bool operator()(const LLManipTranslate::ManipulatorHandle& a,
const LLManipTranslate::ManipulatorHandle& b) const
{
return a.mEndPosition.mV[VZ] < b.mEndPosition.mV[VZ];
}
};
LLManipTranslate::LLManipTranslate( LLToolComposite* composite )
: LLManip( std::string("Move"), composite ),
mLastHoverMouseX(-1),
@@ -118,9 +128,13 @@ LLManipTranslate::LLManipTranslate( LLToolComposite* composite )
mAxisArrowLength(50),
mConeSize(0),
mArrowLengthMeters(0.f),
mGridSizeMeters(1.f),
mPlaneManipOffsetMeters(0.f),
mUpdateTimer(),
mSnapOffsetMeters(0.f),
mSubdivisions(10.f),
mInSnapRegime(FALSE),
mSnapped(FALSE),
mArrowScales(1.f, 1.f, 1.f),
mPlaneScales(1.f, 1.f, 1.f),
mPlaneManipPositions(1.f, 1.f, 1.f, 1.f)
@@ -278,7 +292,6 @@ void LLManipTranslate::restoreGL()
LLManipTranslate::~LLManipTranslate()
{
for_each(mProjectedManipulators.begin(), mProjectedManipulators.end(), DeletePointer());
}
@@ -418,8 +431,9 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
}
// Handle auto-rotation if necessary.
LLRect world_rect = gViewerWindow->getWorldViewRectScaled();
const F32 ROTATE_ANGLE_PER_SECOND = 30.f * DEG_TO_RAD;
const S32 ROTATE_H_MARGIN = gViewerWindow->getWindowWidth() / 20;
const S32 ROTATE_H_MARGIN = world_rect.getWidth() / 20;
const F32 rotate_angle = ROTATE_ANGLE_PER_SECOND / gFPSClamped;
BOOL rotated = FALSE;
@@ -431,7 +445,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
gAgentCamera.cameraOrbitAround(rotate_angle);
rotated = TRUE;
}
else if (x > gViewerWindow->getWindowWidth() - ROTATE_H_MARGIN)
else if (x > world_rect.getWidth() - ROTATE_H_MARGIN)
{
gAgentCamera.cameraOrbitAround(-rotate_angle);
rotated = TRUE;
@@ -899,8 +913,9 @@ void LLManipTranslate::highlightManipulators(S32 x, S32 y)
planar_manip_xy_visible = TRUE;
}
for_each(mProjectedManipulators.begin(), mProjectedManipulators.end(), DeletePointer());
mProjectedManipulators.clear();
// Project up to 9 manipulators to screen space 2*X, 2*Y, 2*Z, 3*planes
std::vector<ManipulatorHandle> projected_manipulators;
projected_manipulators.reserve(9);
for (S32 i = 0; i < num_arrow_manips; i+= 2)
{
@@ -910,12 +925,12 @@ void LLManipTranslate::highlightManipulators(S32 x, S32 y)
LLVector4 projected_end = mManipulatorVertices[i + 1] * transform;
projected_end = projected_end * (1.f / projected_end.mV[VW]);
ManipulatorHandle* projManipulator =
new ManipulatorHandle(LLVector3(projected_start.mV[VX], projected_start.mV[VY], projected_start.mV[VZ]),
ManipulatorHandle projected_manip(
LLVector3(projected_start.mV[VX], projected_start.mV[VY], projected_start.mV[VZ]),
LLVector3(projected_end.mV[VX], projected_end.mV[VY], projected_end.mV[VZ]),
MANIPULATOR_IDS[i / 2],
10.f); // 10 pixel hotspot for arrows
mProjectedManipulators.insert(projManipulator);
projected_manipulators.push_back(projected_manip);
}
if (planar_manip_yz_visible)
@@ -927,12 +942,12 @@ void LLManipTranslate::highlightManipulators(S32 x, S32 y)
LLVector4 projected_end = mManipulatorVertices[i + 1] * transform;
projected_end = projected_end * (1.f / projected_end.mV[VW]);
ManipulatorHandle* projManipulator =
new ManipulatorHandle(LLVector3(projected_start.mV[VX], projected_start.mV[VY], projected_start.mV[VZ]),
ManipulatorHandle projected_manip(
LLVector3(projected_start.mV[VX], projected_start.mV[VY], projected_start.mV[VZ]),
LLVector3(projected_end.mV[VX], projected_end.mV[VY], projected_end.mV[VZ]),
MANIPULATOR_IDS[i / 2],
20.f); // 20 pixels for planar manipulators
mProjectedManipulators.insert(projManipulator);
projected_manipulators.push_back(projected_manip);
}
if (planar_manip_xz_visible)
@@ -944,12 +959,12 @@ void LLManipTranslate::highlightManipulators(S32 x, S32 y)
LLVector4 projected_end = mManipulatorVertices[i + 1] * transform;
projected_end = projected_end * (1.f / projected_end.mV[VW]);
ManipulatorHandle* projManipulator =
new ManipulatorHandle(LLVector3(projected_start.mV[VX], projected_start.mV[VY], projected_start.mV[VZ]),
ManipulatorHandle projected_manip(
LLVector3(projected_start.mV[VX], projected_start.mV[VY], projected_start.mV[VZ]),
LLVector3(projected_end.mV[VX], projected_end.mV[VY], projected_end.mV[VZ]),
MANIPULATOR_IDS[i / 2],
20.f); // 20 pixels for planar manipulators
mProjectedManipulators.insert(projManipulator);
projected_manipulators.push_back(projected_manip);
}
if (planar_manip_xy_visible)
@@ -961,29 +976,35 @@ void LLManipTranslate::highlightManipulators(S32 x, S32 y)
LLVector4 projected_end = mManipulatorVertices[i + 1] * transform;
projected_end = projected_end * (1.f / projected_end.mV[VW]);
ManipulatorHandle* projManipulator =
new ManipulatorHandle(LLVector3(projected_start.mV[VX], projected_start.mV[VY], projected_start.mV[VZ]),
ManipulatorHandle projected_manip(
LLVector3(projected_start.mV[VX], projected_start.mV[VY], projected_start.mV[VZ]),
LLVector3(projected_end.mV[VX], projected_end.mV[VY], projected_end.mV[VZ]),
MANIPULATOR_IDS[i / 2],
20.f); // 20 pixels for planar manipulators
mProjectedManipulators.insert(projManipulator);
projected_manipulators.push_back(projected_manip);
}
LLVector2 manip_start_2d;
LLVector2 manip_end_2d;
LLVector2 manip_dir;
F32 half_width = gViewerWindow->getWindowWidth() / 2.f;
F32 half_height = gViewerWindow->getWindowHeight() / 2.f;
LLRect world_view_rect = gViewerWindow->getWorldViewRectScaled();
F32 half_width = (F32)world_view_rect.getWidth() / 2.f;
F32 half_height = (F32)world_view_rect.getHeight() / 2.f;
LLVector2 mousePos((F32)x - half_width, (F32)y - half_height);
LLVector2 mouse_delta;
for (minpulator_list_t::iterator iter = mProjectedManipulators.begin();
iter != mProjectedManipulators.end(); ++iter)
// Keep order consistent with insertion via stable_sort
std::stable_sort( projected_manipulators.begin(),
projected_manipulators.end(),
ClosestToCamera() );
std::vector<ManipulatorHandle>::iterator it = projected_manipulators.begin();
for ( ; it != projected_manipulators.end(); ++it)
{
ManipulatorHandle* manipulator = *iter;
ManipulatorHandle& manipulator = *it;
{
manip_start_2d.setVec(manipulator->mStartPosition.mV[VX] * half_width, manipulator->mStartPosition.mV[VY] * half_height);
manip_end_2d.setVec(manipulator->mEndPosition.mV[VX] * half_width, manipulator->mEndPosition.mV[VY] * half_height);
manip_start_2d.setVec(manipulator.mStartPosition.mV[VX] * half_width, manipulator.mStartPosition.mV[VY] * half_height);
manip_end_2d.setVec(manipulator.mEndPosition.mV[VX] * half_width, manipulator.mEndPosition.mV[VY] * half_height);
manip_dir = manip_end_2d - manip_start_2d;
mouse_delta = mousePos - manip_start_2d;
@@ -995,9 +1016,9 @@ void LLManipTranslate::highlightManipulators(S32 x, S32 y)
if (mouse_pos_manip > 0.f &&
mouse_pos_manip < manip_length &&
mouse_dist_manip_squared < manipulator->mHotSpotRadius * manipulator->mHotSpotRadius)
mouse_dist_manip_squared < manipulator.mHotSpotRadius * manipulator.mHotSpotRadius)
{
mHighlightedPart = manipulator->mManipID;
mHighlightedPart = manipulator.mManipID;
break;
}
}
@@ -1238,7 +1259,7 @@ void LLManipTranslate::renderSnapGuides()
{
LLVector3 cam_to_selection = getPivotPoint() - LLViewerCamera::getInstance()->getOrigin();
F32 current_range = cam_to_selection.normVec();
guide_size_meters = SNAP_GUIDE_SCREEN_SIZE * gViewerWindow->getWindowHeight() * current_range / LLViewerCamera::getInstance()->getPixelMeterRatio();
guide_size_meters = SNAP_GUIDE_SCREEN_SIZE * gViewerWindow->getWorldViewHeightRaw() * current_range / LLViewerCamera::getInstance()->getPixelMeterRatio();
F32 fraction_of_fov = mAxisArrowLength / (F32) LLViewerCamera::getInstance()->getViewHeightInPixels();
F32 apparent_angle = fraction_of_fov * LLViewerCamera::getInstance()->getView(); // radians
@@ -1813,7 +1834,7 @@ void LLManipTranslate::renderTranslationHandles()
// Drag handles
if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
mArrowLengthMeters = mAxisArrowLength / gViewerWindow->getWindowHeight();
mArrowLengthMeters = mAxisArrowLength / gViewerWindow->getWorldViewHeightRaw();
mArrowLengthMeters /= gAgentCamera.mHUDCurZoom;
}
else

View File

@@ -89,17 +89,6 @@ protected:
F32 getMinGridScale();
private:
struct compare_manipulators
{
bool operator() (const ManipulatorHandle* const a, const ManipulatorHandle* const b) const
{
if (a->mEndPosition.mV[VZ] != b->mEndPosition.mV[VZ])
return (a->mEndPosition.mV[VZ] < b->mEndPosition.mV[VZ]);
else
return a->mManipID < b->mManipID;
}
};
S32 mLastHoverMouseX;
S32 mLastHoverMouseY;
BOOL mSendUpdateOnMouseUp;
@@ -116,8 +105,6 @@ private:
LLVector3d mDragCursorStartGlobal;
LLVector3d mDragSelectionStartGlobal;
LLTimer mUpdateTimer;
typedef std::set<ManipulatorHandle*, compare_manipulators> minpulator_list_t;
minpulator_list_t mProjectedManipulators;
LLVector4 mManipulatorVertices[18];
F32 mSnapOffsetMeters;
LLVector3 mSnapOffsetAxis;

View File

@@ -586,7 +586,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo
}
}
gViewerWindow->setupViewport();
gViewerWindow->setup3DViewport();
gPipeline.resetFrameStats(); // Reset per-frame statistics.
if (!gDisconnected)
@@ -619,6 +619,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo
gPipeline.createObjects(max_geom_update_time);
gPipeline.processPartitionQ();
gPipeline.updateGeom(max_geom_update_time);
stop_glerror();
gPipeline.updateGL();
stop_glerror();
@@ -731,7 +732,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo
glLoadMatrixf(proj.m);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(mod.m);
gViewerWindow->setupViewport();
gViewerWindow->setup3DViewport();
LLGLState::checkStates();
LLGLState::checkTextureChannels();
@@ -886,7 +887,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo
if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender)
{
gPipeline.mDeferredScreen.bindTarget();
glClearColor(0,0,0,0);
glClearColor(1,0,1,1);
gPipeline.mDeferredScreen.clear();
}
else if(!tiling)

View File

@@ -1133,12 +1133,13 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
{
std::string fragment;
//Keep this! Fixes shadow softening with ssao off.
/*//Keep this! Fixes shadow softening with ssao off.
//Disabled for now.
if (mVertexShaderLevel[SHADER_DEFERRED] < 2 && !gSavedSettings.getBOOL("RenderDeferredSSAO"))
{
fragment = "deferred/softenLightNoSSAOF.glsl";
}
else
else*/
{
fragment = "deferred/softenLightF.glsl";
}
@@ -1148,6 +1149,12 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredSoftenProgram.mShaderFiles.push_back(make_pair(fragment, GL_FRAGMENT_SHADER_ARB));
gDeferredSoftenProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
if (gSavedSettings.getBOOL("RenderDeferredSSAO"))
{ //if using SSAO, take screen space light map into account as if shadows are enabled
gDeferredSoftenProgram.mShaderLevel = llmax(gDeferredSoftenProgram.mShaderLevel, 2);
}
success = gDeferredSoftenProgram.createShader(NULL, NULL);
}
@@ -1292,16 +1299,6 @@ BOOL LLViewerShaderMgr::loadShadersDeferred()
if (mVertexShaderLevel[SHADER_DEFERRED] > 2)
{
if (success)
{
gDeferredPostProgram.mName = "Deferred Post Shader";
gDeferredPostProgram.mShaderFiles.clear();
gDeferredPostProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredV.glsl", GL_VERTEX_SHADER_ARB));
gDeferredPostProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredF.glsl", GL_FRAGMENT_SHADER_ARB));
gDeferredPostProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED];
success = gDeferredPostProgram.createShader(NULL, NULL);
}
if (success)
{
gDeferredPostGIProgram.mName = "Deferred Post GI Shader";

View File

@@ -235,6 +235,8 @@ LLVector2 gDebugRaycastTexCoord;
LLVector3 gDebugRaycastNormal;
LLVector3 gDebugRaycastBinormal;
S32 gDebugRaycastFaceHit;
LLVector3 gDebugRaycastStart;
LLVector3 gDebugRaycastEnd;
// HUD display lines in lower right
BOOL gDisplayWindInfo = FALSE;
@@ -305,7 +307,7 @@ public:
mTextColor = LLColor4( 0.86f, 0.86f, 0.86f, 1.f );
// Draw stuff growing up from right lower corner of screen
U32 xpos = mWindow->getWindowWidth() - 350;
U32 xpos = mWindow->getWorldViewWidthScaled() - 350;
U32 ypos = 64;
const U32 y_inc = 20;
@@ -1517,8 +1519,8 @@ LLViewerWindow::LLViewerWindow(
mActive(TRUE),
mWantFullscreen(fullscreen),
mShowFullscreenProgress(FALSE),
mWindowRect(0, height, width, 0),
mVirtualWindowRect(0, height, width, 0),
mWindowRectRaw(0, height, width, 0),
mWindowRectScaled(0, height, width, 0),
mLeftMouseDown(FALSE),
mRightMouseDown(FALSE),
mToolTip(NULL),
@@ -1596,8 +1598,8 @@ LLViewerWindow::LLViewerWindow(
{
LLCoordWindow size;
mWindow->getSize(&size);
mWindowRect.set(0, size.mY, size.mX, 0);
mVirtualWindowRect.set(0, llround((F32)size.mY / mDisplayScale.mV[VY]), llround((F32)size.mX / mDisplayScale.mV[VX]), 0);
mWindowRectRaw.set(0, size.mY, size.mX, 0);
mWindowRectScaled.set(0, llround((F32)size.mY / mDisplayScale.mV[VY]), llround((F32)size.mX / mDisplayScale.mV[VX]), 0);
}
LLFontManager::initClass();
@@ -1652,7 +1654,7 @@ LLViewerWindow::LLViewerWindow(
gBumpImageList.init();
// Create container for all sub-views
mRootView = new LLRootView("root", mVirtualWindowRect, FALSE);
mRootView = new LLRootView("root", mWindowRectScaled, FALSE);
if (!gNoRender)
{
@@ -1661,8 +1663,8 @@ LLViewerWindow::LLViewerWindow(
}
// Make avatar head look forward at start
mCurrentMousePoint.mX = getWindowWidth() / 2;
mCurrentMousePoint.mY = getWindowHeight() / 2;
mCurrentMousePoint.mX = getWindowWidthScaled() / 2;
mCurrentMousePoint.mY = getWindowHeightScaled() / 2;
gShowOverlayTitle = gSavedSettings.getBOOL("ShowOverlayTitle");
mOverlayTitle = gSavedSettings.getString("OverlayTitle");
@@ -1709,8 +1711,8 @@ void LLViewerWindow::initGLDefaults()
void LLViewerWindow::initBase()
{
S32 height = getWindowHeight();
S32 width = getWindowWidth();
S32 height = getWindowHeightScaled();
S32 width = getWindowWidthScaled();
LLRect full_window(0, height, width, 0);
@@ -2196,8 +2198,8 @@ void LLViewerWindow::sendShapeToSim()
msg->addU32Fast(_PREHASH_CircuitCode, gMessageSystem->mOurCircuitCode);
msg->nextBlockFast(_PREHASH_HeightWidthBlock);
msg->addU32Fast(_PREHASH_GenCounter, 0);
U16 height16 = (U16) mWindowRect.getHeight();
U16 width16 = (U16) mWindowRect.getWidth();
U16 height16 = (U16) mWindowRectRaw.getHeight();
U16 width16 = (U16) mWindowRectRaw.getWidth();
msg->addU16Fast(_PREHASH_Height, height16);
msg->addU16Fast(_PREHASH_Width, width16);
gAgent.sendReliableMessage();
@@ -2236,18 +2238,18 @@ void LLViewerWindow::reshape(S32 width, S32 height)
}
// update our window rectangle
mWindowRect.mRight = mWindowRect.mLeft + width;
mWindowRect.mTop = mWindowRect.mBottom + height;
mWindowRectRaw.mRight = mWindowRectRaw.mLeft + width;
mWindowRectRaw.mTop = mWindowRectRaw.mBottom + height;
calcDisplayScale();
BOOL display_scale_changed = mDisplayScale != LLUI::sGLScaleFactor;
LLUI::setScaleFactor(mDisplayScale);
// update our window rectangle
mVirtualWindowRect.mRight = mVirtualWindowRect.mLeft + llround((F32)width / mDisplayScale.mV[VX]);
mVirtualWindowRect.mTop = mVirtualWindowRect.mBottom + llround((F32)height / mDisplayScale.mV[VY]);
mWindowRectScaled.mRight = mWindowRectScaled.mLeft + llround((F32)width / mDisplayScale.mV[VX]);
mWindowRectScaled.mTop = mWindowRectScaled.mBottom + llround((F32)height / mDisplayScale.mV[VY]);
setupViewport();
setup2DViewport();
// Inform lower views of the change
// round up when converting coordinates to make sure there are no gaps at edge of window
@@ -2392,8 +2394,8 @@ void LLViewerWindow::draw()
microsecondsToTimecodeString(gFrameTime,text);
const LLFontGL* font = LLResMgr::getInstance()->getRes( LLFONT_SANSSERIF );
font->renderUTF8(text, 0,
llround((getWindowWidth()/2)-100.f),
llround((getWindowHeight()-60.f)),
llround((getWindowWidthScaled()/2)-100.f),
llround((getWindowHeightScaled()-60.f)),
LLColor4( 1.f, 1.f, 1.f, 1.f ),
LLFontGL::LEFT, LLFontGL::TOP);
}
@@ -2420,8 +2422,8 @@ void LLViewerWindow::draw()
int pos_y = sub_region / llceil(zoom_factor);
int pos_x = sub_region - (pos_y*llceil(zoom_factor));
// offset for this tile
glTranslatef((F32)getWindowWidth() * -(F32)pos_x,
(F32)getWindowHeight() * -(F32)pos_y,
glTranslatef((F32)getWindowWidthScaled() * -(F32)pos_x,
(F32)getWindowHeightScaled() * -(F32)pos_y,
0.f);
glScalef(zoom_factor, zoom_factor, 1.f);
LLUI::sGLScaleFactor *= zoom_factor;
@@ -2486,8 +2488,8 @@ void LLViewerWindow::draw()
const S32 DIST_FROM_TOP = 20;
LLFontGL::getFontSansSerifBig()->renderUTF8(
mOverlayTitle, 0,
llround( getWindowWidth() * 0.5f),
getWindowHeight() - DIST_FROM_TOP,
llround( getWindowWidthScaled() * 0.5f),
getWindowHeightScaled() - DIST_FROM_TOP,
LLColor4(1, 1, 1, 0.4f),
LLFontGL::HCENTER, LLFontGL::TOP);
}
@@ -2810,6 +2812,10 @@ void LLViewerWindow::handleScrollWheel(S32 clicks)
}
// Zoom the camera in and out behavior
if(top_ctrl == 0
&& getWorldViewRectScaled().pointInRect(mCurrentMousePoint.mX, mCurrentMousePoint.mY)
&& gAgentCamera.isInitialized())
gAgentCamera.handleScrollWheel(clicks);
return;
@@ -2817,8 +2823,8 @@ void LLViewerWindow::handleScrollWheel(S32 clicks)
void LLViewerWindow::moveCursorToCenter()
{
S32 x = mVirtualWindowRect.getWidth() / 2;
S32 y = mVirtualWindowRect.getHeight() / 2;
S32 x = getWorldViewWidthScaled() / 2;
S32 y = getWorldViewHeightScaled() / 2;
//on a forced move, all deltas get zeroed out to prevent jumping
mCurrentMousePoint.set(x,y);
@@ -2843,15 +2849,28 @@ BOOL LLViewerWindow::handlePerFrameHover()
S32 x = mCurrentMousePoint.mX;
S32 y = mCurrentMousePoint.mY;
MASK mask = gKeyboard->currentMask(TRUE);
if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_RAYCAST))
{
gDebugRaycastFaceHit = -1;
gDebugRaycastObject = cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE,
&gDebugRaycastFaceHit,
&gDebugRaycastIntersection,
&gDebugRaycastTexCoord,
&gDebugRaycastNormal,
&gDebugRaycastBinormal,
&gDebugRaycastStart,
&gDebugRaycastEnd);
}
//RN: fix for asynchronous notification of mouse leaving window not working
LLCoordWindow mouse_pos;
mWindow->getCursorPosition(&mouse_pos);
if (mouse_pos.mX < 0 ||
mouse_pos.mY < 0 ||
mouse_pos.mX > mWindowRect.getWidth() ||
mouse_pos.mY > mWindowRect.getHeight())
mouse_pos.mX > mWindowRectRaw.getWidth() ||
mouse_pos.mY > mWindowRectRaw.getHeight())
{
mMouseInWindow = FALSE;
}
@@ -3239,16 +3258,6 @@ BOOL LLViewerWindow::handlePerFrameHover()
LLSelectMgr::getInstance()->deselectUnused();
}
if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_RAYCAST))
{
gDebugRaycastFaceHit = -1;
gDebugRaycastObject = cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE,
&gDebugRaycastFaceHit,
&gDebugRaycastIntersection,
&gDebugRaycastTexCoord,
&gDebugRaycastNormal,
&gDebugRaycastBinormal);
}
// per frame picking - for tooltips and changing cursor over interactive objects
@@ -3294,9 +3303,9 @@ void LLViewerWindow::saveLastMouse(const LLCoordGL &point)
{
mCurrentMousePoint.mX = 0;
}
else if (point.mX > getWindowWidth())
else if (point.mX > getWindowWidthScaled())
{
mCurrentMousePoint.mX = getWindowWidth();
mCurrentMousePoint.mX = getWindowWidthScaled();
}
else
{
@@ -3307,9 +3316,9 @@ void LLViewerWindow::saveLastMouse(const LLCoordGL &point)
{
mCurrentMousePoint.mY = 0;
}
else if (point.mY > getWindowHeight() )
else if (point.mY > getWindowHeightScaled() )
{
mCurrentMousePoint.mY = getWindowHeight();
mCurrentMousePoint.mY = getWindowHeightScaled();
}
else
{
@@ -3566,8 +3575,8 @@ void LLViewerWindow::pickAsync(S32 x, S32 y_from_bot, MASK mask, void (*callback
if (mPickScreenRegion.mLeft < 0) mPickScreenRegion.translate(-mPickScreenRegion.mLeft, 0);
if (mPickScreenRegion.mBottom < 0) mPickScreenRegion.translate(0, -mPickScreenRegion.mBottom);
if (mPickScreenRegion.mRight > mWindowRect.getWidth() ) mPickScreenRegion.translate(mWindowRect.getWidth() - mPickScreenRegion.mRight, 0);
if (mPickScreenRegion.mTop > mWindowRect.getHeight() ) mPickScreenRegion.translate(0, mWindowRect.getHeight() - mPickScreenRegion.mTop);
if (mPickScreenRegion.mRight > mWindowRectRaw.getWidth() ) mPickScreenRegion.translate(mWindowRectRaw.getWidth() - mPickScreenRegion.mRight, 0);
if (mPickScreenRegion.mTop > mWindowRectRaw.getHeight() ) mPickScreenRegion.translate(0, mWindowRectRaw.getHeight() - mPickScreenRegion.mTop);
}
// set frame buffer region for picking results
@@ -3683,7 +3692,9 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de
LLVector3 *intersection,
LLVector2 *uv,
LLVector3 *normal,
LLVector3 *binormal)
LLVector3 *binormal,
LLVector3* start,
LLVector3* end)
{
S32 x = mouse_x;
S32 y = mouse_y;
@@ -3715,7 +3726,22 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de
LLVector3 mouse_world_start = mouse_point_global;
LLVector3 mouse_world_end = mouse_point_global + mouse_direction_global * depth;
if (!LLViewerJoystick::getInstance()->getOverrideCamera())
{ //always set raycast intersection to mouse_world_end unless
//flycam is on (for DoF effect)
gDebugRaycastIntersection = mouse_world_end;
}
if (start)
{
*start = mouse_world_start;
}
if (end)
{
*end = mouse_world_end;
}
LLViewerObject* found = NULL;
if (this_object) // check only this object
@@ -3787,16 +3813,16 @@ LLVector3 LLViewerWindow::mouseDirectionGlobal(const S32 x, const S32 y) const
// find vertical field of view
F32 fov = LLViewerCamera::getInstance()->getView();
// find screen resolution
S32 height = getWindowHeight();
S32 width = getWindowWidth();
// find world view center in scaled ui coordinates
F32 center_x = getWorldViewRectScaled().getCenterX();
F32 center_y = getWorldViewRectScaled().getCenterY();
// calculate pixel distance to screen
F32 distance = (height / 2.f) / (tan(fov / 2.f));
F32 distance = ((F32)getWorldViewHeightScaled() * 0.5f) / (tan(fov / 2.f));
// calculate click point relative to middle of screen
F32 click_x = x - width / 2.f;
F32 click_y = y - height / 2.f;
F32 click_x = x - center_x;
F32 click_y = y - center_y;
// compute mouse vector
LLVector3 mouse_vector = distance * LLViewerCamera::getInstance()->getAtAxis()
@@ -3811,12 +3837,15 @@ LLVector3 LLViewerWindow::mouseDirectionGlobal(const S32 x, const S32 y) const
LLVector3 LLViewerWindow::mousePointHUD(const S32 x, const S32 y) const
{
// find screen resolution
S32 height = getWindowHeight();
S32 width = getWindowWidth();
S32 height = getWorldViewHeightScaled();
// find world view center
F32 center_x = getWorldViewRectScaled().getCenterX();
F32 center_y = getWorldViewRectScaled().getCenterY();
// remap with uniform scale (1/height) so that top is -0.5, bottom is +0.5
F32 hud_x = -((F32)x - (F32)width/2.f) / height;
F32 hud_y = ((F32)y - (F32)height/2.f) / height;
F32 hud_x = -((F32)x - center_x) / height;
F32 hud_y = ((F32)y - center_y) / height;
return LLVector3(0.f, hud_x/gAgentCamera.mHUDCurZoom, hud_y/gAgentCamera.mHUDCurZoom);
}
@@ -3830,12 +3859,16 @@ LLVector3 LLViewerWindow::mouseDirectionCamera(const S32 x, const S32 y) const
F32 fov_width = fov_height * LLViewerCamera::getInstance()->getAspect();
// find screen resolution
S32 height = getWindowHeight();
S32 width = getWindowWidth();
S32 height = getWorldViewHeightScaled();
S32 width = getWorldViewWidthScaled();
// find world view center
F32 center_x = getWorldViewRectScaled().getCenterX();
F32 center_y = getWorldViewRectScaled().getCenterY();
// calculate click point relative to middle of screen
F32 click_x = (((F32)x / (F32)width) - 0.5f) * fov_width * -1.f;
F32 click_y = (((F32)y / (F32)height) - 0.5f) * fov_height;
F32 click_x = (((F32)x - center_x) / (F32)width) * fov_width * -1.f;
F32 click_y = (((F32)y - center_y) / (F32)height) * fov_height;
// compute mouse vector
LLVector3 mouse_vector = LLVector3(0.f, 0.f, -1.f);
@@ -4086,8 +4119,8 @@ void LLViewerWindow::movieSize(S32 new_width, S32 new_height)
||(size.mY != new_height + BORDERHEIGHT))
{
// use actual display dimensions, not virtual UI dimensions
S32 x = gViewerWindow->getWindowDisplayWidth();
S32 y = gViewerWindow->getWindowDisplayHeight();
S32 x = gViewerWindow->getWindowWidthRaw();
S32 y = gViewerWindow->getWindowHeightRaw();
BORDERWIDTH = size.mX - x;
BORDERHEIGHT = size.mY- y;
LLCoordScreen new_size(new_width + BORDERWIDTH,
@@ -4185,9 +4218,9 @@ BOOL LLViewerWindow::thumbnailSnapshot(LLImageRaw *raw, S32 preview_width, S32 p
S32 w = preview_width ;
S32 h = preview_height ;
LLVector2 display_scale = mDisplayScale ;
mDisplayScale.setVec((F32)w / mWindowRect.getWidth(), (F32)h / mWindowRect.getHeight()) ;
mDisplayScale.setVec((F32)w / mWindowRectRaw.getWidth(), (F32)h / mWindowRectRaw.getHeight()) ;
LLRect window_rect = mWindowRect;
mWindowRect.set(0, h, w, 0);
mWindowRectRaw.set(0, h, w, 0);
gDisplaySwapBuffers = FALSE;
gDepthDirty = TRUE;
@@ -4316,10 +4349,11 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
LLPipeline::sShowHUDAttachments = FALSE;
}
// Copy screen to a buffer
// crop sides or top and bottom, if taking a snapshot of different aspect ratio
// from window
LLRect window_rect = mWindowRect;
LLRect window_rect = show_ui ? getWindowRectRaw() : getWorldViewRectRaw();
S32 snapshot_width = window_rect.getWidth();
S32 snapshot_height = window_rect.getHeight();
@@ -4386,7 +4420,7 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
window_width = snapshot_width;
window_height = snapshot_height;
scale_factor = 1.f;
mWindowRect.set(0, snapshot_height, snapshot_width, 0);
mWindowRectRaw.set(0, snapshot_height, snapshot_width, 0);
target.bindTarget();
}
}
@@ -4640,41 +4674,55 @@ void LLViewerWindow::drawMouselookInstructions()
S32 LLViewerWindow::getWindowHeight() const
{
return mVirtualWindowRect.getHeight();
return mWindowRectScaled.getHeight();
}
S32 LLViewerWindow::getWindowWidth() const
{
return mVirtualWindowRect.getWidth();
return mWindowRectScaled.getWidth();
}
S32 LLViewerWindow::getWindowDisplayHeight() const
{
return mWindowRect.getHeight();
return mWindowRectRaw.getHeight();
}
S32 LLViewerWindow::getWindowDisplayWidth() const
{
return mWindowRect.getWidth();
}
void LLViewerWindow::setupViewport(S32 x_offset, S32 y_offset)
{
gGLViewport[0] = x_offset;
gGLViewport[1] = y_offset;
gGLViewport[2] = mWindowRect.getWidth();
gGLViewport[3] = mWindowRect.getHeight();
glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]);
}
void LLViewerWindow::setup3DRender()
{
LLViewerCamera::getInstance()->setPerspective(NOT_FOR_SELECTION, 0, 0, mWindowRect.getWidth(), mWindowRect.getHeight(), FALSE, LLViewerCamera::getInstance()->getNear(), MAX_FAR_CLIP*2.f);
return mWindowRectRaw.getWidth();
}
void LLViewerWindow::setup2DRender()
{
gl_state_for_2d(mWindowRect.getWidth(), mWindowRect.getHeight());
// setup ortho camera
gl_state_for_2d(mWindowRectRaw.getWidth(), mWindowRectRaw.getHeight());
setup2DViewport();
}
void LLViewerWindow::setup2DViewport(S32 x_offset, S32 y_offset)
{
gGLViewport[0] = mWindowRectRaw.mLeft + x_offset;
gGLViewport[1] = mWindowRectRaw.mBottom + y_offset;
gGLViewport[2] = mWindowRectRaw.getWidth();
gGLViewport[3] = mWindowRectRaw.getHeight();
glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]);
}
void LLViewerWindow::setup3DRender()
{
// setup perspective camera
LLViewerCamera::getInstance()->setPerspective(NOT_FOR_SELECTION, getWindowRectRaw().mLeft, getWindowRectRaw().mBottom, getWindowRectRaw().getWidth(), getWindowRectRaw().getHeight(), FALSE, LLViewerCamera::getInstance()->getNear(), MAX_FAR_CLIP*2.f);
setup3DViewport();
}
void LLViewerWindow::setup3DViewport(S32 x_offset, S32 y_offset)
{
gGLViewport[0] = getWindowRectRaw().mLeft + x_offset;
gGLViewport[1] = getWindowRectRaw().mBottom + y_offset;
gGLViewport[2] = getWindowRectRaw().getWidth();
gGLViewport[3] = getWindowRectRaw().getHeight();
glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]);
}
@@ -4927,7 +4975,7 @@ BOOL LLViewerWindow::checkSettings()
getWindow()->setNativeAspectRatio(gSavedSettings.getF32("FullScreenAspectRatio"));
}
reshape(getWindowDisplayWidth(), getWindowDisplayHeight());
reshape(getWindowWidthRaw(), getWindowHeightRaw());
// force aspect ratio
if (mIsFullscreenChecked)
@@ -5161,7 +5209,7 @@ void LLViewerWindow::calcDisplayScale()
F32 ui_scale_factor = gSavedSettings.getF32("UIScaleFactor");
LLVector2 display_scale;
display_scale.setVec(llmax(1.f / mWindow->getPixelAspectRatio(), 1.f), llmax(mWindow->getPixelAspectRatio(), 1.f));
F32 height_normalization = gSavedSettings.getBOOL("UIAutoScale") ? ((F32)mWindowRect.getHeight() / display_scale.mV[VY]) / 768.f : 1.f;
F32 height_normalization = gSavedSettings.getBOOL("UIAutoScale") ? ((F32)mWindowRectRaw.getHeight() / display_scale.mV[VY]) / 768.f : 1.f;
if(mWindow->getFullscreen())
{
display_scale *= (ui_scale_factor * height_normalization);
@@ -5179,8 +5227,8 @@ void LLViewerWindow::calcDisplayScale()
if (mWindow->getFullscreen())
{
display_scale.mV[0] = llround(display_scale.mV[0], 2.0f/(F32) mWindowRect.getWidth());
display_scale.mV[1] = llround(display_scale.mV[1], 2.0f/(F32) mWindowRect.getHeight());
display_scale.mV[0] = llround(display_scale.mV[0], 2.0f/(F32) mWindowRectRaw.getWidth());
display_scale.mV[1] = llround(display_scale.mV[1], 2.0f/(F32) mWindowRectRaw.getHeight());
}
if (display_scale != mDisplayScale)
@@ -5204,7 +5252,7 @@ S32 LLViewerWindow::getChatConsoleBottomPad()
LLRect LLViewerWindow::getChatConsoleRect()
{
LLRect full_window(0, getWindowHeight(), getWindowWidth(), 0);
LLRect full_window(0, getWindowHeightScaled(), getWindowWidthScaled(), 0);
LLRect console_rect = full_window;
const S32 CONSOLE_PADDING_TOP = 24;
@@ -5225,7 +5273,7 @@ LLRect LLViewerWindow::getChatConsoleRect()
{
// Make console rect somewhat narrow so having inventory open is
// less of a problem.
console_rect.mRight = console_rect.mLeft + 2 * getWindowWidth() / 3;
console_rect.mRight = console_rect.mLeft + 2 * getWindowWidthScaled() / 3;
}
return console_rect;
@@ -5374,9 +5422,9 @@ void LLPickInfo::fetchResults()
//glReadPixels(mScreenRegion.mLeft, mScreenRegion.mBottom, mScreenRegion.getWidth(), mScreenRegion.getHeight(), GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, mPickDepthBuffer );
// find pick region that is fully onscreen
LLCoordGL scaled_pick_point;;
scaled_pick_point.mX = llclamp(llround((F32)mMousePt.mX * gViewerWindow->getDisplayScale().mV[VX]), PICK_HALF_WIDTH, gViewerWindow->getWindowDisplayWidth() - PICK_HALF_WIDTH);
scaled_pick_point.mY = llclamp(llround((F32)mMousePt.mY * gViewerWindow->getDisplayScale().mV[VY]), PICK_HALF_WIDTH, gViewerWindow->getWindowDisplayHeight() - PICK_HALF_WIDTH);
//LLCoordGL scaled_pick_point;;
//scaled_pick_point.mX = llclamp(llround((F32)mMousePt.mX * gViewerWindow->getDisplayScale().mV[VX]), PICK_HALF_WIDTH, gViewerWindow->getWindowDisplayWidth() - PICK_HALF_WIDTH);
//scaled_pick_point.mY = llclamp(llround((F32)mMousePt.mY * gViewerWindow->getDisplayScale().mV[VY]), PICK_HALF_WIDTH, gViewerWindow->getWindowDisplayHeight() - PICK_HALF_WIDTH);
//S32 pixel_index = PICK_HALF_WIDTH * PICK_DIAMETER + PICK_HALF_WIDTH;
//S32 pick_id = (U32)mPickBuffer[(pixel_index * 4) + 0] << 16 | (U32)mPickBuffer[(pixel_index * 4) + 1] << 8 | (U32)mPickBuffer[(pixel_index * 4) + 2];
//F32 depth = mPickDepthBuffer[pixel_index];

View File

@@ -190,20 +190,20 @@ public:
LLView* getRootView() const { return mRootView; }
// Window in raw pixels as seen on screen.
const LLRect& getWindowRect() const { return mWindowRect; };
const LLRect& getWindowRect() const { return mWindowRectRaw; };
S32 getWindowDisplayHeight() const;
S32 getWindowDisplayWidth() const;
//Temporary wrappers.
const LLRect& getWindowRectRaw() const { return getWindowRect(); }
S32 getWindowHeightRaw() const { return getWindowDisplayHeight(); }
S32 getWindowWidthRaw() const { return getWindowDisplayWidth(); }
const LLRect& getWorldviewRectRaw() const { return getWindowRect(); }
const LLRect& getWorldViewRectRaw() const { return getWindowRect(); }
S32 getWorldViewHeightRaw() const { return getWindowDisplayHeight(); }
S32 getWorldViewWidthRaw() const { return getWindowDisplayWidth(); }
// Window in scaled pixels (via UI scale), use this for
// UI elements checking size.
const LLRect& getVirtualWindowRect() const { return mVirtualWindowRect; };
const LLRect& getVirtualWindowRect() const { return mWindowRectScaled; };
S32 getWindowHeight() const;
S32 getWindowWidth() const;
//Temporary wrappers.
@@ -236,7 +236,8 @@ public:
const LLPickInfo& getLastPick() const { return mLastPick; }
const LLPickInfo& getHoverPick() const { return mHoverPick; }
void setupViewport(S32 x_offset = 0, S32 y_offset = 0);
void setup2DViewport(S32 x_offset = 0, S32 y_offset = 0);
void setup3DViewport(S32 x_offset = 0, S32 y_offset = 0);
void setup3DRender();
void setup2DRender();
@@ -341,7 +342,9 @@ public:
LLVector3 *intersection = NULL,
LLVector2 *uv = NULL,
LLVector3 *normal = NULL,
LLVector3 *binormal = NULL);
LLVector3 *binormal = NULL,
LLVector3* start = NULL,
LLVector3* end = NULL);
// Returns a pointer to the last object hit
@@ -396,9 +399,9 @@ protected:
BOOL mActive;
BOOL mWantFullscreen;
BOOL mShowFullscreenProgress;
LLRect mWindowRect;
LLRect mVirtualWindowRect;
LLView* mRootView; // a view of size mWindowRect, containing all child views
LLRect mWindowRectRaw;
LLRect mWindowRectScaled;
LLView* mRootView; // a view of size mWindowRectRaw, containing all child views
LLVector2 mDisplayScale;
LLCoordGL mCurrentMousePoint; // last mouse position in GL coords

View File

@@ -4465,34 +4465,39 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
if (visible && !isSelf() && !mIsDummy && sUseImpostors && !mNeedsAnimUpdate && !sFreezeCounter)
{
const LLVector4a* ext = mDrawable->getSpatialExtents();
LLVector4a size;
size.setSub(ext[1],ext[0]);
F32 mag = size.getLength3().getF32()*0.5f;
F32 impostor_area = 256.f*512.f*(8.125f - LLVOAvatar::sLODFactor*8.f);
if (LLMuteList::getInstance()->isMuted(getID()))
{ // muted avatars update at 16 hz
mUpdatePeriod = 16;
}
else if (mVisibilityRank <= LLVOAvatar::sMaxVisible * 0.25f)
else if (mVisibilityRank <= LLVOAvatar::sMaxVisible ||
mDrawable->mDistanceWRTCamera < 1.f + mag)
{ //first 25% of max visible avatars are not impostored
//also, don't impostor avatars whose bounding box may be penetrating the
//impostor camera near clip plane
mUpdatePeriod = 1;
}
else if (mVisibilityRank > LLVOAvatar::sMaxVisible * 0.75f)
{ //back 25% of max visible avatars are slow updating impostors
mUpdatePeriod = 8;
}
else if (mVisibilityRank > (U32) LLVOAvatar::sMaxVisible)
else if (mVisibilityRank > LLVOAvatar::sMaxVisible * 4)
{ //background avatars are REALLY slow updating impostors
mUpdatePeriod = 16;
}
else if (mVisibilityRank > LLVOAvatar::sMaxVisible * 3)
{ //back 25% of max visible avatars are slow updating impostors
mUpdatePeriod = 8;
}
else if (mImpostorPixelArea <= impostor_area)
{ // stuff in between gets an update period based on pixel area
mUpdatePeriod = llclamp((S32) sqrtf(impostor_area*4.f/mImpostorPixelArea), 2, 8);
}
else if (mVisibilityRank > LLVOAvatar::sMaxVisible * 0.25f)
{ // force nearby impostors in ultra crowded areas
mUpdatePeriod = 2;
}
else
{ // not impostored
mUpdatePeriod = 1;
{
//nearby avatars, update the impostors more frequently.
mUpdatePeriod = 4;
}
visible = (LLDrawable::getCurrentFrame()+mID.mData[0])%mUpdatePeriod == 0 ? TRUE : FALSE;
@@ -10021,7 +10026,7 @@ void LLVOAvatar::cullAvatarsByPixelArea()
std::sort(LLCharacter::sInstances.begin(), LLCharacter::sInstances.end(), CompareScreenAreaGreater());
// Update the avatars that have changed status
U32 rank = 0;
U32 rank = 2; //1 is reserved for self.
for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin();
iter != LLCharacter::sInstances.end(); ++iter)
{
@@ -10045,7 +10050,7 @@ void LLVOAvatar::cullAvatarsByPixelArea()
if (inst->isSelf())
{
inst->setVisibilityRank(0);
inst->setVisibilityRank(1);
}
else if (inst->mDrawable.notNull() && inst->mDrawable->isVisible())
{

View File

@@ -243,14 +243,15 @@ void LLVOTextBubble::getGeometry(S32 idx,
LLColor4U color = LLColor4U(getTE(idx)->getColor());
U32 offset = mDrawable->getFace(idx)->getGeomIndex();
normalsp.assignArray((U8*)face.mNormals, sizeof(face.mNormals[0]), face.mNumVertices);
texcoordsp.assignArray((U8*)face.mTexCoords, sizeof(face.mTexCoords[0]), face.mNumVertices);
for (U32 i = 0; i < (U32)face.mNumVertices; i++)
{
LLVector4a vertpos;
vertpos.setMul(face.mPositions[i],scale);
vertpos.add(pos);
(verticesp++)->set(vertpos.getF32ptr());
(normalsp++)->set(face.mNormals[i].getF32ptr());
*texcoordsp++ = face.mTexCoords[i];
LLVector4a t;
t.setMul(face.mPositions[i],scale);
((LLVector4a*)(verticesp++))->setAdd(t,pos);
*colorsp++ = color;
}

View File

@@ -2562,8 +2562,15 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& e
end_face = face+1;
}
bool special_cursor = specialHoverCursor();
for (S32 i = start_face; i < end_face; ++i)
{
if (!special_cursor && !pick_transparent && getTE(i)->getColor().mV[3] == 0.f)
{ //don't attempt to pick completely transparent faces unless
//pick_transparent is true
continue;
}
face_hit = volume->lineSegmentIntersect(v_start, v_end, i,
&p, &tc, &n, &bn);

View File

@@ -286,6 +286,11 @@ void LLVOWater::updateSpatialExtents(LLVector4a &newMin, LLVector4a& newMax)
U32 LLVOWater::getPartitionType() const
{
if (mIsEdgePatch)
{
return LLViewerRegion::PARTITION_VOIDWATER;
}
return LLViewerRegion::PARTITION_WATER;
}
@@ -304,6 +309,7 @@ LLWaterPartition::LLWaterPartition()
LLVoidWaterPartition::LLVoidWaterPartition()
{
mOcclusionEnabled = FALSE;
mDrawableType = LLPipeline::RENDER_TYPE_VOIDWATER;
mPartitionType = LLViewerRegion::PARTITION_VOIDWATER;
}

View File

@@ -754,13 +754,13 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples)
if (LLPipeline::sRenderDeferred)
{ //share depth buffer between deferred targets
mDeferredScreen.shareDepthBuffer(mScreen);
for (U32 i = 0; i < 3; i++)
/*for (U32 i = 0; i < 3; i++)
{ //share stencil buffer with screen space lightmap to stencil out sky
if (mDeferredLight[i].getTexture(0))
{
mDeferredScreen.shareDepthBuffer(mDeferredLight[i]);
}
}
}*/
}
gGL.getTexUnit(0)->disable();
@@ -5924,8 +5924,6 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
tc2 /= (F32) res_mod.get();
}
gGL.setColorMask(true, true);
LLFastTimer ftm(LLFastTimer::FTM_RENDER_BLOOM);
gGL.color4f(1,1,1,1);
LLGLDepthTest depth(GL_FALSE);
@@ -6021,11 +6019,8 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT);
gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA);
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
gGL.getTexUnit(0)->disable();
gGL.getTexUnit(0)->enable(LLTexUnit::TT_RECT_TEXTURE);
gGL.getTexUnit(0)->bind(&mScreen);
mScreen.bindTexture(0, 0);
gGL.color4f(1,1,1,1);
gPipeline.enableLightsFullbright(LLColor4(1,1,1,1));
gGL.begin(LLRender::TRIANGLE_STRIP);
@@ -6040,7 +6035,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
gGL.end();
gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
gGL.getTexUnit(0)->unbind(mScreen.getUsage());
mGlow[2].flush();
}
@@ -6070,7 +6065,6 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
for (S32 i = 0; i < kernel; i++)
{
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
{
LLFastTimer ftm(LLFastTimer::FTM_RENDER_BLOOM_FBO);
mGlow[i%2].bindTarget();
@@ -6118,7 +6112,11 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
gViewerWindow->setupViewport();
gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft;
gGLViewport[1] = gViewerWindow->getWorldViewRectRaw().mBottom;
gGLViewport[2] = gViewerWindow->getWorldViewRectRaw().getWidth();
gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight();
glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]);
tc2.setVec((F32) gViewerWindow->getWorldViewWidthRaw(),
(F32) gViewerWindow->getWorldViewHeightRaw());
@@ -6138,7 +6136,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
shader = &gDeferredGIFinalProgram;
dof_enabled = false;
}
else if (LLToolMgr::getInstance()->inBuildMode() || !render_dof)
else if (!dof_enabled || LLToolMgr::getInstance()->inBuildMode() || !render_dof)
{ //squish focal length when in build mode (or if DoF is disabled) so DoF doesn't make editing objects difficult
shader = &gDeferredPostNoDoFProgram;
dof_enabled = false;
@@ -6262,7 +6260,7 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield, b
shader->uniform1f("magnification", magnification);
}
S32 channel = shader->enableTexture(LLViewerShaderMgr::DEFERRED_DIFFUSE, LLTexUnit::TT_RECT_TEXTURE);
S32 channel = shader->enableTexture(LLViewerShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage());
if (channel > -1)
{
mScreen.bindTexture(0, channel);
@@ -6389,25 +6387,23 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRen
noise_map = mNoiseMap;
}
//LLGLState::checkTextureChannels();
shader.bind();
S32 channel = 0;
channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_DIFFUSE, LLTexUnit::TT_RECT_TEXTURE);
channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_DIFFUSE, mDeferredScreen.getUsage());
if (channel > -1)
{
mDeferredScreen.bindTexture(0,channel);
gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
}
channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_SPECULAR, LLTexUnit::TT_RECT_TEXTURE);
channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_SPECULAR, mDeferredScreen.getUsage());
if (channel > -1)
{
mDeferredScreen.bindTexture(1, channel);
gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
}
channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_NORMAL, LLTexUnit::TT_RECT_TEXTURE);
channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_NORMAL, mDeferredScreen.getUsage());
if (channel > -1)
{
mDeferredScreen.bindTexture(2, channel);
@@ -6489,14 +6485,6 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRen
gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR);
}
channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_GI_LIGHT, LLTexUnit::TT_RECT_TEXTURE);
if (channel > -1)
{
has_gi = TRUE;
gi_source->bindTexture(0, channel);
gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
}
channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_GI_DEPTH);
if (channel > -1)
{
@@ -6538,16 +6526,17 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRen
shader.uniformMatrix4fv("gi_norm_mat", 1, FALSE, mGINormalMatrix.m);
}
}
stop_glerror();
channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_DEPTH, LLTexUnit::TT_RECT_TEXTURE);
channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_DEPTH, mDeferredDepth.getUsage());
if (channel > -1)
{
gGL.getTexUnit(channel)->bind(&mDeferredDepth, TRUE);
gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
//gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
stop_glerror();
glTexParameteri(LLTexUnit::getInternalType(mDeferredDepth.getUsage()), GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
glTexParameteri(LLTexUnit::getInternalType(mDeferredDepth.getUsage()), GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA);
//glTexParameteri(LLTexUnit::getInternalType(mDeferredDepth.getUsage()), GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
//glTexParameteri(LLTexUnit::getInternalType(mDeferredDepth.getUsage()), GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA);
stop_glerror();
@@ -6576,7 +6565,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRen
stop_glerror();
channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_LIGHT, LLTexUnit::TT_RECT_TEXTURE);
channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_LIGHT, mDeferredLight[light_index].getUsage());
if (channel > -1)
{
mDeferredLight[light_index].bindTexture(0, channel);
@@ -6596,6 +6585,13 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, LLRen
mGlow[1].bindTexture(0, channel);
}
channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_GI_LIGHT, LLTexUnit::TT_RECT_TEXTURE);
if (channel > -1)
{
gi_source->bindTexture(0, channel);
gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
}
channel = shader.enableTexture(LLViewerShaderMgr::DEFERRED_EDGE, LLTexUnit::TT_RECT_TEXTURE);
if (channel > -1)
{
@@ -6808,9 +6804,9 @@ void LLPipeline::renderDeferredLighting()
}
//ati doesn't seem to love actually using the stencil buffer on FBO's
LLGLEnable stencil(GL_STENCIL_TEST);
glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
LLGLDisable stencil(GL_STENCIL_TEST);
//glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF);
//glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
gGL.setColorMask(true, true);
@@ -7662,16 +7658,15 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep)
void LLPipeline::unbindDeferredShader(LLGLSLShader &shader)
{
stop_glerror();
shader.disableTexture(LLViewerShaderMgr::DEFERRED_POSITION, LLTexUnit::TT_RECT_TEXTURE);
shader.disableTexture(LLViewerShaderMgr::DEFERRED_NORMAL, LLTexUnit::TT_RECT_TEXTURE);
shader.disableTexture(LLViewerShaderMgr::DEFERRED_DIFFUSE, LLTexUnit::TT_RECT_TEXTURE);
shader.disableTexture(LLViewerShaderMgr::DEFERRED_SPECULAR, LLTexUnit::TT_RECT_TEXTURE);
shader.disableTexture(LLViewerShaderMgr::DEFERRED_DEPTH, LLTexUnit::TT_RECT_TEXTURE);
shader.disableTexture(LLViewerShaderMgr::DEFERRED_LIGHT, LLTexUnit::TT_RECT_TEXTURE);
shader.disableTexture(LLViewerShaderMgr::DEFERRED_NORMAL, mDeferredScreen.getUsage());
shader.disableTexture(LLViewerShaderMgr::DEFERRED_DIFFUSE, mDeferredScreen.getUsage());
shader.disableTexture(LLViewerShaderMgr::DEFERRED_SPECULAR, mDeferredScreen.getUsage());
shader.disableTexture(LLViewerShaderMgr::DEFERRED_DEPTH, mDeferredScreen.getUsage());
shader.disableTexture(LLViewerShaderMgr::DEFERRED_LIGHT, mDeferredLight[0].getUsage());
shader.disableTexture(LLViewerShaderMgr::DEFERRED_GI_LIGHT, LLTexUnit::TT_RECT_TEXTURE);
shader.disableTexture(LLViewerShaderMgr::DEFERRED_EDGE, LLTexUnit::TT_RECT_TEXTURE);
shader.disableTexture(LLViewerShaderMgr::DEFERRED_SUN_LIGHT, LLTexUnit::TT_RECT_TEXTURE);
shader.disableTexture(LLViewerShaderMgr::DEFERRED_LOCAL_LIGHT, LLTexUnit::TT_RECT_TEXTURE);
shader.disableTexture(LLViewerShaderMgr::DEFERRED_EDGE, mEdgeMap.getUsage());
shader.disableTexture(LLViewerShaderMgr::DEFERRED_SUN_LIGHT, mDeferredLight[1].getUsage());
shader.disableTexture(LLViewerShaderMgr::DEFERRED_LOCAL_LIGHT, mDeferredLight[2].getUsage());
shader.disableTexture(LLViewerShaderMgr::DEFERRED_LUMINANCE);
shader.disableTexture(LLViewerShaderMgr::DIFFUSE_MAP);
shader.disableTexture(LLViewerShaderMgr::DEFERRED_GI_MIP);
@@ -7953,12 +7948,12 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
glClear(GL_DEPTH_BUFFER_BIT);
}
glClearColor(0.f, 0.f, 0.f, 0.f);
gViewerWindow->setupViewport();
gViewerWindow->setup3DViewport();
gPipeline.popRenderTypeMask();
LLDrawPoolWater::sNeedsReflectionUpdate = FALSE;
LLDrawPoolWater::sNeedsDistortionUpdate = FALSE;
LLViewerCamera::getInstance()->setUserClipPlane(LLPlane(-pnorm, -pd));
LLPlane npnorm(-pnorm, -pd);
LLViewerCamera::getInstance()->setUserClipPlane(npnorm);
LLGLState::checkStates();
//LLGLState::checkTextureChannels();
@@ -7989,7 +7984,6 @@ glh::matrix4f look(const LLVector3 pos, const LLVector3 dir, const LLVector3 up)
dirN = dir;
dirN.normVec();
ret.m[ 0] = lftN[0];
ret.m[ 1] = upN[0];
@@ -8573,12 +8567,13 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
//F32 nearDist[] = { n.mV[0], n.mV[1], n.mV[2], n.mV[2] };
//put together a universal "near clip" plane for shadow frusta
/*LLPlane shadow_near_clip;
LLPlane shadow_near_clip;
{
LLVector3 p = gAgentCamera.getCameraPositionAgent();//gAgent.getPositionAgent();
p += mSunDir * gSavedSettings.getF32("RenderFarClip")*2.f;
LLVector3 p = gAgent.getPositionAgent();//gAgentCamera.getCameraPositionAgent();
static const LLCachedControl<F32> render_far_clip("RenderFarClip");
p += mSunDir * render_far_clip*2.f;
shadow_near_clip.setVec(p, mSunDir);
}*/
}
LLVector3 lightDir = -mSunDir;
lightDir.normVec();
@@ -8654,7 +8649,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
near_clip = -max.mV[2];
F32 far_clip = -min.mV[2]*2.f;
far_clip = llmin(far_clip, 128.f);
//far_clip = llmin(far_clip, 128.f);
far_clip = llmin(far_clip, camera.getFar());
F32 range = far_clip-near_clip;
@@ -8947,11 +8942,6 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
fovx = acos(fovx);
fovz = acos(fovz);
if (fovx > cutoff || llround(fovz, 0.01f) > cutoff)
{
// llerrs << "WTF?" << llendl;
}
mShadowFOV.mV[j] = cutoff;
}
@@ -9017,8 +9007,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE);
shadow_cam.ignoreAgentFrustumPlane(LLCamera::AGENT_PLANE_NEAR);
//shadow_cam.getAgentPlane(LLCamera::AGENT_PLANE_NEAR).set(shadow_near_clip);
//shadow_cam.ignoreAgentFrustumPlane(LLCamera::AGENT_PLANE_NEAR);
shadow_cam.getAgentPlane(LLCamera::AGENT_PLANE_NEAR).set(shadow_near_clip);
//translate and scale to from [-1, 1] to [0, 1]
glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f,
@@ -9369,9 +9359,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
glClearColor(0.0f,0.0f,0.0f,0.0f);
gGL.setColorMask(true, true);
glStencilMask(0xFFFFFFFF);
glClearStencil(0);
// get the number of pixels per angle
F32 pa = gViewerWindow->getWindowHeightRaw() / (RAD_TO_DEG * viewer_camera->getView());
@@ -9382,61 +9370,43 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
if (!avatar->mImpostor.isComplete() || resX != avatar->mImpostor.getWidth() ||
resY != avatar->mImpostor.getHeight())
{
static const LLCachedControl<bool> shadow_precision("DeferredHighPrecision",true); //TO-DO: Profile 16bit format later
avatar->mImpostor.allocate(resX,resY, (!LLPipeline::sRenderDeferred || shadow_precision) ? GL_RGBA : GL_RGBA16F_ARB,TRUE,TRUE);
if (LLPipeline::sRenderDeferred)
{
static const LLCachedControl<bool> shadow_precision("DeferredHighPrecision",true);
const GLuint format = shadow_precision ? GL_RGBA : GL_RGBA16F_ARB; //TO-DO: Profile 16bit format later
avatar->mImpostor.allocate(resX,resY,format,TRUE,TRUE);
addDeferredAttachments(avatar->mImpostor);
}
else
{
avatar->mImpostor.allocate(resX,resY,GL_RGBA,TRUE,TRUE);
}
gGL.getTexUnit(0)->bind(&avatar->mImpostor);
gGL.getTexUnit(0)->setTextureFilteringOption(LLTexUnit::TFO_POINT);
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
}
LLGLEnable stencil(GL_STENCIL_TEST);
glStencilMask(0xFFFFFFFF);
glStencilFunc(GL_ALWAYS, 1, 0xFFFFFFFF);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
avatar->mImpostor.bindTarget();
{
LLGLEnable scissor(GL_SCISSOR_TEST);
glScissor(0, 0, resX, resY);
avatar->mImpostor.bindTarget();
avatar->mImpostor.clear();
}
if (LLPipeline::sRenderDeferred)
{
stop_glerror();
avatar->mImpostor.clear();
renderGeomDeferred(camera);
renderGeomPostDeferred(camera);
}
else
{
LLGLEnable scissor(GL_SCISSOR_TEST);
glScissor(0, 0, resX, resY);
avatar->mImpostor.clear();
renderGeom(camera);
}
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
glStencilFunc(GL_EQUAL, 1, 0xFFFFFF);
//if (!sRenderDeferred || muted)
{
LLVector3 left = camera.getLeftAxis()*tdim.mV[0]*2.f;
LLVector3 up = camera.getUpAxis()*tdim.mV[1]*2.f;
//Safe??
{ //create alpha mask based on depth buffer (grey out if muted)
if (LLPipeline::sRenderDeferred)
{
GLuint buff = GL_COLOR_ATTACHMENT0_EXT;
glDrawBuffersARB(1, &buff);
}
LLGLEnable blend(muted ? 0 : GL_BLEND);
LLGLDisable blend(GL_BLEND);
if (muted)
{
@@ -9447,25 +9417,34 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
gGL.setColorMask(false, true);
}
gGL.setSceneBlendType(LLRender::BT_ADD);
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
LLGLDepthTest depth(GL_FALSE, GL_FALSE);
LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_GREATER);
gGL.flush();
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
static const F32 clip_plane = 0.99999f;
gGL.color4f(1,1,1,1);
gGL.color4ub(64,64,64,255);
gGL.begin(LLRender::QUADS);
gGL.vertex3fv((pos+left-up).mV);
gGL.vertex3fv((pos-left-up).mV);
gGL.vertex3fv((pos-left+up).mV);
gGL.vertex3fv((pos+left+up).mV);
gGL.vertex3f(-1, -1, clip_plane);
gGL.vertex3f(1, -1, clip_plane);
gGL.vertex3f(1, 1, clip_plane);
gGL.vertex3f(-1, 1, clip_plane);
gGL.end();
gGL.flush();
gGL.setSceneBlendType(LLRender::BT_ALPHA);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
}
avatar->mImpostor.flush();
avatar->setImpostorDim(tdim);