Jump to content

Horizon is bending upwards


You are about to reply to a thread that has been inactive for 477 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

There is a fix for it (and other water-related issues) in the Cool VL Viewer:

diff -BwdurN viewer-release/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl cv130212/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl
--- viewer-release/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl	2023-01-27 21:04:11.000000000 +0100
+++ cv130212/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl	2021-12-03 23:51:06.000000000 +0100
@@ -66,11 +66,11 @@
 	pos.xy = eyeVec.xy + oEyeVec.xy/d*ld;
 	view.xyz = oEyeVec;
 		
-	d = clamp(ld/1536.0-0.5, 0.0, 1.0);	
+	d = clamp(ld/8192.0-0.5, 0.0, 1.0); // 8192 instead of 1536 for a better looking horizon (from BlackDragon). HB
 	d *= d;
 		
 	oPosition = vec4(position, 1.0);
-	oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d);
+//	oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d); // SL-11589 remove ”U” shaped horizon. Not yet in LL's release viewer. HB
 	vary_position = modelview_matrix * oPosition;
 	oPosition = modelViewProj * oPosition;
 	
@@ -78,7 +78,7 @@
 	
 	//get wave position parameter (create sweeping horizontal waves)
 	vec3 v = pos.xyz;
-	v.x += (cos(v.x*0.08/*+time*0.01*/)+sin(v.y*0.02))*6.0;
+	v.x += (cos(v.x*0.02/*+time*0.01*/)+sin(v.y*0.02))*6.0; // x*0.02 instead of x*0.08 for better looking waves. HB
 	    
 	//push position for further horizon effect.
 	pos.xyz = oEyeVec.xyz*(waterHeight/oEyeVec.z);
diff -BwdurN viewer-release/indra/newview/app_settings/shaders/class1/environment/waterV.glsl cv130212/indra/newview/app_settings/shaders/class1/environment/waterV.glsl
--- viewer-release/indra/newview/app_settings/shaders/class1/environment/waterV.glsl	2023-01-27 21:04:11.000000000 +0100
+++ cv130212/indra/newview/app_settings/shaders/class1/environment/waterV.glsl	2021-12-03 23:52:33.000000000 +0100
@@ -64,18 +64,18 @@
 	pos.xy = eyeVec.xy + oEyeVec.xy/d*ld;
 	view.xyz = oEyeVec;
 		
-	d = clamp(ld/1536.0-0.5, 0.0, 1.0);	
+	d = clamp(ld/8192.0-0.5, 0.0, 1.0);	// 8192 instead of 1536 for a better looking horizon (from BlackDragon). HB
 	d *= d;
 		
 	oPosition = vec4(position, 1.0);
-	oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d);
+//	oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d); // SL-11589 remove ”U” shaped horizon. Not yet in LL's release viewer. HB
 	oPosition = modelViewProj * oPosition;
 	
 	refCoord.xyz = oPosition.xyz + vec3(0,0,0.2);
 	
 	//get wave position parameter (create sweeping horizontal waves)
 	vec3 v = pos.xyz;
-	v.x += (cos(v.x*0.08/*+time*0.01*/)+sin(v.y*0.02))*6.0;
+	v.x += (cos(v.x*0.02/*+time*0.01*/)+sin(v.y*0.02))*6.0; // x*0.02 instead of x*0.08 for better looking waves. HB
 	    
 	//push position for further horizon effect.
 	pos.xyz = oEyeVec.xyz*(waterHeight/oEyeVec.z);
diff -BwdurN viewer-release/indra/newview/app_settings/shaders/class3/deferred/waterV.glsl cv130212/indra/newview/app_settings/shaders/class3/deferred/waterV.glsl
--- viewer-release/indra/newview/app_settings/shaders/class3/deferred/waterV.glsl	2023-01-27 21:04:11.000000000 +0100
+++ cv130212/indra/newview/app_settings/shaders/class3/deferred/waterV.glsl	2021-06-25 20:32:35.000000000 +0200
@@ -68,7 +68,7 @@
 	d *= d;
 		
 	oPosition = vec4(position, 1.0);
