ditch 1D/2D/3D qualifiers on texture

gl4
Daniel Kolesa 2018-10-28 20:44:03 +01:00
parent cf88690a76
commit 5f3c618607
24 changed files with 249 additions and 264 deletions

View File

@ -36,14 +36,14 @@ lazyshader 0 "tqaaresolve" [
vec2 vel = prevtc.xy/prevtc.w - texcoord0; vec2 vel = prevtc.xy/prevtc.w - texcoord0;
float scale = clamp(maxvelocity.x*inversesqrt(dot(vel, vel) + 1e-6), 0.0, 1.0); float scale = clamp(maxvelocity.x*inversesqrt(dot(vel, vel) + 1e-6), 0.0, 1.0);
float mask = 1.0 - texture2DRect(tex0, texcoord0 + quincunx.xy).a; float mask = 1.0 - textureRect(tex0, texcoord0 + quincunx.xy).a;
vec4 color = texture2DRect(tex0, texcoord0 + mask*quincunx.xy); vec4 color = textureRect(tex0, texcoord0 + mask*quincunx.xy);
vec4 prevcolor = texture2DRect(tex1, texcoord0 + mask*(quincunx.zw + vel*scale)); vec4 prevcolor = textureRect(tex1, texcoord0 + mask*(quincunx.zw + vel*scale));
vec4 l0 = textureGather(tex0, texcoord1, 1); vec4 l0 = textureGather(tex0, texcoord1, 1);
vec4 l1 = textureGatherOffset(tex0, texcoord1, ivec2(1, 1), 1); vec4 l1 = textureGatherOffset(tex0, texcoord1, ivec2(1, 1), 1);
float l2 = texture2DRectOffset(tex0, texcoord0, ivec2(1, -1)).g; float l2 = textureRectOffset(tex0, texcoord0, ivec2(1, -1)).g;
float l3 = texture2DRectOffset(tex0, texcoord0, ivec2(-1, 1)).g; float l3 = textureRectOffset(tex0, texcoord0, ivec2(-1, 1)).g;
vec4 l01min = min(l0, l1), l01max = max(l0, l1); vec4 l01min = min(l0, l1), l01max = max(l0, l1);
l01min.xy = min(l01min.xy, l01min.zw); l01min.xy = min(l01min.xy, l01min.zw);
l01max.xy = max(l01max.xy, l01max.zw); l01max.xy = max(l01max.xy, l01max.zw);

View File

@ -90,7 +90,7 @@ ambientobscurancevariantshader = [
normal *= normscale > 0.75 ? normscale : 0.0; normal *= normscale > 0.75 ? normscale : 0.0;
normal = normalmatrix * normal; normal = normalmatrix * normal;
]]) ]])
vec2 noise = texture2D(tex2, texcoord1).rg*2.0-1.0; vec2 noise = texture(tex2, texcoord1).rg*2.0-1.0;
float obscure = 0.0; float obscure = 0.0;
@(loopconcat i $maxaotaps [result [ @(loopconcat i $maxaotaps [result [
vec2 offset@[i] = reflect(vec2(@(at $aotapoffsets $i)), noise); vec2 offset@[i] = reflect(vec2(@(at $aotapoffsets $i)), noise);
@ -193,19 +193,19 @@ bilateralvariantshader = [
#define tc @(? $upscaled [texcoord1] [gl_FragCoord.xy]) #define tc @(? $upscaled [texcoord1] [gl_FragCoord.xy])
#define depthtc @(? $reduced [texcoord0] [gl_FragCoord.xy]) #define depthtc @(? $reduced [texcoord0] [gl_FragCoord.xy])
#define tapvec(type, i) @(? (=s $filterdir "x") [type(i, 0.0)] [type(0.0, i)]) #define tapvec(type, i) @(? (=s $filterdir "x") [type(i, 0.0)] [type(0.0, i)])
#define texval(i) texture2DRect(tex0, tc + tapvec(vec2, i)) #define texval(i) textureRect(tex0, tc + tapvec(vec2, i))
#define texvaloffset(i) texture2DRectOffset(tex0, tc, tapvec(ivec2, i)) #define texvaloffset(i) textureRectOffset(tex0, tc, tapvec(ivec2, i))
#define depthval(i) gfetch(tex1, depthtc + tapvec(vec2, i)) #define depthval(i) gfetch(tex1, depthtc + tapvec(vec2, i))
#define depthvaloffset(i) gfetchoffset(tex1, depthtc, tapvec(ivec2, i)) #define depthvaloffset(i) gfetchoffset(tex1, depthtc, tapvec(ivec2, i))
@(cond [$packed] [ @(cond [$packed] [
if $aodepthformat [result [ if $aodepthformat [result [
vec2 vals = texture2DRect(tex0, tc).rg; vec2 vals = textureRect(tex0, tc).rg;
#define color vals.x #define color vals.x
@(if $upscaled [gdepthunpack depth [gfetch(tex1, depthtc)]] [result [ @(if $upscaled [gdepthunpack depth [gfetch(tex1, depthtc)]] [result [
#define depth vals.y #define depth vals.y
]]) ]])
]] [result [ ]] [result [
vec4 vals = texture2DRect(tex0, tc); vec4 vals = textureRect(tex0, tc);
#define color vals.a #define color vals.a
@(if $upscaled [gdepthunpack depth [gfetch(tex1, depthtc)]] [result [ @(if $upscaled [gdepthunpack depth [gfetch(tex1, depthtc)]] [result [
float depth = dot(vals.rgb, gdepthunpackparams); float depth = dot(vals.rgb, gdepthunpackparams);
@ -219,7 +219,7 @@ bilateralvariantshader = [
float depth = dot(gfetch(tex1, depthtc).rgb, gdepthunpackparams); float depth = dot(gfetch(tex1, depthtc).rgb, gdepthunpackparams);
]]) ]])
]] [result [ ]] [result [
float color = texture2DRect(tex0, tc).r; float color = textureRect(tex0, tc).r;
@(gdepthunpack depth [gfetch(tex1, depthtc)]) @(gdepthunpack depth [gfetch(tex1, depthtc)])
]]) ]])
float weights = 1.0; float weights = 1.0;

View File

@ -121,7 +121,7 @@ decalvariantshader = [
{ {
@(if (dtopt "n") [result [ @(if (dtopt "n") [result [
@(? (dtopt "p") [ @(? (dtopt "p") [
float height = texture2D(normalmap, texcoord0.xy).a; float height = texture(normalmap, texcoord0.xy).a;
vec3 camvecn = normalize(camvec); vec3 camvecn = normalize(camvec);
vec2 dtc = texcoord0.xy + (camvecn * world).xy*(height*parallaxscale.x + parallaxscale.y); vec2 dtc = texcoord0.xy + (camvecn * world).xy*(height*parallaxscale.x + parallaxscale.y);
] [ ] [
@ -129,7 +129,7 @@ decalvariantshader = [
]) ])
@(? (|| (! (dtopt "0")) (dtopt "r")) [ @(? (|| (! (dtopt "0")) (dtopt "r")) [
vec3 bump = texture2D(normalmap, dtc).rgb*2.0 - 1.0; vec3 bump = texture(normalmap, dtc).rgb*2.0 - 1.0;
vec3 bumpw = world * bump; vec3 bumpw = world * bump;
#define nvec bumpw #define nvec bumpw
]) ])
@ -137,10 +137,10 @@ decalvariantshader = [
#define dtc texcoord0.xy #define dtc texcoord0.xy
]]) ]])
vec4 diffuse = texture2D(diffusemap, dtc); vec4 diffuse = texture(diffusemap, dtc);
@(if (dtopt "g") [result [ @(if (dtopt "g") [result [
vec4 glowspec = texture2D(glowmap, dtc); vec4 glowspec = texture(glowmap, dtc);
#define glow glowspec.rgb #define glow glowspec.rgb
#define spec glowspec.a #define spec glowspec.a
glow *= @(? (dtopt "G") [mix(glowcolor.xyz, pulseglowcolor.xyz, pulse)] [glowcolor.xyz]); glow *= @(? (dtopt "G") [mix(glowcolor.xyz, pulseglowcolor.xyz, pulse)] [glowcolor.xyz]);
@ -149,7 +149,7 @@ decalvariantshader = [
@(if (dtopt "0") [result [ @(if (dtopt "0") [result [
@(if (&& (dtopt "S") [! (dtopt "g")]) [result [ @(if (&& (dtopt "S") [! (dtopt "g")]) [result [
float spec = @(? (|| (! (dtopt "n")) (dtopt "p")) [texture2D(glowmap, dtc).r] [texture2D(normalmap, dtc).a]); float spec = @(? (|| (! (dtopt "n")) (dtopt "p")) [texture(glowmap, dtc).r] [texture(normalmap, dtc).a]);
]]) ]])
@(gspecpack [gloss.x] (if (dtopt "s") [? (dtopt "S") [spec * specscale.x] [specscale.x]])) @(gspecpack [gloss.x] (if (dtopt "s") [? (dtopt "S") [spec * specscale.x] [specscale.x]]))
]]) ]])
@ -167,7 +167,7 @@ decalvariantshader = [
]) ])
float invfresnel = dot(camvecn, nvec); float invfresnel = dot(camvecn, nvec);
vec3 rvec = 2.0*nvec*invfresnel - camvecn; vec3 rvec = 2.0*nvec*invfresnel - camvecn;
vec3 reflect = textureCube(envmap, rvec).rgb * diffuse.a; vec3 reflect = texture(envmap, rvec).rgb * diffuse.a;
@(? (dtopt "R") [ @(? (dtopt "R") [
vec3 rmod = envscale.xyz*spec; vec3 rmod = envscale.xyz*spec;
] [ ] [

View File

@ -250,7 +250,7 @@ deferredlightvariantshader = [
return dot(mix(cols.xyz, cols.yzw, offset.x), vec3(1.0/9.0)); return dot(mix(cols.xyz, cols.yzw, offset.x), vec3(1.0/9.0));
} }
]] [dlopt "E"] [result [ ]] [dlopt "E"] [result [
#define shadowval(xy, xoff, yoff) float(shadow2DRect(tex4, vec3(xy + vec2(xoff, yoff), shadowtc.z))) #define shadowval(xy, xoff, yoff) float(textureRect(tex4, vec3(xy + vec2(xoff, yoff), shadowtc.z)))
float filtershadow(vec3 shadowtc) float filtershadow(vec3 shadowtc)
{ {
vec2 offset = fract(shadowtc.xy - 0.5); vec2 offset = fract(shadowtc.xy - 0.5);
@ -269,7 +269,7 @@ deferredlightvariantshader = [
(4.0/25.0)*shadowval(center.xy, 0.0, 0.0); (4.0/25.0)*shadowval(center.xy, 0.0, 0.0);
} }
]] [dlopt "F"] [result [ ]] [dlopt "F"] [result [
#define shadowval(center, xoff, yoff) float(shadow2DRect(tex4, center + vec3(xoff, yoff, 0.0))) #define shadowval(center, xoff, yoff) float(textureRect(tex4, center + vec3(xoff, yoff, 0.0)))
float filtershadow(vec3 shadowtc) float filtershadow(vec3 shadowtc)
{ {
vec2 offset = fract(shadowtc.xy - 0.5); vec2 offset = fract(shadowtc.xy - 0.5);
@ -290,7 +290,7 @@ deferredlightvariantshader = [
shadowval(center, 1.0, 1.0))); shadowval(center, 1.0, 1.0)));
} }
]] [dlopt "f"] [result [ ]] [dlopt "f"] [result [
#define shadowval(center, xoff, yoff) float(shadow2DRect(tex4, center + vec3(xoff, yoff, 0.0))) #define shadowval(center, xoff, yoff) float(textureRect(tex4, center + vec3(xoff, yoff, 0.0)))
float filtershadow(vec3 shadowtc) float filtershadow(vec3 shadowtc)
{ {
return dot(vec4(0.25), return dot(vec4(0.25),
@ -300,7 +300,7 @@ deferredlightvariantshader = [
shadowval(shadowtc, 1.0, 0.4))); shadowval(shadowtc, 1.0, 0.4)));
} }
]] [result [ ]] [result [
#define filtershadow(shadowtc) float(shadow2DRect(tex4, shadowtc)) #define filtershadow(shadowtc) float(textureRect(tex4, shadowtc))
]] ]]
]) ])
@ -342,7 +342,7 @@ deferredlightvariantshader = [
]]) ]])
tc.xy += 0.5; tc.xy += 0.5;
tc.z = tc.z * @(divf 1 $numrh) + offset; tc.z = tc.z * @(divf 1 $numrh) + offset;
vec4 shr = texture3D(tex6, tc), shg = texture3D(tex7, tc), shb = texture3D(tex8, tc), sha = texture3D(tex9, tc); vec4 shr = texture(tex6, tc), shg = texture(tex7, tc), shb = texture(tex8, tc), sha = texture(tex9, tc);
shr.rgb -= 0.5; shr.rgb -= 0.5;
shg.rgb -= 0.5; shg.rgb -= 0.5;
shb.rgb -= 0.5; shb.rgb -= 0.5;
@ -369,7 +369,7 @@ deferredlightvariantshader = [
#define accumalpha(alpha) resolved.a += alpha #define accumalpha(alpha) resolved.a += alpha
@(if (&& [dlopt "a"] [! $avatar] [! $transparent]) [result [ @(if (&& [dlopt "a"] [! $avatar] [! $transparent]) [result [
float ao = texture2DRect(tex5, gl_FragCoord.xy*aoscale).r; float ao = textureRect(tex5, gl_FragCoord.xy*aoscale).r;
]]) ]])
for(int sampleidx = 0; sampleidx < @msaasamples; sampleidx++) for(int sampleidx = 0; sampleidx < @msaasamples; sampleidx++)
@ -383,7 +383,7 @@ deferredlightvariantshader = [
#define accumalpha(alpha) fragcolor.a = alpha #define accumalpha(alpha) fragcolor.a = alpha
]] ]]
] [result [ ] [result [
#define gfetch(sampler, coords) texture2DRect(sampler, coords) #define gfetch(sampler, coords) textureRect(sampler, coords)
#define accumlight(light) fragcolor.rgb = light #define accumlight(light) fragcolor.rgb = light
#define accumalpha(alpha) fragcolor.a = alpha #define accumalpha(alpha) fragcolor.a = alpha
@ -466,7 +466,7 @@ deferredlightvariantshader = [
@(if (&& (dlopt "a") [! $avatar] [! $transparent]) [result [ @(if (&& (dlopt "a") [! $avatar] [! $transparent]) [result [
@(? (! (&& (dlopt "M") [dlopt "R"])) [ @(? (! (&& (dlopt "M") [dlopt "R"])) [
float ao = texture2DRect(tex5, gl_FragCoord.xy*aoscale).r; float ao = textureRect(tex5, gl_FragCoord.xy*aoscale).r;
]) ])
@(if (dlopt "d") [result [ @(if (dlopt "d") [result [
#define aomask ao #define aomask ao

View File

@ -24,7 +24,7 @@ shader 0 "blendbrush" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = texture2D(tex0, texcoord0).r * color; fragcolor = texture(tex0, texcoord0).r * color;
} }
] ]

View File

@ -232,11 +232,11 @@ shader 0 [fxaa@fxaapreset@fxaaopts] [
void main(void) void main(void)
{ {
#define posM texcoord0 #define posM texcoord0
vec4 rgbyM = texture2DRect(tex0, posM); vec4 rgbyM = textureRect(tex0, posM);
float lumaS = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2( 0, 1))); float lumaS = FXAA_LUMA(textureRectOffset(tex0, posM, ivec2( 0, 1)));
float lumaE = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2( 1, 0))); float lumaE = FXAA_LUMA(textureRectOffset(tex0, posM, ivec2( 1, 0)));
float lumaN = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2( 0, -1))); float lumaN = FXAA_LUMA(textureRectOffset(tex0, posM, ivec2( 0, -1)));
float lumaW = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2(-1, 0))); float lumaW = FXAA_LUMA(textureRectOffset(tex0, posM, ivec2(-1, 0)));
#define lumaM FXAA_LUMA(rgbyM) #define lumaM FXAA_LUMA(rgbyM)
float maxSM = max(lumaS, lumaM); float maxSM = max(lumaS, lumaM);
@ -258,10 +258,10 @@ shader 0 [fxaa@fxaapreset@fxaaopts] [
return; return;
} }
float lumaNW = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2(-1, -1))); float lumaNW = FXAA_LUMA(textureRectOffset(tex0, posM, ivec2(-1, -1)));
float lumaSE = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2( 1, 1))); float lumaSE = FXAA_LUMA(textureRectOffset(tex0, posM, ivec2( 1, 1)));
float lumaNE = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2( 1, -1))); float lumaNE = FXAA_LUMA(textureRectOffset(tex0, posM, ivec2( 1, -1)));
float lumaSW = FXAA_LUMA(texture2DRectOffset(tex0, posM, ivec2(-1, 1))); float lumaSW = FXAA_LUMA(textureRectOffset(tex0, posM, ivec2(-1, 1)));
float lumaNS = lumaN + lumaS; float lumaNS = lumaN + lumaS;
float lumaWE = lumaW + lumaE; float lumaWE = lumaW + lumaE;
@ -311,9 +311,9 @@ shader 0 [fxaa@fxaapreset@fxaaopts] [
vec2 posN = posB - offNP * FXAA_QUALITY_P0; vec2 posN = posB - offNP * FXAA_QUALITY_P0;
vec2 posP = posB + offNP * FXAA_QUALITY_P0; vec2 posP = posB + offNP * FXAA_QUALITY_P0;
float subpixD = ((-2.0)*subpixC) + 3.0; float subpixD = ((-2.0)*subpixC) + 3.0;
float lumaEndN = FXAA_LUMA(texture2DRect(tex0, posN)); float lumaEndN = FXAA_LUMA(textureRect(tex0, posN));
float subpixE = subpixC * subpixC; float subpixE = subpixC * subpixC;
float lumaEndP = FXAA_LUMA(texture2DRect(tex0, posP)); float lumaEndP = FXAA_LUMA(textureRect(tex0, posP));
if(!pairN) lumaNN = lumaSS; if(!pairN) lumaNN = lumaSS;
float gradientScaled = gradient * 1.0/4.0; float gradientScaled = gradient * 1.0/4.0;
@ -332,8 +332,8 @@ shader 0 [fxaa@fxaapreset@fxaaopts] [
#if (FXAA_QUALITY_PS > @i) #if (FXAA_QUALITY_PS > @i)
if(contN || contP) if(contN || contP)
{ {
if(contN) lumaEndN = FXAA_LUMA(texture2DRect(tex0, posN)); if(contN) lumaEndN = FXAA_LUMA(textureRect(tex0, posN));
if(contP) lumaEndP = FXAA_LUMA(texture2DRect(tex0, posP)); if(contP) lumaEndP = FXAA_LUMA(textureRect(tex0, posP));
if(contN) lumaEndN = lumaEndN - lumaNN * 0.5; if(contN) lumaEndN = lumaEndN - lumaNN * 0.5;
if(contP) lumaEndP = lumaEndP - lumaNN * 0.5; if(contP) lumaEndP = lumaEndP - lumaNN * 0.5;
contN = abs(lumaEndN) < gradientScaled; contN = abs(lumaEndN) < gradientScaled;
@ -369,7 +369,7 @@ shader 0 [fxaa@fxaapreset@fxaaopts] [
if(!horzSpan) posS.x += pixelOffsetSubpix * lengthSign; if(!horzSpan) posS.x += pixelOffsetSubpix * lengthSign;
if( horzSpan) posS.y += pixelOffsetSubpix * lengthSign; if( horzSpan) posS.y += pixelOffsetSubpix * lengthSign;
fragcolor = texture2DRect(tex0, posS); fragcolor = textureRect(tex0, posS);
} }
] ]

View File

@ -198,9 +198,9 @@ radiancehintsshader = [
{ {
vec3 rhpos = rhcenter + rhtap*rhspread; vec3 rhpos = rhcenter + rhtap*rhspread;
vec2 rsmtc = rsmcenter + rsmtap*rsmspread; vec2 rsmtc = rsmcenter + rsmtap*rsmspread;
float rsmdepth = texture2DRect(tex0, rsmtc).x; float rsmdepth = textureRect(tex0, rsmtc).x;
vec3 rsmcolor = texture2DRect(tex1, rsmtc).rgb; vec3 rsmcolor = textureRect(tex1, rsmtc).rgb;
vec3 rsmnormal = texture2DRect(tex2, rsmtc).xyz*2.0 - 1.0; vec3 rsmnormal = textureRect(tex2, rsmtc).xyz*2.0 - 1.0;
vec3 rsmpos = (rsmworldmatrix * vec4(rsmtc, rsmdepth, 1.0)).xyz; vec3 rsmpos = (rsmworldmatrix * vec4(rsmtc, rsmdepth, 1.0)).xyz;
vec3 dir = rhpos - rsmpos; vec3 dir = rhpos - rsmpos;
@ -255,10 +255,10 @@ lazyshader 0 radiancehintsborder [
{ {
float outside = clamp(borderscale.z*(abs(texcoord0.z - bordercenter.z) - borderrange.z), 0.0, 1.0); float outside = clamp(borderscale.z*(abs(texcoord0.z - bordercenter.z) - borderrange.z), 0.0, 1.0);
vec3 tc = vec3(texcoord0.xy, clamp(texcoord0.z, bordercenter.z - borderrange.z, bordercenter.z + borderrange.z)); vec3 tc = vec3(texcoord0.xy, clamp(texcoord0.z, bordercenter.z - borderrange.z, bordercenter.z + borderrange.z));
rhr = mix(texture3D(tex3, tc), vec4(0.5, 0.5, 0.5, 0.0), outside); rhr = mix(texture(tex3, tc), vec4(0.5, 0.5, 0.5, 0.0), outside);
rhg = mix(texture3D(tex4, tc), vec4(0.5, 0.5, 0.5, 0.0), outside); rhg = mix(texture(tex4, tc), vec4(0.5, 0.5, 0.5, 0.0), outside);
rhb = mix(texture3D(tex5, tc), vec4(0.5, 0.5, 0.5, 0.0), outside); rhb = mix(texture(tex5, tc), vec4(0.5, 0.5, 0.5, 0.0), outside);
rha = mix(texture3D(tex6, tc), vec4(0.5, 0.5, 0.5, 0.0), outside); rha = mix(texture(tex6, tc), vec4(0.5, 0.5, 0.5, 0.0), outside);
} }
] ]
@ -281,10 +281,10 @@ lazyshader 0 radiancehintscached [
void main(void) void main(void)
{ {
rhr = texture3D(tex7, texcoord0); rhr = texture(tex7, texcoord0);
rhg = texture3D(tex8, texcoord0); rhg = texture(tex8, texcoord0);
rhb = texture3D(tex9, texcoord0); rhb = texture(tex9, texcoord0);
rha = texture3D(tex10, texcoord0); rha = texture(tex10, texcoord0);
} }
] ]

View File

@ -39,9 +39,9 @@ grassvariantshader = [
@(? (grassopt "b") [uniform sampler2D tex1; in vec2 texcoord1;]) @(? (grassopt "b") [uniform sampler2D tex1; in vec2 texcoord1;])
void main(void) void main(void)
{ {
vec4 color = texture2D(tex0, texcoord0) * colorscale; vec4 color = texture(tex0, texcoord0) * colorscale;
@(? (grassopt "b") [ @(? (grassopt "b") [
color.a *= texture2D(tex1, texcoord1).r; color.a *= texture(tex1, texcoord1).r;
]) ])
if(color.a <= grasstest) if(color.a <= grasstest)
discard; discard;

View File

@ -23,7 +23,7 @@ shader 0 "hud" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
vec4 color = texture2D(tex0, texcoord0); vec4 color = texture(tex0, texcoord0);
fragcolor = colorscale * color; fragcolor = colorscale * color;
} }
] ]
@ -48,7 +48,7 @@ shader 0 "hudtext" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
float dist = texture2D(tex0, texcoord0).r; float dist = texture(tex0, texcoord0).r;
float border = smoothstep(textparams.x, textparams.y, dist); float border = smoothstep(textparams.x, textparams.y, dist);
float outline = smoothstep(textparams.z, textparams.w, dist); float outline = smoothstep(textparams.z, textparams.w, dist);
fragcolor = vec4(colorscale.rgb * outline, colorscale.a * border); fragcolor = vec4(colorscale.rgb * outline, colorscale.a * border);
@ -74,7 +74,7 @@ shader 0 "hudrgb" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
vec4 color = texture2D(tex0, texcoord0); vec4 color = texture(tex0, texcoord0);
fragcolor.rgb = colorscale.rgb * color.rgb; fragcolor.rgb = colorscale.rgb * color.rgb;
fragcolor.a = colorscale.a; fragcolor.a = colorscale.a;
} }
@ -117,7 +117,7 @@ shader 0 "hudrect" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = colorscale * texture2DRect(tex0, texcoord0); fragcolor = colorscale * textureRect(tex0, texcoord0);
} }
] ]
@ -140,7 +140,7 @@ shader 0 "hud3d" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = color * texture3D(tex0, texcoord0); fragcolor = color * texture(tex0, texcoord0);
} }
] ]
@ -163,7 +163,7 @@ shader 0 "hudcubemap" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = colorscale * textureCube(tex0, texcoord0); fragcolor = colorscale * texture(tex0, texcoord0);
} }
] ]

