Merge branch 'master' of git@github.com:Shyotl/SingularityViewer.git

This commit is contained in:
Shyotl
2018-04-09 02:36:30 -05:00
12 changed files with 280 additions and 174 deletions

View File

@@ -65,6 +65,7 @@ public:
// currently unused
};
public:
virtual void postInitialized() {}
virtual void show() = 0;
virtual void hide() = 0;
virtual void close() = 0;

View File

@@ -185,6 +185,11 @@ void LLWindowCallbacks::handleResumeWatchdog(LLWindow *window)
}
bool LLWindowCallbacks::handleDPIScaleChange(LLWindow *window, float xDPIScale, float yDPIScale, U32 width, U32 height)
{
return false;
}
std::string LLWindowCallbacks::translateString(const char* tag)
{
return std::string();

View File

@@ -79,7 +79,8 @@ public:
DND_LINK // Drop accepted would result in a "link" operation
};
virtual DragNDropResult handleDragNDrop(LLWindow *window, LLCoordGL pos, MASK mask, DragNDropAction action, std::string data);
virtual bool handleDPIScaleChange(LLWindow *window, float xDPIScale, float yDPIScale, U32 width = 0, U32 height = 0);
virtual void handlePingWatchdog(LLWindow *window, const char * msg);
virtual void handlePauseWatchdog(LLWindow *window);
virtual void handleResumeWatchdog(LLWindow *window);

View File

@@ -53,6 +53,7 @@
#include <shellapi.h>
#include <fstream>
#include <Imm.h>
#include <ShellScalingAPI.h>
// Require DirectInput version 8
#define DIRECTINPUT_VERSION 0x0800
@@ -395,6 +396,8 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks,
mKeyVirtualKey = 0;
mhDC = NULL;
mhRC = NULL;
mUser32Lib = nullptr;
mSHCoreLib = nullptr;
LL_INFOS() << "Desired FSAA Samples = " << mFSAASamples << LL_ENDL;
@@ -659,6 +662,8 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks,
// Initialize (boot strap) the Language text input management,
// based on the system's (or user's) default settings.
allowLanguageTextInput(NULL, FALSE);
initDPIAwareness();
}
@@ -674,6 +679,16 @@ LLWindowWin32::~LLWindowWin32()
delete [] mWindowClassName;
mWindowClassName = NULL;
FreeLibrary(mUser32Lib);
FreeLibrary(mSHCoreLib);
}
void LLWindowWin32::postInitialized()
{
float xDPIScale, yDPIScale;
getDPIScales(xDPIScale, yDPIScale);
mCallbacks->handleDPIScaleChange(this, xDPIScale, yDPIScale);
}
void LLWindowWin32::show()
@@ -1774,7 +1789,50 @@ void LLWindowWin32::initCursors()
}
}
void LLWindowWin32::initDPIAwareness()
{
mUser32Lib = LoadLibrary(L"user32.dll");
mSHCoreLib = LoadLibrary(L"Shcore.dll");
if (mUser32Lib && mSHCoreLib)
{
MonitorFromWindowFn = reinterpret_cast<decltype(MonitorFromWindowFn)>(GetProcAddress(mUser32Lib, "MonitorFromWindow"));
GetDpiForMonitorFn = reinterpret_cast<decltype(GetDpiForMonitorFn)>(GetProcAddress(mSHCoreLib, "GetDpiForMonitor"));
if (MonitorFromWindowFn && GetDpiForMonitorFn)
{
HRESULT(WINAPI* SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS);
SetProcessDpiAwareness = reinterpret_cast<decltype(SetProcessDpiAwareness)>(GetProcAddress(mSHCoreLib, "SetProcessDpiAwareness"));
if (SetProcessDpiAwareness && SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE) == S_OK)
return;
BOOL(WINAPI* SetProcessDPIAware)(void);
SetProcessDPIAware = reinterpret_cast<decltype(SetProcessDPIAware)>(GetProcAddress(mUser32Lib, "SetProcessDPIAware"));
if (SetProcessDPIAware && SetProcessDPIAware())
return;
}
}
FreeLibrary(mUser32Lib);
FreeLibrary(mSHCoreLib);
mUser32Lib = nullptr;
mSHCoreLib = nullptr;
}
void LLWindowWin32::getDPIScales(float &xDPIScale, float& yDPIScale)
{
xDPIScale = yDPIScale = 1.f;
if (mUser32Lib)
{
uint32_t xDPI, yDPI;
auto window = MonitorFromWindowFn(mWindowHandle, MONITOR_DEFAULTTONEAREST);
if (GetDpiForMonitorFn(window, MDT_EFFECTIVE_DPI, &xDPI, &yDPI) == S_OK)
{
xDPIScale = (float)xDPI / (float)USER_DEFAULT_SCREEN_DPI;
yDPIScale = (float)yDPI / (float)USER_DEFAULT_SCREEN_DPI;
}
}
}
void LLWindowWin32::updateCursor()
{
@@ -2657,6 +2715,26 @@ LRESULT CALLBACK LLWindowWin32::mainWindowProc(HWND h_wnd, UINT u_msg, WPARAM w_
};
return 0;
case WM_DPICHANGED:
{
window_imp->mCallbacks->handlePingWatchdog(window_imp, "Main:WM_DPICHANGED");
if (gDebugWindowProc)
{
LL_INFOS("Window") << "WM_DPICHANGED " << LOWORD(w_param) << " " << HIWORD(w_param) << LL_ENDL;
}
LPRECT rect = (LPRECT)l_param;
S32 width = ((LPRECT)l_param)->right - ((LPRECT)l_param)->left;
S32 height = ((LPRECT)l_param)->bottom - ((LPRECT)l_param)->top;
LL_INFOS() << "rect: " << width << "x" << height << LL_ENDL;
if(window_imp->mCallbacks->handleDPIScaleChange(window_imp,
(F32)LOWORD(w_param) / (F32)USER_DEFAULT_SCREEN_DPI,
(F32)HIWORD(w_param) / (F32)USER_DEFAULT_SCREEN_DPI,
width,
height))
SetWindowPos(h_wnd, HWND_TOP, rect->left, rect->top, rect->right - rect->left, rect->bottom - rect->top, SWP_NOZORDER | SWP_NOACTIVATE);
}
return 0;
break;
}

