summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/deferred
diff options
context:
space:
mode:
authorCosmic Linden <cosmic@lindenlab.com>2023-10-13 10:38:42 -0700
committerCosmic Linden <cosmic@lindenlab.com>2023-10-13 10:38:42 -0700
commitb9ba57fd0004751dfbcbea90264a6e16c5849e5e (patch)
tree49f3da7af8ecc47ec5c1a3505360a0df13203d1f /indra/newview/app_settings/shaders/class1/deferred
parent57433341abffba9382e6899b164af40200f5d6d3 (diff)
DRTVWR-592: (WIP) Fix terrain PBR texture repeat seam. Legacy terrain texture repeats currently broken
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl25
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl22
2 files changed, 37 insertions, 10 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl
index 73d4d9e3bc..5f94855963 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainF.glsl
@@ -70,6 +70,7 @@ vec2 encode_normal(vec3 n);
vec3 linear_to_srgb(vec3 c);
vec3 srgb_to_linear(vec3 c);
+in vec4 debug_pos; // TODO: Remove
// *TODO: This mixing function feels like it can be optimized. The terrain code's use of texcoord1 is dubious. It feels like the same thing can be accomplished with less memory bandwidth by calculating the offsets on-the-fly
float terrain_mix(vec4 samples, float alpha1, float alpha2, float alphaFinal)
{
@@ -148,9 +149,8 @@ vec3 sample_and_mix_vector3_no_scale(float alpha1, float alpha2, float alphaFina
void main()
{
- // Adjust the texture repeats for a more sensible default.
- float texture_density_factor = 2.0;
- vec2 terrain_texcoord = texture_density_factor * vary_texcoord0.xy;
+ vec2 terrain_texcoord = vary_texcoord0.xy;
+ terrain_texcoord -= vec2(21.0);// TODO: Remove
float alpha1 = texture(alpha_ramp, vary_texcoord0.zw).a;
float alpha2 = texture(alpha_ramp,vary_texcoord1.xy).a;
float alphaFinal = texture(alpha_ramp, vary_texcoord1.zw).a;
@@ -162,6 +162,25 @@ void main()
discard;
}
+ // TODO: Remove all of this
+ float debug_pos_x = debug_pos.x;
+ //float debug_pos_x = terrain_texcoord.y;
+ float debug_metric = debug_pos_x;
+ debug_metric = debug_metric - floor(debug_metric);
+ debug_metric *= debug_metric;
+ float debug_metric2 = debug_pos_x / 4.0;
+ debug_metric2 = debug_metric2 - floor(debug_metric2);
+ debug_metric2 *= debug_metric2;
+ debug_metric2 *= debug_metric2;
+ debug_metric2 *= 16.0;
+ float debug_metric3 = debug_pos_x / 16.0;
+ debug_metric3 = debug_metric3 - floor(debug_metric3);
+ debug_metric3 *= debug_metric3;
+ debug_metric3 *= debug_metric3;
+ debug_metric3 *= debug_metric3;
+ debug_metric3 *= 16.0;
+ //col.xyz = vec3(debug_metric3, debug_metric2, debug_metric);// TODO: Remove
+
vec3 normal_texture = sample_and_mix_vector3_no_scale(alpha1, alpha2, alphaFinal, terrain_texcoord, detail_0_normal, detail_1_normal, detail_2_normal, detail_3_normal);
vec3[4] orm_factors;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl
index 6037a58c0d..fd80d1bb2c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbrterrainV.glsl
@@ -43,24 +43,27 @@ out vec4 vary_texcoord1;
uniform vec4 object_plane_s;
uniform vec4 object_plane_t;
-vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1)
+vec4 texgen_object_pbr(vec4 tc, mat4 mat, vec4 tp0, vec4 tp1)
{
vec4 tcoord;
- tcoord.x = dot(vpos, tp0);
- tcoord.y = dot(vpos, tp1);
- tcoord.z = tc.z;
- tcoord.w = tc.w;
+ tcoord.x = dot(tc, tp0);
+ tcoord.y = dot(tc, tp1);
+ tcoord.z = tcoord.z;
+ tcoord.w = tcoord.w;
tcoord = mat * tcoord;
- return tcoord;
+ return tcoord;
}
+out vec4 debug_pos; // TODO: Remove
+
void main()
{
//transform vertex
gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
+ debug_pos = vec4(texcoord0, 0.0, 1.0);
vec3 n = normal_matrix * normal;
vec3 t = normal_matrix * tangent.xyz;
@@ -71,7 +74,12 @@ void main()
// Transform and pass tex coords
// *NOTE: KHR texture transform is ignored for now
- vary_texcoord0.xy = texgen_object(vec4(position, 1.0), vec4(texcoord0,0,1), texture_matrix0, object_plane_s, object_plane_t).xy;
+ vary_texcoord0.xy = texgen_object_pbr(vec4(texcoord0, 0, 1), texture_matrix0, object_plane_s, object_plane_t).xy;
+ // Adjust the texture repeats for a more sensible default.
+ // *TODO: Remove this extra factor when KHR texture transform is added
+ float texture_density_factor = 3.0;
+ //texture_density_factor /= 256.0; // TODO: Remove
+ vary_texcoord0.xy *= texture_density_factor;
vec4 tc = vec4(texcoord1,0,1);