View File

@ -102,10 +102,10 @@ watershader = [
void main(void) void main(void)
{ {
vec3 camdir = camera - surface, camvec = normalize(camdir); vec3 camdir = camera - surface, camvec = normalize(camdir);
vec3 bump = texture2D(tex1, texcoord0 + millis*vec2( 0.25, 0.75)*0.1250).rgb; vec3 bump = texture(tex1, texcoord0 + millis*vec2( 0.25, 0.75)*0.1250).rgb;
vec3 bump2 = texture2D(tex1, texcoord0 + millis*vec2(-0.75, -0.25)*0.1450).rgb; vec3 bump2 = texture(tex1, texcoord0 + millis*vec2(-0.75, -0.25)*0.1450).rgb;
vec3 bump3 = texture2D(tex1, texcoord1 + millis*vec2(-0.50, 0.50)*0.0805).rgb; vec3 bump3 = texture(tex1, texcoord1 + millis*vec2(-0.50, 0.50)*0.0805).rgb;
vec3 bump4 = texture2D(tex1, texcoord1 + millis*vec2( 0.25, -0.75)*0.0825).rgb; vec3 bump4 = texture(tex1, texcoord1 + millis*vec2( 0.25, -0.75)*0.0825).rgb;
bump = normalize(bump + bump2 + bump3 + bump4 - 2.0); bump = normalize(bump + bump2 + bump3 + bump4 - 2.0);
vec2 rtc = bump.xy * waterrefract.w; vec2 rtc = bump.xy * waterrefract.w;
@ -126,7 +126,7 @@ watershader = [
@(? (>= (strstr $arg1 "caustics") 0) [ @(? (>= (strstr $arg1 "caustics") 0) [
vec2 ctc = vec2(dot(causticsS, rpos.xyz), dot(causticsT, rpos.xyz)); vec2 ctc = vec2(dot(causticsS, rpos.xyz), dot(causticsT, rpos.xyz));
float caustics = causticsblend.x*texture2D(tex2, ctc).r + causticsblend.y*texture2D(tex3, ctc).r + causticsblend.z; float caustics = causticsblend.x*texture(tex2, ctc).r + causticsblend.y*texture(tex3, ctc).r + causticsblend.z;
rcolor *= caustics; rcolor *= caustics;
]) ])
@ -157,7 +157,7 @@ watershader = [
float fresnel = 0.25 + 0.75*pow(clamp(1.0 - dot(camvec, bump), 0.0, 1.0), 4.0); float fresnel = 0.25 + 0.75*pow(clamp(1.0 - dot(camvec, bump), 0.0, 1.0), 4.0);
rcolor = mix(rcolor, reflect, fresnel*edgefade); rcolor = mix(rcolor, reflect, fresnel*edgefade);
]] [if (>= (strstr $arg1 "env") 0) [result [ ]] [if (>= (strstr $arg1 "env") 0) [result [
vec3 reflect = textureCube(tex4, reflectdir).rgb*0.5; vec3 reflect = texture(tex4, reflectdir).rgb*0.5;
float fresnel = 0.5*pow(clamp(1.0 - dot(camvec, bump), 0.0, 1.0), 4.0); float fresnel = 0.5*pow(clamp(1.0 - dot(camvec, bump), 0.0, 1.0), 4.0);
rcolor = mix(rcolor, reflect, fresnel); rcolor = mix(rcolor, reflect, fresnel);
]]]) ]]])
@ -201,7 +201,7 @@ causticshader = [
vec4 ctc = causticsmatrix * vec4(gl_FragCoord.xy, depth, 1.0); vec4 ctc = causticsmatrix * vec4(gl_FragCoord.xy, depth, 1.0);
ctc.xyz /= ctc.w; ctc.xyz /= ctc.w;
]) ])
float caustics = causticsblend.x*texture2D(tex0, ctc.xy).r + causticsblend.y*texture2D(tex1, ctc.xy).r + causticsblend.z; float caustics = causticsblend.x*texture(tex0, ctc.xy).r + causticsblend.y*texture(tex1, ctc.xy).r + causticsblend.z;
caustics *= clamp(ctc.z, 0.0, 1.0) * clamp(exp2(ctc.z*waterdeepfade.w), 0.0, 1.0); caustics *= clamp(ctc.z, 0.0, 1.0) * clamp(exp2(ctc.z*waterdeepfade.w), 0.0, 1.0);
fragcolor.rgb = vec3(0.5 + caustics); fragcolor.rgb = vec3(0.5 + caustics);
} }
@ -271,8 +271,8 @@ lazyshader 0 "lava" [
void main(void) void main(void)
{ {
vec3 diffuse = texture2D(tex0, texcoord0).rgb; vec3 diffuse = texture(tex0, texcoord0).rgb;
vec3 bump = texture2D(tex1, texcoord0).rgb*2.0-1.0; vec3 bump = texture(tex1, texcoord0).rgb*2.0-1.0;
vec3 bumpw = normalize(world * bump); vec3 bumpw = normalize(world * bump);
gcolor.rgb = diffuse; gcolor.rgb = diffuse;
@(gspecpack 0.0 lavaspec) @(gspecpack 0.0 lavaspec)
@ -318,8 +318,8 @@ lazyshader 0 "waterfallenv" [
void main(void) void main(void)
{ {
vec3 camvec = normalize(camdir); vec3 camvec = normalize(camdir);
vec3 diffuse = texture2D(tex0, texcoord0).rgb; vec3 diffuse = texture(tex0, texcoord0).rgb;
vec3 bump = texture2D(tex1, texcoord0).rgb*2.0 - 1.0; vec3 bump = texture(tex1, texcoord0).rgb*2.0 - 1.0;
vec3 bumpw = normalize(world * bump); vec3 bumpw = normalize(world * bump);
vec2 rtc = bump.xy * waterfallrefract.w; vec2 rtc = bump.xy * waterfallrefract.w;
@ -328,7 +328,7 @@ lazyshader 0 "waterfallenv" [
vec3 rcolor = gfetch(tex8, rtc).rgb * waterfallrefract.xyz; vec3 rcolor = gfetch(tex8, rtc).rgb * waterfallrefract.xyz;
float invfresnel = dot(camvec, bumpw); float invfresnel = dot(camvec, bumpw);
vec3 env = textureCube(tex3, 2.0*bumpw*invfresnel - camvec).rgb; vec3 env = texture(tex3, 2.0*bumpw*invfresnel - camvec).rgb;
env *= 0.1 + 0.4*pow(clamp(1.0 - invfresnel, 0.0, 1.0), 2.0); env *= 0.1 + 0.4*pow(clamp(1.0 - invfresnel, 0.0, 1.0), 2.0);
gcolor.rgb = vec3(0.0); gcolor.rgb = vec3(0.0);
@ -369,8 +369,8 @@ lazyshader 0 "waterfall" [
void main(void) void main(void)
{ {
vec3 diffuse = texture2D(tex0, texcoord0).rgb; vec3 diffuse = texture(tex0, texcoord0).rgb;
vec3 bump = texture2D(tex1, texcoord0).rgb*2.0 - 1.0; vec3 bump = texture(tex1, texcoord0).rgb*2.0 - 1.0;
vec3 bumpw = normalize(world * bump); vec3 bumpw = normalize(world * bump);
vec2 rtc = bump.xy * waterfallrefract.w; vec2 rtc = bump.xy * waterfallrefract.w;
@ -421,7 +421,7 @@ lazyshader 0 "glassenv" [
void main(void) void main(void)
{ {
vec3 camvec = normalize(camdir); vec3 camvec = normalize(camdir);
vec3 bump = texture2D(tex1, texcoord0).rgb*2.0 - 1.0; vec3 bump = texture(tex1, texcoord0).rgb*2.0 - 1.0;
vec3 bumpw = normalize(world * bump); vec3 bumpw = normalize(world * bump);
vec2 rtc = bump.xy * glassrefract.w; vec2 rtc = bump.xy * glassrefract.w;
@ -431,7 +431,7 @@ lazyshader 0 "glassenv" [
rcolor *= glassrefract.xyz; rcolor *= glassrefract.xyz;
float invfresnel = dot(camvec, bumpw); float invfresnel = dot(camvec, bumpw);
vec3 env = textureCube(tex0, 2.0*bumpw*invfresnel - camvec).rgb; vec3 env = texture(tex0, 2.0*bumpw*invfresnel - camvec).rgb;
env *= 0.1 + 0.4*pow(clamp(1.0 - invfresnel, 0.0, 1.0), 2.0); env *= 0.1 + 0.4*pow(clamp(1.0 - invfresnel, 0.0, 1.0), 2.0);
gcolor.rgb = vec3(0.0); gcolor.rgb = vec3(0.0);
@ -471,7 +471,7 @@ lazyshader 0 "glass" [
void main(void) void main(void)
{ {
vec3 bump = texture2D(tex1, texcoord0).rgb*2.0 - 1.0; vec3 bump = texture(tex1, texcoord0).rgb*2.0 - 1.0;
vec3 bumpw = normalize(world * bump); vec3 bumpw = normalize(world * bump);
vec2 rtc = bump.xy * glassrefract.w; vec2 rtc = bump.xy * glassrefract.w;

View File

@ -87,7 +87,7 @@ shader 0 "ldr" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
vec4 color = texture2D(tex0, texcoord0); vec4 color = texture(tex0, texcoord0);
fragcolor = colorscale * color; fragcolor = colorscale * color;
} }
] ]
@ -137,7 +137,7 @@ shader 0 "fogged" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
vec4 color = texture2D(tex0, texcoord0); vec4 color = texture(tex0, texcoord0);
fragcolor = colorscale * color; fragcolor = colorscale * color;
} }
] ]

View File

@ -109,7 +109,7 @@ shadowmodelfragmentshader = [
void main(void) void main(void)
{ {
@(? (mdlopt "a") [ @(? (mdlopt "a") [
vec4 color = texture2D(tex0, texcoord0); vec4 color = texture(tex0, texcoord0);
if(color.a <= alphatest) if(color.a <= alphatest)
discard; discard;
]) ])
@ -224,7 +224,7 @@ modelfragmentshader = [
void main(void) void main(void)
{ {
vec4 diffuse = texture2D(tex0, texcoord0); vec4 diffuse = texture(tex0, texcoord0);
@(? (mdlopt "a") [ @(? (mdlopt "a") [
if(diffuse.a <= alphatest) if(diffuse.a <= alphatest)
@ -234,7 +234,7 @@ modelfragmentshader = [
gcolor.rgb = diffuse.rgb*colorscale.rgb; gcolor.rgb = diffuse.rgb*colorscale.rgb;
@(? (|| (mdlopt "d") [mdlopt "D"]) [ @(? (|| (mdlopt "d") [mdlopt "D"]) [
vec4 decal = texture2D(tex4, texcoord0); vec4 decal = texture(tex4, texcoord0);
@(? (mdlopt "D") [ @(? (mdlopt "D") [
gcolor.rgb = mix(gcolor.rgb, decal.rgb, decal.a); gcolor.rgb = mix(gcolor.rgb, decal.rgb, decal.a);
] [ ] [
@ -243,7 +243,7 @@ modelfragmentshader = [
]) ])
@(if (mdlopt "n") [result [ @(if (mdlopt "n") [result [
vec3 normal = texture2D(tex3, texcoord0).rgb - 0.5; vec3 normal = texture(tex3, texcoord0).rgb - 0.5;
@(? (mdlopt "c") [ @(? (mdlopt "c") [
if(!gl_FrontFacing) normal.z = -normal.z; if(!gl_FrontFacing) normal.z = -normal.z;
]) ])
@ -257,7 +257,7 @@ modelfragmentshader = [
float spec = maskscale.x; float spec = maskscale.x;
@(if (mdlopt "m") [result [ @(if (mdlopt "m") [result [
vec3 masks = texture2D(tex1, texcoord0).rgb; vec3 masks = texture(tex1, texcoord0).rgb;
spec *= masks.r; // specmap in red channel spec *= masks.r; // specmap in red channel
@(? (mdlopt "e") [ @(? (mdlopt "e") [
@ -265,7 +265,7 @@ modelfragmentshader = [
float invfresnel = dot(camn, normal); float invfresnel = dot(camn, normal);
vec3 rvec = 2.0*invfresnel*normal - camn; vec3 rvec = 2.0*invfresnel*normal - camn;
float rmod = envmapscale.x*clamp(invfresnel, 0.0, 1.0) + envmapscale.y; float rmod = envmapscale.x*clamp(invfresnel, 0.0, 1.0) + envmapscale.y;
vec3 reflect = textureCube(tex2, rvec).rgb; vec3 reflect = texture(tex2, rvec).rgb;
gcolor.rgb = mix(gcolor.rgb, reflect, rmod*masks.b); // envmap mask in blue channel gcolor.rgb = mix(gcolor.rgb, reflect, rmod*masks.b); // envmap mask in blue channel
]) ])
@ -349,7 +349,7 @@ rsmmodelfragmentshader = [
layout(location = 1) out vec4 gnormal; layout(location = 1) out vec4 gnormal;
void main(void) void main(void)
{ {
vec4 diffuse = texture2D(tex0, texcoord0); vec4 diffuse = texture(tex0, texcoord0);
@(? (mdlopt "a") [ @(? (mdlopt "a") [
if(diffuse.a <= alphatest) if(diffuse.a <= alphatest)
discard; discard;

View File

@ -19,7 +19,7 @@ lazyshader 0 "moviergb" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = texture2DRect(tex0, texcoord0); fragcolor = textureRect(tex0, texcoord0);
} }
] ]
@ -38,7 +38,7 @@ lazyshader 0 "movieyuv" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
vec3 color = texture2DRect(tex0, texcoord0).rgb; vec3 color = textureRect(tex0, texcoord0).rgb;
fragcolor = vec4(dot(color, vec3(0.439216, -0.367788, -0.071427)) + 0.501961, fragcolor = vec4(dot(color, vec3(0.439216, -0.367788, -0.071427)) + 0.501961,
dot(color, vec3(-0.148224, -0.290992, 0.439216)) + 0.501961, dot(color, vec3(-0.148224, -0.290992, 0.439216)) + 0.501961,
dot(color, vec3(0.256788, 0.504125, 0.097905)) + 0.062745, dot(color, vec3(0.256788, 0.504125, 0.097905)) + 0.062745,
@ -61,10 +61,10 @@ lazyshader 0 "moviey" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
vec3 color1 = texture2DRectOffset(tex0, texcoord0, ivec2( -2, 0)).rgb; vec3 color1 = textureRectOffset(tex0, texcoord0, ivec2( -2, 0)).rgb;
vec3 color2 = texture2DRectOffset(tex0, texcoord0, ivec2( -1, 0)).rgb; vec3 color2 = textureRectOffset(tex0, texcoord0, ivec2( -1, 0)).rgb;
vec3 color3 = texture2DRect(tex0, texcoord0).rgb; vec3 color3 = textureRect(tex0, texcoord0).rgb;
vec3 color4 = texture2DRectOffset(tex0, texcoord0, ivec2( 1, 0)).rgb; vec3 color4 = textureRectOffset(tex0, texcoord0, ivec2( 1, 0)).rgb;
fragcolor = vec4(dot(color3, vec3(0.256788, 0.504125, 0.097905)) + 0.062745, fragcolor = vec4(dot(color3, vec3(0.256788, 0.504125, 0.097905)) + 0.062745,
dot(color2, vec3(0.256788, 0.504125, 0.097905)) + 0.062745, dot(color2, vec3(0.256788, 0.504125, 0.097905)) + 0.062745,
dot(color1, vec3(0.256788, 0.504125, 0.097905)) + 0.062745, dot(color1, vec3(0.256788, 0.504125, 0.097905)) + 0.062745,
@ -87,10 +87,10 @@ lazyshader 0 "movieu" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
vec3 color1 = texture2DRectOffset(tex0, texcoord0, ivec2(-3, 0)).rgb; vec3 color1 = textureRectOffset(tex0, texcoord0, ivec2(-3, 0)).rgb;
vec3 color2 = texture2DRectOffset(tex0, texcoord0, ivec2(-1, 0)).rgb; vec3 color2 = textureRectOffset(tex0, texcoord0, ivec2(-1, 0)).rgb;
vec3 color3 = texture2DRectOffset(tex0, texcoord0, ivec2( 1, 0)).rgb; vec3 color3 = textureRectOffset(tex0, texcoord0, ivec2( 1, 0)).rgb;
vec3 color4 = texture2DRectOffset(tex0, texcoord0, ivec2( 3, 0)).rgb; vec3 color4 = textureRectOffset(tex0, texcoord0, ivec2( 3, 0)).rgb;
fragcolor = vec4(dot(color3, vec3(-0.148224, -0.290992, 0.43921)) + 0.501961, fragcolor = vec4(dot(color3, vec3(-0.148224, -0.290992, 0.43921)) + 0.501961,
dot(color2, vec3(-0.148224, -0.290992, 0.43921)) + 0.501961, dot(color2, vec3(-0.148224, -0.290992, 0.43921)) + 0.501961,
dot(color1, vec3(-0.148224, -0.290992, 0.43921)) + 0.501961, dot(color1, vec3(-0.148224, -0.290992, 0.43921)) + 0.501961,
@ -113,10 +113,10 @@ lazyshader 0 "moviev" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
vec3 color1 = texture2DRectOffset(tex0, texcoord0, ivec2(-3, 0)).rgb; vec3 color1 = textureRectOffset(tex0, texcoord0, ivec2(-3, 0)).rgb;
vec3 color2 = texture2DRectOffset(tex0, texcoord0, ivec2(-1, 0)).rgb; vec3 color2 = textureRectOffset(tex0, texcoord0, ivec2(-1, 0)).rgb;
vec3 color3 = texture2DRectOffset(tex0, texcoord0, ivec2( 1, 0)).rgb; vec3 color3 = textureRectOffset(tex0, texcoord0, ivec2( 1, 0)).rgb;
vec3 color4 = texture2DRectOffset(tex0, texcoord0, ivec2( 3, 0)).rgb; vec3 color4 = textureRectOffset(tex0, texcoord0, ivec2( 3, 0)).rgb;
fragcolor = vec4(dot(color3, vec3(0.439216, -0.367788, -0.071427)) + 0.501961, fragcolor = vec4(dot(color3, vec3(0.439216, -0.367788, -0.071427)) + 0.501961,
dot(color2, vec3(0.439216, -0.367788, -0.071427)) + 0.501961, dot(color2, vec3(0.439216, -0.367788, -0.071427)) + 0.501961,
dot(color1, vec3(0.439216, -0.367788, -0.071427)) + 0.501961, dot(color1, vec3(0.439216, -0.367788, -0.071427)) + 0.501961,

View File

@ -51,8 +51,8 @@ explosionshader = [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
vec2 dtc = texcoord0 + texture2D(tex0, texcoord2).xy*0.1; // use color texture as noise to distort texcoords vec2 dtc = texcoord0 + texture(tex0, texcoord2).xy*0.1; // use color texture as noise to distort texcoords
vec4 diffuse = texture2D(tex0, dtc); vec4 diffuse = texture(tex0, dtc);
float blend = max(pow(clamp(1.0 - dot(texcoord1, texcoord1), 0.0, 1.0), blendparams.x), blendparams.y); float blend = max(pow(clamp(1.0 - dot(texcoord1, texcoord1), 0.0, 1.0), blendparams.x), blendparams.y);
diffuse *= blend*4.0; // dup alpha into RGB channels + intensify and over saturate diffuse *= blend*4.0; // dup alpha into RGB channels + intensify and over saturate
diffuse.b += 0.5 - blend*0.5; // blue tint diffuse.b += 0.5 - blend*0.5; // blue tint
@ -114,7 +114,7 @@ shader 0 "particletext" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
float dist = texture2D(tex0, texcoord0).r; float dist = texture(tex0, texcoord0).r;
float border = smoothstep(textparams.x, textparams.y, dist); float border = smoothstep(textparams.x, textparams.y, dist);
float outline = smoothstep(textparams.z, textparams.w, dist); float outline = smoothstep(textparams.z, textparams.w, dist);
fragcolor = vec4(color.rgb * outline, color.a * border); fragcolor = vec4(color.rgb * outline, color.a * border);
@ -159,7 +159,7 @@ particleshader = [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
vec4 diffuse = texture2D(tex0, texcoord0); vec4 diffuse = texture(tex0, texcoord0);
@(if (>= (strstr $arg1 "soft") 0) [result [ @(if (>= (strstr $arg1 "soft") 0) [result [
@(gdepthunpack depth [gfetch(tex2, gl_FragCoord.xy)]) @(gdepthunpack depth [gfetch(tex2, gl_FragCoord.xy)])

View File

@ -24,7 +24,7 @@ fsps = [result [
@arg2 @arg2
void main(void) void main(void)
{ {
vec4 color = texture2DRect(tex0, texcoord0); vec4 color = textureRect(tex0, texcoord0);
@arg1 @arg1
} }
]] ]]
@ -43,10 +43,10 @@ fsvs4 = [
fsps4 = [ fsps4 = [
fsps [ fsps [
vec4 s00 = texture2DRect(tex0, texcoord1); vec4 s00 = textureRect(tex0, texcoord1);
vec4 s02 = texture2DRect(tex0, texcoord2); vec4 s02 = textureRect(tex0, texcoord2);
vec4 s20 = texture2DRect(tex0, texcoord3); vec4 s20 = textureRect(tex0, texcoord3);
vec4 s22 = texture2DRect(tex0, texcoord4); vec4 s22 = textureRect(tex0, texcoord4);
@arg1 @arg1
] [ ] [
in vec2 texcoord1, texcoord2, texcoord3, texcoord4; in vec2 texcoord1, texcoord2, texcoord3, texcoord4;
@ -93,15 +93,15 @@ lazyshader 0 "rotoscope" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
vec4 c00 = texture2DRect(tex0, t00); vec4 c00 = textureRect(tex0, t00);
vec4 c01 = texture2DRect(tex0, t01); vec4 c01 = textureRect(tex0, t01);
vec4 c02 = texture2DRect(tex0, t02); vec4 c02 = textureRect(tex0, t02);
vec4 c10 = texture2DRect(tex0, t10); vec4 c10 = textureRect(tex0, t10);
vec4 c11 = texture2DRect(tex0, t11); vec4 c11 = textureRect(tex0, t11);
vec4 c12 = texture2DRect(tex0, t12); vec4 c12 = textureRect(tex0, t12);
vec4 c20 = texture2DRect(tex0, t20); vec4 c20 = textureRect(tex0, t20);
vec4 c21 = texture2DRect(tex0, t21); vec4 c21 = textureRect(tex0, t21);
vec4 c22 = texture2DRect(tex0, t22); vec4 c22 = textureRect(tex0, t22);
vec4 diag1 = c00 - c22; vec4 diag1 = c00 - c22;
vec4 diag2 = c02 - c20; vec4 diag2 = c02 - c20;
@ -140,7 +140,7 @@ blur3shader = [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = 0.5*(texture2DRect(tex0, texcoord0) + texture2DRect(tex0, texcoord1)); fragcolor = 0.5*(textureRect(tex0, texcoord0) + textureRect(tex0, texcoord1));
} }
] ]
] ]
@ -165,7 +165,7 @@ blur5shader = [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = 0.4*texture2DRect(tex0, texcoord0) + 0.3*(texture2DRect(tex0, texcoord1) + texture2DRect(tex0, texcoord2)); fragcolor = 0.4*textureRect(tex0, texcoord0) + 0.3*(textureRect(tex0, texcoord1) + textureRect(tex0, texcoord2));
} }
] ]
] ]

View File

@ -21,7 +21,7 @@ shader 0 "scalelinear" [
void main(void) void main(void)
{ {
fragcolor = texture2DRect(tex0, texcoord0); fragcolor = textureRect(tex0, texcoord0);
} }
] ]
@ -57,13 +57,13 @@ loop i 2 [
@(if $i [result [ @(if $i [result [
float offset = fract(texcoord0.y-0.5); float offset = fract(texcoord0.y-0.5);
center.y -= offset; center.y -= offset;
#define texval(tap) texture2DRect(tex0, center + vec2(0.0, tap)) #define texval(tap) textureRect(tex0, center + vec2(0.0, tap))
#define texvaloffset(tap) texture2DRectOffset(tex0, center, ivec2(0, tap)) #define texvaloffset(tap) textureRectOffset(tex0, center, ivec2(0, tap))
]] [result [ ]] [result [
float offset = fract(texcoord0.x-0.5); float offset = fract(texcoord0.x-0.5);
center.x -= offset; center.x -= offset;
#define texval(tap) texture2DRect(tex0, center + vec2(tap, 0.0)) #define texval(tap) textureRect(tex0, center + vec2(tap, 0.0))
#define texvaloffset(tap) texture2DRectOffset(tex0, center, ivec2(tap, 0)) #define texvaloffset(tap) textureRectOffset(tex0, center, ivec2(tap, 0))
]]) ]])
vec4 weight = cubic(offset); vec4 weight = cubic(offset);
weight.y += weight.z; weight.y += weight.z;
@ -91,7 +91,7 @@ shader 0 "reorient" [
void main(void) void main(void)
{ {
fragcolor = texture2DRect(tex0, texcoord0); fragcolor = textureRect(tex0, texcoord0);
} }
] ]

View File

@ -161,9 +161,9 @@ gfetchdefs = [
@(if (! $arg3) [gdepthunpackparams]) @(if (! $arg3) [gdepthunpackparams])
]] [result [ ]] [result [
uniform sampler2DRect @(prettylist $arg1); uniform sampler2DRect @(prettylist $arg1);
#define @[gfetchprefix](sampler, coords) texture2DRect(sampler, coords) #define @[gfetchprefix](sampler, coords) textureRect(sampler, coords)
#define @[gfetchprefix]offset(sampler, coords, offset) texture2DRectOffset(sampler, coords, offset) #define @[gfetchprefix]offset(sampler, coords, offset) textureRectOffset(sampler, coords, offset)
#define @[gfetchprefix]proj(sampler, coords) texture2DRectProj(sampler, coords) #define @[gfetchprefix]proj(sampler, coords) textureRectProj(sampler, coords)
@(if (! $arg3) [gdepthunpackparams]) @(if (! $arg3) [gdepthunpackparams])
]] ]]
] ]

View File

@ -24,7 +24,7 @@ shader 0 "skybox" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
vec4 color = texture2D(tex0, texcoord0); vec4 color = texture(tex0, texcoord0);
fragcolor = colorscale * color; fragcolor = colorscale * color;
} }
] ]
@ -51,7 +51,7 @@ shader 0 "skyboxoverbright" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
vec4 color = texture2D(tex0, texcoord0); vec4 color = texture(tex0, texcoord0);
float lum = dot(vec3(@lumweights), color.rgb); float lum = dot(vec3(@lumweights), color.rgb);
float overbright = mix(overbrightparams.x, overbrightparams.y, clamp(lum - overbrightparams.z, 0.0, 1.0)); float overbright = mix(overbrightparams.x, overbrightparams.y, clamp(lum - overbrightparams.z, 0.0, 1.0));
color.rgb *= overbright; color.rgb *= overbright;

View File

@ -111,9 +111,9 @@ shader 0 [SMAALumaEdgeDetection@smaapreset@smaaopts] [
void main(void) void main(void)
{ {
// Calculate lumas: // Calculate lumas:
float L = SMAA_LUMA(texture2DRect(tex0, texcoord0)); float L = SMAA_LUMA(textureRect(tex0, texcoord0));
float Lleft = SMAA_LUMA(texture2DRectOffset(tex0, texcoord0, ivec2(-1, 0))); float Lleft = SMAA_LUMA(textureRectOffset(tex0, texcoord0, ivec2(-1, 0)));
float Ltop = SMAA_LUMA(texture2DRectOffset(tex0, texcoord0, ivec2(0, -1))); float Ltop = SMAA_LUMA(textureRectOffset(tex0, texcoord0, ivec2(0, -1)));
// We do the usual threshold: // We do the usual threshold:
vec2 delta = abs(L - vec2(Lleft, Ltop)); vec2 delta = abs(L - vec2(Lleft, Ltop));
@ -128,14 +128,14 @@ shader 0 [SMAALumaEdgeDetection@smaapreset@smaaopts] [
]) ])
{ {
// Calculate right and bottom deltas: // Calculate right and bottom deltas:
float Lright = SMAA_LUMA(texture2DRectOffset(tex0, texcoord0, ivec2(1, 0))); float Lright = SMAA_LUMA(textureRectOffset(tex0, texcoord0, ivec2(1, 0)));
float Lbottom = SMAA_LUMA(texture2DRectOffset(tex0, texcoord0, ivec2(0, 1))); float Lbottom = SMAA_LUMA(textureRectOffset(tex0, texcoord0, ivec2(0, 1)));
// Calculate the maximum delta in the direct neighborhood: // Calculate the maximum delta in the direct neighborhood:
vec2 maxDelta = max(delta, abs(L - vec2(Lright, Lbottom))); vec2 maxDelta = max(delta, abs(L - vec2(Lright, Lbottom)));
// Calculate left-left and top-top deltas: // Calculate left-left and top-top deltas:
float Lleftleft = SMAA_LUMA(texture2DRectOffset(tex0, texcoord0, ivec2(-2, 0))); float Lleftleft = SMAA_LUMA(textureRectOffset(tex0, texcoord0, ivec2(-2, 0)));
float Ltoptop = SMAA_LUMA(texture2DRectOffset(tex0, texcoord0, ivec2(0, -2))); float Ltoptop = SMAA_LUMA(textureRectOffset(tex0, texcoord0, ivec2(0, -2)));
// Calculate the final maximum delta: // Calculate the final maximum delta:
maxDelta = max(maxDelta, abs(vec2(Lleft, Ltop) - vec2(Lleftleft, Ltoptop))); maxDelta = max(maxDelta, abs(vec2(Lleft, Ltop) - vec2(Lleftleft, Ltoptop)));
@ -175,9 +175,9 @@ shader 0 [SMAAColorEdgeDetection@smaapreset@smaaopts] [
void main(void) void main(void)
{ {
// Calculate color deltas: // Calculate color deltas:
vec3 C = texture2DRect(tex0, texcoord0).rgb; vec3 C = textureRect(tex0, texcoord0).rgb;
vec3 Cleft = abs(C - texture2DRectOffset(tex0, texcoord0, ivec2(-1, 0)).rgb); vec3 Cleft = abs(C - textureRectOffset(tex0, texcoord0, ivec2(-1, 0)).rgb);
vec3 Ctop = abs(C - texture2DRectOffset(tex0, texcoord0, ivec2(0, -1)).rgb); vec3 Ctop = abs(C - textureRectOffset(tex0, texcoord0, ivec2(0, -1)).rgb);
vec2 delta; vec2 delta;
delta.x = max(max(Cleft.r, Cleft.g), Cleft.b); delta.x = max(max(Cleft.r, Cleft.g), Cleft.b);
delta.y = max(max(Ctop.r, Ctop.g), Ctop.b); delta.y = max(max(Ctop.r, Ctop.g), Ctop.b);
@ -194,11 +194,11 @@ shader 0 [SMAAColorEdgeDetection@smaapreset@smaaopts] [
]) ])
{ {
// Calculate right and bottom deltas: // Calculate right and bottom deltas:
vec3 Cright = abs(C - texture2DRectOffset(tex0, texcoord0, ivec2(1, 0)).rgb); vec3 Cright = abs(C - textureRectOffset(tex0, texcoord0, ivec2(1, 0)).rgb);
vec3 Cbottom = abs(C - texture2DRectOffset(tex0, texcoord0, ivec2(0, 1)).rgb); vec3 Cbottom = abs(C - textureRectOffset(tex0, texcoord0, ivec2(0, 1)).rgb);
// Calculate left-left and top-top deltas: // Calculate left-left and top-top deltas:
vec3 Cleftleft = abs(C - texture2DRectOffset(tex0, texcoord0, ivec2(-2, 0)).rgb); vec3 Cleftleft = abs(C - textureRectOffset(tex0, texcoord0, ivec2(-2, 0)).rgb);
vec3 Ctoptop = abs(C - texture2DRectOffset(tex0, texcoord0, ivec2(0, -2)).rgb); vec3 Ctoptop = abs(C - textureRectOffset(tex0, texcoord0, ivec2(0, -2)).rgb);
// Calculate the maximum delta in the direct neighborhood: // Calculate the maximum delta in the direct neighborhood:
vec3 t = max(max(Cright, Cbottom), max(Cleftleft, Ctoptop)); vec3 t = max(max(Cright, Cbottom), max(Cleftleft, Ctoptop));
// Calculate the final maximum delta: // Calculate the final maximum delta:
@ -257,45 +257,45 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
* These functions allows to perform diagonal pattern searches. * These functions allows to perform diagonal pattern searches.
*/ */
float SMAASearchDiagRightUp(void) { float SMAASearchDiagRightUp(void) {
vec2 e = texture2DRectOffset(tex0, texcoord0, ivec2(1, -1)).rg; vec2 e = textureRectOffset(tex0, texcoord0, ivec2(1, -1)).rg;
vec2 texcoord = texcoord0 + vec2(1.0, -1.0); vec2 texcoord = texcoord0 + vec2(1.0, -1.0);
for (int i = 1; i < SMAA_MAX_SEARCH_STEPS_DIAG; i++) { for (int i = 1; i < SMAA_MAX_SEARCH_STEPS_DIAG; i++) {
if (e.x + e.y < 1.5) break; if (e.x + e.y < 1.5) break;
texcoord += vec2(1.0, -1.0); texcoord += vec2(1.0, -1.0);
e = texture2DRect(tex0, texcoord).rg; e = textureRect(tex0, texcoord).rg;
} }
return (texcoord.x - texcoord0.x) - 1.0; return (texcoord.x - texcoord0.x) - 1.0;
} }
float SMAASearchDiagLeftDown(void) { float SMAASearchDiagLeftDown(void) {
vec2 e = texture2DRectOffset(tex0, texcoord0, ivec2(-1, 1)).rg; vec2 e = textureRectOffset(tex0, texcoord0, ivec2(-1, 1)).rg;
vec2 texcoord = texcoord0 + vec2(-1.0, 1.0); vec2 texcoord = texcoord0 + vec2(-1.0, 1.0);
for (int i = 1; i < SMAA_MAX_SEARCH_STEPS_DIAG; i++) { for (int i = 1; i < SMAA_MAX_SEARCH_STEPS_DIAG; i++) {
if (e.x + e.y < 1.5) break; if (e.x + e.y < 1.5) break;
texcoord += vec2(-1.0, 1.0); texcoord += vec2(-1.0, 1.0);
e = texture2DRect(tex0, texcoord).rg; e = textureRect(tex0, texcoord).rg;
} }
return (texcoord0.x - texcoord.x) - 1.0 + SMAARound(e.y); return (texcoord0.x - texcoord.x) - 1.0 + SMAARound(e.y);
} }
float SMAASearchDiagLeftUp(void) { float SMAASearchDiagLeftUp(void) {
vec2 e = texture2DRectOffset(tex0, texcoord5, ivec2(-1, -1)).rg; vec2 e = textureRectOffset(tex0, texcoord5, ivec2(-1, -1)).rg;
vec2 texcoord = texcoord5 + vec2(-1.0, -1.0); vec2 texcoord = texcoord5 + vec2(-1.0, -1.0);
for (int i = 1; i < SMAA_MAX_SEARCH_STEPS_DIAG; i++) { for (int i = 1; i < SMAA_MAX_SEARCH_STEPS_DIAG; i++) {
if (SMAADecodeDiagBilinearAccess(e.x) + e.y < 1.5) break; if (SMAADecodeDiagBilinearAccess(e.x) + e.y < 1.5) break;
texcoord += vec2(-1.0, -1.0); texcoord += vec2(-1.0, -1.0);
e = texture2DRect(tex0, texcoord).rg; e = textureRect(tex0, texcoord).rg;
} }
return (texcoord5.x - texcoord.x) - 1.0; return (texcoord5.x - texcoord.x) - 1.0;
} }
float SMAASearchDiagRightDown(void) { float SMAASearchDiagRightDown(void) {
vec2 e = texture2DRectOffset(tex0, texcoord5, ivec2(1, 1)).rg; vec2 e = textureRectOffset(tex0, texcoord5, ivec2(1, 1)).rg;
vec2 texcoord = texcoord5 + vec2(1.0, 1.0); vec2 texcoord = texcoord5 + vec2(1.0, 1.0);
for (int i = 1; i < SMAA_MAX_SEARCH_STEPS_DIAG; i++) { for (int i = 1; i < SMAA_MAX_SEARCH_STEPS_DIAG; i++) {
if (SMAADecodeDiagBilinearAccess(e.x) + e.y < 1.5) break; if (SMAADecodeDiagBilinearAccess(e.x) + e.y < 1.5) break;
texcoord += vec2(1.0, 1.0); texcoord += vec2(1.0, 1.0);
e = texture2DRect(tex0, texcoord).rg; e = textureRect(tex0, texcoord).rg;
} }
return (texcoord.x - texcoord5.x) - 1.0 + SMAARound(e.y); return (texcoord.x - texcoord5.x) - 1.0 + SMAARound(e.y);
} }
@ -316,7 +316,7 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
// Move to proper place, according to the subpixel offset: // Move to proper place, according to the subpixel offset:
SMAA_AREA_OFFSET(texcoord, offset); SMAA_AREA_OFFSET(texcoord, offset);
return SMAA_AREA(texture2DRect(tex1, texcoord)); return SMAA_AREA(textureRect(tex1, texcoord));
} }
/** /**
@ -332,8 +332,8 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
if (d.x + d.y > 2.0) { // d.x + d.y + 1 > 3 if (d.x + d.y > 2.0) { // d.x + d.y + 1 > 3
vec4 coords = vec4(0.25 - d.x, d.x, d.y, -0.25 - d.y) + texcoord0.xyxy; vec4 coords = vec4(0.25 - d.x, d.x, d.y, -0.25 - d.y) + texcoord0.xyxy;
vec4 c; vec4 c;
c.xy = texture2DRectOffset(tex0, coords.xy, ivec2(-1, 0)).rg; c.xy = textureRectOffset(tex0, coords.xy, ivec2(-1, 0)).rg;
c.zw = texture2DRectOffset(tex0, coords.zw, ivec2( 1, 0)).rg; c.zw = textureRectOffset(tex0, coords.zw, ivec2( 1, 0)).rg;
c.xz = SMAADecodeDiagBilinearAccess(c.xz); c.xz = SMAADecodeDiagBilinearAccess(c.xz);
c = SMAARound(c); c = SMAARound(c);
@ -349,9 +349,9 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
if (d.x + d.y > 2.0) { // d.x + d.y + 1 > 3 if (d.x + d.y > 2.0) { // d.x + d.y + 1 > 3
vec4 coords = vec4(-d.xx, d.yy) + texcoord0.xyxy; vec4 coords = vec4(-d.xx, d.yy) + texcoord0.xyxy;
vec4 c; vec4 c;
c.x = texture2DRectOffset(tex0, coords.xy, ivec2(-1, 0)).g; c.x = textureRectOffset(tex0, coords.xy, ivec2(-1, 0)).g;
c.y = texture2DRectOffset(tex0, coords.xy, ivec2( 0, -1)).r; c.y = textureRectOffset(tex0, coords.xy, ivec2( 0, -1)).r;
c.zw = texture2DRectOffset(tex0, coords.zw, ivec2( 1, 0)).gr; c.zw = textureRectOffset(tex0, coords.zw, ivec2( 1, 0)).gr;
vec2 e = 2.0 * c.xz + c.yw; vec2 e = 2.0 * c.xz + c.yw;
e *= step(d, vec2(float(SMAA_MAX_SEARCH_STEPS_DIAG) - 0.5)); e *= step(d, vec2(float(SMAA_MAX_SEARCH_STEPS_DIAG) - 0.5));
@ -374,7 +374,7 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
*/ */
float SMAASearchLength(vec2 e, float bias, float scale) { float SMAASearchLength(vec2 e, float bias, float scale) {
e.r = bias + e.r * scale; e.r = bias + e.r * scale;
return 255.0 * texture2DRect(tex2, e*vec2(float(SMAA_SEARCHTEX_WIDTH), float(SMAA_SEARCHTEX_HEIGHT))).r; return 255.0 * textureRect(tex2, e*vec2(float(SMAA_SEARCHTEX_WIDTH), float(SMAA_SEARCHTEX_HEIGHT))).r;
} }
/** /**
@ -388,12 +388,12 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
* Sampling with different offsets in each direction allows to disambiguate * Sampling with different offsets in each direction allows to disambiguate
* which edges are active from the four fetched ones. * which edges are active from the four fetched ones.
*/ */
vec2 e = texture2DRect(tex0, texcoord1).rg; vec2 e = textureRect(tex0, texcoord1).rg;
vec2 texcoord = texcoord1; vec2 texcoord = texcoord1;
for(int i = 1; i < SMAA_MAX_SEARCH_STEPS; i++) { for(int i = 1; i < SMAA_MAX_SEARCH_STEPS; i++) {
if(e.g <= 0.8281 || e.r > 0.0) break; // Is there some edge not activated or a crossing edge that breaks the line? if(e.g <= 0.8281 || e.r > 0.0) break; // Is there some edge not activated or a crossing edge that breaks the line?
texcoord.x -= 2.0; texcoord.x -= 2.0;
e = texture2DRect(tex0, texcoord).rg; e = textureRect(tex0, texcoord).rg;
} }
// We correct the previous (-0.25, -0.125) offset we applied: // We correct the previous (-0.25, -0.125) offset we applied:
// The searches are bias by 1, so adjust the coords accordingly: // The searches are bias by 1, so adjust the coords accordingly:
@ -402,34 +402,34 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
} }
float SMAASearchXRight(void) { float SMAASearchXRight(void) {
vec2 e = texture2DRect(tex0, texcoord2).rg; vec2 e = textureRect(tex0, texcoord2).rg;
vec2 texcoord = texcoord2; vec2 texcoord = texcoord2;
for(int i = 1; i < SMAA_MAX_SEARCH_STEPS; i++) { for(int i = 1; i < SMAA_MAX_SEARCH_STEPS; i++) {
if(e.g <= 0.8281 || e.r > 0.0) break; // Is there some edge not activated or a crossing edge that breaks the line? if(e.g <= 0.8281 || e.r > 0.0) break; // Is there some edge not activated or a crossing edge that breaks the line?
texcoord.x += 2.0; texcoord.x += 2.0;
e = texture2DRect(tex0, texcoord).rg; e = textureRect(tex0, texcoord).rg;
} }
return texcoord.x - (0.25 + 1.0) + SMAASearchLength(e, 0.5, 0.5); return texcoord.x - (0.25 + 1.0) + SMAASearchLength(e, 0.5, 0.5);
} }
float SMAASearchYUp(void) { float SMAASearchYUp(void) {
vec2 e = texture2DRect(tex0, texcoord3).rg; vec2 e = textureRect(tex0, texcoord3).rg;
vec2 texcoord = texcoord3; vec2 texcoord = texcoord3;
for(int i = 1; i < SMAA_MAX_SEARCH_STEPS; i++) { for(int i = 1; i < SMAA_MAX_SEARCH_STEPS; i++) {
if(e.r <= 0.8281 || e.g > 0.0) break; // Is there some edge not activated or a crossing edge that breaks the line? if(e.r <= 0.8281 || e.g > 0.0) break; // Is there some edge not activated or a crossing edge that breaks the line?
texcoord.y -= 2.0; texcoord.y -= 2.0;
e = texture2DRect(tex0, texcoord).rg; e = textureRect(tex0, texcoord).rg;
} }
return texcoord.y + (0.25 + 1.0) - SMAASearchLength(e.gr, 0.0, 0.5); return texcoord.y + (0.25 + 1.0) - SMAASearchLength(e.gr, 0.0, 0.5);
} }
float SMAASearchYDown(void) { float SMAASearchYDown(void) {
vec2 e = texture2DRect(tex0, texcoord4).rg; vec2 e = textureRect(tex0, texcoord4).rg;
vec2 texcoord = texcoord4; vec2 texcoord = texcoord4;
for(int i = 1; i < SMAA_MAX_SEARCH_STEPS; i++) { for(int i = 1; i < SMAA_MAX_SEARCH_STEPS; i++) {
if(e.r <= 0.8281 || e.g > 0.0) break; // Is there some edge not activated or a crossing edge that breaks the line? if(e.r <= 0.8281 || e.g > 0.0) break; // Is there some edge not activated or a crossing edge that breaks the line?
texcoord.y += 2.0; texcoord.y += 2.0;
e = texture2DRect(tex0, texcoord).rg; e = textureRect(tex0, texcoord).rg;
} }
return texcoord.y - (0.25 + 1.0) + SMAASearchLength(e.gr, 0.5, 0.5); return texcoord.y - (0.25 + 1.0) + SMAASearchLength(e.gr, 0.5, 0.5);
} }
@ -450,7 +450,7 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
// Move to proper place, according to the subpixel offset: // Move to proper place, according to the subpixel offset:
SMAA_AREA_OFFSET(texcoord, offset); SMAA_AREA_OFFSET(texcoord, offset);
return SMAA_AREA(texture2DRect(tex1, texcoord)); return SMAA_AREA(textureRect(tex1, texcoord));
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -461,16 +461,16 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
vec2 SMAADetectHorizontalCornerPattern(vec3 coords, vec2 d) { vec2 SMAADetectHorizontalCornerPattern(vec3 coords, vec2 d) {
vec2 e; vec2 e;
if(d.x >= d.y) coords.x = coords.z + 1.0 - 0.5*step(d.x, d.y); if(d.x >= d.y) coords.x = coords.z + 1.0 - 0.5*step(d.x, d.y);
e.r = texture2DRectOffset(tex0, coords.xy, ivec2(0, 1)).r; e.r = textureRectOffset(tex0, coords.xy, ivec2(0, 1)).r;
e.g = texture2DRectOffset(tex0, coords.xy, ivec2(0, -2)).r; e.g = textureRectOffset(tex0, coords.xy, ivec2(0, -2)).r;
return clamp(1.0 - (1.0 - SMAA_CORNER_ROUNDING_NORM) * e, 0.0, 1.0); return clamp(1.0 - (1.0 - SMAA_CORNER_ROUNDING_NORM) * e, 0.0, 1.0);
} }
vec2 SMAADetectVerticalCornerPattern(vec3 coords, vec2 d) { vec2 SMAADetectVerticalCornerPattern(vec3 coords, vec2 d) {
vec2 e; vec2 e;
if(d.x >= d.y) coords.y = coords.z + 1.0 - 0.5*step(d.x, d.y); if(d.x >= d.y) coords.y = coords.z + 1.0 - 0.5*step(d.x, d.y);
e.r = texture2DRectOffset(tex0, coords.xy, ivec2( 1, 0)).g; e.r = textureRectOffset(tex0, coords.xy, ivec2( 1, 0)).g;
e.g = texture2DRectOffset(tex0, coords.xy, ivec2(-2, 0)).g; e.g = textureRectOffset(tex0, coords.xy, ivec2(-2, 0)).g;
return clamp(1.0 - (1.0 - SMAA_CORNER_ROUNDING_NORM) * e, 0.0, 1.0); return clamp(1.0 - (1.0 - SMAA_CORNER_ROUNDING_NORM) * e, 0.0, 1.0);
} }
@ -483,7 +483,7 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
{ {
vec4 weights = vec4(0.0); vec4 weights = vec4(0.0);
vec2 e = texture2DRect(tex0, texcoord5).rg; vec2 e = textureRect(tex0, texcoord5).rg;
if (e.g > 0.5) { // Edge at north if (e.g > 0.5) { // Edge at north
#if SMAA_MAX_SEARCH_STEPS_DIAG > 0 #if SMAA_MAX_SEARCH_STEPS_DIAG > 0
@ -511,9 +511,9 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
// filtering. Sampling at -0.25 (see CROSSING_OFFSET) enables to // filtering. Sampling at -0.25 (see CROSSING_OFFSET) enables to
// discern what value each edge has: // discern what value each edge has:
vec2 e; vec2 e;
e.x = texture2DRect(tex0, coords.xy).r; e.x = textureRect(tex0, coords.xy).r;
// Fetch the right crossing edges: // Fetch the right crossing edges:
e.y = texture2DRectOffset(tex0, coords.zy, ivec2(1, 0)).r; e.y = textureRectOffset(tex0, coords.zy, ivec2(1, 0)).r;
// Ok, we know how this pattern looks like, now it is time for getting // Ok, we know how this pattern looks like, now it is time for getting
// the actual area: // the actual area:
@ -544,9 +544,9 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
// Fetch the top crossing edges: // Fetch the top crossing edges:
vec2 e; vec2 e;
e.x = texture2DRect(tex0, coords.xy).g; e.x = textureRect(tex0, coords.xy).g;
// Fetch the bottom crossing edges: // Fetch the bottom crossing edges:
e.y = texture2DRectOffset(tex0, coords.xz, ivec2(0, 1)).g; e.y = textureRectOffset(tex0, coords.xz, ivec2(0, 1)).g;
// Get the area for this direction: // Get the area for this direction:
weights.ba = SMAAArea(d, e, subsamples.x); weights.ba = SMAAArea(d, e, subsamples.x);
@ -585,9 +585,9 @@ shader 0 [SMAANeighborhoodBlending@smaapreset@smaaopts] [
{ {
// Fetch the blending weights for current pixel: // Fetch the blending weights for current pixel:
vec4 a; vec4 a;
a.xz = texture2DRect(tex1, texcoord0).rb; a.xz = textureRect(tex1, texcoord0).rb;
a.y = texture2DRectOffset(tex1, texcoord0, ivec2(0, 1)).g; a.y = textureRectOffset(tex1, texcoord0, ivec2(0, 1)).g;
a.w = texture2DRectOffset(tex1, texcoord0, ivec2(1, 0)).a; a.w = textureRectOffset(tex1, texcoord0, ivec2(1, 0)).a;
// Up to 4 lines can be crossing a pixel (one through each edge). We // Up to 4 lines can be crossing a pixel (one through each edge). We
// favor blending by choosing the line with the maximum weight for each // favor blending by choosing the line with the maximum weight for each
@ -604,19 +604,19 @@ shader 0 [SMAANeighborhoodBlending@smaapreset@smaaopts] [
// We exploit bilinear filtering to mix current pixel with the chosen // We exploit bilinear filtering to mix current pixel with the chosen
// neighbor: // neighbor:
fragcolor = texture2DRect(tex0, texcoord0 + offset); fragcolor = textureRect(tex0, texcoord0 + offset);
@(? (smaaopt "s") [ @(? (smaaopt "s") [
a.xz = texture2DRect(tex3, texcoord0).rb; a.xz = textureRect(tex3, texcoord0).rb;
a.y = texture2DRectOffset(tex3, texcoord0, ivec2(0, 1)).g; a.y = textureRectOffset(tex3, texcoord0, ivec2(0, 1)).g;
a.w = texture2DRectOffset(tex3, texcoord0, ivec2(1, 0)).a; a.w = textureRectOffset(tex3, texcoord0, ivec2(1, 0)).a;
offset.x = a.w > a.z ? a.w : -a.z; offset.x = a.w > a.z ? a.w : -a.z;
offset.y = a.y > a.x ? a.y : -a.x; offset.y = a.y > a.x ? a.y : -a.x;
if (abs(offset.x) > abs(offset.y)) if (abs(offset.x) > abs(offset.y))
offset.y = 0.0; offset.y = 0.0;
else else
offset.x = 0.0; offset.x = 0.0;
fragcolor = 0.5*(fragcolor + texture2DRect(tex2, texcoord0 + offset)); fragcolor = 0.5*(fragcolor + textureRect(tex2, texcoord0 + offset));
]) ])
} }
] ]

View File

@ -40,7 +40,7 @@ stainvariantshader = [
]) ])
void main(void) void main(void)
{ {
vec4 diffuse = texture2D(tex0, texcoord0); vec4 diffuse = texture(tex0, texcoord0);
@(if (stainopt "o") [result [ @(if (stainopt "o") [result [
diffuse.rgb = mix(vec3(0.5), diffuse.rgb, color.rgb); diffuse.rgb = mix(vec3(0.5), diffuse.rgb, color.rgb);
fragcolor.rgb = diffuse.rgb; fragcolor.rgb = diffuse.rgb;

View File

@ -19,7 +19,7 @@ shader 0 "hdrreduce" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor.rgb = texture2DRect(tex0, texcoord0).rgb; fragcolor.rgb = textureRect(tex0, texcoord0).rgb;
} }
] ]
@ -38,7 +38,7 @@ shader 0 "hdrreduce2w" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor.rgb = 0.5*(texture2DRectOffset(tex0, texcoord0, ivec2(-1, 0)).rgb + texture2DRectOffset(tex0, texcoord0, ivec2(1, 0)).rgb); fragcolor.rgb = 0.5*(textureRectOffset(tex0, texcoord0, ivec2(-1, 0)).rgb + textureRectOffset(tex0, texcoord0, ivec2(1, 0)).rgb);
} }
] ]
@ -57,8 +57,8 @@ shader 0 "hdrreduce2" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor.rgb = 0.25*(texture2DRectOffset(tex0, texcoord0, ivec2(-1, -1)).rgb + texture2DRectOffset(tex0, texcoord0, ivec2(1, -1)).rgb + fragcolor.rgb = 0.25*(textureRectOffset(tex0, texcoord0, ivec2(-1, -1)).rgb + textureRectOffset(tex0, texcoord0, ivec2(1, -1)).rgb +
texture2DRectOffset(tex0, texcoord0, ivec2(1, 1)).rgb + texture2DRectOffset(tex0, texcoord0, ivec2(-1, 1)).rgb); textureRectOffset(tex0, texcoord0, ivec2(1, 1)).rgb + textureRectOffset(tex0, texcoord0, ivec2(-1, 1)).rgb);
} }
] ]
@ -181,7 +181,7 @@ shader 0 "hdrluminance" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
vec3 color = texture2DRect(tex0, texcoord0).rgb*2.0; vec3 color = textureRect(tex0, texcoord0).rgb*2.0;
@(hdrgammadecode color) @(hdrgammadecode color)
float lum = dot(color, vec3(@lumweights)); float lum = dot(color, vec3(@lumweights));
float loglum = sqrt(clamp(lum, 0.015625, 4.0)) * (1.0/2.0); // allow values as low as 2^-6, and as high 2^2 float loglum = sqrt(clamp(lum, 0.015625, 4.0)) * (1.0/2.0); // allow values as low as 2^-6, and as high 2^2
@ -206,7 +206,7 @@ shader 0 "hdrluminance2w" [
void main(void) void main(void)
{ {
@(loopconcat i 2 [result [ @(loopconcat i 2 [result [
vec3 color@[i] = texture2DRectOffset(tex0, texcoord0, ivec2(@(at ["-1, 0" "1, 0"] $i))).rgb*2.0; vec3 color@[i] = textureRectOffset(tex0, texcoord0, ivec2(@(at ["-1, 0" "1, 0"] $i))).rgb*2.0;
@(hdrgammadecode [color@[i]]) @(hdrgammadecode [color@[i]])
float lum@[i] = dot(color@[i], vec3(@lumweights)); float lum@[i] = dot(color@[i], vec3(@lumweights));
float loglum@[i] = sqrt(clamp(lum@[i], 0.015625, 4.0)) * (1.0/2.0); float loglum@[i] = sqrt(clamp(lum@[i], 0.015625, 4.0)) * (1.0/2.0);
@ -232,7 +232,7 @@ shader 0 "hdrluminance2" [
void main(void) void main(void)
{ {
@(loopconcat i 4 [result [ @(loopconcat i 4 [result [
vec3 color@[i] = texture2DRectOffset(tex0, texcoord0, ivec2(@(at ["-1, -1" "1, -1" "1, 1" "-1, 1"] $i))).rgb*2.0; vec3 color@[i] = textureRectOffset(tex0, texcoord0, ivec2(@(at ["-1, -1" "1, -1" "1, 1" "-1, 1"] $i))).rgb*2.0;
@(hdrgammadecode [color@[i]]) @(hdrgammadecode [color@[i]])
float lum@[i] = dot(color@[i], vec3(@lumweights)); float lum@[i] = dot(color@[i], vec3(@lumweights));
float loglum@[i] = sqrt(clamp(lum@[i], 0.015625, 4.0)) * (1.0/2.0); float loglum@[i] = sqrt(clamp(lum@[i], 0.015625, 4.0)) * (1.0/2.0);
@ -253,7 +253,7 @@ shader 0 "hdraccum" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
float lum = texture2DRect(tex0, vec2(0.5, 0.5)).r * 2.0; float lum = textureRect(tex0, vec2(0.5, 0.5)).r * 2.0;
lum *= lum; lum *= lum;
fragcolor = vec4(vec3(lum*0.25), accumscale); fragcolor = vec4(vec3(lum*0.25), accumscale);
} }
@ -274,7 +274,7 @@ shader 0 "hdrbloom" [
{ {
gl_Position = vvertex; gl_Position = vvertex;
texcoord0 = vtexcoord0; texcoord0 = vtexcoord0;
float avglum = 4.0 * @(? (>= $hwvtexunits 4) [texture2D(tex2, vec2(0.5, 0.5)).r] [vcolor]); float avglum = 4.0 * @(? (>= $hwvtexunits 4) [texture(tex2, vec2(0.5, 0.5)).r] [vcolor]);
lumscale = hdrparams.x * -log2(1.0 - clamp(avglum, 0.03, 0.3))/(avglum + 1e-4); lumscale = hdrparams.x * -log2(1.0 - clamp(avglum, 0.03, 0.3))/(avglum + 1e-4);
lumthreshold = -log2(1.0 - hdrparams.z); lumthreshold = -log2(1.0 - hdrparams.z);
} }
@ -286,7 +286,7 @@ shader 0 "hdrbloom" [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
vec3 color = texture2DRect(tex0, texcoord0).rgb*2.0; vec3 color = textureRect(tex0, texcoord0).rgb*2.0;
@(hdrgammadecode color) @(hdrgammadecode color)
float lum = dot(color, vec3(@lumweights)); float lum = dot(color, vec3(@lumweights));
color *= max(lum*lumscale - lumthreshold, 0.0) / (lum + 1e-4); color *= max(lum*lumscale - lumthreshold, 0.0) / (lum + 1e-4);
@ -313,7 +313,7 @@ hdrtonemapvertexshader = [
gl_Position = vvertex; gl_Position = vvertex;
texcoord0 = vtexcoord0; texcoord0 = vtexcoord0;
texcoord1 = vtexcoord1; texcoord1 = vtexcoord1;
float avglum = 4.0 * @(? (>= $hwvtexunits 4) [texture2D(tex2, vec2(0.5, 0.5)).r] [vcolor]); float avglum = 4.0 * @(? (>= $hwvtexunits 4) [texture(tex2, vec2(0.5, 0.5)).r] [vcolor]);
lumscale = hdrparams.x * -log2(1.0 - clamp(avglum, 0.03, 0.3))/(avglum + 1e-4); lumscale = hdrparams.x * -log2(1.0 - clamp(avglum, 0.03, 0.3))/(avglum + 1e-4);
lumsaturate = -log2(1.0 - hdrparams.y) / lumscale; lumsaturate = -log2(1.0 - hdrparams.y) / lumscale;
} }
@ -355,7 +355,7 @@ hdrtonemapshaders = [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
vec3 color = texture2DRect(tex0, texcoord0).rgb; vec3 color = textureRect(tex0, texcoord0).rgb;
fragcolor.rgb = color; fragcolor.rgb = color;
@arg4 @arg4
@(? $arg3 $arg3 [fragcolor.a = 0.0;]) @(? $arg3 $arg3 [fragcolor.a = 0.0;])
@ -369,8 +369,8 @@ hdrtonemapshaders = [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
vec3 bloom = texture2DRect(tex1, texcoord1).rgb*hdrparams.w; vec3 bloom = textureRect(tex1, texcoord1).rgb*hdrparams.w;
vec3 color = texture2DRect(tex0, texcoord0).rgb*2.0; vec3 color = textureRect(tex0, texcoord0).rgb*2.0;
color += bloom; color += bloom;
@(hdrgammadecode color) @(hdrgammadecode color)
@(hdrtonemapfrag color) @(hdrtonemapfrag color)
@ -394,7 +394,7 @@ msaatonemapshaders = [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
vec3 bloom = texture2DRect(tex1, texcoord1).rgb*hdrparams.w; vec3 bloom = textureRect(tex1, texcoord1).rgb*hdrparams.w;
vec3 color = texelFetch(tex0, ivec2(texcoord0), gl_SampleID).rgb*2.0; vec3 color = texelFetch(tex0, ivec2(texcoord0), gl_SampleID).rgb*2.0;
color += bloom; color += bloom;
@(hdrgammadecode color) @(hdrgammadecode color)
@ -412,7 +412,7 @@ msaatonemapshaders = [
layout(location = 0) out vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
vec3 bloom = texture2DRect(tex1, texcoord1).rgb*hdrparams.w; vec3 bloom = textureRect(tex1, texcoord1).rgb*hdrparams.w;
vec3 resolved = vec3(0.0); vec3 resolved = vec3(0.0);
for(int sampleidx = 0; sampleidx < @msaasamples; sampleidx++) for(int sampleidx = 0; sampleidx < @msaasamples; sampleidx++)
{ {
@ -441,7 +441,7 @@ msaasplitshaders = [
]]) ]])
void main(void) void main(void)
{ {
vec3 bloom = texture2DRect(tex1, texcoord1).rgb*hdrparams.w; vec3 bloom = textureRect(tex1, texcoord1).rgb*hdrparams.w;
@arg4 @arg4
@(loopconcat i $msaasamples [result [ @(loopconcat i $msaasamples [result [
vec3 color@i = texelFetch(tex0, ivec2(texcoord0), @i).rgb*2.0 + bloom; vec3 color@i = texelFetch(tex0, ivec2(texcoord0), @i).rgb*2.0 + bloom;

View File

@ -69,12 +69,12 @@ volumetricvariantshader = [
@(if (volopt "p") [ @(if (volopt "p") [
if (|| (volopt "g") (volopt "G")) [ if (|| (volopt "g") (volopt "G")) [
? (> $usetexgather 1) [ ? (> $usetexgather 1) [
#define filtershadow(shadowtc) float(shadow2D(tex4, vec3(shadowtc.xy*shadowatlasscale, shadowtc.z))) #define filtershadow(shadowtc) float(shadow(tex4, vec3(shadowtc.xy*shadowatlasscale, shadowtc.z)))
] [ ] [
#define filtershadow(shadowtc) step(shadowtc.z, float(texture2D(tex4, shadowtc.xy*shadowatlasscale))) #define filtershadow(shadowtc) step(shadowtc.z, float(texture(tex4, shadowtc.xy*shadowatlasscale)))
] ]
] [result [ ] [result [
#define filtershadow(shadowtc) float(shadow2DRect(tex4, shadowtc)) #define filtershadow(shadowtc) float(textureRect(tex4, shadowtc))
]] ]]
]) ])
@ -204,11 +204,11 @@ volumetricbilateralvariantshader = [
#define tc gl_FragCoord.xy #define tc gl_FragCoord.xy
#define depthtc @(? $reduced [texcoord0] [gl_FragCoord.xy]) #define depthtc @(? $reduced [texcoord0] [gl_FragCoord.xy])
#define tapvec(type, i) @(? (=s $filterdir "x") [type(i, 0.0)] [type(0.0, i)]) #define tapvec(type, i) @(? (=s $filterdir "x") [type(i, 0.0)] [type(0.0, i)])
#define texval(i) texture2DRect(tex0, tc + tapvec(vec2, i)) #define texval(i) textureRect(tex0, tc + tapvec(vec2, i))
#define texvaloffset(i) texture2DRectOffset(tex0, tc, tapvec(ivec2, i)) #define texvaloffset(i) textureRectOffset(tex0, tc, tapvec(ivec2, i))
#define depthval(i) gfetch(tex3, depthtc + tapvec(vec2, i)) #define depthval(i) gfetch(tex3, depthtc + tapvec(vec2, i))
#define depthvaloffset(i) gfetchoffset(tex3, depthtc, tapvec(ivec2, i)) #define depthvaloffset(i) gfetchoffset(tex3, depthtc, tapvec(ivec2, i))
vec3 color = texture2DRect(tex0, tc).rgb; vec3 color = textureRect(tex0, tc).rgb;
@(gdepthunpack depth [gfetch(tex3, depthtc)]) @(gdepthunpack depth [gfetch(tex3, depthtc)])
float weights = 1.0; float weights = 1.0;
@(loopconcat i (* 2 $numtaps) [ @(loopconcat i (* 2 $numtaps) [

View File

@ -136,12 +136,12 @@ worldvariantshader = [
triblend *= triblend; triblend *= triblend;
triblend /= triblend.x + triblend.y + triblend.z; triblend /= triblend.x + triblend.y + triblend.z;
vec4 diffusex = texture2D(diffusemap, texcoordx); vec4 diffusex = texture(diffusemap, texcoordx);
vec4 diffusey = texture2D(diffusemap, texcoordy); vec4 diffusey = texture(diffusemap, texcoordy);
vec4 diffusez = texture2D(@(? (wtopt "d") "detaildiffusemap" "diffusemap"), texcoordz); vec4 diffusez = texture(@(? (wtopt "d") "detaildiffusemap" "diffusemap"), texcoordz);
vec4 diffuse = diffusex*triblend.x + diffusey*triblend.y + diffusez*triblend.z; vec4 diffuse = diffusex*triblend.x + diffusey*triblend.y + diffusez*triblend.z;
]] [result [ ]] [result [
vec4 diffuse = texture2D(diffusemap, texcoord0); vec4 diffuse = texture(diffusemap, texcoord0);
]]) ]])
gcolor.rgb = diffuse.rgb*colorparams.rgb; gcolor.rgb = diffuse.rgb*colorparams.rgb;
@ -150,7 +150,7 @@ worldvariantshader = [
vec3 camvecn = normalize(camvec); vec3 camvecn = normalize(camvec);
float invfresnel = dot(camvecn, normal); float invfresnel = dot(camvecn, normal);
vec3 rvec = 2.0*normal*invfresnel - camvecn; vec3 rvec = 2.0*normal*invfresnel - camvecn;
vec3 reflect = textureCube(envmap, rvec).rgb; vec3 reflect = texture(envmap, rvec).rgb;
@(? (wtopt "R") [ @(? (wtopt "R") [
vec3 rmod = envscale.xyz*diffuse.a; vec3 rmod = envscale.xyz*diffuse.a;
] [ ] [
@ -161,12 +161,12 @@ worldvariantshader = [
@(if (wtopt "g") [result [ @(if (wtopt "g") [result [
@(? (wtopt "T") [ @(? (wtopt "T") [
vec3 glowx = texture2D(glowmap, texcoordx).rgb; vec3 glowx = texture(glowmap, texcoordx).rgb;
vec3 glowy = texture2D(glowmap, texcoordy).rgb; vec3 glowy = texture(glowmap, texcoordy).rgb;
vec3 glowz = texture2D(glowmap, texcoordz).rgb; vec3 glowz = texture(glowmap, texcoordz).rgb;
vec3 glow = glowx*triblend.x + glowy*triblend.y + glowz*triblend.z; vec3 glow = glowx*triblend.x + glowy*triblend.y + glowz*triblend.z;
] [ ] [
vec3 glow = texture2D(glowmap, texcoord0).rgb; vec3 glow = texture(glowmap, texcoord0).rgb;
]) ])
glow *= @(? (wtopt "G") [mix(glowcolor.xyz, pulseglowcolor.xyz, pulse)] [glowcolor.xyz]); glow *= @(? (wtopt "G") [mix(glowcolor.xyz, pulseglowcolor.xyz, pulse)] [glowcolor.xyz]);
@(if (wtopt "a") [result [ @(if (wtopt "a") [result [
@ -190,7 +190,7 @@ worldvariantshader = [
@(gdepthpackfrag (|| $msaalight [&& $msaasamples [! (wtopt "a")]]) "" hashid) @(gdepthpackfrag (|| $msaalight [&& $msaasamples [! (wtopt "a")]]) "" hashid)
@(? (wtopt "b") [ @(? (wtopt "b") [
float blend = abs(texture2D(blendmap, texcoord1).r - blendlayer); float blend = abs(texture(blendmap, texcoord1).r - blendlayer);
gcolor.rgb *= blend; gcolor.rgb *= blend;
gnormal.rgb *= blend; gnormal.rgb *= blend;
gnormal.a *= blendlayer; gnormal.a *= blendlayer;
@ -396,9 +396,9 @@ bumpvariantshader = [
#define worldz mat3(tangentx, tangenty, normal) #define worldz mat3(tangentx, tangenty, normal)
@(if (btopt "p") [result [ @(if (btopt "p") [result [
float heightx = texture2D(normalmap, texcoordx).a; float heightx = texture(normalmap, texcoordx).a;
float heighty = texture2D(normalmap, texcoordy).a; float heighty = texture(normalmap, texcoordy).a;
float heightz = texture2D(@(? (btopt "d") "detailnormalmap" "normalmap"), texcoordz).a; float heightz = texture(@(? (btopt "d") "detailnormalmap" "normalmap"), texcoordz).a;
vec3 camvect = camvecn * mat3(tangentx, tangenty, tangentz); vec3 camvect = camvecn * mat3(tangentx, tangenty, tangentz);
vec2 dtcx = texcoordx + camvect.yz*(heightx*parallaxscale.x + parallaxscale.y); vec2 dtcx = texcoordx + camvect.yz*(heightx*parallaxscale.x + parallaxscale.y);
@ -410,14 +410,14 @@ bumpvariantshader = [
#define dtcz texcoordz #define dtcz texcoordz
]]) ]])
vec4 diffusex = texture2D(diffusemap, dtcx); vec4 diffusex = texture(diffusemap, dtcx);
vec4 diffusey = texture2D(diffusemap, dtcy); vec4 diffusey = texture(diffusemap, dtcy);
vec4 diffusez = texture2D(@(? (btopt "d") "detaildiffusemap" "diffusemap"), dtcz); vec4 diffusez = texture(@(? (btopt "d") "detaildiffusemap" "diffusemap"), dtcz);
vec4 diffuse = diffusex*triblend.x + diffusey*triblend.y + diffusez*triblend.z; vec4 diffuse = diffusex*triblend.x + diffusey*triblend.y + diffusez*triblend.z;
vec3 bumpx = (texture2D(normalmap, dtcx).rgb*2.0 - 1.0)*triblend.x; vec3 bumpx = (texture(normalmap, dtcx).rgb*2.0 - 1.0)*triblend.x;
vec3 bumpy = (texture2D(normalmap, dtcy).rgb*2.0 - 1.0)*triblend.y; vec3 bumpy = (texture(normalmap, dtcy).rgb*2.0 - 1.0)*triblend.y;
vec3 bumpz = (texture2D(@(? (btopt "d") "detailnormalmap" "normalmap"), dtcz).rgb*2.0 - 1.0)*triblend.z; vec3 bumpz = (texture(@(? (btopt "d") "detailnormalmap" "normalmap"), dtcz).rgb*2.0 - 1.0)*triblend.z;
vec3 bumpw = normalize(worldx*bumpx + worldy*bumpy + worldz*bumpz); vec3 bumpw = normalize(worldx*bumpx + worldy*bumpy + worldz*bumpz);
@(? (btopt "A") [ @(? (btopt "A") [
@ -425,15 +425,15 @@ bumpvariantshader = [
]) ])
]] [result [ ]] [result [
@(? (btopt "p") [ @(? (btopt "p") [
float height = texture2D(normalmap, texcoord0).a; float height = texture(normalmap, texcoord0).a;
vec2 dtc = texcoord0 + (camvecn * world).xy*(height*parallaxscale.x + parallaxscale.y); vec2 dtc = texcoord0 + (camvecn * world).xy*(height*parallaxscale.x + parallaxscale.y);
] [ ] [
#define dtc texcoord0 #define dtc texcoord0
]) ])
vec4 diffuse = texture2D(diffusemap, dtc); vec4 diffuse = texture(diffusemap, dtc);
vec3 bump = texture2D(normalmap, dtc).rgb*2.0 - 1.0; vec3 bump = texture(normalmap, dtc).rgb*2.0 - 1.0;
vec3 bumpw = normalize(world * bump); vec3 bumpw = normalize(world * bump);
]]) ]])
@ -442,7 +442,7 @@ bumpvariantshader = [
@(if (btopt "r") [result [ @(if (btopt "r") [result [
float invfresnel = dot(camvecn, bumpw); float invfresnel = dot(camvecn, bumpw);
vec3 rvec = 2.0*bumpw*invfresnel - camvecn; vec3 rvec = 2.0*bumpw*invfresnel - camvecn;
vec3 reflect = textureCube(envmap, rvec).rgb; vec3 reflect = texture(envmap, rvec).rgb;
@(? (btopt "R") [ @(? (btopt "R") [
vec3 rmod = envscale.xyz*diffuse.a; vec3 rmod = envscale.xyz*diffuse.a;
] [ ] [
@ -453,12 +453,12 @@ bumpvariantshader = [
@(if (btopt "g") [result [ @(if (btopt "g") [result [
@(? (btopt "T") [ @(? (btopt "T") [
vec3 glowx = texture2D(glowmap, dtcx).rgb; vec3 glowx = texture(glowmap, dtcx).rgb;
vec3 glowy = texture2D(glowmap, dtcy).rgb; vec3 glowy = texture(glowmap, dtcy).rgb;
vec3 glowz = texture2D(glowmap, dtcz).rgb; vec3 glowz = texture(glowmap, dtcz).rgb;
vec3 glow = glowx*triblend.x + glowy*triblend.y + glowz*triblend.z; vec3 glow = glowx*triblend.x + glowy*triblend.y + glowz*triblend.z;
] [ ] [
vec3 glow = texture2D(glowmap, dtc).rgb; vec3 glow = texture(glowmap, dtc).rgb;
]) ])
glow *= @(? (btopt "G") [mix(glowcolor.xyz, pulseglowcolor.xyz, pulse)] [glowcolor.xyz]); glow *= @(? (btopt "G") [mix(glowcolor.xyz, pulseglowcolor.xyz, pulse)] [glowcolor.xyz]);
@(if (btopt "a") [result [ @(if (btopt "a") [result [
@ -484,7 +484,7 @@ bumpvariantshader = [
@(gdepthpackfrag (|| $msaalight [&& $msaasamples [! (btopt "a")]]) "" hashid) @(gdepthpackfrag (|| $msaalight [&& $msaasamples [! (btopt "a")]]) "" hashid)
@(? (btopt "b") [ @(? (btopt "b") [
float blend = abs(texture2D(blendmap, texcoord1).r - blendlayer); float blend = abs(texture(blendmap, texcoord1).r - blendlayer);
gcolor.rgb *= blend; gcolor.rgb *= blend;
gnormal.rgb *= blend; gnormal.rgb *= blend;
gnormal.a *= blendlayer; gnormal.a *= blendlayer;
@ -625,7 +625,7 @@ defershader 1 "rsmworld" [
layout(location = 1) out vec4 gnormal; layout(location = 1) out vec4 gnormal;
void main(void) void main(void)
{ {
vec4 diffuse = texture2D(diffusemap, texcoord0); vec4 diffuse = texture(diffusemap, texcoord0);
@(if (= $i 2) [result [ @(if (= $i 2) [result [
#define alpha 1.0 #define alpha 1.0
@ -637,7 +637,7 @@ defershader 1 "rsmworld" [
gnormal = vec4(normal.xyz*0.5+0.5, 0.0); gnormal = vec4(normal.xyz*0.5+0.5, 0.0);
@(if (= $i 1) [result [ @(if (= $i 1) [result [
float blend = abs(texture2D(blendmap, texcoord1).r - blendlayer); float blend = abs(texture(blendmap, texcoord1).r - blendlayer);
gcolor.rgb *= blend; gcolor.rgb *= blend;
gcolor.a = blendlayer; gcolor.a = blendlayer;
gnormal *= blend; gnormal *= blend;

View File

@ -112,29 +112,14 @@ static void showglslinfo(GLenum type, GLuint obj, const char *name, const char *
static void compileglslshader(Shader &s, GLenum type, GLuint &obj, const char *def, const char *name, bool msg = true) static void compileglslshader(Shader &s, GLenum type, GLuint &obj, const char *def, const char *name, bool msg = true)
{ {
const char *source = def + strspn(def, " \t\r\n"); const char *source = def + strspn(def, " \t\r\n");
const char *parts[16]; const char *parts[] = {
int numparts = 0; "#version 400\n",
parts[numparts++] = "#version 400\n"; "#define textureRect(sampler, coords) texture(sampler, coords)\n"
"#define textureRectProj(sampler, coords) textureProj(sampler, coords)\n"
parts[numparts++] = "#define textureRectOffset(sampler, coords, offset) textureOffset(sampler, coords, offset)\n",
"#define texture1D(sampler, coords) texture(sampler, coords)\n" source
"#define texture2D(sampler, coords) texture(sampler, coords)\n" };
"#define texture2DOffset(sampler, coords, offset) textureOffset(sampler, coords, offset)\n" GLsizei numparts = sizeof(parts) / sizeof(void *);
"#define texture2DProj(sampler, coords) textureProj(sampler, coords)\n"
"#define shadow2D(sampler, coords) texture(sampler, coords)\n"
"#define shadow2DOffset(sampler, coords, offset) textureOffset(sampler, coords, offset)\n"
"#define texture3D(sampler, coords) texture(sampler, coords)\n"
"#define textureCube(sampler, coords) texture(sampler, coords)\n";
parts[numparts++] =
"#define texture2DRect(sampler, coords) texture(sampler, coords)\n"
"#define texture2DRectProj(sampler, coords) textureProj(sampler, coords)\n"
"#define shadow2DRect(sampler, coords) texture(sampler, coords)\n";
parts[numparts++] =
"#define texture2DRectOffset(sampler, coords, offset) textureOffset(sampler, coords, offset)\n"
"#define shadow2DRectOffset(sampler, coords, offset) textureOffset(sampler, coords, offset)\n";
parts[numparts++] = source;
obj = glCreateShader_(type); obj = glCreateShader_(type);
glShaderSource_(obj, numparts, (const GLchar **)parts, NULL); glShaderSource_(obj, numparts, (const GLchar **)parts, NULL);
glCompileShader_(obj); glCompileShader_(obj);
@ -786,7 +771,7 @@ void setupshaders()
"in vec4 colorscale;\n" "in vec4 colorscale;\n"
"layout(location = 0) out vec4 fragcolor;\n" "layout(location = 0) out vec4 fragcolor;\n"
"void main(void) {\n" "void main(void) {\n"
" vec4 color = texture2D(tex0, texcoord0);\n" " vec4 color = texture(tex0, texcoord0);\n"
" fragcolor = colorscale * color;\n" " fragcolor = colorscale * color;\n"
"}\n"); "}\n");
hudtextshader = newshader(0, "<init>hudtext", hudtextshader = newshader(0, "<init>hudtext",
@ -806,7 +791,7 @@ void setupshaders()
"in vec4 colorscale;\n" "in vec4 colorscale;\n"
"layout(location = 0) out vec4 fragcolor;\n" "layout(location = 0) out vec4 fragcolor;\n"
"void main(void) {\n" "void main(void) {\n"
" float dist = texture2D(tex0, texcoord0).r;\n" " float dist = texture(tex0, texcoord0).r;\n"
" float border = smoothstep(textparams.x, textparams.y, dist);\n" " float border = smoothstep(textparams.x, textparams.y, dist);\n"
" float outline = smoothstep(textparams.z, textparams.w, dist);\n" " float outline = smoothstep(textparams.z, textparams.w, dist);\n"
" fragcolor = vec4(colorscale.rgb * outline, colorscale.a * border);\n" " fragcolor = vec4(colorscale.rgb * outline, colorscale.a * border);\n"