View File

@@ -43,6 +43,7 @@ typedef void (*LLW32MsgCallback)(const MSG &msg);
class LLWindowWin32 : public LLWindow
{
public:
/*virtual*/ void postInitialized();
/*virtual*/ void show();
/*virtual*/ void hide();
/*virtual*/ void close();
@@ -129,6 +130,8 @@ protected:
void initCursors();
void initInputDevices();
void initDPIAwareness();
void getDPIScales(float& xDPIScale, float& yDPIScale);
HCURSOR loadColorCursor(LPCTSTR name);
BOOL isValid();
void moveWindow(const LLCoordScreen& position,const LLCoordScreen& size);
@@ -219,6 +222,11 @@ protected:
U32 mRawWParam;
U32 mRawLParam;
HMODULE mUser32Lib;
HMODULE mSHCoreLib;
HMONITOR(WINAPI *MonitorFromWindowFn)(HWND, DWORD);
HRESULT(WINAPI *GetDpiForMonitorFn)(HMONITOR, INT, UINT *, UINT *);
friend class LLWindowManager;
};

View File

@@ -31,7 +31,6 @@ out vec4 frag_color;
//class 1 -- no shadows
uniform sampler2D diffuseRect;
uniform sampler2D specularRect;
uniform sampler2D depthMap;
@@ -63,38 +62,33 @@ uniform float size;
VARYING vec4 vary_fragcoord;
vec3 decode_normal(vec2 enc);
uniform mat4 inv_proj;
uniform vec2 noise_scale;
vec3 decode_normal(vec2 enc);
vec4 getPosition(vec2 pos_screen);
vec3 srgb_to_linear(vec3 cs);
vec4 srgb_to_linear(vec4 cs);
vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret.rgb = srgb_to_linear(ret.rgb);
ret = srgb_to_linear(ret);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
float det = min(lod/(proj_lod*0.5), 1.0);
float d = min(dist.x, dist.y);
d *= min(1, d * (proj_lod - lod));
d *= min(1, d * (proj_lod - lod));
float edge = 0.25*det;
ret *= clamp(d/edge, 0.0, 1.0);
return ret;
}
vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret.rgb = srgb_to_linear(ret.rgb);
ret = srgb_to_linear(ret);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
float det = min(lod/(proj_lod*0.5), 1.0);
@@ -111,7 +105,7 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret.rgb = srgb_to_linear(ret.rgb);
ret = srgb_to_linear(ret);
vec2 dist = tc-vec2(0.5);
@@ -136,8 +130,9 @@ void main()
{
discard;
}
vec3 norm = texture2D(normalMap, frag.xy).xyz;
float envIntensity = norm.z;
norm = decode_normal(norm.xy);
@@ -166,12 +161,12 @@ void main()
lv = proj_origin-pos.xyz;
lv = normalize(lv);
float da = dot(norm, lv);
vec3 col = vec3(0,0,0);
vec3 diff_tex = texture2D(diffuseRect, frag.xy).rgb;
vec3 dlit = vec3(0, 0, 0);
float noise = texture2D(noiseMap, frag.xy*noise_scale).b;
if (proj_tc.z > 0.0 &&
proj_tc.x < 1.0 &&
@@ -184,32 +179,34 @@ void main()
if (da > 0.0)
{
lit = da * dist_atten * noise;
float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0);
float lod = diff * proj_lod;
vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod);
dlit = color.rgb * plcol.rgb * plcol.a;
lit = da * dist_atten * noise;
col = dlit*lit*diff_tex;
amb_da += (da*0.5)*proj_ambiance;
}
//float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0);
vec4 amb_plcol = texture2DLodAmbient(projectionMap, proj_tc.xy, proj_lod);
amb_da += (da*da*0.5+0.5)*proj_ambiance;
amb_da *= dist_atten * noise;
amb_da = min(amb_da, 1.0-lit);
col += amb_da*color.rgb*diff_tex*amb_plcol.rgb*amb_plcol.a;
col += amb_da*color*diff_tex*amb_plcol.rgb*amb_plcol.a;
}
vec4 spec = texture2D(specularRect, frag.xy);
if (spec.a > 0.0)
{
dlit *= min(da*6.0, 1.0) * dist_atten;
@@ -252,21 +249,21 @@ void main()
if (stc.z > 0.0)
{
stc /= stc.w;
float fatten = clamp(envIntensity*envIntensity+envIntensity*0.25, 0.25, 1.0);
stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5);
if (stc.x < 1.0 &&
stc.y < 1.0 &&
stc.x > 0.0 &&
stc.y > 0.0)
{
col += color.rgb*texture2DLodSpecular(projectionMap, stc.xy, proj_lod).rgb*spec.rgb;
col += color.rgb * texture2DLodSpecular(projectionMap, stc.xy, (1 - spec.a) * (proj_lod * 0.6)).rgb * envIntensity;
}
}
}
}
//not sure why, but this line prevents MATBUG-194
col = max(col, vec3(0.0));
frag_color.rgb = col;
frag_color.a = 0.0;
}