-	oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d);
+//	oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d); // SL-11589 remove ”U” shaped horizon
 	vary_position = modelview_matrix * oPosition;
 	oPosition = modelViewProj * oPosition;
 	

Just copy these shader files (to be found in the installation directory of the Cool VL Viewer):

  • app_settings/shaders/class1/deferred/waterV.glsl
  • app_settings/shaders/class1/environment/waterV.glsl
  • app_settings/shaders/class3/deferred/waterV.glsl

and replace the same shaders in LL's viewer installation directory, FS or any other TPV derived from LL's EEP/performance viewer (this might break old Windlight viewers, such as Singularity, Genesis and others).

Edited by Henri Beauchamp
  • Like 1
  • Thanks 2
Link to comment
Share on other sites

Okay, I figured out how to open those files but the original looks a lot different to me. Am I really supposed to replace all of that with all of the above?

 

/**
 * @file waterV.glsl
 *
 * $LicenseInfo:firstyear=2007&license=viewerlgpl$
 * Second Life Viewer Source Code
 * Copyright (C) 2007, Linden Research, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation;
 * version 2.1 of the License only.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 * $/LicenseInfo$
 */

uniform mat4 modelview_matrix;
uniform mat4 modelview_projection_matrix;

ATTRIBUTE vec3 position;


void calcAtmospherics(vec3 inPositionEye);

uniform vec2 waveDir1;
uniform vec2 waveDir2;
uniform float time;
uniform vec3 eyeVec;
uniform float waterHeight;

VARYING vec4 refCoord;
VARYING vec4 littleWave;
VARYING vec4 view;

VARYING vec4 vary_position;

float wave(vec2 v, float t, float f, vec2 d, float s)
{
   return (dot(d, v)*f + t*s)*f;
}

void main()
{
    //transform vertex
    vec4 pos = vec4(position.xyz, 1.0);
    mat4 modelViewProj = modelview_projection_matrix;
    
    vec4 oPosition;
            
    //get view vector
    vec3 oEyeVec;
    oEyeVec.xyz = pos.xyz-eyeVec;
        
    float d = length(oEyeVec.xy);
    float ld = min(d, 2560.0);
    
    pos.xy = eyeVec.xy + oEyeVec.xy/d*ld;
    view.xyz = oEyeVec;
        
    d = clamp(ld/1536.0-0.5, 0.0, 1.0);    
    d *= d;
        
    oPosition = vec4(position, 1.0);
    oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d);
    vary_position = modelview_matrix * oPosition;
    oPosition = modelViewProj * oPosition;
    
    refCoord.xyz = oPosition.xyz + vec3(0,0,0.2);
    
    //get wave position parameter (create sweeping horizontal waves)
    vec3 v = pos.xyz;
    v.x += (cos(v.x*0.08/*+time*0.01*/)+sin(v.y*0.02))*6.0;
        
    //push position for further horizon effect.
    pos.xyz = oEyeVec.xyz*(waterHeight/oEyeVec.z);
    pos.w = 1.0;
    pos = modelview_matrix*pos;
    
    calcAtmospherics(pos.xyz);
        
    //pass wave parameters to pixel shader
    vec2 bigWave =  (v.xy) * vec2(0.04,0.04)  + waveDir1 * time * 0.055;
    //get two normal map (detail map) texture coordinates
    littleWave.xy = (v.xy) * vec2(0.45, 0.9)   + waveDir2 * time * 0.13;
    littleWave.zw = (v.xy) * vec2(0.1, 0.2) + waveDir1 * time * 0.1;
    view.w = bigWave.y;
    refCoord.w = bigWave.x;
    
    gl_Position = oPosition;
}

 

Link to comment
Share on other sites

53 minutes ago, SapphireDemonspider said:

Okay, I figured out how to open those files but the original looks a lot different to me. Am I really supposed to replace all of that with all of the above?

