@@ -171,11 +171,7 @@ hudhalo = [
171
171
varying vec2 texcoord0;
172
172
varying vec4 colorscale;
173
173
174
- @(? (>= (strstr $arg1 " ref" ) 0) [
175
- @(gfetchdefs [refractdepth refractmask])
176
- ] [
177
- @(gfetchdefs [refractdepth])
178
- ])
174
+ @(gfetchdefs [earlydepth])
179
175
180
176
fragdata(0) vec4 fragcolor;
181
177
@@ -212,16 +208,10 @@ hudhalo = [
212
208
213
209
// extract the depth information from the scene
214
210
vec2 duv = gl_FragCoord.xy * halodepth;
215
- float depth = dot(gfetch(refractdepth , duv).rgb, gdepthunpackparams);
211
+ float depth = dot(gfetch(earlydepth , duv).rgb, gdepthunpackparams);
216
212
vec3 pos = (linearworldmatrix * vec4(depth * gl_FragCoord.xy, depth, 1.0)).xyz;
217
213
float maxdist = distance(camera, pos); // linearize and calculate distance
218
214
219
- @(? (>= (strstr $arg1 " ref" ) 0) [
220
- float rdepth = dot(gfetch(refractmask, duv).rgb, gdepthunpackparams);
221
- vec3 rpos = (linearworldmatrix * vec4(rdepth * gl_FragCoord.xy, rdepth, 1.0)).xyz;
222
- maxdist = max(maxdist, distance(camera, rpos));
223
- ])
224
-
225
215
// depth test and discard if it fails
226
216
@(if (>= (strstr $arg1 " depth" ) 0) [result [
227
217
if(dist > maxdist) discard;
@@ -278,11 +268,11 @@ hudglass = [
278
268
279
269
@(? (>= (strstr $arg1 " focus" ) 0) [
280
270
uniform sampler2D tex6;
281
- uniform vec4 glassfocus, glassdepth;
271
+ uniform vec4 glassfocus, glassedgeparams, glassedgesize, glassdepth;
282
272
uniform vec3 camera;
283
273
uniform mat4 linearworldmatrix;
284
274
285
- @(gfetchdefs tex7 )
275
+ @(gfetchdefs [earlydepth] )
286
276
])
287
277
288
278
uniform float time;
@@ -324,7 +314,7 @@ hudglass = [
324
314
325
315
@(if (>= (strstr $arg1 " focus" ) 0) [result [
326
316
float focusdepth = dot(texture2D(tex6, vec2(0.5)).rgb, gdepthunpackparams),
327
- curdepth = dot(gfetch(tex7 , texcoord0 * glassdepth.xy).rgb, gdepthunpackparams);
317
+ curdepth = dot(gfetch(earlydepth , texcoord0 * glassdepth.xy).rgb, gdepthunpackparams);
328
318
vec3 focuspos = (linearworldmatrix * vec4(focusdepth * glasssize.xy * 0.5, focusdepth, 1.0)).xyz,
329
319
curpos = (linearworldmatrix * vec4(curdepth * texcoord0, curdepth, 1.0)).xyz;
330
320
float curoffset = abs(distance(focuspos, curpos) - glassfocus.z);
@@ -335,6 +325,37 @@ hudglass = [
335
325
if(glassamt > 0.0)
336
326
outcolor = mix(outcolor, texture2DRect(tex5, texcoord0 * glassscale).rgb, clamp(glassamt, 0.0, 1.0));
337
327
328
+ @(if (>= (strstr $arg1 " focus" ) 0) [result [
329
+ if(glassedgeparams.x > 0.0)
330
+ {
331
+ float edgesrc = dot(outcolor, vec3(0.21, 0.72, 0.07));
332
+ if(edgesrc <= glassedgeparams.x)
333
+ {
334
+ float edgedist = distance(camera, curpos);
335
+ if(edgedist <= glassedgeparams.z)
336
+ {
337
+ float edgeskew = clamp(edgedist * glassedgeparams.w, 0.0, 1.0),
338
+ edgecheck = glassedgesize.x + glassedgesize.y * edgeskew,
339
+ edgemax = 0.0;
340
+
341
+ @(looplistconcatn _coord _idx [" 0.0, 1.0" " 0.0, -1.0" " 1.0, 0.0" " -1.0, 0.0" ] [result [
342
+ vec2 edgecoord@[_idx] = texcoord0 + vec2(@[_coord]) * glassedgesize.z;
343
+ float edgedepth@[_idx] = dot(gfetch(earlydepth, edgecoord@[_idx] * glassdepth.xy).rgb, gdepthunpackparams);
344
+ vec3 edgepos@[_idx] = (linearworldmatrix * vec4(edgedepth@[_idx] * edgecoord@[_idx], edgedepth@[_idx], 1.0)).xyz;
345
+ float edgedist@[_idx] = distance(camera, edgepos@[_idx]), edgeoff@[_idx] = abs(edgedist - edgedist@[_idx]);
346
+ edgemax = max(edgemax, edgeoff@[_idx]);
347
+ ]])
348
+
349
+ if(edgemax >= edgecheck)
350
+ {
351
+ float edgepc = (1.0 - edgesrc * glassedgeparams.y) * (1.0 - edgeskew);
352
+ outcolor = mix(outcolor, vec3(glassedgesize.w), clamp(edgepc, 0.0, 1.0));
353
+ }
354
+ }
355
+ }
356
+ }
357
+ ]])
358
+
338
359
if(glassfx.x > 0.0) outcolor = mix(outcolor, vec3(dot(outcolor, vec3(0.21, 0.72, 0.07))), clamp(glassfx.x * dist, 0.0, 1.0));
339
360
if(glassfx.y > 0.0) outcolor = mix(outcolor, outcolor * 0.25, clamp(glassfx.y * dist, 0.0, 1.0));
340
361
if(glassfx.z > 0.0) outcolor = mix(outcolor, outcolor * glassfx.w, clamp(glassfx.z * dist, 0.0, 1.0));
@@ -459,56 +480,6 @@ hudvisor "hudvisorchroma"
459
480
hudvisor " hudvisorview"
460
481
hudvisor " hudvisorviewchroma"
461
482
462
- huddepth = [
463
- shader $SHADER_DEFAULT $arg1 [
464
- attribute vec4 vvertex, vcolor;
465
- attribute vec2 vtexcoord0;
466
- uniform mat4 hudmatrix;
467
- varying vec2 texcoord0;
468
-
469
- void main(void)
470
- {
471
- gl_Position = hudmatrix * vvertex;
472
- texcoord0 = vtexcoord0;
473
- }
474
- ] [
475
- @(? (>= (strstr $arg1 " ref" ) 0) [
476
- @(gfetchdefs [refractdepth refractmask])
477
- ] [
478
- @(gfetchdefs [refractdepth])
479
- ])
480
- uniform vec3 gdepthpackparams;
481
- varying vec2 texcoord0;
482
-
483
- fragdata(0) vec4 fragcolor;
484
-
485
- void main(void)
486
- {
487
- @(if (= $gdepthformat 1) [result [
488
- vec3 packdepth = gfetch(refractdepth, texcoord0).rgb;
489
- ]] [result [
490
- @(gdepthunpack depth [gfetch(refractdepth, texcoord0)])
491
- @(gpackdepth packdepth depth)
492
- ]])
493
-
494
- @(? (>= (strstr $arg1 " ref" ) 0) [
495
- @(if (= $gdepthformat 1) [result [
496
- vec3 refdepth = gfetch(refractmask, texcoord0).rgb;
497
- ]] [result [
498
- @(gdepthunpack rdepth [gfetch(refractmask, texcoord0)])
499
- @(gpackdepth refdepth rdepth)
500
- ]])
501
-
502
- if(refdepth != vec3(0.0)) packdepth = refdepth;
503
- ])
504
-
505
- fragcolor = vec4(packdepth, 0.0);
506
- }
507
- ]
508
- ]
509
- huddepth " huddepth"
510
- huddepth " huddepthref"
511
-
512
483
shader $SHADER_DEFAULT " hudfocus" [
513
484
attribute vec4 vvertex;
514
485
uniform mat4 hudmatrix;
@@ -522,7 +493,7 @@ shader $SHADER_DEFAULT "hudfocus" [
522
493
uniform vec2 focussize;
523
494
uniform vec3 focusparams;
524
495
525
- @(gfetchdefs tex7 )
496
+ @(gfetchdefs [earlydepth] )
526
497
@(ginterpdepth)
527
498
528
499
fragdata(0) vec4 fragcolor;
@@ -531,7 +502,7 @@ shader $SHADER_DEFAULT "hudfocus" [
531
502
{
532
503
if(focusparams.y > 0.0)
533
504
{
534
- @(gdepthunpack curdepth [gfetch(tex7 , focussize)])
505
+ @(gdepthunpack curdepth [gfetch(earlydepth , focussize)])
535
506
@(gdepthunpack prvdepth [texture2D(tex0, vec2(0.5))])
536
507
537
508
if(curdepth != prvdepth)
0 commit comments