View File

@@ -23,7 +23,6 @@
* $/LicenseInfo$
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
#else
@@ -56,9 +55,10 @@ uniform float far_clip;
uniform vec3 proj_origin; //origin of projection to be used for angular attenuation
uniform float sun_wash;
uniform float size;
uniform vec3 color;
uniform float falloff;
uniform float size;
VARYING vec3 trans_center;
VARYING vec4 vary_fragcoord;
@@ -73,16 +73,15 @@ vec4 srgb_to_linear(vec4 cs);
vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret = srgb_to_linear(ret);
vec2 dist = tc-vec2(0.5);
float det = max(1.0-lod/(proj_lod*0.5), 0.0);
float d = dot(dist,dist);
ret *= min(clamp((0.25-d)/0.25, 0.0, 1.0)+det, 1.0);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
float det = min(lod/(proj_lod*0.5), 1.0);
float d = min(dist.x, dist.y);
d *= min(1, d * (proj_lod - lod));
float edge = 0.25*det;
ret *= clamp(d/edge, 0.0, 1.0);
return ret;
}
@@ -90,7 +89,7 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret = srgb_to_linear(ret);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
float det = min(lod/(proj_lod*0.5), 1.0);
@@ -132,10 +131,11 @@ void main()
{
discard;
}
vec3 norm = texture2D(normalMap, frag.xy).xyz;
float envIntensity = norm.z;
norm = decode_normal(norm.xy);
norm = normalize(norm);
@@ -162,26 +162,21 @@ void main()
lv = proj_origin-pos.xyz;
lv = normalize(lv);
float da = dot(norm, lv);
vec3 col = vec3(0,0,0);
vec3 diff_tex = texture2D(diffuseRect, frag.xy).rgb;
vec4 spec = texture2D(specularRect, frag.xy);
vec3 col = vec3(0,0,0);
vec3 diff_tex = texture2D(diffuseRect, frag.xy).rgb;
vec3 dlit = vec3(0, 0, 0);
float noise = texture2D(noiseMap, frag.xy*noise_scale).b;
vec3 dlit = vec3(0, 0, 0);
if (proj_tc.z > 0.0 &&
proj_tc.x < 1.0 &&
proj_tc.y < 1.0 &&
proj_tc.x > 0.0 &&
proj_tc.y > 0.0)
{
float amb_da = proj_ambiance;
float lit = 0.0;
float amb_da = proj_ambiance;
if (da > 0.0)
{
@@ -189,28 +184,34 @@ void main()
float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0);
float lod = diff * proj_lod;
vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod);
dlit = color.rgb * plcol.rgb * plcol.a;
col = dlit*lit*diff_tex;
//amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance;
amb_da += (da*0.5)*proj_ambiance;
}
//float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0);
vec4 amb_plcol = texture2DLodAmbient(projectionMap, proj_tc.xy, proj_lod);
amb_da += (da*da*0.5+0.5)*proj_ambiance;
amb_da *= dist_atten * noise;
amb_da = min(amb_da, 1.0-lit);
col += amb_da*color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a*diff_tex.rgb;
col += amb_da*color*diff_tex*amb_plcol.rgb*amb_plcol.a;
}
vec4 spec = texture2D(specularRect, frag.xy);
if (spec.a > 0.0)
{
dlit *= min(da*6.0, 1.0) * dist_atten;
vec3 npos = -normalize(pos);
//vec3 ref = dot(pos+lv, norm);
@@ -223,17 +224,15 @@ void main()
float gtdenom = 2 * nh;
float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh));
if (nh > 0.0)
{
float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da);
col += dlit*scol*spec.rgb;
//col += spec.rgb;
}
}
if (envIntensity > 0.0)
{
vec3 ref = reflect(normalize(pos), norm);
@@ -245,29 +244,27 @@ void main()
if (ds < 0.0)
{
vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds;
vec4 stc = (proj_mat * vec4(pfinal.xyz, 1.0));
if (stc.z > 0.0)
{
stc.xy /= stc.w;
stc /= stc.w;
float fatten = clamp(envIntensity*envIntensity+envIntensity*0.5, 0.25, 1.0);
//stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5);
stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5);
if (stc.x < 1.0 &&
stc.y < 1.0 &&
stc.x > 0.0 &&
stc.y > 0.0)
{
col += color.rgb*texture2DLodSpecular(projectionMap, stc.xy, proj_lod-envIntensity*proj_lod).rgb*spec.rgb;
col += color.rgb * texture2DLodSpecular(projectionMap, stc.xy, (1 - spec.a) * (proj_lod * 0.6)).rgb * envIntensity;
}
}
}
}
//not sure why, but this line prevents MATBUG-194
col = max(col, vec3(0.0));
frag_color.rgb = col;
frag_color.a = 0.0;
}