The text in Henri's post is the result of running "diff" on three pairs of shader files, where each pair one compares the released LL version (same as Firestorm's current release) and the corresponding file in the Cool VL Viewer. He's suggesting you download the Cool VL installation files and use its versions for those three files.

If you examine the diff outputs, you can see there aren't that many changes. For example, in the first two, this line:

    d = clamp(ld/1536.0-0.5, 0.0, 1.0);	

is changed to this:

    d = clamp(ld/8192.0-0.5, 0.0, 1.0); // 8192 instead of 1536 for a better looking horizon (from BlackDragon). HB

and this line:

    v.x += (cos(v.x*0.08/*+time*0.01*/)+sin(v.y*0.02))*6.0;

is changed to:

    v.x += (cos(v.x*0.02/*+time*0.01*/)+sin(v.y*0.02))*6.0; // x*0.02 instead of x*0.08 for better looking waves. HB

Also, in all three files, the following line is commented out (preceded by "//" ) in the Cool VL version:

    oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d);

Maybe that makes it clearer what's intended?

Link to comment
Share on other sites

Simply replace the 3 shaders files I listed: use the Cool VL Viewer's ones in place of the other viewer's files. No manual editing should be needed for LL's viewer and FS (but this would be needed for Alchemy and Black Dragon, for example, since they have their own changes in their shaders, with may be some of the fixes already implemented).

Edited by Henri Beauchamp
  • Like 1
  • Thanks 2
Link to comment
Share on other sites

Thanks, Henri.

I'll try that in LL's viewer too.

LL was issuing viewers in which this weird water horizon was fixed, a long time ago.  I think it was the Snowglobe viewer, but do not remember for sure.  Much was lost when LL ended Snowglobe and introduced the sequestered project.  I miss having a sky rendered from an astronomical database.  Recognizable constellations and deep sky objects were a comfort to me.  Silly me also liked Linden Trees swaying madly in the wind and the sound of the wind roaring past.  I'll admit, that, sometimes I muted the wind when it was being particularly persistent.  Sometimes I run Cool VL Viewer just to hear the wind.

Link to comment
Share on other sites

4 hours ago, Ardy Lay said:

Silly me also liked Linden Trees swaying madly in the wind and the sound of the wind roaring past.

The Cool VL Viewer still has them: Advanced -> Rendering -> Animate trees

4 hours ago, Ardy Lay said:

Sometimes I run Cool VL Viewer just to hear the wind.

For some unknown reason, LL added some code in their viewer (which ”contaminated” all derived TPVs, but not true forks like mine), to mute the wind when your avatar is not flying... I instead opted to add a wind sound volume slider, for when it becomes a little too overwhelming (which is often the case in sky boxes)...

Edited by Henri Beauchamp
  • Like 1
Link to comment
Share on other sites

36 minutes ago, NiranV Dean said:

This issue was fixed long ago in BD, Henri ported it to Cool, im not aware of any other Viewer having this fixed

Actually, no. This specific fix that I backported to the Cool VL Viewer came from one of LL's many viewer ”maint” branches: you can see the reference for LL's internal JIRA issue it fixes (SL-11589) in the comment I added in the shaders...

I did however backport another fix from BD (IIRC, ”square”/non infinite water bodies appearing at high altitude) to the old Windlight water shaders, back in 2015 (see the release notes where I credited you for them), but this one was useless for the EE shaders and since disappeared... There are however a couple other fixes/improvements coming from you and which survived in EE shaders, and I also added a comment for them (you can see it in the diff above). 🙂

Edited by Henri Beauchamp
Link to comment
Share on other sites

ah, i didnt see the video, i was going by the thread description, rolling water was exactly what i fixed.

Edit: I watched the video.

THAT is EXACTLY what i fixed long ago and i'm pretty sure that was the fix you ported.

https://git.alchemyviewer.org/NiranV.Dean/blackdragon/-/commit/c6b473f3c3ad43641a0dbf2f9441c1418ccfc07d