View File

@@ -22,7 +22,6 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
@@ -35,7 +34,6 @@ uniform sampler2D specularRect;
uniform sampler2D depthMap;
uniform sampler2D normalMap;
uniform samplerCube environmentMap;
uniform sampler2D lightMap;
uniform sampler2D noiseMap;
uniform sampler2D projectionMap;
uniform sampler2D lightFunc;
@@ -54,6 +52,9 @@ uniform float far_clip;
uniform vec3 proj_origin; //origin of projection to be used for angular attenuation
uniform float sun_wash;
// Shadows
uniform sampler2D lightMap;
uniform int proj_shadow_idx;
uniform float shadow_fade;
@@ -69,23 +70,18 @@ uniform vec2 noise_scale;
vec3 decode_normal(vec2 enc);
vec4 getPosition(vec2 pos_screen);
vec3 srgb_to_linear(vec3 cs);
vec4 srgb_to_linear(vec4 cs);
vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret.rgb = srgb_to_linear(ret.rgb);
ret = srgb_to_linear(ret);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
float det = min(lod/(proj_lod*0.5), 1.0);
float d = min(dist.x, dist.y);
d *= min(1, d * (proj_lod - lod));
d *= min(1, d * (proj_lod - lod));
float edge = 0.25*det;
ret *= clamp(d/edge, 0.0, 1.0);
return ret;
@@ -94,7 +90,7 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret.rgb = srgb_to_linear(ret.rgb);
ret = srgb_to_linear(ret);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
@@ -112,7 +108,7 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret.rgb = srgb_to_linear(ret.rgb);
ret = srgb_to_linear(ret);
vec2 dist = tc-vec2(0.5);
@@ -137,9 +133,9 @@ void main()
{
discard;
}
float shadow = 1.0;
if (proj_shadow_idx >= 0)
{
vec4 shd = texture2D(lightMap, frag.xy);
@@ -148,9 +144,9 @@ void main()
sh[1] = shd.a;
shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0);
}
vec3 norm = texture2D(normalMap, frag.xy).xyz;
float envIntensity = norm.z;
norm = decode_normal(norm.xy);
@@ -181,7 +177,7 @@ void main()
float da = dot(norm, lv);
vec3 col = vec3(0,0,0);
vec3 diff_tex = texture2D(diffuseRect, frag.xy).rgb;
vec3 dlit = vec3(0, 0, 0);
@@ -194,33 +190,32 @@ void main()
{
float lit = 0.0;
float amb_da = proj_ambiance;
if (da > 0.0)
{
lit = da * dist_atten * noise;
float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0);
float lod = diff * proj_lod;
vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod);
dlit = color.rgb * plcol.rgb * plcol.a;
lit = da * dist_atten * noise;
col = dlit*lit*diff_tex*shadow;
amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance;
}
//float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0);
vec4 amb_plcol = texture2DLodAmbient(projectionMap, proj_tc.xy, proj_lod);
amb_da += (da*da*0.5+0.5)*proj_ambiance;
amb_da *= dist_atten * noise;
amb_da = min(amb_da, 1.0-lit);
col += amb_da*color.rgb*diff_tex*amb_plcol.rgb*amb_plcol.a;
col += amb_da*color*diff_tex*amb_plcol.rgb*amb_plcol.a;
}
@@ -229,7 +224,7 @@ void main()
if (spec.a > 0.0)
{
dlit *= min(da*6.0, 1.0) * dist_atten;
vec3 npos = -normalize(pos);
//vec3 ref = dot(pos+lv, norm);
@@ -242,7 +237,7 @@ void main()
float gtdenom = 2 * nh;
float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh));
if (nh > 0.0)
{
float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da);
@@ -262,27 +257,23 @@ void main()
if (ds < 0.0)
{
vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds;
vec4 stc = (proj_mat * vec4(pfinal.xyz, 1.0));
stc /= stc.w;
if (stc.z > 0.0)
{
float fatten = clamp(envIntensity*envIntensity+envIntensity*0.25, 0.25, 1.0);
stc /= stc.w;
stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5);
if (stc.x < 1.0 &&
stc.y < 1.0 &&
stc.x > 0.0 &&
stc.y > 0.0)
{
col += color.rgb*texture2DLodSpecular(projectionMap, stc.xy, proj_lod).rgb*shadow*spec.rgb;
col += color.rgb * texture2DLodSpecular(projectionMap, stc.xy, (1 - spec.a) * (proj_lod * 0.6)).rgb * shadow * envIntensity;
}
}
}
}
//not sure why, but this line prevents MATBUG-194
col = max(col, vec3(0.0));

View File

@@ -22,7 +22,6 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color;
@@ -35,7 +34,6 @@ uniform sampler2D specularRect;
uniform sampler2D depthMap;
uniform sampler2D normalMap;
uniform samplerCube environmentMap;
uniform sampler2D lightMap;
uniform sampler2D noiseMap;
uniform sampler2D projectionMap;
uniform sampler2D lightFunc;
@@ -54,12 +52,15 @@ uniform float far_clip;
uniform vec3 proj_origin; //origin of projection to be used for angular attenuation
uniform float sun_wash;
// Shadow
uniform sampler2D lightMap;
uniform int proj_shadow_idx;
uniform float shadow_fade;
uniform float size;
uniform vec3 color;
uniform float falloff;
uniform float size;
VARYING vec3 trans_center;
VARYING vec4 vary_fragcoord;
@@ -74,18 +75,13 @@ vec4 srgb_to_linear(vec4 cs);
vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret = srgb_to_linear(ret);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
float det = min(lod/(proj_lod*0.5), 1.0);
float d = min(dist.x, dist.y);
d *= min(1, d * (proj_lod - lod));
d *= min(1, d * (proj_lod - lod));
float edge = 0.25*det;
ret *= clamp(d/edge, 0.0, 1.0);
return ret;
@@ -95,7 +91,7 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
{
vec4 ret = texture2DLod(projectionMap, tc, lod);
ret = srgb_to_linear(ret);
vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
float det = min(lod/(proj_lod*0.5), 1.0);
@@ -137,7 +133,7 @@ void main()
{
discard;
}
float shadow = 1.0;
if (proj_shadow_idx >= 0)
@@ -148,9 +144,11 @@ void main()
sh[1] = shd.a;
shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0);
}
vec3 norm = texture2D(normalMap, frag.xy).xyz;
float envIntensity = norm.z;
norm = decode_normal(norm.xy);
norm = normalize(norm);
@@ -177,24 +175,21 @@ void main()
lv = proj_origin-pos.xyz;
lv = normalize(lv);
float da = dot(norm, lv);
vec3 col = vec3(0,0,0);
vec3 diff_tex = texture2D(diffuseRect, frag.xy).rgb;
vec4 spec = texture2D(specularRect, frag.xy);
float noise = texture2D(noiseMap, frag.xy*noise_scale).b;
vec3 col = vec3(0,0,0);
vec3 diff_tex = texture2D(diffuseRect, frag.xy).rgb;
vec3 dlit = vec3(0, 0, 0);
float noise = texture2D(noiseMap, frag.xy*noise_scale).b;
if (proj_tc.z > 0.0 &&
proj_tc.x < 1.0 &&
proj_tc.y < 1.0 &&
proj_tc.x > 0.0 &&
proj_tc.y > 0.0)
{
float amb_da = proj_ambiance;
float lit = 0.0;
float amb_da = proj_ambiance;
if (da > 0.0)
{
@@ -202,31 +197,34 @@ void main()
float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0);
float lod = diff * proj_lod;
vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod);
dlit = color.rgb * plcol.rgb * plcol.a;
col = dlit*lit*diff_tex*shadow;
amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance;
}
//float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0);
vec4 amb_plcol = texture2DLodAmbient(projectionMap, proj_tc.xy, proj_lod);
amb_da += (da*da*0.5+0.5)*proj_ambiance;
amb_da *= dist_atten * noise;
amb_da = min(amb_da, 1.0-lit);
col += amb_da*color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a;
col += amb_da*color*diff_tex*amb_plcol.rgb*amb_plcol.a;
}
vec4 spec = texture2D(specularRect, frag.xy);
if (spec.a > 0.0)
{
dlit *= min(da*6.0, 1.0) * dist_atten;
vec3 npos = -normalize(pos);
//vec3 ref = dot(pos+lv, norm);
@@ -239,7 +237,7 @@ void main()
float gtdenom = 2 * nh;
float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh));
if (nh > 0.0)
{
float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da);
@@ -247,10 +245,6 @@ void main()
//col += spec.rgb;
}
}
if (envIntensity > 0.0)
{
@@ -263,29 +257,24 @@ void main()
if (ds < 0.0)
{
vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds;
vec4 stc = (proj_mat * vec4(pfinal.xyz, 1.0));
if (stc.z > 0.0)
{
stc.xy /= stc.w;
stc /= stc.w;
float fatten = clamp(envIntensity*envIntensity+envIntensity*0.5, 0.25, 1.0);
//stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5);
stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5);
if (stc.x < 1.0 &&
stc.y < 1.0 &&
stc.x > 0.0 &&
stc.y > 0.0)
{
col += color.rgb*texture2DLodSpecular(projectionMap, stc.xy, proj_lod-envIntensity*proj_lod).rgb*shadow*spec.rgb;
col += color.rgb * texture2DLodSpecular(projectionMap, stc.xy, (1 - spec.a) * (proj_lod * 0.6)).rgb * shadow * envIntensity;
}
}
}
}
//not sure why, but this line prevents MATBUG-194
col = max(col, vec3(0.0));