https://git.alchemyviewer.org/NiranV.Dean/blackdragon/-/commit/fe272ae174d41d41738e7c569b6692900b0fcfa1


http://sldev.free.fr/forum/viewtopic.php?f=3&t=2&p=6968&hilit=Black+Dragon#p6968

 

You are also referring to these which were also things i fixed, i was only aware that you ported the water hurling fix that the OP is having.

https://git.alchemyviewer.org/NiranV.Dean/blackdragon/-/commit/35aa90392b4ab4250b38a6df30fa58cf57efb9c2

https://git.alchemyviewer.org/NiranV.Dean/blackdragon/-/commit/35aa90392b4ab4250b38a6df30fa58cf57efb9c2

 

Also this is the current version for EE:

https://git.alchemyviewer.org/NiranV.Dean/blackdragon/-/blob/Release_4.3.1/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl

I'm using the original LL shader with only the two above changes (water hurling and water waves fixed) both of which still are not fixed in LL Viewer to-date. My changes are hardly useless for EE since they applied to EE exactly identical, EE hardly even touched the water shader.

Edited by NiranV Dean
  • Like 1
Link to comment
Share on other sites

1 hour ago, NiranV Dean said:

I'm using the original LL shader with only the two above changes (water hurling and water waves fixed) both of which still are not fixed in LL Viewer to-date. My changes are hardly useless for EE since they applied to EE exactly identical, EE hardly even touched the water shader.

It is likely that I lost the Windlight shaders fix during EE backporting to the Cool VL Viewer since, in a first step, I simply copied LL's shaders to make up my dual-render viewer... Then, I re-backported fixes to my EE port, and I can assure you the U-shaped fix came from one of LL's maint viewers (thus my comment ”SL-11589 remove 'U' shaped horizon. Not yet in LL's release viewer.”): I won't have had any clue it was referenced as ”SL-11589” otherwise, since those JIRA issues are (sadly) not visible to us, TPV developers...

But that fix may as well have made its way to LL's maint viewer via Alchemy, itself having picked it up from BD... Even though I am trying hard to credit the right person(s) for each given backport I make (and even when the said backport is almost rewritten from scratch by me), it's very hard to keep track of who made the first fix, after some time (7 years later, in this case)...

Edited by Henri Beauchamp
Link to comment
Share on other sites

2 hours ago, Henri Beauchamp said:

It is likely that I lost the Windlight shaders fix during EE backporting to the Cool VL Viewer since, in a first step, I simply copied LL's shaders to make up my dual-render viewer... Then, I re-backported fixes to my EE port, and I can assure you the U-shaped fix came from one of LL's maint viewers (thus my comment ”SL-11589 remove 'U' shaped horizon. Not yet in LL's release viewer.”): I won't have had any clue it was referenced as ”SL-11589” otherwise, since those JIRA issues are (sadly) not visible to us, TPV developers...

But that fix may as well have made its way to LL's maint viewer via Alchemy, itself having picked it up from BD... Even though I am trying hard to credit the right person(s) for each given backport I make (and even when the said backport is almost rewritten from scratch by me), it's very hard to keep track of who made the first fix, after some time (7 years later, in this case)...

Yea... i don't know what happened there, i vaguely remember something about those fixes going official, i may have offered them to LL during EE because someone (maybe Alchemy) suggested it to me but i've never seen any of those fixes going anywhere (at least not the maintenance releases i was tracking). If anything they also weren't using the original commits either due to some patch failing or something, they have done that before although all commits i have ever seen like that never made it into any RC, let alone release.

I wasn't saying you are wrong or not crediting anyone, just that i remember fixing this issue a while back (apparently 8 years already...) and i only know of you implementing said fix into your own Viewer, thus making it only 2 Viewers that fixed this, i remember being very proud that you took my fixes!

  • Like 2
Link to comment
Share on other sites

  • 4 weeks later...
You are about to reply to a thread that has been inactive for 477 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...