View File

@@ -1569,6 +1569,22 @@ BOOL LLViewerWindow::handleDeviceChange(LLWindow *window)
return FALSE;
}
bool LLViewerWindow::handleDPIScaleChange(LLWindow *window, float xDPIScale, float yDPIScale, U32 width, U32 height)
{
LL_INFOS() << "handleDPIScaleChange" << LL_ENDL;
if (mDPIScaleX != xDPIScale || mDPIScaleY != yDPIScale)
{
LL_INFOS() << "handleDPIScaleChange APPLY" << LL_ENDL;
mDPIScaleX = xDPIScale;
mDPIScaleY = yDPIScale;
if (!mWindow->getFullscreen()) {
reshape(width ? width : getWindowWidthRaw(), height ? height : getWindowHeightRaw());
return true;
}
}
return false;
}
void LLViewerWindow::handlePingWatchdog(LLWindow *window, const char * msg)
{
LLAppViewer::instance()->pingMainloopTimeout(msg);
@@ -1637,7 +1653,9 @@ LLViewerWindow::LLViewerWindow(
//mStatesDirty(false), //Singu Note: No longer needed. State update is now in restoreGL.
mIsFullscreenChecked(false),
mCurrResolutionIndex(0),
mProgressView(NULL)
mProgressView(NULL),
mDPIScaleX(1.f),
mDPIScaleY(1.f)
{
LLNotificationChannel::buildChannel("VW_alerts", "Visible", LLNotificationFilters::filterBy<std::string>(&LLNotification::getType, "alert"));
LLNotificationChannel::buildChannel("VW_alertmodal", "Visible", LLNotificationFilters::filterBy<std::string>(&LLNotification::getType, "alertmodal"));
@@ -1706,10 +1724,9 @@ LLViewerWindow::LLViewerWindow(
// Get the real window rect the window was created with (since there are various OS-dependent reasons why
// the size of a window or fullscreen context may have been adjusted slightly...)
F32 ui_scale_factor = gSavedSettings.getF32("UIScaleFactor");
mDisplayScale.setVec(llmax(1.f / mWindow->getPixelAspectRatio(), 1.f), llmax(mWindow->getPixelAspectRatio(), 1.f));
mDisplayScale *= ui_scale_factor;
mDisplayScale.scaleVec(getUIScale());
LLUI::setScaleFactor(mDisplayScale);
{
@@ -1799,6 +1816,8 @@ LLViewerWindow::LLViewerWindow(
mDebugText = new LLDebugText(this);
mWindow->postInitialized();
}
void LLViewerWindow::initGLDefaults()
@@ -5730,17 +5749,17 @@ F32 LLViewerWindow::getDisplayAspectRatio() const
void LLViewerWindow::calcDisplayScale()
{
F32 ui_scale_factor = gSavedSettings.getF32("UIScaleFactor");
LLVector2 ui_scale_factor = getUIScale();
LLVector2 display_scale;
display_scale.setVec(llmax(1.f / mWindow->getPixelAspectRatio(), 1.f), llmax(mWindow->getPixelAspectRatio(), 1.f));
if(mWindow->getFullscreen())
{
F32 height_normalization = gSavedSettings.getBOOL("UIAutoScale") ? ((F32)mWindowRectRaw.getHeight() / display_scale.mV[VY]) / 768.f : 1.f;
display_scale *= (ui_scale_factor * height_normalization);
display_scale.scaleVec(ui_scale_factor * height_normalization);
}
else
{
display_scale *= ui_scale_factor;
display_scale.scaleVec(ui_scale_factor);
}
// limit minimum display scale
@@ -5765,6 +5784,20 @@ void LLViewerWindow::calcDisplayScale()
}
}
LLVector2 LLViewerWindow::getUIScale() const
{
LL_INFOS() << "getUIScale" << LL_ENDL;
static LLCachedControl<F32> ui_scale_factor("UIScaleFactor");
if (mWindow->getFullscreen())
{
return LLVector2(ui_scale_factor, ui_scale_factor);
}
else
{
return LLVector2(mDPIScaleX * ui_scale_factor, mDPIScaleY * ui_scale_factor);
}
}
S32 LLViewerWindow::getChatConsoleBottomPad()
{
static const LLCachedControl<S32> user_offset("ConsoleBottomOffset");

View File

@@ -181,6 +181,7 @@ public:
/*virtual*/ void handleDataCopy(LLWindow *window, S32 data_type, void *data);
/*virtual*/ BOOL handleTimerEvent(LLWindow *window);
/*virtual*/ BOOL handleDeviceChange(LLWindow *window);
/*virtual*/ bool handleDPIScaleChange(LLWindow *window, float xDPIScale, float yDPIScale, U32 width = 0, U32 height = 0);
/*virtual*/ void handlePingWatchdog(LLWindow *window, const char * msg);
/*virtual*/ void handlePauseWatchdog(LLWindow *window);
@@ -393,6 +394,8 @@ public:
const LLVector2& getDisplayScale() const { return mDisplayScale; }
void calcDisplayScale();
LLVector2 getUIScale() const;
private:
bool shouldShowToolTipFor(LLMouseHandler *mh);
static bool onAlert(const LLSD& notify);
@@ -464,6 +467,9 @@ protected:
bool mIsFullscreenChecked; // Did the user check the fullscreen checkbox in the display settings
U32 mCurrResolutionIndex;
float mDPIScaleX;
float mDPIScaleY;
protected:
static std::string sSnapshotBaseName;
static std::string sSnapshotDir;

View File

@@ -1250,9 +1250,9 @@ void LLWorldMapView::drawFrustum()
F32 half_width_pixels = half_width_meters * meters_to_pixels;
// Compute the frustum coordinates. Take the UI scale into account.
static LLCachedControl<F32> ui_scale_factor("UIScaleFactor");
F32 ctr_x = (getLocalRect().getWidth() * 0.5f + sPanX) * ui_scale_factor;
F32 ctr_y = (getLocalRect().getHeight() * 0.5f + sPanY) * ui_scale_factor;
LLVector2 ui_scale_factor = gViewerWindow->getUIScale();
F32 ctr_x = (getLocalRect().getWidth() * 0.5f + sPanX) * ui_scale_factor.mV[VX];
F32 ctr_y = (getLocalRect().getHeight() * 0.5f + sPanY) * ui_scale_factor.mV[VY];
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);