remove pre-gl4 compatibility code

This removes all feature checks for pre-gl4 features as well as now
irrelevant bug workarounds. At least nvidia geforce 400 series, radeon
HD 6000 series or intel HD 4000 or newer is required. Also upgrade all
shaders to #version 400 and remove compatibility macros for legacy
GLSL support.
Daniel Kolesa 2018-10-28 23:07:08 +01:00
commit 5fc5c37873
36 changed files with 980 additions and 1653 deletions

View File

@ -5,19 +5,15 @@
//////////////////////////////////////////////// ////////////////////////////////////////////////
lazyshader 0 "tqaaresolve" [ lazyshader 0 "tqaaresolve" [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
@(? $tqaaresolvegather [ out vec2 texcoord1;
varying vec2 texcoord1;
])
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
texcoord0 = vtexcoord0; texcoord0 = vtexcoord0;
@(? $tqaaresolvegather [ texcoord1 = vtexcoord0 - 0.5;
texcoord1 = vtexcoord0 - 0.5;
])
} }
] [ ] [
@(gfetchdefs tex2) @(gfetchdefs tex2)
@ -26,11 +22,9 @@ lazyshader 0 "tqaaresolve" [
uniform mat4 reprojectmatrix; uniform mat4 reprojectmatrix;
uniform vec2 maxvelocity; uniform vec2 maxvelocity;
uniform vec2 colorweight; uniform vec2 colorweight;
varying vec2 texcoord0; in vec2 texcoord0;
@(? $tqaaresolvegather [ in vec2 texcoord1;
varying vec2 texcoord1; layout(location = 0) out vec4 fragcolor;
])
fragdata(0) vec4 fragcolor;
void main(void) void main(void)
{ {
@(gdepthunpack depth [gfetch(tex2, texcoord0)] [ @(gdepthunpack depth [gfetch(tex2, texcoord0)] [
@ -42,28 +36,19 @@ 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));
@(? $tqaaresolvegather [ 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 = textureRectOffset(tex0, texcoord0, ivec2(1, -1)).g;
float l2 = texture2DRectOffset(tex0, texcoord0, ivec2(1, -1)).g; float l3 = textureRectOffset(tex0, texcoord0, ivec2(-1, 1)).g;
float l3 = texture2DRectOffset(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); float lmin = min(min(l01min.x, l01min.y), min(l2, l3));
float lmin = min(min(l01min.x, l01min.y), min(l2, l3)); float lmax = max(max(l01max.x, l01max.y), max(l2, l3));
float lmax = max(max(l01max.x, l01max.y), max(l2, l3));
] [
float l0 = texture2DRect(tex0, texcoord0 + vec2(-1.0, -0.5)).g;
float l1 = texture2DRect(tex0, texcoord0 + vec2( 0.5, -1.0)).g;
float l2 = texture2DRect(tex0, texcoord0 + vec2( 1.0, 0.5)).g;
float l3 = texture2DRect(tex0, texcoord0 + vec2(-0.5, 1.0)).g;
float lmin = min(color.g, min(min(l0, l1), min(l2, l3)));
float lmax = max(color.g, max(max(l0, l1), max(l2, l3)));
])
float weight = 0.5 - 0.5*clamp((colorweight.x*max(prevcolor.g - lmax, lmin - prevcolor.g) + colorweight.y) / (lmax - lmin + 1e-4), 0.0, 1.0); float weight = 0.5 - 0.5*clamp((colorweight.x*max(prevcolor.g - lmax, lmin - prevcolor.g) + colorweight.y) / (lmax - lmin + 1e-4), 0.0, 1.0);
weight *= clamp(1.0 - 2.0*(prevcolor.a - color.a), 0.0, 1.0); weight *= clamp(1.0 - 2.0*(prevcolor.a - color.a), 0.0, 1.0);

View File

@ -25,10 +25,10 @@ ambientobscurancevariantshader = [
derivnormal = (>= (strstr $arg2 "d") 0) derivnormal = (>= (strstr $arg2 "d") 0)
maxaotaps = $arg3 maxaotaps = $arg3
shader 0 $arg1 [ shader 0 $arg1 [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
@(screentexcoord 1) @(screentexcoord 1)
varying vec2 texcoord0, texcoord1; out vec2 texcoord0, texcoord1;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -53,8 +53,8 @@ ambientobscurancevariantshader = [
#define depthtc texcoord0 #define depthtc texcoord0
]) ])
uniform vec3 gdepthpackparams; uniform vec3 gdepthpackparams;
varying vec2 texcoord0, texcoord1; in vec2 texcoord0, texcoord1;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
@(if (&& $derivnormal [= $aodepthformat 1]) [result [ @(if (&& $derivnormal [= $aodepthformat 1]) [result [
@ -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);
@ -127,9 +127,9 @@ ambientobscuranceshader = [
] ]
shader 0 "linearizedepth" [ shader 0 "linearizedepth" [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -138,8 +138,8 @@ shader 0 "linearizedepth" [
] [ ] [
@(gfetchdefs tex0 $msaasamples) @(gfetchdefs tex0 $msaasamples)
uniform vec3 gdepthpackparams; uniform vec3 gdepthpackparams;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
@(if (! $aodepthformat) [ @(if (! $aodepthformat) [
@ -165,14 +165,14 @@ bilateralvariantshader = [
reduced = $arg4 reduced = $arg4
filterdir = $arg5 filterdir = $arg5
shader 0 $arg1 [ shader 0 $arg1 [
attribute vec4 vvertex; in vec4 vvertex;
@(if $reduced [result [ @(if $reduced [result [
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
]]) ]])
@(if $upscaled [result [ @(if $upscaled [result [
@(screentexcoord 1) @(screentexcoord 1)
varying vec2 texcoord1; out vec2 texcoord1;
]]) ]])
void main(void) void main(void)
{ {
@ -185,27 +185,27 @@ bilateralvariantshader = [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
uniform vec2 bilateralparams; uniform vec2 bilateralparams;
uniform vec3 gdepthpackparams; uniform vec3 gdepthpackparams;
@(? $reduced [varying vec2 texcoord0;]) @(? $reduced [in vec2 texcoord0;])
@(? $upscaled [varying vec2 texcoord1;]) @(? $upscaled [in vec2 texcoord1;])
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
#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

@ -6,12 +6,12 @@
blurshader = [ blurshader = [
shader 0 $arg1 [ shader 0 $arg1 [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
uniform float offsets[8]; uniform float offsets[8];
varying vec2 texcoord0, texcoordp1, texcoordn1; out vec2 texcoord0, texcoordp1, texcoordn1;
@(loopconcat+ i 2 (min (- $arg2 1) 2) [result [ @(loopconcat+ i 2 (min (- $arg2 1) 2) [result [
varying vec2 texcoordp@i, texcoordn@i; out vec2 texcoordp@i, texcoordn@i;
]]) ]])
void main(void) void main(void)
{ {
@ -33,11 +33,11 @@ blurshader = [
uniform float weights[8]; uniform float weights[8];
uniform float offsets[8]; uniform float offsets[8];
uniform sampler@[arg4] tex0; uniform sampler@[arg4] tex0;
varying vec2 texcoord0, texcoordp1, texcoordn1; in vec2 texcoord0, texcoordp1, texcoordn1;
@(loopconcat+ i 2 (min (- $arg2 1) 2) [result [ @(loopconcat+ i 2 (min (- $arg2 1) 2) [result [
varying vec2 texcoordp@i, texcoordn@i; in vec2 texcoordp@i, texcoordn@i;
]]) ]])
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
#define texval(coords) texture@[arg4](tex0, (coords)) #define texval(coords) texture@[arg4](tex0, (coords))

View File

@ -51,22 +51,22 @@ decalvariantshader = [
defuniformparam "bumpblend" 1 // alpha-blend strength for normals defuniformparam "bumpblend" 1 // alpha-blend strength for normals
] ]
variantshader $stype $arg1 $srow [ variantshader $stype $arg1 $srow [
attribute vec4 vvertex; in vec4 vvertex;
@(? (dtopt "n") [ @(? (dtopt "n") [
attribute vec4 vtangent; in vec4 vtangent;
varying mat3 world; out mat3 world;
] [ ] [
varying vec3 nvec; out vec3 nvec;
]) ])
attribute vec4 vnormal; in vec4 vnormal;
attribute vec3 vtexcoord0; in vec3 vtexcoord0;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
varying vec4 texcoord0; out vec4 texcoord0;
@(? (|| (dtopt "p") (dtopt "r")) [ @(? (|| (dtopt "p") (dtopt "r")) [
uniform vec3 camera; uniform vec3 camera;
varying vec3 camvec; out vec3 camvec;
]) ])
@(? (dtopt "G") [uniform float millis; flat varying float pulse;]) @(? (dtopt "G") [uniform float millis; flat out float pulse;])
void main(void) void main(void)
{ {
gl_Position = camprojmatrix * vvertex; gl_Position = camprojmatrix * vvertex;
@ -91,37 +91,37 @@ decalvariantshader = [
} }
] [ ] [
@(cond [dtopt "0"] [result [ @(cond [dtopt "0"] [result [
fragdata(0) vec4 gcolor; layout(location = 0) out vec4 gcolor;
fragblend(0) vec4 gcolorblend; layout(location = 0, index = 1) out vec4 gcolorblend;
]] [dtopt "1"] [ ]] [dtopt "1"] [
? $usepacknorm [ ? $usepacknorm [
fragdata(0) vec4 gnormal; layout(location = 0) out vec4 gnormal;
] [ ] [
fragdata(0) vec4 gnormal; layout(location = 0) out vec4 gnormal;
fragblend(0) vec4 gnormalblend; layout(location = 0, index = 1) out vec4 gnormalblend;
] ]
] [result [ ] [result [
fragdata(0) vec4 gcolor; layout(location = 0) out vec4 gcolor;
fragdata(1) vec4 gnormal; layout(location = 1) out vec4 gnormal;
]]) ]])
uniform sampler2D diffusemap; uniform sampler2D diffusemap;
uniform vec4 colorparams; uniform vec4 colorparams;
varying vec4 texcoord0; in vec4 texcoord0;
@(? (dtopt "n") [ @(? (dtopt "n") [
uniform sampler2D normalmap; uniform sampler2D normalmap;
varying mat3 world; in mat3 world;
] [ ] [
varying vec3 nvec; in vec3 nvec;
]) ])
@(? (|| (dtopt "p") (dtopt "r")) [varying vec3 camvec;]) @(? (|| (dtopt "p") (dtopt "r")) [in vec3 camvec;])
@(? (|| (dtopt "g") (dtopt "S")) [uniform sampler2D glowmap;]) @(? (|| (dtopt "g") (dtopt "S")) [uniform sampler2D glowmap;])
@(? (dtopt "G") [flat varying float pulse;]) @(? (dtopt "G") [flat in float pulse;])
@(? (dtopt "r") [uniform samplerCube envmap;]) @(? (dtopt "r") [uniform samplerCube envmap;])
void main(void) void main(void)
{ {
@(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

@ -36,7 +36,7 @@ msaadetectedges = [
] ]
lazyshader 0 msaaedgedetect [ lazyshader 0 msaaedgedetect [
attribute vec4 vvertex; in vec4 vvertex;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -119,16 +119,13 @@ deferredlightvariantshader = [
transparent = (<= 8 $arg2 16) transparent = (<= 8 $arg2 16)
avatar = (<= 17 $arg2 31) avatar = (<= 17 $arg2 31)
variantshader 0 $arg1 $arg2 (? (< $arg2 0) [ variantshader 0 $arg1 $arg2 (? (< $arg2 0) [
attribute vec4 vvertex; in vec4 vvertex;
uniform mat4 lightmatrix; uniform mat4 lightmatrix;
void main(void) void main(void)
{ {
gl_Position = lightmatrix * vvertex; gl_Position = lightmatrix * vvertex;
} }
]) [ ]) [
@(? (&& (dlopt "S") [< $glslversion 400]) [
#extension GL_ARB_sample_shading : enable
])
@(? (&& (dlopt "T") [glext "GL_EXT_shader_samples_identical"]) [ @(? (&& (dlopt "T") [glext "GL_EXT_shader_samples_identical"]) [
#extension GL_EXT_shader_samples_identical : enable #extension GL_EXT_shader_samples_identical : enable
]) ])
@ -183,7 +180,7 @@ deferredlightvariantshader = [
uniform vec4 lightscale; uniform vec4 lightscale;
@(? (&& (dlopt "a") [! $avatar] [! $transparent]) [uniform sampler2DRect tex5; uniform vec2 aoscale; uniform vec4 aoparams;]) @(? (&& (dlopt "a") [! $avatar] [! $transparent]) [uniform sampler2DRect tex5; uniform vec2 aoscale; uniform vec4 aoparams;])
@(gdepthunpackparams) @(gdepthunpackparams)
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
@(if (dlopt "p") [ @(if (dlopt "p") [
? $spotlight [ ? $spotlight [
@ -253,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);
@ -272,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);
@ -293,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),
@ -303,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))
]] ]]
]) ])
@ -345,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;
@ -372,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++)
@ -386,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
@ -469,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

@ -5,12 +5,12 @@
//////////////////////////////////////////////// ////////////////////////////////////////////////
shader 0 "blendbrush" [ shader 0 "blendbrush" [
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
uniform vec4 texgenS, texgenT; uniform vec4 texgenS, texgenT;
uniform float ldrscale; uniform float ldrscale;
varying vec4 color; out vec4 color;
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
gl_Position = camprojmatrix * vvertex; gl_Position = camprojmatrix * vvertex;
@ -19,22 +19,22 @@ shader 0 "blendbrush" [
} }
] [ ] [
uniform sampler2D tex0; uniform sampler2D tex0;
varying vec4 color; in vec4 color;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) 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;
} }
] ]
lazyshader 0 "prefab" [ lazyshader 0 "prefab" [
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
attribute vec3 vnormal; in vec3 vnormal;
uniform mat4 prefabmatrix; uniform mat4 prefabmatrix;
uniform mat3 prefabworld; uniform mat3 prefabworld;
varying vec3 nvec; out vec3 nvec;
varying vec4 color; out vec4 color;
@(msaainterpvert) @(msaainterpvert)
void main(void) void main(void)
@ -45,8 +45,8 @@ lazyshader 0 "prefab" [
@(msaapackvert) @(msaapackvert)
} }
] [ ] [
varying vec3 nvec; in vec3 nvec;
varying vec4 color; in vec4 color;
@(msaainterpfrag) @(msaainterpfrag)
void main(void) void main(void)

View File

@ -216,9 +216,9 @@ fxaadefs = [
] ]
shader 0 [fxaa@fxaapreset@fxaaopts] [ shader 0 [fxaa@fxaapreset@fxaaopts] [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -226,17 +226,17 @@ shader 0 [fxaa@fxaapreset@fxaaopts] [
} }
] [ ] [
@fxaadefs @fxaadefs
varying vec2 texcoord0; in vec2 texcoord0;
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
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

@ -5,15 +5,15 @@
//////////////////////////////////////////////// ////////////////////////////////////////////////
lazyshader 0 "rsmsky" [ lazyshader 0 "rsmsky" [
attribute vec4 vvertex; in vec4 vvertex;
uniform mat4 rsmmatrix; uniform mat4 rsmmatrix;
void main(void) void main(void)
{ {
gl_Position = rsmmatrix * vvertex; gl_Position = rsmmatrix * vvertex;
} }
] [ ] [
fragdata(0) vec4 gcolor; layout(location = 0) out vec4 gcolor;
fragdata(1) vec4 gnormal; layout(location = 1) out vec4 gnormal;
void main(void) void main(void)
{ {
gcolor = vec4(0.0, 0.0, 0.0, 1.0); gcolor = vec4(0.0, 0.0, 0.0, 1.0);
@ -170,11 +170,11 @@ rsmtapoffsets32 = [
radiancehintsshader = [ radiancehintsshader = [
numtaps = (cond [> $arg1 20] 32 [> $arg1 12] 20 12) numtaps = (cond [> $arg1 20] 32 [> $arg1 12] 20 12)
shader 0 [radiancehints@arg1] [ shader 0 [radiancehints@arg1] [
attribute vec4 vvertex; in vec4 vvertex;
attribute vec3 vtexcoord0; in vec3 vtexcoord0;
uniform mat4 rsmtcmatrix; uniform mat4 rsmtcmatrix;
varying vec3 rhcenter; out vec3 rhcenter;
varying vec2 rsmcenter; out vec2 rsmcenter;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -187,20 +187,20 @@ radiancehintsshader = [
uniform vec2 rsmspread; uniform vec2 rsmspread;
uniform float rhatten, rhspread, rhaothreshold, rhaoatten, rhaoheight; uniform float rhatten, rhspread, rhaothreshold, rhaoatten, rhaoheight;
uniform vec3 rsmdir; uniform vec3 rsmdir;
varying vec3 rhcenter; in vec3 rhcenter;
varying vec2 rsmcenter; in vec2 rsmcenter;
fragdata(0) vec4 rhr; layout(location = 0) out vec4 rhr;
fragdata(1) vec4 rhg; layout(location = 1) out vec4 rhg;
fragdata(2) vec4 rhb; layout(location = 2) out vec4 rhb;
fragdata(3) vec4 rha; layout(location = 3) out vec4 rha;
void calcrhsample(vec3 rhtap, vec2 rsmtap, inout vec4 shr, inout vec4 shg, inout vec4 shb, inout vec4 sha) void calcrhsample(vec3 rhtap, vec2 rsmtap, inout vec4 shr, inout vec4 shg, inout vec4 shb, inout vec4 sha)
{ {
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;
@ -234,9 +234,9 @@ radiancehintsshader = [
] ]
lazyshader 0 radiancehintsborder [ lazyshader 0 radiancehintsborder [
attribute vec4 vvertex; in vec4 vvertex;
attribute vec3 vtexcoord0; in vec3 vtexcoord0;
varying vec3 texcoord0; out vec3 texcoord0;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -245,27 +245,27 @@ lazyshader 0 radiancehintsborder [
] [ ] [
uniform sampler3D tex3, tex4, tex5, tex6; uniform sampler3D tex3, tex4, tex5, tex6;
uniform vec3 bordercenter, borderrange, borderscale; uniform vec3 bordercenter, borderrange, borderscale;
varying vec3 texcoord0; in vec3 texcoord0;
fragdata(0) vec4 rhr; layout(location = 0) out vec4 rhr;
fragdata(1) vec4 rhg; layout(location = 1) out vec4 rhg;
fragdata(2) vec4 rhb; layout(location = 2) out vec4 rhb;
fragdata(3) vec4 rha; layout(location = 3) out vec4 rha;
void main(void) void main(void)
{ {
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);
} }
] ]
lazyshader 0 radiancehintscached [ lazyshader 0 radiancehintscached [
attribute vec4 vvertex; in vec4 vvertex;
attribute vec3 vtexcoord0; in vec3 vtexcoord0;
varying vec3 texcoord0; out vec3 texcoord0;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -273,23 +273,23 @@ lazyshader 0 radiancehintscached [
} }
] [ ] [
uniform sampler3D tex7, tex8, tex9, tex10; uniform sampler3D tex7, tex8, tex9, tex10;
varying vec3 texcoord0; in vec3 texcoord0;
fragdata(0) vec4 rhr; layout(location = 0) out vec4 rhr;
fragdata(1) vec4 rhg; layout(location = 1) out vec4 rhg;
fragdata(2) vec4 rhb; layout(location = 2) out vec4 rhb;
fragdata(3) vec4 rha; layout(location = 3) out vec4 rha;
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);
} }
] ]
lazyshader 0 radiancehintsdisable [ lazyshader 0 radiancehintsdisable [
attribute vec4 vvertex; in vec4 vvertex;
uniform vec3 rhcenter; uniform vec3 rhcenter;
uniform float rhbounds; uniform float rhbounds;
void main(void) void main(void)
@ -297,10 +297,10 @@ lazyshader 0 radiancehintsdisable [
gl_Position = vec4((vvertex.xy - rhcenter.xy)/rhbounds, vvertex.zw); gl_Position = vec4((vvertex.xy - rhcenter.xy)/rhbounds, vvertex.zw);
} }
] [ ] [
fragdata(0) vec4 rhr; layout(location = 0) out vec4 rhr;
fragdata(1) vec4 rhg; layout(location = 1) out vec4 rhg;
fragdata(2) vec4 rhb; layout(location = 2) out vec4 rhb;
fragdata(3) vec4 rha; layout(location = 3) out vec4 rha;
void main(void) void main(void)
{ {

View File

@ -13,13 +13,13 @@ grassvariantshader = [
local grasstype local grasstype
grasstype = $arg2 grasstype = $arg2
variantshader 0 $arg1 (? (grassopt "b") 0 -1) [ variantshader 0 $arg1 (? (grassopt "b") 0 -1) [
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
@(ginterpvert) @(ginterpvert)
varying vec2 texcoord0; out vec2 texcoord0;
varying vec4 colorscale; out vec4 colorscale;
@(? (grassopt "b") [uniform vec4 blendmapparams; varying vec2 texcoord1;]) @(? (grassopt "b") [uniform vec4 blendmapparams; out vec2 texcoord1;])
void main(void) void main(void)
{ {
gl_Position = camprojmatrix * vvertex; gl_Position = camprojmatrix * vvertex;
@ -34,14 +34,14 @@ grassvariantshader = [
uniform sampler2D tex0; uniform sampler2D tex0;
uniform float grasstest; uniform float grasstest;
@(ginterpfrag) @(ginterpfrag)
varying vec2 texcoord0; in vec2 texcoord0;
varying vec4 colorscale; in vec4 colorscale;
@(? (grassopt "b") [uniform sampler2D tex1; varying 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

@ -5,11 +5,11 @@
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
shader 0 "hud" [ shader 0 "hud" [
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 hudmatrix; uniform mat4 hudmatrix;
varying vec2 texcoord0; out vec2 texcoord0;
varying vec4 colorscale; out vec4 colorscale;
void main(void) void main(void)
{ {
gl_Position = hudmatrix * vvertex; gl_Position = hudmatrix * vvertex;
@ -18,22 +18,22 @@ shader 0 "hud" [
} }
] [ ] [
uniform sampler2D tex0; uniform sampler2D tex0;
varying vec2 texcoord0; in vec2 texcoord0;
varying vec4 colorscale; in vec4 colorscale;
fragdata(0) 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;
} }
] ]
shader 0 "hudtext" [ shader 0 "hudtext" [
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 hudmatrix; uniform mat4 hudmatrix;
varying vec2 texcoord0; out vec2 texcoord0;
varying vec4 colorscale; out vec4 colorscale;
void main(void) void main(void)
{ {
gl_Position = hudmatrix * vvertex; gl_Position = hudmatrix * vvertex;
@ -43,12 +43,12 @@ shader 0 "hudtext" [
] [ ] [
uniform sampler2D tex0; uniform sampler2D tex0;
uniform vec4 textparams; uniform vec4 textparams;
varying vec2 texcoord0; in vec2 texcoord0;
varying vec4 colorscale; in vec4 colorscale;
fragdata(0) 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);
@ -56,11 +56,11 @@ shader 0 "hudtext" [
] ]
shader 0 "hudrgb" [ shader 0 "hudrgb" [
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 hudmatrix; uniform mat4 hudmatrix;
varying vec2 texcoord0; out vec2 texcoord0;
varying vec4 colorscale; out vec4 colorscale;
void main(void) void main(void)
{ {
gl_Position = hudmatrix * vvertex; gl_Position = hudmatrix * vvertex;
@ -69,29 +69,29 @@ shader 0 "hudrgb" [
} }
] [ ] [
uniform sampler2D tex0; uniform sampler2D tex0;
varying vec2 texcoord0; in vec2 texcoord0;
varying vec4 colorscale; in vec4 colorscale;
fragdata(0) 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;
} }
] ]
shader 0 "hudnotexture" [ shader 0 "hudnotexture" [
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
uniform mat4 hudmatrix; uniform mat4 hudmatrix;
varying vec4 color; out vec4 color;
void main(void) void main(void)
{ {
gl_Position = hudmatrix * vvertex; gl_Position = hudmatrix * vvertex;
color = vcolor; color = vcolor;
} }
] [ ] [
varying vec4 color; in vec4 color;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = color; fragcolor = color;
@ -99,11 +99,11 @@ shader 0 "hudnotexture" [
] ]
shader 0 "hudrect" [ shader 0 "hudrect" [
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 hudmatrix; uniform mat4 hudmatrix;
varying vec2 texcoord0; out vec2 texcoord0;
varying vec4 colorscale; out vec4 colorscale;
void main(void) void main(void)
{ {
gl_Position = hudmatrix * vvertex; gl_Position = hudmatrix * vvertex;
@ -112,21 +112,21 @@ shader 0 "hudrect" [
} }
] [ ] [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
varying vec2 texcoord0; in vec2 texcoord0;
varying vec4 colorscale; in vec4 colorscale;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = colorscale * texture2DRect(tex0, texcoord0); fragcolor = colorscale * textureRect(tex0, texcoord0);
} }
] ]
shader 0 "hud3d" [ shader 0 "hud3d" [
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
attribute vec3 vtexcoord0; in vec3 vtexcoord0;
uniform mat4 hudmatrix; uniform mat4 hudmatrix;
varying vec3 texcoord0; out vec3 texcoord0;
varying vec4 color; out vec4 color;
void main(void) void main(void)
{ {
gl_Position = hudmatrix * vvertex; gl_Position = hudmatrix * vvertex;
@ -135,21 +135,21 @@ shader 0 "hud3d" [
} }
] [ ] [
uniform sampler3D tex0; uniform sampler3D tex0;
varying vec3 texcoord0; in vec3 texcoord0;
varying vec4 color; in vec4 color;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = color * texture3D(tex0, texcoord0); fragcolor = color * texture(tex0, texcoord0);
} }
] ]
shader 0 "hudcubemap" [ shader 0 "hudcubemap" [
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
attribute vec3 vtexcoord0; in vec3 vtexcoord0;
uniform mat4 hudmatrix; uniform mat4 hudmatrix;
varying vec3 texcoord0; out vec3 texcoord0;
varying vec4 colorscale; out vec4 colorscale;
void main(void) void main(void)
{ {
gl_Position = hudmatrix * vvertex; gl_Position = hudmatrix * vvertex;
@ -158,12 +158,12 @@ shader 0 "hudcubemap" [
} }
] [ ] [
uniform samplerCube tex0; uniform samplerCube tex0;
varying vec3 texcoord0; in vec3 texcoord0;
varying vec4 colorscale; in vec4 colorscale;
fragdata(0) 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

@ -5,7 +5,7 @@
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
shader 0 "refractmask" [ shader 0 "refractmask" [
attribute vec4 vvertex; in vec4 vvertex;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
void main(void) void main(void)
{ {
@ -14,7 +14,7 @@ shader 0 "refractmask" [
] [ ] [
@(gfetchdefs tex0) @(gfetchdefs tex0)
uniform vec3 gdepthpackparams; uniform vec3 gdepthpackparams;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
@(if (= $gdepthformat 1) [result [ @(if (= $gdepthformat 1) [result [
@ -28,7 +28,7 @@ shader 0 "refractmask" [
] ]
lazyshader 0 "waterminimap" [ lazyshader 0 "waterminimap" [
attribute vec4 vvertex; in vec4 vvertex;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
@(ginterpvert) @(ginterpvert)
void main(void) void main(void)
@ -50,15 +50,15 @@ lazyshader 0 "waterminimap" [
watershader = [ watershader = [
lazyshader 0 $arg1 [ lazyshader 0 $arg1 [
attribute vec4 vvertex; in vec4 vvertex;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
uniform vec3 camera; uniform vec3 camera;
varying vec2 texcoord0, texcoord1; out vec2 texcoord0, texcoord1;
varying vec3 surface; out vec3 surface;
@(? (>= (strstr $arg1 "reflect") 0) [ @(? (>= (strstr $arg1 "reflect") 0) [
uniform mat4 raymatrix; uniform mat4 raymatrix;
varying vec3 esurface; out vec3 esurface;
]) ])
@(ginterpvert 1) @(ginterpvert 1)
void main(void) void main(void)
@ -77,8 +77,8 @@ watershader = [
uniform float millis; uniform float millis;
uniform vec3 camera; uniform vec3 camera;
uniform mat4 linearworldmatrix; uniform mat4 linearworldmatrix;
varying vec2 texcoord0, texcoord1; in vec2 texcoord0, texcoord1;
varying vec3 surface; in vec3 surface;
uniform sampler2D tex0, tex1; uniform sampler2D tex0, tex1;
uniform vec4 viewsize; uniform vec4 viewsize;
uniform vec3 watercolor, waterdeepcolor, waterdeepfade; uniform vec3 watercolor, waterdeepcolor, waterdeepfade;
@ -95,17 +95,17 @@ watershader = [
]) ])
@(? (>= (strstr $arg1 "reflect") 0) [ @(? (>= (strstr $arg1 "reflect") 0) [
uniform mat4 raymatrix; uniform mat4 raymatrix;
varying vec3 esurface; in vec3 esurface;
]) ])
@(ginterpfrag 1) @(ginterpfrag 1)
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);
]]]) ]]])
@ -181,7 +181,7 @@ watershader "underwater"
causticshader = [ causticshader = [
lazyshader 0 $arg1 [ lazyshader 0 $arg1 [
attribute vec4 vvertex; in vec4 vvertex;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -192,7 +192,7 @@ causticshader = [
uniform vec3 causticsblend; uniform vec3 causticsblend;
uniform sampler2D tex0, tex1; uniform sampler2D tex0, tex1;
uniform vec4 waterdeepfade; uniform vec4 waterdeepfade;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
@(gdepthunpack depth [gfetch(tex9, gl_FragCoord.xy)] [ @(gdepthunpack depth [gfetch(tex9, gl_FragCoord.xy)] [
@ -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);
} }
@ -211,7 +211,7 @@ causticshader caustics
waterfogshader = [ waterfogshader = [
lazyshader 0 $arg1 [ lazyshader 0 $arg1 [
attribute vec4 vvertex; in vec4 vvertex;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -224,7 +224,7 @@ waterfogshader = [
uniform vec2 fogdensity; uniform vec2 fogdensity;
uniform vec3 waterdeepcolor, waterdeepfade; uniform vec3 waterdeepcolor, waterdeepfade;
uniform float waterheight; uniform float waterheight;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
@(gdepthunpack depth [gfetch(tex9, gl_FragCoord.xy)] [ @(gdepthunpack depth [gfetch(tex9, gl_FragCoord.xy)] [
@ -246,12 +246,12 @@ waterfogshader = [
waterfogshader waterfog waterfogshader waterfog
lazyshader 0 "lava" [ lazyshader 0 "lava" [
attribute vec4 vvertex; in vec4 vvertex;
attribute vec3 vnormal; in vec3 vnormal;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
varying mat3 world; out mat3 world;
varying vec2 texcoord0; out vec2 texcoord0;
@(ginterpvert) @(ginterpvert)
void main(void) void main(void)
{ {
@ -265,14 +265,14 @@ lazyshader 0 "lava" [
] [ ] [
uniform sampler2D tex0, tex1; uniform sampler2D tex0, tex1;
uniform float lavaglow, lavaspec; uniform float lavaglow, lavaspec;
varying mat3 world; in mat3 world;
varying vec2 texcoord0; in vec2 texcoord0;
@(ginterpfrag) @(ginterpfrag)
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)
@ -283,14 +283,14 @@ lazyshader 0 "lava" [
] ]
lazyshader 0 "waterfallenv" [ lazyshader 0 "waterfallenv" [
attribute vec4 vvertex; in vec4 vvertex;
attribute vec3 vnormal; in vec3 vnormal;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
uniform vec4 camera; uniform vec4 camera;
varying vec3 camdir; out vec3 camdir;
varying mat3 world; out mat3 world;
varying vec2 texcoord0; out vec2 texcoord0;
@(ginterpvert 1) @(ginterpvert 1)
void main(void) void main(void)
{ {
@ -310,16 +310,16 @@ lazyshader 0 "waterfallenv" [
uniform float waterfallspec; uniform float waterfallspec;
uniform vec4 waterfallrefract; uniform vec4 waterfallrefract;
uniform float refractdepth; uniform float refractdepth;
varying vec3 camdir; in vec3 camdir;
varying mat3 world; in mat3 world;
varying vec2 texcoord0; in vec2 texcoord0;
@(ginterpfrag 1) @(ginterpfrag 1)
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);
@ -340,12 +340,12 @@ lazyshader 0 "waterfallenv" [
] ]
lazyshader 0 "waterfall" [ lazyshader 0 "waterfall" [
attribute vec4 vvertex; in vec4 vvertex;
attribute vec3 vnormal; in vec3 vnormal;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
varying mat3 world; out mat3 world;
varying vec2 texcoord0; out vec2 texcoord0;
@(ginterpvert 1) @(ginterpvert 1)
void main(void) void main(void)
{ {
@ -363,14 +363,14 @@ lazyshader 0 "waterfall" [
uniform float waterfallspec; uniform float waterfallspec;
uniform vec4 waterfallrefract; uniform vec4 waterfallrefract;
uniform float refractdepth; uniform float refractdepth;
varying mat3 world; in mat3 world;
varying vec2 texcoord0; in vec2 texcoord0;
@(ginterpfrag 1) @(ginterpfrag 1)
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;
@ -387,14 +387,14 @@ lazyshader 0 "waterfall" [
] ]
lazyshader 0 "glassenv" [ lazyshader 0 "glassenv" [
attribute vec4 vvertex; in vec4 vvertex;
attribute vec3 vnormal; in vec3 vnormal;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
uniform vec4 camera; uniform vec4 camera;
varying vec3 camdir; out vec3 camdir;
varying mat3 world; out mat3 world;
varying vec2 texcoord0; out vec2 texcoord0;
@(ginterpvert 1) @(ginterpvert 1)
void main(void) void main(void)
{ {
@ -413,15 +413,15 @@ lazyshader 0 "glassenv" [
uniform float glassspec; uniform float glassspec;
uniform vec4 glassrefract; uniform vec4 glassrefract;
uniform float refractdepth; uniform float refractdepth;
varying vec3 camdir; in vec3 camdir;
varying mat3 world; in mat3 world;
varying vec2 texcoord0; in vec2 texcoord0;
@(ginterpfrag 1) @(ginterpfrag 1)
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);
@ -443,12 +443,12 @@ lazyshader 0 "glassenv" [
] ]
lazyshader 0 "glass" [ lazyshader 0 "glass" [
attribute vec4 vvertex; in vec4 vvertex;
attribute vec3 vnormal; in vec3 vnormal;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
varying mat3 world; out mat3 world;
varying vec2 texcoord0; out vec2 texcoord0;
@(ginterpvert 1) @(ginterpvert 1)
void main(void) void main(void)
{ {
@ -465,13 +465,13 @@ lazyshader 0 "glass" [
uniform float glassspec; uniform float glassspec;
uniform vec4 glassrefract; uniform vec4 glassrefract;
uniform float refractdepth; uniform float refractdepth;
varying mat3 world; in mat3 world;
varying vec2 texcoord0; in vec2 texcoord0;
@(ginterpfrag 1) @(ginterpfrag 1)
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

@ -1,11 +1,11 @@
shader 0 "null" [ shader 0 "null" [
attribute vec4 vvertex; in vec4 vvertex;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
} }
] [ ] [
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = vec4(1.0, 0.0, 1.0, 1.0); fragcolor = vec4(1.0, 0.0, 1.0, 1.0);
@ -19,7 +19,7 @@ shader 0 "null" [
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
shader 0 "nocolor" [ shader 0 "nocolor" [
attribute vec4 vvertex; in vec4 vvertex;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
void main() { gl_Position = camprojmatrix * vvertex; } void main() { gl_Position = camprojmatrix * vvertex; }
] [ ] [
@ -27,7 +27,7 @@ shader 0 "nocolor" [
] ]
shader 0 "bbquery" [ shader 0 "bbquery" [
attribute vec4 vvertex; in vec4 vvertex;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
uniform vec3 bborigin, bbsize; uniform vec3 bborigin, bbsize;
void main() { gl_Position = camprojmatrix * vec4(bborigin + vvertex.xyz*bbsize, vvertex.w); } void main() { gl_Position = camprojmatrix * vec4(bborigin + vvertex.xyz*bbsize, vvertex.w); }
@ -36,9 +36,9 @@ shader 0 "bbquery" [
] ]
shader 0 "depth" [ shader 0 "depth" [
attribute vec4 vvertex; in vec4 vvertex;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
@(ginterpdepth) @(ginterpdepth out)
void main() void main()
{ {
gl_Position = camprojmatrix * vvertex; gl_Position = camprojmatrix * vvertex;
@ -46,9 +46,9 @@ shader 0 "depth" [
} }
] [ ] [
@(? $gdepthformat [ @(? $gdepthformat [
fragdata(0) vec4 gdepth; layout(location = 0) out vec4 gdepth;
]) ])
@(ginterpdepth) @(ginterpdepth in)
void main() void main()
{ {
@(if (= $gdepthformat 1) [result [ @(if (= $gdepthformat 1) [result [
@ -68,12 +68,12 @@ shader 0 "depth" [
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
shader 0 "ldr" [ shader 0 "ldr" [
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
uniform float ldrscale; uniform float ldrscale;
varying vec2 texcoord0; out vec2 texcoord0;
varying vec4 colorscale; out vec4 colorscale;
void main(void) void main(void)
{ {
gl_Position = camprojmatrix * vvertex; gl_Position = camprojmatrix * vvertex;
@ -82,29 +82,29 @@ shader 0 "ldr" [
} }
] [ ] [
uniform sampler2D tex0; uniform sampler2D tex0;
varying vec2 texcoord0; in vec2 texcoord0;
varying vec4 colorscale; in vec4 colorscale;
fragdata(0) 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;
} }
] ]
shader 0 "ldrnotexture" [ shader 0 "ldrnotexture" [
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
uniform float ldrscale; uniform float ldrscale;
varying vec4 color; out vec4 color;
void main(void) void main(void)
{ {
gl_Position = camprojmatrix * vvertex; gl_Position = camprojmatrix * vvertex;
color = vec4(ldrscale * vcolor.rgb, vcolor.a); color = vec4(ldrscale * vcolor.rgb, vcolor.a);
} }
] [ ] [
varying vec4 color; in vec4 color;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = color; fragcolor = color;
@ -119,11 +119,11 @@ shader 0 "ldrnotexture" [
shader 0 "fogged" [ shader 0 "fogged" [
//:fog //:fog
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
varying vec2 texcoord0; out vec2 texcoord0;
varying vec4 colorscale; out vec4 colorscale;
void main(void) void main(void)
{ {
gl_Position = camprojmatrix * vvertex; gl_Position = camprojmatrix * vvertex;
@ -132,29 +132,29 @@ shader 0 "fogged" [
} }
] [ ] [
uniform sampler2D tex0; uniform sampler2D tex0;
varying vec2 texcoord0; in vec2 texcoord0;
varying vec4 colorscale; in vec4 colorscale;
fragdata(0) 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;
} }
] ]
shader 0 "foggednotexture" [ shader 0 "foggednotexture" [
//:fog //:fog
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
varying vec4 color; out vec4 color;
void main(void) void main(void)
{ {
gl_Position = camprojmatrix * vvertex; gl_Position = camprojmatrix * vvertex;
color = vcolor; color = vcolor;
} }
] [ ] [
varying vec4 color; in vec4 color;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = color; fragcolor = color;
@ -162,16 +162,16 @@ shader 0 "foggednotexture" [
] ]
shader 0 "fogoverlay" [ shader 0 "fogoverlay" [
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
varying vec4 color; out vec4 color;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
color = vcolor; color = vcolor;
} }
] [ ] [
varying vec4 color; in vec4 color;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = color; fragcolor = color;

View File

@ -20,7 +20,7 @@ qtangentdecode = [
skelanimdefs = [ skelanimdefs = [
result [ result [
attribute vec4 vboneweight, vboneindex; in vec4 vboneweight, vboneindex;
//:uniform animdata //:uniform animdata
uniform vec4 animdata[@@(min $maxvsuniforms $maxskelanimdata)]; uniform vec4 animdata[@@(min $maxvsuniforms $maxskelanimdata)];
] ]
@ -72,13 +72,13 @@ shadowmodelvertexshader = [
local modeltype local modeltype
modeltype = $arg1 modeltype = $arg1
result [ result [
attribute vec4 vvertex; in vec4 vvertex;
@(if (mdlopt "b") [skelanimdefs $arg2]) @(if (mdlopt "b") [skelanimdefs $arg2])
uniform mat4 modelmatrix; uniform mat4 modelmatrix;
@(? (mdlopt "a") [ @(? (mdlopt "a") [
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform vec2 texscroll; uniform vec2 texscroll;
varying vec2 texcoord0; out vec2 texcoord0;
]) ])
void main(void) void main(void)
{ {
@ -104,12 +104,12 @@ shadowmodelfragmentshader = [
@(? (mdlopt "a") [ @(? (mdlopt "a") [
uniform sampler2D tex0; uniform sampler2D tex0;
uniform float alphatest; uniform float alphatest;
varying vec2 texcoord0; in vec2 texcoord0;
]) ])
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;
]) ])
@ -144,23 +144,23 @@ modelvertexshader = [
local modeltype local modeltype
modeltype = $arg1 modeltype = $arg1
result [ result [
attribute vec4 vvertex, vtangent; in vec4 vvertex, vtangent;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
@(if (mdlopt "b") [skelanimdefs $arg2 (mdlopt "n")]) @(if (mdlopt "b") [skelanimdefs $arg2 (mdlopt "n")])
uniform mat4 modelmatrix; uniform mat4 modelmatrix;
uniform mat3 modelworld; uniform mat3 modelworld;
uniform vec3 modelcamera; uniform vec3 modelcamera;
uniform vec2 texscroll; uniform vec2 texscroll;
@(? (mdlopt "n") [ @(? (mdlopt "n") [
varying mat3 world; out mat3 world;
] [ ] [
varying vec3 nvec; out vec3 nvec;
]) ])
@(? (mdlopt "e") [ @(? (mdlopt "e") [
varying vec3 camvec; out vec3 camvec;
]) ])
@(msaainterpvert) @(msaainterpvert)
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
@ -201,13 +201,13 @@ modelfragmentshader = [
modeltype = $arg1 modeltype = $arg1
result [ result [
@(? (mdlopt "n") [ @(? (mdlopt "n") [
varying mat3 world; in mat3 world;
] [ ] [
varying vec3 nvec; in vec3 nvec;
]) ])
@(? (mdlopt "e") [ @(? (mdlopt "e") [
uniform vec2 envmapscale; uniform vec2 envmapscale;
varying vec3 camvec; in vec3 camvec;
]) ])
uniform vec4 colorscale; uniform vec4 colorscale;
uniform vec2 fullbright; uniform vec2 fullbright;
@ -219,12 +219,12 @@ modelfragmentshader = [
@(? (mdlopt "n") [uniform sampler2D tex3;]) @(? (mdlopt "n") [uniform sampler2D tex3;])
@(? (|| (mdlopt "d") [mdlopt "D"]) [uniform sampler2D tex4;]) @(? (|| (mdlopt "d") [mdlopt "D"]) [uniform sampler2D tex4;])
@(msaainterpfrag) @(msaainterpfrag)
varying vec2 texcoord0; in vec2 texcoord0;
uniform float aamask; uniform float aamask;
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
]) ])
@ -308,14 +308,14 @@ rsmmodelvertexshader = [
local modeltype local modeltype
modeltype = $arg1 modeltype = $arg1
result [ result [
attribute vec4 vvertex, vtangent; in vec4 vvertex, vtangent;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
@(if (mdlopt "b") [skelanimdefs $arg2 (mdlopt "n")]) @(if (mdlopt "b") [skelanimdefs $arg2 (mdlopt "n")])
uniform mat4 modelmatrix; uniform mat4 modelmatrix;
uniform mat3 modelworld; uniform mat3 modelworld;
uniform vec2 texscroll; uniform vec2 texscroll;
varying vec2 texcoord0; out vec2 texcoord0;
varying vec3 nvec; out vec3 nvec;
void main(void) void main(void)
{ {
@(if (mdlopt "b") [ @(if (mdlopt "b") [
@ -339,17 +339,17 @@ rsmmodelfragmentshader = [
local modeltype local modeltype
modeltype = $arg1 modeltype = $arg1
result [ result [
varying vec2 texcoord0; in vec2 texcoord0;
varying vec3 nvec; in vec3 nvec;
uniform vec4 colorscale; uniform vec4 colorscale;
@(? (mdlopt "a") [uniform float alphatest;]) @(? (mdlopt "a") [uniform float alphatest;])
uniform vec3 rsmdir; uniform vec3 rsmdir;
uniform sampler2D tex0; uniform sampler2D tex0;
fragdata(0) vec4 gcolor; layout(location = 0) out vec4 gcolor;
fragdata(1) 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

@ -5,9 +5,9 @@
//////////////////////////////////////////////// ////////////////////////////////////////////////
lazyshader 0 "moviergb" [ lazyshader 0 "moviergb" [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -15,18 +15,18 @@ lazyshader 0 "moviergb" [
} }
] [ ] [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = texture2DRect(tex0, texcoord0); fragcolor = textureRect(tex0, texcoord0);
} }
] ]
lazyshader 0 "movieyuv" [ lazyshader 0 "movieyuv" [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -34,11 +34,11 @@ lazyshader 0 "movieyuv" [
} }
] [ ] [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) 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,
@ -47,9 +47,9 @@ lazyshader 0 "movieyuv" [
] ]
lazyshader 0 "moviey" [ lazyshader 0 "moviey" [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -57,14 +57,14 @@ lazyshader 0 "moviey" [
} }
] [ ] [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) 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,
@ -73,9 +73,9 @@ lazyshader 0 "moviey" [
] ]
lazyshader 0 "movieu" [ lazyshader 0 "movieu" [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -83,14 +83,14 @@ lazyshader 0 "movieu" [
} }
] [ ] [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) 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,
@ -99,9 +99,9 @@ lazyshader 0 "movieu" [
] ]
lazyshader 0 "moviev" [ lazyshader 0 "moviev" [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -109,14 +109,14 @@ lazyshader 0 "moviev" [
} }
] [ ] [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) 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

@ -11,18 +11,18 @@
explosionshader = [ explosionshader = [
shader 0 $arg1 [ shader 0 $arg1 [
//:fog //:fog
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
uniform mat4 explosionmatrix; uniform mat4 explosionmatrix;
uniform vec3 center; uniform vec3 center;
uniform float millis; uniform float millis;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform vec4 texgenS, texgenT; uniform vec4 texgenS, texgenT;
@(? (>= (strstr $arg1 "soft") 0) [ @(? (>= (strstr $arg1 "soft") 0) [
uniform vec2 lineardepthscale; uniform vec2 lineardepthscale;
varying float lineardepth; out float lineardepth;
]) ])
varying vec4 color; out vec4 color;
varying vec2 texcoord0, texcoord1, texcoord2; out vec2 texcoord0, texcoord1, texcoord2;
void main(void) void main(void)
{ {
vec4 wobble = vec4(vvertex.xyz*(1.0 + 0.5*abs(fract(dot(vvertex.xyz, center) + millis*2.0) - 0.5)), vvertex.w); vec4 wobble = vec4(vvertex.xyz*(1.0 + 0.5*abs(fract(dot(vvertex.xyz, center) + millis*2.0) - 0.5)), vvertex.w);
@ -42,17 +42,17 @@ explosionshader = [
@(if (>= (strstr $arg1 "soft") 0) [result [ @(if (>= (strstr $arg1 "soft") 0) [result [
@(gfetchdefs tex2) @(gfetchdefs tex2)
uniform vec3 softparams; uniform vec3 softparams;
varying float lineardepth; in float lineardepth;
]]) ]])
varying vec4 color; in vec4 color;
varying vec2 texcoord0, texcoord1, texcoord2; in vec2 texcoord0, texcoord1, texcoord2;
uniform sampler2D tex0; uniform sampler2D tex0;
uniform vec2 blendparams; uniform vec2 blendparams;
fragdata(0) 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
@ -74,18 +74,18 @@ explosionshader "explosionsoft"
shader 0 "particlenotexture" [ shader 0 "particlenotexture" [
//:fog //:fog
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
uniform vec4 colorscale; uniform vec4 colorscale;
varying vec4 color; out vec4 color;
void main(void) void main(void)
{ {
gl_Position = camprojmatrix * vvertex; gl_Position = camprojmatrix * vvertex;
color = vcolor * colorscale; color = vcolor * colorscale;
} }
] [ ] [
varying vec4 color; in vec4 color;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = color; fragcolor = color;
@ -94,12 +94,12 @@ shader 0 "particlenotexture" [
shader 0 "particletext" [ shader 0 "particletext" [
//:fog //:fog
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
uniform float ldrscale; uniform float ldrscale;
varying vec4 color; out vec4 color;
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
gl_Position = camprojmatrix * vvertex; gl_Position = camprojmatrix * vvertex;
@ -109,12 +109,12 @@ shader 0 "particletext" [
] [ ] [
uniform vec4 textparams; uniform vec4 textparams;
uniform sampler2D tex0; uniform sampler2D tex0;
varying vec4 color; in vec4 color;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) 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);
@ -124,16 +124,16 @@ shader 0 "particletext" [
particleshader = [ particleshader = [
shader 0 $arg1 [ shader 0 $arg1 [
//:fog //:fog
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
uniform vec4 colorscale; uniform vec4 colorscale;
varying vec4 color; out vec4 color;
varying vec2 texcoord0; out vec2 texcoord0;
@(? (>= (strstr $arg1 "soft") 0) [ @(? (>= (strstr $arg1 "soft") 0) [
uniform vec2 lineardepthscale; uniform vec2 lineardepthscale;
varying float lineardepth; out float lineardepth;
varying vec2 surface; out vec2 surface;
]) ])
void main(void) void main(void)
{ {
@ -150,16 +150,16 @@ particleshader = [
@(if (>= (strstr $arg1 "soft") 0) [result [ @(if (>= (strstr $arg1 "soft") 0) [result [
@(gfetchdefs tex2) @(gfetchdefs tex2)
uniform vec3 softparams; uniform vec3 softparams;
varying float lineardepth; in float lineardepth;
varying vec2 surface; in vec2 surface;
]]) ]])
uniform sampler2D tex0; uniform sampler2D tex0;
varying vec4 color; in vec4 color;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) 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

@ -5,9 +5,9 @@
//////////////////////////////////////////////// ////////////////////////////////////////////////
fsvs = [result [ fsvs = [result [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
@arg2 @arg2
void main(void) void main(void)
{ {
@ -19,12 +19,12 @@ fsvs = [result [
fsps = [result [ fsps = [result [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
@arg2 @arg2
void main(void) void main(void)
{ {
vec4 color = texture2DRect(tex0, texcoord0); vec4 color = textureRect(tex0, texcoord0);
@arg1 @arg1
} }
]] ]]
@ -37,19 +37,19 @@ fsvs4 = [
texcoord4 = vtexcoord0 + vec2( 1.5, 1.5); texcoord4 = vtexcoord0 + vec2( 1.5, 1.5);
@arg1 @arg1
] [ ] [
varying vec2 texcoord1, texcoord2, texcoord3, texcoord4; out vec2 texcoord1, texcoord2, texcoord3, texcoord4;
] ]
] ]
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
] [ ] [
varying vec2 texcoord1, texcoord2, texcoord3, texcoord4; in vec2 texcoord1, texcoord2, texcoord3, texcoord4;
] ]
] ]
@ -70,10 +70,10 @@ lazyshader 0 "sobel" (fsvs4) (fsps4 [
// rotoscope // rotoscope
lazyshader 0 "rotoscope" [ lazyshader 0 "rotoscope" [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
uniform vec4 params; uniform vec4 params;
varying vec2 t11, t00, t12, t01, t20, t02, t21, t10, t22; out vec2 t11, t00, t12, t01, t20, t02, t21, t10, t22;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -89,19 +89,19 @@ lazyshader 0 "rotoscope" [
} }
] [ ] [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
varying vec2 t11, t00, t12, t01, t20, t02, t21, t10, t22; in vec2 t11, t00, t12, t01, t20, t02, t21, t10, t22;
fragdata(0) 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;
@ -125,9 +125,9 @@ lazyshader 0 "rotoscope" [
blur3shader = [ blur3shader = [
lazyshader 0 $arg1 [ lazyshader 0 $arg1 [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0, texcoord1; out vec2 texcoord0, texcoord1;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -136,11 +136,11 @@ blur3shader = [
} }
] [ ] [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
varying vec2 texcoord0, texcoord1; in vec2 texcoord0, texcoord1;
fragdata(0) 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));
} }
] ]
] ]
@ -149,9 +149,9 @@ blur3shader vblur3 0 1
blur5shader = [ blur5shader = [
lazyshader 0 $arg1 [ lazyshader 0 $arg1 [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0, texcoord1, texcoord2; out vec2 texcoord0, texcoord1, texcoord2;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -161,11 +161,11 @@ blur5shader = [
} }
] [ ] [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
varying vec2 texcoord0, texcoord1, texcoord2; in vec2 texcoord0, texcoord1, texcoord2;
fragdata(0) 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

@ -5,9 +5,9 @@
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
shader 0 "scalelinear" [ shader 0 "scalelinear" [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
@ -16,20 +16,20 @@ shader 0 "scalelinear" [
} }
] [ ] [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = texture2DRect(tex0, texcoord0); fragcolor = textureRect(tex0, texcoord0);
} }
] ]
loop i 2 [ loop i 2 [
lazyshader 0 (? $i "scalecubicy" "scalecubicx") [ lazyshader 0 (? $i "scalecubicy" "scalecubicx") [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
@ -38,8 +38,8 @@ loop i 2 [
} }
] [ ] [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
vec4 cubic(float s) vec4 cubic(float s)
{ {
@ -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;
@ -74,9 +74,9 @@ loop i 2 [
] ]
shader 0 "reorient" [ shader 0 "reorient" [
attribute vec4 vvertex; in vec4 vvertex;
uniform vec3 reorientx, reorienty; uniform vec3 reorientx, reorienty;
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
@ -86,12 +86,12 @@ shader 0 "reorient" [
} }
] [ ] [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = texture2DRect(tex0, texcoord0); fragcolor = textureRect(tex0, texcoord0);
} }
] ]

View File

@ -8,26 +8,26 @@ ginterpdepth = [
result [ result [
uniform vec2 lineardepthscale; uniform vec2 lineardepthscale;
uniform vec3 gdepthpackparams; uniform vec3 gdepthpackparams;
varying float lineardepth; @arg1 float lineardepth;
] ]
] ]
ginterpvert = [ ginterpvert = [
if (|| $gdepthformat $arg1) [ginterpdepth] if (|| $gdepthformat $arg1) [ginterpdepth out]
] ]
msaainterpvert = [ginterpvert $msaasamples] msaainterpvert = [ginterpvert $msaasamples]
ginterpfrag = [ ginterpfrag = [
result [ result [
fragdata(0) vec4 gcolor; layout(location = 0) out vec4 gcolor;
fragdata(1) vec4 gnormal; layout(location = 1) out vec4 gnormal;
@(? $gdepthformat [ @(? $gdepthformat [
fragdata(2) vec4 gdepth; layout(location = 2) out vec4 gdepth;
fragdata(3) vec4 gglow; layout(location = 3) out vec4 gglow;
] [ ] [
fragdata(2) vec4 gglow; layout(location = 2) out vec4 gglow;
]) ])
@(if (|| $gdepthformat $arg1) [ginterpdepth]) @(if (|| $gdepthformat $arg1) [ginterpdepth in])
] ]
] ]
msaainterpfrag = [ginterpfrag $msaasamples] msaainterpfrag = [ginterpfrag $msaasamples]
@ -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

@ -5,12 +5,12 @@
//////////////////////////////////////////////// ////////////////////////////////////////////////
shader 0 "skybox" [ shader 0 "skybox" [
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 skymatrix; uniform mat4 skymatrix;
uniform float ldrscale; uniform float ldrscale;
varying vec4 colorscale; out vec4 colorscale;
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
gl_Position = skymatrix * vvertex; gl_Position = skymatrix * vvertex;
@ -19,23 +19,23 @@ shader 0 "skybox" [
} }
] [ ] [
uniform sampler2D tex0; uniform sampler2D tex0;
varying vec4 colorscale; in vec4 colorscale;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) 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;
} }
] ]
shader 0 "skyboxoverbright" [ shader 0 "skyboxoverbright" [
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 skymatrix; uniform mat4 skymatrix;
uniform float ldrscale; uniform float ldrscale;
varying vec4 colorscale; out vec4 colorscale;
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
gl_Position = skymatrix * vvertex; gl_Position = skymatrix * vvertex;
@ -46,12 +46,12 @@ shader 0 "skyboxoverbright" [
uniform sampler2D tex0; uniform sampler2D tex0;
uniform vec3 overbrightparams; uniform vec3 overbrightparams;
uniform float ldrscale; uniform float ldrscale;
varying vec4 colorscale; in vec4 colorscale;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) 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;
@ -60,9 +60,9 @@ shader 0 "skyboxoverbright" [
] ]
shader 0 "atmosphere" [ shader 0 "atmosphere" [
attribute vec4 vvertex; in vec4 vvertex;
uniform mat4 sunmatrix; uniform mat4 sunmatrix;
varying vec3 camvec; out vec3 camvec;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -80,8 +80,8 @@ shader 0 "atmosphere" [
uniform vec3 betar, betam, betarm; uniform vec3 betar, betam, betarm;
uniform vec2 hdrgamma; uniform vec2 hdrgamma;
uniform float atmoalpha; uniform float atmoalpha;
varying vec3 camvec; in vec3 camvec;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
vec3 calcextinction(float dist) vec3 calcextinction(float dist)
{ {
@ -142,10 +142,10 @@ shader 0 "atmosphere" [
] ]
shader 0 "skyfog" [ shader 0 "skyfog" [
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
uniform mat4 skymatrix; uniform mat4 skymatrix;
uniform float ldrscale; uniform float ldrscale;
varying vec4 color; out vec4 color;
void main(void) void main(void)
{ {
gl_Position = skymatrix * vvertex; gl_Position = skymatrix * vvertex;
@ -153,8 +153,8 @@ shader 0 "skyfog" [
} }
] [ ] [
uniform sampler2D tex0; uniform sampler2D tex0;
varying vec4 color; in vec4 color;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = color; fragcolor = color;

View File

@ -93,9 +93,9 @@ smaadefs = [
] ]
shader 0 [SMAALumaEdgeDetection@smaapreset@smaaopts] [ shader 0 [SMAALumaEdgeDetection@smaapreset@smaaopts] [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
@ -105,15 +105,15 @@ shader 0 [SMAALumaEdgeDetection@smaapreset@smaaopts] [
] [ ] [
@smaadefs @smaadefs
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
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)));
@ -157,9 +157,9 @@ shader 0 [SMAALumaEdgeDetection@smaapreset@smaaopts] [
] ]
shader 0 [SMAAColorEdgeDetection@smaapreset@smaaopts] [ shader 0 [SMAAColorEdgeDetection@smaapreset@smaaopts] [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
@ -169,15 +169,15 @@ shader 0 [SMAAColorEdgeDetection@smaapreset@smaaopts] [
] [ ] [
@smaadefs @smaadefs
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
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:
@ -214,9 +214,9 @@ shader 0 [SMAAColorEdgeDetection@smaapreset@smaaopts] [
shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
@smaadefs @smaadefs
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0, texcoord1, texcoord2, texcoord3, texcoord4, texcoord5; out vec2 texcoord0, texcoord1, texcoord2, texcoord3, texcoord4, texcoord5;
void main(void) void main(void)
{ {
@ -232,10 +232,10 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
} }
] [ ] [
@smaadefs @smaadefs
varying vec2 texcoord0, texcoord1, texcoord2, texcoord3, texcoord4, texcoord5; in vec2 texcoord0, texcoord1, texcoord2, texcoord3, texcoord4, texcoord5;
uniform sampler2DRect tex0, tex1, tex2; uniform sampler2DRect tex0, tex1, tex2;
uniform vec4 subsamples; uniform vec4 subsamples;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
#if __VERSION__ >= 130 || defined(GL_EXT_gpu_shader4) #if __VERSION__ >= 130 || defined(GL_EXT_gpu_shader4)
#define SMAARound(e) round(e) #define SMAARound(e) round(e)
@ -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);
@ -563,9 +563,9 @@ shader 0 [SMAABlendingWeightCalculation@smaapreset@smaaopts] [
] ]
shader 0 [SMAANeighborhoodBlending@smaapreset@smaaopts] [ shader 0 [SMAANeighborhoodBlending@smaapreset@smaaopts] [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
@ -574,10 +574,10 @@ shader 0 [SMAANeighborhoodBlending@smaapreset@smaaopts] [
} }
] [ ] [
@smaadefs @smaadefs
varying vec2 texcoord0; in vec2 texcoord0;
uniform sampler2DRect tex0, tex1; uniform sampler2DRect tex0, tex1;
@(? (smaaopt "s") [uniform sampler2DRect tex2, tex3;]) @(? (smaaopt "s") [uniform sampler2DRect tex2, tex3;])
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
// Neighborhood Blending Pixel Shader (Third Pass) // Neighborhood Blending Pixel Shader (Third Pass)
@ -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

@ -18,12 +18,12 @@ stainvariantshader = [
@(? (stainopt "f") [ @(? (stainopt "f") [
//:fog //:fog
]) ])
attribute vec4 vvertex, vcolor; in vec4 vvertex, vcolor;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
uniform vec4 colorscale; uniform vec4 colorscale;
varying vec4 color; out vec4 color;
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
gl_Position = camprojmatrix * vvertex; gl_Position = camprojmatrix * vvertex;
@ -32,15 +32,15 @@ stainvariantshader = [
} }
]]) [ ]]) [
uniform sampler2D tex0; uniform sampler2D tex0;
varying vec4 color; in vec4 color;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
@(? (stainopt "t") [ @(? (stainopt "t") [
fragdata(1) vec4 gglow; layout(location = 1) out vec4 gglow;
]) ])
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

@ -5,9 +5,9 @@
//////////////////////////////////////////////// ////////////////////////////////////////////////
shader 0 "hdrreduce" [ shader 0 "hdrreduce" [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -15,18 +15,18 @@ shader 0 "hdrreduce" [
} }
] [ ] [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) 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;
} }
] ]
shader 0 "hdrreduce2w" [ shader 0 "hdrreduce2w" [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -34,18 +34,18 @@ shader 0 "hdrreduce2w" [
} }
] [ ] [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) 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);
} }
] ]
shader 0 "hdrreduce2" [ shader 0 "hdrreduce2" [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -53,24 +53,24 @@ shader 0 "hdrreduce2" [
} }
] [ ] [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) 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);
} }
] ]
lazyshader 0 msaaresolve [ lazyshader 0 msaaresolve [
attribute vec4 vvertex; in vec4 vvertex;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
} }
] [ ] [
uniform sampler2DMS tex0; uniform sampler2DMS tex0;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = texelFetch(tex0, ivec2(gl_FragCoord.xy), 0); fragcolor = texelFetch(tex0, ivec2(gl_FragCoord.xy), 0);
@ -78,7 +78,7 @@ lazyshader 0 msaaresolve [
] ]
lazyshader 0 msaaresolvedepth [ lazyshader 0 msaaresolvedepth [
attribute vec4 vvertex; in vec4 vvertex;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -88,7 +88,7 @@ lazyshader 0 msaaresolvedepth [
@(if $gdepthformat [result [ @(if $gdepthformat [result [
@(gdepthunpackparams) @(gdepthunpackparams)
uniform vec2 gdepthinvscale; uniform vec2 gdepthinvscale;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
]]) ]])
void main(void) void main(void)
{ {
@ -104,9 +104,9 @@ lazyshader 0 msaaresolvedepth [
] ]
lazyshader 0 msaareducew [ lazyshader 0 msaareducew [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 tap0, tap1; out vec2 tap0, tap1;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -115,8 +115,8 @@ lazyshader 0 msaareducew [
} }
] [ ] [
uniform sampler2DMS tex0; uniform sampler2DMS tex0;
varying vec2 tap0, tap1; in vec2 tap0, tap1;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = 0.5*(texelFetch(tex0, ivec2(tap0), 0) + texelFetch(tex0, ivec2(tap1), 0)); fragcolor = 0.5*(texelFetch(tex0, ivec2(tap0), 0) + texelFetch(tex0, ivec2(tap1), 0));
@ -124,9 +124,9 @@ lazyshader 0 msaareducew [
] ]
lazyshader 0 msaareduce [ lazyshader 0 msaareduce [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 tap0, tap1, tap2, tap3; out vec2 tap0, tap1, tap2, tap3;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -137,8 +137,8 @@ lazyshader 0 msaareduce [
} }
] [ ] [
uniform sampler2DMS tex0; uniform sampler2DMS tex0;
varying vec2 tap0, tap1, tap2, tap3; in vec2 tap0, tap1, tap2, tap3;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
fragcolor = 0.25*(texelFetch(tex0, ivec2(tap0), 0) + texelFetch(tex0, ivec2(tap1), 0) + fragcolor = 0.25*(texelFetch(tex0, ivec2(tap0), 0) + texelFetch(tex0, ivec2(tap1), 0) +
@ -166,9 +166,9 @@ hdrgammaencode = [
] ]
shader 0 "hdrluminance" [ shader 0 "hdrluminance" [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -177,11 +177,11 @@ shader 0 "hdrluminance" [
] [ ] [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
uniform vec2 hdrgamma; uniform vec2 hdrgamma;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) 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
@ -190,9 +190,9 @@ shader 0 "hdrluminance" [
] ]
shader 0 "hdrluminance2w" [ shader 0 "hdrluminance2w" [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -201,12 +201,12 @@ shader 0 "hdrluminance2w" [
] [ ] [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
uniform vec2 hdrgamma; uniform vec2 hdrgamma;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
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);
@ -216,9 +216,9 @@ shader 0 "hdrluminance2w" [
] ]
shader 0 "hdrluminance2" [ shader 0 "hdrluminance2" [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -227,12 +227,12 @@ shader 0 "hdrluminance2" [
] [ ] [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
uniform vec2 hdrgamma; uniform vec2 hdrgamma;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
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);
@ -242,7 +242,7 @@ shader 0 "hdrluminance2" [
] ]
shader 0 "hdraccum" [ shader 0 "hdraccum" [
attribute vec4 vvertex; in vec4 vvertex;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -250,43 +250,43 @@ shader 0 "hdraccum" [
] [ ] [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
uniform float accumscale; uniform float accumscale;
fragdata(0) 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);
} }
] ]
shader 0 "hdrbloom" [ shader 0 "hdrbloom" [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
@(? (>= $hwvtexunits 4) [ @(? (>= $hwvtexunits 4) [
uniform sampler2D tex2; uniform sampler2D tex2;
] [ ] [
attribute float vcolor; in float vcolor;
]) ])
uniform vec4 hdrparams; uniform vec4 hdrparams;
varying vec2 texcoord0; out vec2 texcoord0;
flat varying float lumscale, lumthreshold; flat out float lumscale, lumthreshold;
void main(void) void main(void)
{ {
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);
} }
] [ ] [
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
uniform vec2 hdrgamma; uniform vec2 hdrgamma;
varying vec2 texcoord0; in vec2 texcoord0;
flat varying float lumscale, lumthreshold; flat in float lumscale, lumthreshold;
fragdata(0) 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);
@ -297,23 +297,23 @@ shader 0 "hdrbloom" [
hdrtonemapvertexshader = [ hdrtonemapvertexshader = [
result [ result [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
@(screentexcoord 1) @(screentexcoord 1)
@(? (>= $hwvtexunits 4) [ @(? (>= $hwvtexunits 4) [
uniform sampler2D tex2; uniform sampler2D tex2;
] [ ] [
attribute float vcolor; in float vcolor;
]) ])
uniform vec4 hdrparams; uniform vec4 hdrparams;
varying vec2 texcoord0, texcoord1; out vec2 texcoord0, texcoord1;
flat varying float lumscale, lumsaturate; flat out float lumscale, lumsaturate;
void main(void) void main(void)
{ {
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;
} }
@ -333,16 +333,16 @@ hdrtonemapdefs = [
result [ result [
uniform vec4 hdrparams; uniform vec4 hdrparams;
uniform vec2 hdrgamma; uniform vec2 hdrgamma;
varying vec2 texcoord0, texcoord1; in vec2 texcoord0, texcoord1;
flat varying float lumscale, lumsaturate; flat in float lumscale, lumsaturate;
] ]
] ]
hdrtonemapshaders = [ hdrtonemapshaders = [
(? $arg1 lazyshader shader) 0 [hdrnop@arg1] [ (? $arg1 lazyshader shader) 0 [hdrnop@arg1] [
attribute vec4 vvertex; in vec4 vvertex;
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
gl_Position = vvertex; gl_Position = vvertex;
@ -351,11 +351,11 @@ hdrtonemapshaders = [
] [ ] [
@arg2 @arg2
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) 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;])
@ -366,11 +366,11 @@ hdrtonemapshaders = [
@arg2 @arg2
uniform sampler2DRect tex0, tex1; uniform sampler2DRect tex0, tex1;
@(hdrtonemapdefs) @(hdrtonemapdefs)
fragdata(0) 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)
@ -391,10 +391,10 @@ msaatonemapshaders = [
uniform sampler2DRect tex1; uniform sampler2DRect tex1;
uniform sampler2DMS tex0; uniform sampler2DMS tex0;
@(hdrtonemapdefs) @(hdrtonemapdefs)
fragdata(0) 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)
@ -409,10 +409,10 @@ msaatonemapshaders = [
uniform sampler2DRect tex1; uniform sampler2DRect tex1;
uniform sampler2DMS tex0; uniform sampler2DMS tex0;
@(hdrtonemapdefs) @(hdrtonemapdefs)
fragdata(0) 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++)
{ {
@ -437,11 +437,11 @@ msaasplitshaders = [
uniform sampler2DMS tex0; uniform sampler2DMS tex0;
@(hdrtonemapdefs) @(hdrtonemapdefs)
@(loopconcat i $msaasamples [result [ @(loopconcat i $msaasamples [result [
fragdata(@i) vec4 fragcolor@i; layout(location = @i) out vec4 fragcolor@i;
]]) ]])
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

@ -5,9 +5,9 @@
//////////////////////////////////////////////// ////////////////////////////////////////////////
lazyshader 0 "modelpreview" [ lazyshader 0 "modelpreview" [
attribute vec4 vvertex; in vec4 vvertex;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
varying vec2 texcoord0; out vec2 texcoord0;
void main(void) void main(void)
{ {
@ -22,8 +22,8 @@ lazyshader 0 "modelpreview" [
uniform vec3 sunlightdir; uniform vec3 sunlightdir;
uniform vec3 sunlightcolor; uniform vec3 sunlightcolor;
uniform float cutout; uniform float cutout;
varying vec2 texcoord0; in vec2 texcoord0;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {

View File

@ -6,7 +6,7 @@ volumetricvariantshader = [
maxsteps = $arg4 maxsteps = $arg4
spotlight = (>= $arg2 1) spotlight = (>= $arg2 1)
variantshader 0 $arg1 $arg2 (? (< $arg2 0) [ variantshader 0 $arg1 $arg2 (? (< $arg2 0) [
attribute vec4 vvertex; in vec4 vvertex;
uniform mat4 lightmatrix; uniform mat4 lightmatrix;
void main(void) void main(void)
{ {
@ -43,7 +43,7 @@ volumetricvariantshader = [
uniform float volminstep; uniform float volminstep;
uniform float voldistclamp; uniform float voldistclamp;
uniform float volprefilter; uniform float volprefilter;
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
@(if (volopt "p") [ @(if (volopt "p") [
? $spotlight [ ? $spotlight [
@ -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))
]] ]]
]) ])
@ -183,10 +183,10 @@ volumetricbilateralvariantshader = [
reduced = $arg3 reduced = $arg3
filterdir = $arg4 filterdir = $arg4
shader 0 $arg1 [ shader 0 $arg1 [
attribute vec4 vvertex; in vec4 vvertex;
@(if $reduced [result [ @(if $reduced [result [
@(screentexcoord 0) @(screentexcoord 0)
varying vec2 texcoord0; out vec2 texcoord0;
]]) ]])
void main(void) void main(void)
{ {
@ -197,18 +197,18 @@ volumetricbilateralvariantshader = [
@(gfetchdefs tex3) @(gfetchdefs tex3)
uniform sampler2DRect tex0; uniform sampler2DRect tex0;
uniform vec2 bilateralparams; uniform vec2 bilateralparams;
@(? $reduced [varying vec2 texcoord0;]) @(? $reduced [in vec2 texcoord0;])
fragdata(0) vec4 fragcolor; layout(location = 0) out vec4 fragcolor;
void main(void) void main(void)
{ {
#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

@ -58,25 +58,25 @@ worldvariantshader = [
srow = 1 srow = 1
] ]
variantshader $stype $arg1 $srow [ variantshader $stype $arg1 $srow [
attribute vec4 vvertex; in vec4 vvertex;
attribute vec3 vnormal; in vec3 vnormal;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
uniform vec2 texgenscroll; uniform vec2 texgenscroll;
varying vec3 nvec; out vec3 nvec;
@(ginterpvert (|| $msaalight [&& $msaasamples [! (wtopt "a")]])) @(ginterpvert (|| $msaalight [&& $msaasamples [! (wtopt "a")]]))
@(if (wtopt "T") [result [ @(if (wtopt "T") [result [
uniform vec2 texgenscale; uniform vec2 texgenscale;
varying vec2 texcoordx, texcoordy, texcoordz; out vec2 texcoordx, texcoordy, texcoordz;
@(? (wtopt "d") [uniform vec2 detailscale;]) @(? (wtopt "d") [uniform vec2 detailscale;])
]] [result [ ]] [result [
varying vec2 texcoord0; out vec2 texcoord0;
]]) ]])
@(? (wtopt "r") [uniform vec3 camera; varying vec3 camvec;]) @(? (wtopt "r") [uniform vec3 camera; out vec3 camvec;])
@(? (wtopt "G") [uniform float millis; flat varying float pulse;]) @(? (wtopt "G") [uniform float millis; flat out float pulse;])
@(? (wtopt "b") [ @(? (wtopt "b") [
uniform vec4 blendmapparams; uniform vec4 blendmapparams;
varying vec2 texcoord1; out vec2 texcoord1;
]) ])
void main(void) void main(void)
@ -110,21 +110,21 @@ worldvariantshader = [
uniform vec4 colorparams; uniform vec4 colorparams;
uniform sampler2D diffusemap; uniform sampler2D diffusemap;
@(? (|| $msaalight [&& $msaasamples [! (wtopt "a")]]) [uniform float hashid;]) @(? (|| $msaalight [&& $msaasamples [! (wtopt "a")]]) [uniform float hashid;])
varying vec3 nvec; in vec3 nvec;
@(ginterpfrag (|| $msaalight [&& $msaasamples [! (wtopt "a")]])) @(ginterpfrag (|| $msaalight [&& $msaasamples [! (wtopt "a")]]))
@(if (wtopt "T") [result [ @(if (wtopt "T") [result [
varying vec2 texcoordx, texcoordy, texcoordz; in vec2 texcoordx, texcoordy, texcoordz;
@(? (wtopt "d") [uniform sampler2D detaildiffusemap;]) @(? (wtopt "d") [uniform sampler2D detaildiffusemap;])
]] [result [ ]] [result [
varying vec2 texcoord0; in vec2 texcoord0;
]]) ]])
@(? (wtopt "g") [uniform sampler2D glowmap;]) @(? (wtopt "g") [uniform sampler2D glowmap;])
@(? (wtopt "G") [flat varying float pulse;]) @(? (wtopt "G") [flat in float pulse;])
@(? (wtopt "r") [uniform samplerCube envmap; varying vec3 camvec;]) @(? (wtopt "r") [uniform samplerCube envmap; in vec3 camvec;])
@(? (wtopt "b") [ @(? (wtopt "b") [
uniform float blendlayer; uniform float blendlayer;
uniform sampler2D blendmap; uniform sampler2D blendmap;
varying vec2 texcoord1; in vec2 texcoord1;
]) ])
void main(void) void main(void)
@ -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;
@ -291,30 +291,30 @@ bumpvariantshader = [
srow = 1 srow = 1
] ]
variantshader $stype $arg1 $srow [ variantshader $stype $arg1 $srow [
attribute vec4 vvertex, vtangent; in vec4 vvertex, vtangent;
attribute vec3 vnormal; in vec3 vnormal;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 camprojmatrix; uniform mat4 camprojmatrix;
uniform vec2 texgenscroll; uniform vec2 texgenscroll;
@(ginterpvert (|| $msaalight [&& $msaasamples [! (btopt "a")]] [btopt "A"])) @(ginterpvert (|| $msaalight [&& $msaasamples [! (btopt "a")]] [btopt "A"]))
@(if (btopt "T") [result [ @(if (btopt "T") [result [
uniform vec2 texgenscale; uniform vec2 texgenscale;
varying vec2 texcoordx, texcoordy, texcoordz; out vec2 texcoordx, texcoordy, texcoordz;
varying vec3 normal; out vec3 normal;
varying vec3 tangentx, tangenty, tangentz; out vec3 tangentx, tangenty, tangentz;
@(? (btopt "d") [uniform vec2 detailscale;]) @(? (btopt "d") [uniform vec2 detailscale;])
]] [result [ ]] [result [
varying vec2 texcoord0; out vec2 texcoord0;
varying mat3 world; out mat3 world;
]]) ]])
@(? (|| (btopt "p") (btopt "r") (btopt "T")) [ @(? (|| (btopt "p") (btopt "r") (btopt "T")) [
uniform vec3 camera; uniform vec3 camera;
varying vec3 camvec; out vec3 camvec;
]) ])
@(? (btopt "G") [uniform float millis; flat varying float pulse;]) @(? (btopt "G") [uniform float millis; flat out float pulse;])
@(? (btopt "b") [ @(? (btopt "b") [
uniform vec4 blendmapparams; uniform vec4 blendmapparams;
varying vec2 texcoord1; out vec2 texcoord1;
]) ])
void main(void) void main(void)
@ -361,23 +361,23 @@ bumpvariantshader = [
uniform vec4 colorparams; uniform vec4 colorparams;
uniform sampler2D diffusemap, normalmap; uniform sampler2D diffusemap, normalmap;
@(? (|| $msaalight [&& $msaasamples [! (btopt "a")]]) [uniform float hashid;]) @(? (|| $msaalight [&& $msaasamples [! (btopt "a")]]) [uniform float hashid;])
varying mat3 world; in mat3 world;
@(ginterpfrag (|| $msaalight [&& $msaasamples [! (btopt "a")]] [btopt "A"])) @(ginterpfrag (|| $msaalight [&& $msaasamples [! (btopt "a")]] [btopt "A"]))
@(if (btopt "T") [result [ @(if (btopt "T") [result [
varying vec2 texcoordx, texcoordy, texcoordz; in vec2 texcoordx, texcoordy, texcoordz;
varying vec3 normal, tangentx, tangenty, tangentz; in vec3 normal, tangentx, tangenty, tangentz;
@(? (btopt "d") [uniform sampler2D detaildiffusemap, detailnormalmap;]) @(? (btopt "d") [uniform sampler2D detaildiffusemap, detailnormalmap;])
]] [result [ ]] [result [
varying vec2 texcoord0; in vec2 texcoord0;
]]) ]])
@(? (|| (btopt "p") (btopt "r") (btopt "T")) [varying vec3 camvec;]) @(? (|| (btopt "p") (btopt "r") (btopt "T")) [in vec3 camvec;])
@(? (btopt "g") [uniform sampler2D glowmap;]) @(? (btopt "g") [uniform sampler2D glowmap;])
@(? (btopt "G") [flat varying float pulse;]) @(? (btopt "G") [flat in float pulse;])
@(? (btopt "r") [uniform samplerCube envmap;]) @(? (btopt "r") [uniform samplerCube envmap;])
@(? (btopt "b") [ @(? (btopt "b") [
uniform float blendlayer; uniform float blendlayer;
uniform sampler2D blendmap; uniform sampler2D blendmap;
varying vec2 texcoord1; in vec2 texcoord1;
]) ])
void main(void) void main(void)
@ -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;
@ -574,7 +574,7 @@ bumpshader "triplanardetailbumpspecparallaxworld" "Tdps"
bumpshader "triplanardetailbumpspecmapparallaxworld" "TdpsS" bumpshader "triplanardetailbumpspecmapparallaxworld" "TdpsS"
shader 0 shadowmapworld [ shader 0 shadowmapworld [
attribute vec4 vvertex; in vec4 vvertex;
uniform mat4 shadowmatrix; uniform mat4 shadowmatrix;
void main(void) void main(void)
{ {
@ -589,18 +589,18 @@ shader 0 shadowmapworld [
defershader 1 "rsmworld" [ defershader 1 "rsmworld" [
loop i 2 [ loop i 2 [
variantshader 1 "rsmworld" (- $i 1) [ variantshader 1 "rsmworld" (- $i 1) [
attribute vec4 vvertex; in vec4 vvertex;
attribute vec3 vnormal; in vec3 vnormal;
attribute vec2 vtexcoord0; in vec2 vtexcoord0;
uniform mat4 rsmmatrix; uniform mat4 rsmmatrix;
uniform vec2 texgenscroll; uniform vec2 texgenscroll;
uniform vec4 colorparams; uniform vec4 colorparams;
uniform vec3 rsmdir; uniform vec3 rsmdir;
varying vec4 normal; out vec4 normal;
varying vec2 texcoord0; out vec2 texcoord0;
@(? (= $i 1) [ @(? (= $i 1) [
uniform vec4 blendmapparams; uniform vec4 blendmapparams;
varying vec2 texcoord1; out vec2 texcoord1;
]) ])
void main(void) void main(void)
{ {
@ -614,18 +614,18 @@ defershader 1 "rsmworld" [
] [ ] [
uniform vec4 colorparams; uniform vec4 colorparams;
uniform sampler2D diffusemap; uniform sampler2D diffusemap;
varying vec4 normal; in vec4 normal;
varying vec2 texcoord0; in vec2 texcoord0;
@(? (= $i 1) [ @(? (= $i 1) [
uniform float blendlayer; uniform float blendlayer;
uniform sampler2D blendmap; uniform sampler2D blendmap;
varying vec2 texcoord1; in vec2 texcoord1;
]) ])
fragdata(0) vec4 gcolor; layout(location = 0) out vec4 gcolor;
fragdata(1) 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

@ -8,7 +8,6 @@ VARF(tqaamovemask, 0, 1, 1, cleanupaa());
VARP(tqaaquincunx, 0, 1, 1); VARP(tqaaquincunx, 0, 1, 1);
FVAR(tqaacolorweightscale, 0, 0.25f, 1e3f); FVAR(tqaacolorweightscale, 0, 0.25f, 1e3f);
FVAR(tqaacolorweightbias, 0, 0.01f, 1); FVAR(tqaacolorweightbias, 0, 0.01f, 1);
VAR(tqaaresolvegather, 1, 0, 0);
int tqaaframe = 0; int tqaaframe = 0;
GLuint tqaatex[2] = { 0, 0 }, tqaafbo[2] = { 0, 0 }; GLuint tqaatex[2] = { 0, 0 }, tqaafbo[2] = { 0, 0 };
@ -202,7 +201,6 @@ void loadsmaashaders(bool split = false)
string opts; string opts;
int optslen = 0; int optslen = 0;
if(!hasTRG) opts[optslen++] = 'a';
if((smaadepthmask && (!tqaa || msaalight)) || (smaastencil && ghasstencil > (msaasamples ? 1 : 0))) opts[optslen++] = 'd'; if((smaadepthmask && (!tqaa || msaalight)) || (smaastencil && ghasstencil > (msaasamples ? 1 : 0))) opts[optslen++] = 'd';
if(split) opts[optslen++] = 's'; if(split) opts[optslen++] = 's';
if(tqaa || smaagreenluma || intel_texalpha_bug) opts[optslen++] = 'g'; if(tqaa || smaagreenluma || intel_texalpha_bug) opts[optslen++] = 'g';
@ -505,8 +503,8 @@ void setupsmaa(int w, int h)
if(!smaasearchtex) glGenTextures(1, &smaasearchtex); if(!smaasearchtex) glGenTextures(1, &smaasearchtex);
gensmaasearchdata(); gensmaasearchdata();
gensmaaareadata(); gensmaaareadata();
createtexture(smaaareatex, SMAA_AREATEX_WIDTH, SMAA_AREATEX_HEIGHT, smaaareadata, 3, 1, hasTRG ? GL_RG8 : GL_LUMINANCE8_ALPHA8, GL_TEXTURE_RECTANGLE, 0, 0, 0, false); createtexture(smaaareatex, SMAA_AREATEX_WIDTH, SMAA_AREATEX_HEIGHT, smaaareadata, 3, 1, GL_RG8, GL_TEXTURE_RECTANGLE, 0, 0, 0, false);
createtexture(smaasearchtex, SMAA_SEARCHTEX_WIDTH, SMAA_SEARCHTEX_HEIGHT, smaasearchdata, 3, 0, hasTRG ? GL_R8 : GL_LUMINANCE8, GL_TEXTURE_RECTANGLE, 0, 0, 0, false); createtexture(smaasearchtex, SMAA_SEARCHTEX_WIDTH, SMAA_SEARCHTEX_HEIGHT, smaasearchdata, 3, 0, GL_R8, GL_TEXTURE_RECTANGLE, 0, 0, 0, false);
bool split = multisampledaa(); bool split = multisampledaa();
smaasubsampleorder = split ? (msaapositions[0].x < 0.5f ? 1 : 0) : -1; smaasubsampleorder = split ? (msaapositions[0].x < 0.5f ? 1 : 0) : -1;
smaat2x = tqaa ? 1 : 0; smaat2x = tqaa ? 1 : 0;
@ -521,7 +519,7 @@ void setupsmaa(int w, int h)
switch(i) switch(i)
{ {
case 0: format = tqaa || (!smaagreenluma && !intel_texalpha_bug && !smaacoloredge) ? GL_RGBA8 : GL_RGB; break; case 0: format = tqaa || (!smaagreenluma && !intel_texalpha_bug && !smaacoloredge) ? GL_RGBA8 : GL_RGB; break;
case 1: format = hasTRG ? GL_RG8 : GL_RGBA8; break; case 1: format = GL_RG8; break;
case 2: case 3: format = GL_RGBA8; break; case 2: case 3: format = GL_RGBA8; break;
} }
createtexture(smaatex[i], w, h, NULL, 3, 1, format, GL_TEXTURE_RECTANGLE); createtexture(smaatex[i], w, h, NULL, 3, 1, format, GL_TEXTURE_RECTANGLE);

View File

@ -590,7 +590,7 @@ struct BlendBrush
{ {
loopj(w) *dst++ = 255 - *src++; loopj(w) *dst++ = 255 - *src++;
} }
createtexture(tex, w, h, buf, 3, 1, hasTRG ? GL_R8 : GL_LUMINANCE8); createtexture(tex, w, h, buf, 3, 1, GL_R8);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
GLfloat border[4] = { 0, 0, 0, 0 }; GLfloat border[4] = { 0, 0, 0, 0 };
@ -653,8 +653,8 @@ struct BlendTexture
size = sz; size = sz;
if(data) delete[] data; if(data) delete[] data;
data = new uchar[size*size]; data = new uchar[size*size];
format = hasTRG ? GL_RED : GL_LUMINANCE; format = GL_RED;
createtexture(tex, size, size, NULL, 3, 1, hasTRG ? GL_R8 : GL_LUMINANCE8); createtexture(tex, size, size, NULL, 3, 1, GL_R8);
valid = false; valid = false;
return true; return true;
} }

View File

@ -120,8 +120,7 @@ static inline bool pvsoccluded(const ivec &bborigin, int size)
} }
// rendergl // rendergl
extern bool hasVAO, hasTR, hasTSW, hasPBO, hasFBO, hasAFBO, hasDS, hasTF, hasCBF, hasS3TC, hasFXT1, hasLATC, hasRGTC, hasAF, hasFBB, hasFBMS, hasTMS, hasMSS, hasFBMSBS, hasUBO, hasMBR, hasDB2, hasDBB, hasTG, hasTQ, hasPF, hasTRG, hasTI, hasHFV, hasHFP, hasDBT, hasDC, hasDBGO, hasEGPU4, hasGPU4, hasGPU5, hasBFE, hasEAL, hasCR, hasOQ2, hasES3, hasCB, hasCI; extern bool hasS3TC, hasFXT1, hasLATC, hasAF, hasFBMSBS, hasDBT, hasDBGO, hasES3, hasCI;
extern int glversion, glslversion, glcompat;
extern int maxdrawbufs, maxdualdrawbufs; extern int maxdrawbufs, maxdualdrawbufs;
enum { DRAWTEX_NONE = 0, DRAWTEX_ENVMAP, DRAWTEX_MINIMAP, DRAWTEX_MODELPREVIEW }; enum { DRAWTEX_NONE = 0, DRAWTEX_ENVMAP, DRAWTEX_MINIMAP, DRAWTEX_MODELPREVIEW };

View File

@ -556,20 +556,10 @@ void setupscreen()
SDL_SetWindowMinimumSize(screen, SCR_MINW, SCR_MINH); SDL_SetWindowMinimumSize(screen, SCR_MINW, SCR_MINH);
SDL_SetWindowMaximumSize(screen, SCR_MAXW, SCR_MAXH); SDL_SetWindowMaximumSize(screen, SCR_MAXW, SCR_MAXH);
#ifdef __APPLE__ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
static const int glversions[] = { 32, 20 }; SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
#else SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
static const int glversions[] = { 40, 33, 32, 31, 30, 20 }; glcontext = SDL_GL_CreateContext(screen);
#endif
loopi(sizeof(glversions)/sizeof(glversions[0]))
{
glcompat = glversions[i] <= 30 ? 1 : 0;
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, glversions[i] / 10);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, glversions[i] % 10);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, glversions[i] >= 32 ? SDL_GL_CONTEXT_PROFILE_CORE : 0);
glcontext = SDL_GL_CreateContext(screen);
if(glcontext) break;
}
if(!glcontext) fatal("failed to create OpenGL context: %s", SDL_GetError()); if(!glcontext) fatal("failed to create OpenGL context: %s", SDL_GetError());
SDL_GetWindowSize(screen, &screenw, &screenh); SDL_GetWindowSize(screen, &screenw, &screenh);

View File

@ -1017,7 +1017,7 @@ namespace recorder
if(usefbo) if(usefbo)
{ {
uint tw = screenw, th = screenh; uint tw = screenw, th = screenh;
if(hasFBB && movieaccelblit) { tw = max(tw/2, m.w); th = max(th/2, m.h); } if(movieaccelblit) { tw = max(tw/2, m.w); th = max(th/2, m.h); }
if(tw != scalew || th != scaleh) if(tw != scalew || th != scaleh)
{ {
if(!scalefb) glGenFramebuffers_(1, &scalefb); if(!scalefb) glGenFramebuffers_(1, &scalefb);

View File

@ -2,14 +2,12 @@
#include "engine.h" #include "engine.h"
bool hasVAO = false, hasTR = false, hasTSW = false, hasPBO = false, hasFBO = false, hasAFBO = false, hasDS = false, hasTF = false, hasCBF = false, hasS3TC = false, hasFXT1 = false, hasLATC = false, hasRGTC = false, hasAF = false, hasFBB = false, hasFBMS = false, hasTMS = false, hasMSS = false, hasFBMSBS = false, hasUBO = false, hasMBR = false, hasDB2 = false, hasDBB = false, hasTG = false, hasTQ = false, hasPF = false, hasTRG = false, hasTI = false, hasHFV = false, hasHFP = false, hasDBT = false, hasDC = false, hasDBGO = false, hasEGPU4 = false, hasGPU4 = false, hasGPU5 = false, hasBFE = false, hasEAL = false, hasCR = false, hasOQ2 = false, hasES3 = false, hasCB = false, hasCI = false; bool hasS3TC = false, hasFXT1 = false, hasLATC = false, hasAF = false, hasFBMSBS = false, hasDBT = false, hasDBGO = false, hasES3 = false, hasCI = false;
bool mesa = false, intel = false, amd = false, nvidia = false; bool mesa = false, intel = false, amd = false, nvidia = false;
int hasstencil = 0; int hasstencil = 0;
VAR(glversion, 1, 0, 0); VAR(glversion, 1, 0, 0);
VAR(glslversion, 1, 0, 0);
VAR(glcompat, 1, 0, 0);
// GL_EXT_timer_query // GL_EXT_timer_query
PFNGLGETQUERYOBJECTI64VEXTPROC glGetQueryObjecti64v_ = NULL; PFNGLGETQUERYOBJECTI64VEXTPROC glGetQueryObjecti64v_ = NULL;
@ -268,13 +266,8 @@ void glerror(const char *file, int line, GLenum error)
printf("GL error: %s:%d: %s (%x)\n", file, line, desc, error); printf("GL error: %s:%d: %s (%x)\n", file, line, desc, error);
} }
VAR(amd_pf_bug, 0, 0, 1);
VAR(amd_eal_bug, 0, 0, 1);
VAR(mesa_texrectoffset_bug, 0, 0, 1);
VAR(intel_texalpha_bug, 0, 0, 1); VAR(intel_texalpha_bug, 0, 0, 1);
VAR(intel_mapbufferrange_bug, 0, 0, 1);
VAR(mesa_swap_bug, 0, 0, 1); VAR(mesa_swap_bug, 0, 0, 1);
VAR(useubo, 1, 0, 0);
VAR(usetexgather, 1, 0, 0); VAR(usetexgather, 1, 0, 0);
VAR(usetexcompress, 1, 0, 0); VAR(usetexcompress, 1, 0, 0);
VAR(maxdrawbufs, 1, 0, 0); VAR(maxdrawbufs, 1, 0, 0);
@ -308,27 +301,12 @@ hashset<const char *> glexts;
void parseglexts() void parseglexts()
{ {
if(glversion >= 300) GLint numexts = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &numexts);
loopi(numexts)
{ {
GLint numexts = 0; const char *ext = (const char *)glGetStringi_(GL_EXTENSIONS, i);
glGetIntegerv(GL_NUM_EXTENSIONS, &numexts); glexts.add(newstring(ext));
loopi(numexts)
{
const char *ext = (const char *)glGetStringi_(GL_EXTENSIONS, i);
glexts.add(newstring(ext));
}
}
else
{
const char *exts = (const char *)glGetString(GL_EXTENSIONS);
for(;;)
{
while(*exts == ' ') exts++;
if(!*exts) break;
const char *ext = exts;
while(*exts && *exts != ' ') exts++;
if(exts > ext) glexts.add(newstring(ext, size_t(exts-ext)));
}
} }
} }
@ -375,11 +353,6 @@ void gl_checkextensions()
conoutf(CON_INIT, "Renderer: %s (%s)", renderer, vendor); conoutf(CON_INIT, "Renderer: %s (%s)", renderer, vendor);
conoutf(CON_INIT, "Driver: %s", version); conoutf(CON_INIT, "Driver: %s", version);
#ifdef __APPLE__
// extern int mac_osversion();
// int osversion = mac_osversion(); /* 0x0A0600 = 10.6, assumed minimum */
#endif
if(strstr(renderer, "Mesa") || strstr(version, "Mesa")) if(strstr(renderer, "Mesa") || strstr(version, "Mesa"))
{ {
mesa = true; mesa = true;
@ -396,7 +369,7 @@ void gl_checkextensions()
if(sscanf(version, " %u.%u", &glmajorversion, &glminorversion) != 2) glversion = 100; if(sscanf(version, " %u.%u", &glmajorversion, &glminorversion) != 2) glversion = 100;
else glversion = glmajorversion*100 + glminorversion*10; else glversion = glmajorversion*100 + glminorversion*10;
if(glversion < 200) fatal("OpenGL 2.0 or greater is required!"); if(glversion < 400) fatal("OpenGL 4.0 or greater is required!");
#ifdef WIN32 #ifdef WIN32
glActiveTexture_ = (PFNGLACTIVETEXTUREPROC) getprocaddress("glActiveTexture"); glActiveTexture_ = (PFNGLACTIVETEXTUREPROC) getprocaddress("glActiveTexture");
@ -516,19 +489,11 @@ void gl_checkextensions()
glDrawBuffers_ = (PFNGLDRAWBUFFERSPROC) getprocaddress("glDrawBuffers"); glDrawBuffers_ = (PFNGLDRAWBUFFERSPROC) getprocaddress("glDrawBuffers");
#endif #endif
if(glversion >= 300) glGetStringi_ = (PFNGLGETSTRINGIPROC) getprocaddress("glGetStringi");
{
glGetStringi_ = (PFNGLGETSTRINGIPROC) getprocaddress("glGetStringi");
}
const char *glslstr = (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION); const char *glslstr = (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION);
conoutf(CON_INIT, "GLSL: %s", glslstr ? glslstr : "unknown"); conoutf(CON_INIT, "GLSL: %s", glslstr ? glslstr : "unknown");
uint glslmajorversion, glslminorversion;
if(glslstr && sscanf(glslstr, " %u.%u", &glslmajorversion, &glslminorversion) == 2) glslversion = glslmajorversion*100 + glslminorversion;
if(glslversion < 120) fatal("GLSL 1.20 or greater is required!");
parseglexts(); parseglexts();
GLint texsize = 0, texunits = 0, vtexunits = 0, cubetexsize = 0, drawbufs = 0; GLint texsize = 0, texunits = 0, vtexunits = 0, cubetexsize = 0, drawbufs = 0;
@ -550,292 +515,82 @@ void gl_checkextensions()
maxdrawbufs = drawbufs; maxdrawbufs = drawbufs;
if(maxdrawbufs < 4) fatal("Hardware does not support at least 4 draw buffers."); if(maxdrawbufs < 4) fatal("Hardware does not support at least 4 draw buffers.");
if(glversion >= 210 || hasext("GL_ARB_pixel_buffer_object") || hasext("GL_EXT_pixel_buffer_object")) glBindVertexArray_ = (PFNGLBINDVERTEXARRAYPROC) getprocaddress("glBindVertexArray");
{ glDeleteVertexArrays_ = (PFNGLDELETEVERTEXARRAYSPROC)getprocaddress("glDeleteVertexArrays");
hasPBO = true; glGenVertexArrays_ = (PFNGLGENVERTEXARRAYSPROC) getprocaddress("glGenVertexArrays");
if(glversion < 210 && dbgexts) conoutf(CON_INIT, "Using GL_ARB_pixel_buffer_object extension."); glIsVertexArray_ = (PFNGLISVERTEXARRAYPROC) getprocaddress("glIsVertexArray");
}
else fatal("Pixel buffer object support is required!");
if(glversion >= 300 || hasext("GL_ARB_vertex_array_object")) glBindFragDataLocation_ = (PFNGLBINDFRAGDATALOCATIONPROC)getprocaddress("glBindFragDataLocation");
{ glUniform1ui_ = (PFNGLUNIFORM1UIPROC) getprocaddress("glUniform1ui");
glBindVertexArray_ = (PFNGLBINDVERTEXARRAYPROC) getprocaddress("glBindVertexArray"); glUniform2ui_ = (PFNGLUNIFORM2UIPROC) getprocaddress("glUniform2ui");
glDeleteVertexArrays_ = (PFNGLDELETEVERTEXARRAYSPROC)getprocaddress("glDeleteVertexArrays"); glUniform3ui_ = (PFNGLUNIFORM3UIPROC) getprocaddress("glUniform3ui");
glGenVertexArrays_ = (PFNGLGENVERTEXARRAYSPROC) getprocaddress("glGenVertexArrays"); glUniform4ui_ = (PFNGLUNIFORM4UIPROC) getprocaddress("glUniform4ui");
glIsVertexArray_ = (PFNGLISVERTEXARRAYPROC) getprocaddress("glIsVertexArray"); glUniform1uiv_ = (PFNGLUNIFORM1UIVPROC) getprocaddress("glUniform1uiv");
hasVAO = true; glUniform2uiv_ = (PFNGLUNIFORM2UIVPROC) getprocaddress("glUniform2uiv");
if(glversion < 300 && dbgexts) conoutf(CON_INIT, "Using GL_ARB_vertex_array_object extension."); glUniform3uiv_ = (PFNGLUNIFORM3UIVPROC) getprocaddress("glUniform3uiv");
} glUniform4uiv_ = (PFNGLUNIFORM4UIVPROC) getprocaddress("glUniform4uiv");
else if(hasext("GL_APPLE_vertex_array_object")) glClearBufferiv_ = (PFNGLCLEARBUFFERIVPROC) getprocaddress("glClearBufferiv");
{ glClearBufferuiv_ = (PFNGLCLEARBUFFERUIVPROC) getprocaddress("glClearBufferuiv");
glBindVertexArray_ = (PFNGLBINDVERTEXARRAYPROC) getprocaddress("glBindVertexArrayAPPLE"); glClearBufferfv_ = (PFNGLCLEARBUFFERFVPROC) getprocaddress("glClearBufferfv");
glDeleteVertexArrays_ = (PFNGLDELETEVERTEXARRAYSPROC)getprocaddress("glDeleteVertexArraysAPPLE"); glClearBufferfi_ = (PFNGLCLEARBUFFERFIPROC) getprocaddress("glClearBufferfi");
glGenVertexArrays_ = (PFNGLGENVERTEXARRAYSPROC) getprocaddress("glGenVertexArraysAPPLE");
glIsVertexArray_ = (PFNGLISVERTEXARRAYPROC) getprocaddress("glIsVertexArrayAPPLE");
hasVAO = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_APPLE_vertex_array_object extension.");
}
if(glversion >= 300) glClampColor_ = (PFNGLCLAMPCOLORPROC)getprocaddress("glClampColor");
{
hasTF = hasTRG = hasRGTC = hasPF = hasHFV = hasHFP = true;
glBindFragDataLocation_ = (PFNGLBINDFRAGDATALOCATIONPROC)getprocaddress("glBindFragDataLocation"); glColorMaski_ = (PFNGLCOLORMASKIPROC)getprocaddress("glColorMaski");
glUniform1ui_ = (PFNGLUNIFORM1UIPROC) getprocaddress("glUniform1ui"); glEnablei_ = (PFNGLENABLEIPROC) getprocaddress("glEnablei");
glUniform2ui_ = (PFNGLUNIFORM2UIPROC) getprocaddress("glUniform2ui"); glDisablei_ = (PFNGLENABLEIPROC) getprocaddress("glDisablei");
glUniform3ui_ = (PFNGLUNIFORM3UIPROC) getprocaddress("glUniform3ui");
glUniform4ui_ = (PFNGLUNIFORM4UIPROC) getprocaddress("glUniform4ui");
glUniform1uiv_ = (PFNGLUNIFORM1UIVPROC) getprocaddress("glUniform1uiv");
glUniform2uiv_ = (PFNGLUNIFORM2UIVPROC) getprocaddress("glUniform2uiv");
glUniform3uiv_ = (PFNGLUNIFORM3UIVPROC) getprocaddress("glUniform3uiv");
glUniform4uiv_ = (PFNGLUNIFORM4UIVPROC) getprocaddress("glUniform4uiv");
glClearBufferiv_ = (PFNGLCLEARBUFFERIVPROC) getprocaddress("glClearBufferiv");
glClearBufferuiv_ = (PFNGLCLEARBUFFERUIVPROC) getprocaddress("glClearBufferuiv");
glClearBufferfv_ = (PFNGLCLEARBUFFERFVPROC) getprocaddress("glClearBufferfv");
glClearBufferfi_ = (PFNGLCLEARBUFFERFIPROC) getprocaddress("glClearBufferfi");
hasGPU4 = true;
if(hasext("GL_EXT_gpu_shader4")) glBeginConditionalRender_ = (PFNGLBEGINCONDITIONALRENDERPROC)getprocaddress("glBeginConditionalRender");
{ glEndConditionalRender_ = (PFNGLENDCONDITIONALRENDERPROC) getprocaddress("glEndConditionalRender");
hasEGPU4 = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_EXT_gpu_shader4 extension.");
}
glClampColor_ = (PFNGLCLAMPCOLORPROC)getprocaddress("glClampColor"); glTexParameterIiv_ = (PFNGLTEXPARAMETERIIVPROC) getprocaddress("glTexParameterIiv");
hasCBF = true; glTexParameterIuiv_ = (PFNGLTEXPARAMETERIUIVPROC) getprocaddress("glTexParameterIuiv");
glGetTexParameterIiv_ = (PFNGLGETTEXPARAMETERIIVPROC) getprocaddress("glGetTexParameterIiv");
glGetTexParameterIuiv_ = (PFNGLGETTEXPARAMETERIUIVPROC)getprocaddress("glGetTexParameterIuiv");
glColorMaski_ = (PFNGLCOLORMASKIPROC)getprocaddress("glColorMaski"); glBindRenderbuffer_ = (PFNGLBINDRENDERBUFFERPROC) getprocaddress("glBindRenderbuffer");
glEnablei_ = (PFNGLENABLEIPROC) getprocaddress("glEnablei"); glDeleteRenderbuffers_ = (PFNGLDELETERENDERBUFFERSPROC) getprocaddress("glDeleteRenderbuffers");
glDisablei_ = (PFNGLENABLEIPROC) getprocaddress("glDisablei"); glGenRenderbuffers_ = (PFNGLGENFRAMEBUFFERSPROC) getprocaddress("glGenRenderbuffers");
hasDB2 = true; glRenderbufferStorage_ = (PFNGLRENDERBUFFERSTORAGEPROC) getprocaddress("glRenderbufferStorage");
glGetRenderbufferParameteriv_ = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) getprocaddress("glGetRenderbufferParameteriv");
glCheckFramebufferStatus_ = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) getprocaddress("glCheckFramebufferStatus");
glBindFramebuffer_ = (PFNGLBINDFRAMEBUFFERPROC) getprocaddress("glBindFramebuffer");
glDeleteFramebuffers_ = (PFNGLDELETEFRAMEBUFFERSPROC) getprocaddress("glDeleteFramebuffers");
glGenFramebuffers_ = (PFNGLGENFRAMEBUFFERSPROC) getprocaddress("glGenFramebuffers");
glFramebufferTexture1D_ = (PFNGLFRAMEBUFFERTEXTURE1DPROC) getprocaddress("glFramebufferTexture1D");
glFramebufferTexture2D_ = (PFNGLFRAMEBUFFERTEXTURE2DPROC) getprocaddress("glFramebufferTexture2D");
glFramebufferTexture3D_ = (PFNGLFRAMEBUFFERTEXTURE3DPROC) getprocaddress("glFramebufferTexture3D");
glFramebufferRenderbuffer_ = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) getprocaddress("glFramebufferRenderbuffer");
glGenerateMipmap_ = (PFNGLGENERATEMIPMAPPROC) getprocaddress("glGenerateMipmap");
glBlitFramebuffer_ = (PFNGLBLITFRAMEBUFFERPROC) getprocaddress("glBlitFramebuffer");
glRenderbufferStorageMultisample_ = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)getprocaddress("glRenderbufferStorageMultisample");
glBeginConditionalRender_ = (PFNGLBEGINCONDITIONALRENDERPROC)getprocaddress("glBeginConditionalRender"); glMapBufferRange_ = (PFNGLMAPBUFFERRANGEPROC) getprocaddress("glMapBufferRange");
glEndConditionalRender_ = (PFNGLENDCONDITIONALRENDERPROC) getprocaddress("glEndConditionalRender"); glFlushMappedBufferRange_ = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)getprocaddress("glFlushMappedBufferRange");
hasCR = true;
glTexParameterIiv_ = (PFNGLTEXPARAMETERIIVPROC) getprocaddress("glTexParameterIiv"); glGetUniformIndices_ = (PFNGLGETUNIFORMINDICESPROC) getprocaddress("glGetUniformIndices");
glTexParameterIuiv_ = (PFNGLTEXPARAMETERIUIVPROC) getprocaddress("glTexParameterIuiv"); glGetActiveUniformsiv_ = (PFNGLGETACTIVEUNIFORMSIVPROC) getprocaddress("glGetActiveUniformsiv");
glGetTexParameterIiv_ = (PFNGLGETTEXPARAMETERIIVPROC) getprocaddress("glGetTexParameterIiv"); glGetUniformBlockIndex_ = (PFNGLGETUNIFORMBLOCKINDEXPROC) getprocaddress("glGetUniformBlockIndex");
glGetTexParameterIuiv_ = (PFNGLGETTEXPARAMETERIUIVPROC)getprocaddress("glGetTexParameterIuiv"); glGetActiveUniformBlockiv_ = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)getprocaddress("glGetActiveUniformBlockiv");
hasTI = true; glUniformBlockBinding_ = (PFNGLUNIFORMBLOCKBINDINGPROC) getprocaddress("glUniformBlockBinding");
} glBindBufferBase_ = (PFNGLBINDBUFFERBASEPROC) getprocaddress("glBindBufferBase");
else glBindBufferRange_ = (PFNGLBINDBUFFERRANGEPROC) getprocaddress("glBindBufferRange");
{
if(hasext("GL_ARB_texture_float"))
{
hasTF = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_ARB_texture_float extension.");
}
if(hasext("GL_ARB_texture_rg"))
{
hasTRG = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_ARB_texture_rg extension.");
}
if(hasext("GL_ARB_texture_compression_rgtc") || hasext("GL_EXT_texture_compression_rgtc"))
{
hasRGTC = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_ARB_texture_compression_rgtc extension.");
}
if(hasext("GL_EXT_packed_float"))
{
hasPF = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_EXT_packed_float extension.");
}
if(hasext("GL_EXT_gpu_shader4"))
{
glBindFragDataLocation_ = (PFNGLBINDFRAGDATALOCATIONPROC)getprocaddress("glBindFragDataLocationEXT");
glUniform1ui_ = (PFNGLUNIFORM1UIPROC) getprocaddress("glUniform1uiEXT");
glUniform2ui_ = (PFNGLUNIFORM2UIPROC) getprocaddress("glUniform2uiEXT");
glUniform3ui_ = (PFNGLUNIFORM3UIPROC) getprocaddress("glUniform3uiEXT");
glUniform4ui_ = (PFNGLUNIFORM4UIPROC) getprocaddress("glUniform4uiEXT");
glUniform1uiv_ = (PFNGLUNIFORM1UIVPROC) getprocaddress("glUniform1uivEXT");
glUniform2uiv_ = (PFNGLUNIFORM2UIVPROC) getprocaddress("glUniform2uivEXT");
glUniform3uiv_ = (PFNGLUNIFORM3UIVPROC) getprocaddress("glUniform3uivEXT");
glUniform4uiv_ = (PFNGLUNIFORM4UIVPROC) getprocaddress("glUniform4uivEXT");
hasEGPU4 = hasGPU4 = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_EXT_gpu_shader4 extension.");
}
if(hasext("GL_ARB_color_buffer_float"))
{
glClampColor_ = (PFNGLCLAMPCOLORPROC)getprocaddress("glClampColorARB");
hasCBF = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_ARB_color_buffer_float extension.");
}
if(hasext("GL_EXT_draw_buffers2"))
{
glColorMaski_ = (PFNGLCOLORMASKIPROC)getprocaddress("glColorMaskIndexedEXT");
glEnablei_ = (PFNGLENABLEIPROC) getprocaddress("glEnableIndexedEXT");
glDisablei_ = (PFNGLENABLEIPROC) getprocaddress("glDisableIndexedEXT");
hasDB2 = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_EXT_draw_buffers2 extension.");
}
if(hasext("GL_NV_conditional_render"))
{
glBeginConditionalRender_ = (PFNGLBEGINCONDITIONALRENDERPROC)getprocaddress("glBeginConditionalRenderNV");
glEndConditionalRender_ = (PFNGLENDCONDITIONALRENDERPROC) getprocaddress("glEndConditionalRenderNV");
hasCR = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_NV_conditional_render extension.");
}
if(hasext("GL_EXT_texture_integer"))
{
glTexParameterIiv_ = (PFNGLTEXPARAMETERIIVPROC) getprocaddress("glTexParameterIivEXT");
glTexParameterIuiv_ = (PFNGLTEXPARAMETERIUIVPROC) getprocaddress("glTexParameterIuivEXT");
glGetTexParameterIiv_ = (PFNGLGETTEXPARAMETERIIVPROC) getprocaddress("glGetTexParameterIivEXT");
glGetTexParameterIuiv_ = (PFNGLGETTEXPARAMETERIUIVPROC)getprocaddress("glGetTexParameterIuivEXT");
glClearColorIi_ = (PFNGLCLEARCOLORIIEXTPROC) getprocaddress("glClearColorIiEXT");
glClearColorIui_ = (PFNGLCLEARCOLORIUIEXTPROC) getprocaddress("glClearColorIuiEXT");
hasTI = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_EXT_texture_integer extension.");
}
if(hasext("GL_NV_half_float"))
{
hasHFV = hasHFP = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_NV_half_float extension.");
}
else
{
if(hasext("GL_ARB_half_float_vertex"))
{
hasHFV = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_ARB_half_float_vertex extension.");
}
if(hasext("GL_ARB_half_float_pixel"))
{
hasHFP = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_ARB_half_float_pixel extension.");
}
}
}
if(!hasHFV) fatal("Half-precision floating-point support is required!"); glCopyBufferSubData_ = (PFNGLCOPYBUFFERSUBDATAPROC)getprocaddress("glCopyBufferSubData");
if(glversion >= 300 || hasext("GL_ARB_framebuffer_object")) glTexImage2DMultisample_ = (PFNGLTEXIMAGE2DMULTISAMPLEPROC)getprocaddress("glTexImage2DMultisample");
{ glTexImage3DMultisample_ = (PFNGLTEXIMAGE3DMULTISAMPLEPROC)getprocaddress("glTexImage3DMultisample");
glBindRenderbuffer_ = (PFNGLBINDRENDERBUFFERPROC) getprocaddress("glBindRenderbuffer"); glGetMultisamplefv_ = (PFNGLGETMULTISAMPLEFVPROC) getprocaddress("glGetMultisamplefv");
glDeleteRenderbuffers_ = (PFNGLDELETERENDERBUFFERSPROC) getprocaddress("glDeleteRenderbuffers"); glSampleMaski_ = (PFNGLSAMPLEMASKIPROC) getprocaddress("glSampleMaski");
glGenRenderbuffers_ = (PFNGLGENFRAMEBUFFERSPROC) getprocaddress("glGenRenderbuffers");
glRenderbufferStorage_ = (PFNGLRENDERBUFFERSTORAGEPROC) getprocaddress("glRenderbufferStorage");
glGetRenderbufferParameteriv_ = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) getprocaddress("glGetRenderbufferParameteriv");
glCheckFramebufferStatus_ = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) getprocaddress("glCheckFramebufferStatus");
glBindFramebuffer_ = (PFNGLBINDFRAMEBUFFERPROC) getprocaddress("glBindFramebuffer");
glDeleteFramebuffers_ = (PFNGLDELETEFRAMEBUFFERSPROC) getprocaddress("glDeleteFramebuffers");
glGenFramebuffers_ = (PFNGLGENFRAMEBUFFERSPROC) getprocaddress("glGenFramebuffers");
glFramebufferTexture1D_ = (PFNGLFRAMEBUFFERTEXTURE1DPROC) getprocaddress("glFramebufferTexture1D");
glFramebufferTexture2D_ = (PFNGLFRAMEBUFFERTEXTURE2DPROC) getprocaddress("glFramebufferTexture2D");
glFramebufferTexture3D_ = (PFNGLFRAMEBUFFERTEXTURE3DPROC) getprocaddress("glFramebufferTexture3D");
glFramebufferRenderbuffer_ = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) getprocaddress("glFramebufferRenderbuffer");
glGenerateMipmap_ = (PFNGLGENERATEMIPMAPPROC) getprocaddress("glGenerateMipmap");
glBlitFramebuffer_ = (PFNGLBLITFRAMEBUFFERPROC) getprocaddress("glBlitFramebuffer");
glRenderbufferStorageMultisample_ = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)getprocaddress("glRenderbufferStorageMultisample");
hasAFBO = hasFBO = hasFBB = hasFBMS = hasDS = true;
if(glversion < 300 && dbgexts) conoutf(CON_INIT, "Using GL_ARB_framebuffer_object extension.");
}
else if(hasext("GL_EXT_framebuffer_object"))
{
glBindRenderbuffer_ = (PFNGLBINDRENDERBUFFERPROC) getprocaddress("glBindRenderbufferEXT");
glDeleteRenderbuffers_ = (PFNGLDELETERENDERBUFFERSPROC) getprocaddress("glDeleteRenderbuffersEXT");
glGenRenderbuffers_ = (PFNGLGENFRAMEBUFFERSPROC) getprocaddress("glGenRenderbuffersEXT");
glRenderbufferStorage_ = (PFNGLRENDERBUFFERSTORAGEPROC) getprocaddress("glRenderbufferStorageEXT");
glGetRenderbufferParameteriv_ = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)getprocaddress("glGetRenderbufferParameterivEXT");
glCheckFramebufferStatus_ = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) getprocaddress("glCheckFramebufferStatusEXT");
glBindFramebuffer_ = (PFNGLBINDFRAMEBUFFERPROC) getprocaddress("glBindFramebufferEXT");
glDeleteFramebuffers_ = (PFNGLDELETEFRAMEBUFFERSPROC) getprocaddress("glDeleteFramebuffersEXT");
glGenFramebuffers_ = (PFNGLGENFRAMEBUFFERSPROC) getprocaddress("glGenFramebuffersEXT");
glFramebufferTexture1D_ = (PFNGLFRAMEBUFFERTEXTURE1DPROC) getprocaddress("glFramebufferTexture1DEXT");
glFramebufferTexture2D_ = (PFNGLFRAMEBUFFERTEXTURE2DPROC) getprocaddress("glFramebufferTexture2DEXT");
glFramebufferTexture3D_ = (PFNGLFRAMEBUFFERTEXTURE3DPROC) getprocaddress("glFramebufferTexture3DEXT");
glFramebufferRenderbuffer_ = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) getprocaddress("glFramebufferRenderbufferEXT");
glGenerateMipmap_ = (PFNGLGENERATEMIPMAPPROC) getprocaddress("glGenerateMipmapEXT");
hasFBO = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_EXT_framebuffer_object extension.");
if(hasext("GL_EXT_framebuffer_blit"))
{
glBlitFramebuffer_ = (PFNGLBLITFRAMEBUFFERPROC) getprocaddress("glBlitFramebufferEXT");
hasFBB = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_EXT_framebuffer_blit extension.");
}
if(hasext("GL_EXT_framebuffer_multisample"))
{
glRenderbufferStorageMultisample_ = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)getprocaddress("glRenderbufferStorageMultisampleEXT");
hasFBMS = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_EXT_framebuffer_multisample extension.");
}
if(hasext("GL_EXT_packed_depth_stencil") || hasext("GL_NV_packed_depth_stencil"))
{
hasDS = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_EXT_packed_depth_stencil extension.");
}
}
else fatal("Framebuffer object support is required!");
if(glversion >= 300 || hasext("GL_ARB_map_buffer_range"))
{
glMapBufferRange_ = (PFNGLMAPBUFFERRANGEPROC) getprocaddress("glMapBufferRange");
glFlushMappedBufferRange_ = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)getprocaddress("glFlushMappedBufferRange");
hasMBR = true;
if(glversion < 300 && dbgexts) conoutf(CON_INIT, "Using GL_ARB_map_buffer_range.");
}
if(glversion >= 310 || hasext("GL_ARB_uniform_buffer_object"))
{
glGetUniformIndices_ = (PFNGLGETUNIFORMINDICESPROC) getprocaddress("glGetUniformIndices");
glGetActiveUniformsiv_ = (PFNGLGETACTIVEUNIFORMSIVPROC) getprocaddress("glGetActiveUniformsiv");
glGetUniformBlockIndex_ = (PFNGLGETUNIFORMBLOCKINDEXPROC) getprocaddress("glGetUniformBlockIndex");
glGetActiveUniformBlockiv_ = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)getprocaddress("glGetActiveUniformBlockiv");
glUniformBlockBinding_ = (PFNGLUNIFORMBLOCKBINDINGPROC) getprocaddress("glUniformBlockBinding");
glBindBufferBase_ = (PFNGLBINDBUFFERBASEPROC) getprocaddress("glBindBufferBase");
glBindBufferRange_ = (PFNGLBINDBUFFERRANGEPROC) getprocaddress("glBindBufferRange");
useubo = 1;
hasUBO = true;
if(glversion < 310 && dbgexts) conoutf(CON_INIT, "Using GL_ARB_uniform_buffer_object extension.");
}
if(glversion >= 310 || hasext("GL_ARB_texture_rectangle"))
{
hasTR = true;
if(glversion < 310 && dbgexts) conoutf(CON_INIT, "Using GL_ARB_texture_rectangle extension.");
}
else fatal("Texture rectangle support is required!");
if(glversion >= 310 || hasext("GL_ARB_copy_buffer"))
{
glCopyBufferSubData_ = (PFNGLCOPYBUFFERSUBDATAPROC)getprocaddress("glCopyBufferSubData");
hasCB = true;
if(glversion < 310 && dbgexts) conoutf(CON_INIT, "Using GL_ARB_copy_buffer extension.");
}
if(glversion >= 320 || hasext("GL_ARB_texture_multisample"))
{
glTexImage2DMultisample_ = (PFNGLTEXIMAGE2DMULTISAMPLEPROC)getprocaddress("glTexImage2DMultisample");
glTexImage3DMultisample_ = (PFNGLTEXIMAGE3DMULTISAMPLEPROC)getprocaddress("glTexImage3DMultisample");
glGetMultisamplefv_ = (PFNGLGETMULTISAMPLEFVPROC) getprocaddress("glGetMultisamplefv");
glSampleMaski_ = (PFNGLSAMPLEMASKIPROC) getprocaddress("glSampleMaski");
hasTMS = true;
if(glversion < 320 && dbgexts) conoutf(CON_INIT, "Using GL_ARB_texture_multisample extension.");
}
if(hasext("GL_EXT_framebuffer_multisample_blit_scaled")) if(hasext("GL_EXT_framebuffer_multisample_blit_scaled"))
{ {
hasFBMSBS = true; hasFBMSBS = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_EXT_framebuffer_multisample_blit_scaled extension."); if(dbgexts) conoutf(CON_INIT, "Using GL_EXT_framebuffer_multisample_blit_scaled extension.");
} }
if(hasext("GL_EXT_timer_query")) glGetQueryObjecti64v_ = (PFNGLGETQUERYOBJECTI64VEXTPROC) getprocaddress("glGetQueryObjecti64v");
{ glGetQueryObjectui64v_ = (PFNGLGETQUERYOBJECTUI64VEXTPROC) getprocaddress("glGetQueryObjectui64v");
glGetQueryObjecti64v_ = (PFNGLGETQUERYOBJECTI64VEXTPROC) getprocaddress("glGetQueryObjecti64vEXT");
glGetQueryObjectui64v_ = (PFNGLGETQUERYOBJECTUI64VEXTPROC) getprocaddress("glGetQueryObjectui64vEXT");
hasTQ = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_EXT_timer_query extension.");
}
else if(glversion >= 330 || hasext("GL_ARB_timer_query"))
{
glGetQueryObjecti64v_ = (PFNGLGETQUERYOBJECTI64VEXTPROC) getprocaddress("glGetQueryObjecti64v");
glGetQueryObjectui64v_ = (PFNGLGETQUERYOBJECTUI64VEXTPROC) getprocaddress("glGetQueryObjectui64v");
hasTQ = true;
if(glversion < 330 && dbgexts) conoutf(CON_INIT, "Using GL_ARB_timer_query extension.");
}
if(hasext("GL_EXT_texture_compression_s3tc")) if(hasext("GL_EXT_texture_compression_s3tc"))
{ {
@ -880,97 +635,20 @@ void gl_checkextensions()
if(dbgexts) conoutf(CON_INIT, "Using GL_EXT_depth_bounds_test extension."); if(dbgexts) conoutf(CON_INIT, "Using GL_EXT_depth_bounds_test extension.");
} }
if(glversion >= 320 || hasext("GL_ARB_depth_clamp")) glBindFragDataLocationIndexed_ = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)getprocaddress("glBindFragDataLocationIndexed");
{
hasDC = true;
if(glversion < 320 && dbgexts) conoutf(CON_INIT, "Using GL_ARB_depth_clamp extension.");
}
else if(hasext("GL_NV_depth_clamp"))
{
hasDC = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_NV_depth_clamp extension.");
}
if(glversion >= 330) GLint dualbufs = 0;
{ glGetIntegerv(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS, &dualbufs);
hasTSW = hasEAL = hasOQ2 = true; maxdualdrawbufs = dualbufs;
}
else
{
if(hasext("GL_ARB_texture_swizzle") || hasext("GL_EXT_texture_swizzle"))
{
hasTSW = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_ARB_texture_swizzle extension.");
}
if(hasext("GL_ARB_explicit_attrib_location"))
{
hasEAL = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_ARB_explicit_attrib_location extension.");
}
if(hasext("GL_ARB_occlusion_query2"))
{
hasOQ2 = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_ARB_occlusion_query2 extension.");
}
}
if(glversion >= 330 || hasext("GL_ARB_blend_func_extended")) glMinSampleShading_ = (PFNGLMINSAMPLESHADINGPROC)getprocaddress("glMinSampleShading");
{
glBindFragDataLocationIndexed_ = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)getprocaddress("glBindFragDataLocationIndexed");
if(hasGPU4) glBlendEquationi_ = (PFNGLBLENDEQUATIONIPROC) getprocaddress("glBlendEquationi");
{ glBlendEquationSeparatei_ = (PFNGLBLENDEQUATIONSEPARATEIPROC)getprocaddress("glBlendEquationSeparatei");
GLint dualbufs = 0; glBlendFunci_ = (PFNGLBLENDFUNCIPROC) getprocaddress("glBlendFunci");
glGetIntegerv(GL_MAX_DUAL_SOURCE_DRAW_BUFFERS, &dualbufs); glBlendFuncSeparatei_ = (PFNGLBLENDFUNCSEPARATEIPROC) getprocaddress("glBlendFuncSeparatei");
maxdualdrawbufs = dualbufs;
}
hasBFE = true; usetexgather = !intel && !nvidia ? 2 : 1;
if(glversion < 330 && dbgexts) conoutf(CON_INIT, "Using GL_ARB_blend_func_extended extension.");
}
if(glversion >= 400)
{
hasTG = hasGPU5 = true;
glMinSampleShading_ = (PFNGLMINSAMPLESHADINGPROC)getprocaddress("glMinSampleShading");
hasMSS = true;
glBlendEquationi_ = (PFNGLBLENDEQUATIONIPROC) getprocaddress("glBlendEquationi");
glBlendEquationSeparatei_ = (PFNGLBLENDEQUATIONSEPARATEIPROC)getprocaddress("glBlendEquationSeparatei");
glBlendFunci_ = (PFNGLBLENDFUNCIPROC) getprocaddress("glBlendFunci");
glBlendFuncSeparatei_ = (PFNGLBLENDFUNCSEPARATEIPROC) getprocaddress("glBlendFuncSeparatei");
hasDBB = true;
}
else
{
if(hasext("GL_ARB_texture_gather"))
{
hasTG = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_ARB_texture_gather extension.");
}
if(hasext("GL_ARB_gpu_shader5"))
{
hasGPU5 = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_ARB_gpu_shader5 extension.");
}
if(hasext("GL_ARB_sample_shading"))
{
glMinSampleShading_ = (PFNGLMINSAMPLESHADINGPROC)getprocaddress("glMinSampleShadingARB");
hasMSS = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_ARB_sample_shading extension.");
}
if(hasext("GL_ARB_draw_buffers_blend"))
{
glBlendEquationi_ = (PFNGLBLENDEQUATIONIPROC) getprocaddress("glBlendEquationiARB");
glBlendEquationSeparatei_ = (PFNGLBLENDEQUATIONSEPARATEIPROC)getprocaddress("glBlendEquationSeparateiARB");
glBlendFunci_ = (PFNGLBLENDFUNCIPROC) getprocaddress("glBlendFunciARB");
glBlendFuncSeparatei_ = (PFNGLBLENDFUNCSEPARATEIPROC) getprocaddress("glBlendFuncSeparateiARB");
hasDBB = true;
if(dbgexts) conoutf(CON_INIT, "Using GL_ARB_draw_buffers_blend extension.");
}
}
if(hasTG) usetexgather = hasGPU5 && !intel && !nvidia ? 2 : 1;
if(glversion >= 430 || hasext("GL_ARB_ES3_compatibility")) if(glversion >= 430 || hasext("GL_ARB_ES3_compatibility"))
{ {
@ -1014,20 +692,11 @@ void gl_checkextensions()
if(dbgexts) conoutf(CON_INIT, "Using GL_NV_copy_image extension."); if(dbgexts) conoutf(CON_INIT, "Using GL_NV_copy_image extension.");
} }
extern int gdepthstencil, gstencil, glineardepth, msaadepthstencil, msaalineardepth, batchsunlight, smgather, rhrect, tqaaresolvegather; extern int gdepthstencil, gstencil, glineardepth, msaadepthstencil, msaalineardepth, batchsunlight, smgather, rhrect;
if(amd) if(amd)
{ {
msaalineardepth = glineardepth = 1; // reading back from depth-stencil still buggy on newer cards, and requires stencil for MSAA msaalineardepth = glineardepth = 1; // reading back from depth-stencil still buggy on newer cards, and requires stencil for MSAA
msaadepthstencil = gdepthstencil = 1; // some older AMD GPUs do not support reading from depth-stencil textures, so only use depth-stencil renderbuffer for now msaadepthstencil = gdepthstencil = 1; // some older AMD GPUs do not support reading from depth-stencil textures, so only use depth-stencil renderbuffer for now
if(checkseries(renderer, "Radeon HD", 4000, 5199)) amd_pf_bug = 1;
if(glversion < 400)
{
amd_eal_bug = 1; // explicit_attrib_location broken when used with blend_func_extended on legacy Catalyst
rhrect = 1; // bad cpu stalls on Catalyst 13.x when trying to use 3D textures previously bound to FBOs
}
}
else if(nvidia)
{
} }
else if(intel) else if(intel)
{ {
@ -1035,8 +704,6 @@ void gl_checkextensions()
if(mesa) if(mesa)
{ {
batchsunlight = 0; // causes massive slowdown in linux driver batchsunlight = 0; // causes massive slowdown in linux driver
if(!checkmesaversion(version, 10, 0, 3))
mesa_texrectoffset_bug = 1; // mesa i965 driver has buggy textureOffset with texture rectangles
msaalineardepth = 1; // MSAA depth texture access is buggy and resolves are slow msaalineardepth = 1; // MSAA depth texture access is buggy and resolves are slow
} }
else else
@ -1049,12 +716,9 @@ void gl_checkextensions()
} }
// sampling alpha by itself from a texture generates garbage on Intel drivers on Windows // sampling alpha by itself from a texture generates garbage on Intel drivers on Windows
intel_texalpha_bug = 1; intel_texalpha_bug = 1;
// MapBufferRange is buggy on older Intel drivers on Windows
if(glversion <= 310) intel_mapbufferrange_bug = 1;
} }
} }
if(mesa) mesa_swap_bug = 1; if(mesa) mesa_swap_bug = 1;
if(hasGPU5 && hasTG) tqaaresolvegather = 1;
} }
ICOMMAND(glext, "s", (char *ext), intret(hasext(ext) ? 1 : 0)); ICOMMAND(glext, "s", (char *ext), intret(hasext(ext) ? 1 : 0));
@ -1099,7 +763,7 @@ timer *findtimer(const char *name, bool gpu)
timer *begintimer(const char *name, bool gpu) timer *begintimer(const char *name, bool gpu)
{ {
if(!usetimers || inbetweenframes || (gpu && (!hasTQ || deferquery))) return NULL; if(!usetimers || inbetweenframes || (gpu && deferquery)) return NULL;
timer *t = findtimer(name, gpu); timer *t = findtimer(name, gpu);
if(t->gpu) if(t->gpu)
{ {

View File

@ -16,12 +16,10 @@ int aow = -1, aoh = -1;
GLuint aofbo[4] = { 0, 0, 0, 0 }, aotex[4] = { 0, 0, 0, 0 }, aonoisetex = 0; GLuint aofbo[4] = { 0, 0, 0, 0 }, aotex[4] = { 0, 0, 0, 0 }, aonoisetex = 0;
matrix4 eyematrix, worldmatrix, linearworldmatrix, screenmatrix; matrix4 eyematrix, worldmatrix, linearworldmatrix, screenmatrix;
extern int amd_pf_bug;
int gethdrformat(int prec, int fallback = GL_RGB) int gethdrformat(int prec, int fallback = GL_RGB)
{ {
if(prec >= 3 && hasTF) return GL_RGB16F; if(prec >= 3) return GL_RGB16F;
if(prec >= 2 && hasPF && !amd_pf_bug) return GL_R11F_G11F_B10F; if(prec >= 2) return GL_R11F_G11F_B10F;
if(prec >= 1) return GL_RGB10; if(prec >= 1) return GL_RGB10;
return fallback; return fallback;
} }
@ -62,13 +60,13 @@ void setupbloom(int w, int h)
{ {
glGenBuffers_(1, &bloompbo); glGenBuffers_(1, &bloompbo);
glBindBuffer_(GL_PIXEL_PACK_BUFFER, bloompbo); glBindBuffer_(GL_PIXEL_PACK_BUFFER, bloompbo);
glBufferData_(GL_PIXEL_PACK_BUFFER, 4*(hasTF ? sizeof(GLfloat) : sizeof(GLushort))*(hasTRG ? 1 : 3), NULL, GL_DYNAMIC_COPY); glBufferData_(GL_PIXEL_PACK_BUFFER, 4*sizeof(GLfloat), NULL, GL_DYNAMIC_COPY);
glBindBuffer_(GL_PIXEL_PACK_BUFFER, 0); glBindBuffer_(GL_PIXEL_PACK_BUFFER, 0);
} }
static const uchar gray[12] = { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 }; static const uchar gray[12] = { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 };
static const float grayf[12] = { 0.125f, 0.125f, 0.125f, 0.125f, 0.125f, 0.125f, 0.125f, 0.125f, 0.125f, 0.125f, 0.125f, 0.125f }; static const float grayf[12] = { 0.125f, 0.125f, 0.125f, 0.125f, 0.125f, 0.125f, 0.125f, 0.125f, 0.125f, 0.125f, 0.125f, 0.125f };
createtexture(bloomtex[4], bloompbo ? 4 : 1, 1, hasTF ? (const void *)grayf : (const void *)gray, 3, 1, hasTF ? (hasTRG ? GL_R16F : GL_RGB16F) : (hasTRG ? GL_R16 : GL_RGB16)); createtexture(bloomtex[4], bloompbo ? 4 : 1, 1, (const void *)grayf, 3, 1, GL_R16F);
loopi(5 + (bloomformat != GL_RGB ? 1 : 0)) loopi(5 + (bloomformat != GL_RGB ? 1 : 0))
{ {
@ -184,7 +182,7 @@ void setupao(int w, int h)
delete[] noise; delete[] noise;
bool upscale = aoreduce && aobilateral && aobilateralupscale; bool upscale = aoreduce && aobilateral && aobilateralupscale;
GLenum format = aoprec && hasTRG ? GL_R8 : GL_RGBA8, GLenum format = aoprec && GL_R8,
packformat = aobilateral && aopackdepth ? (aodepthformat ? GL_RG16F : GL_RGBA8) : format; packformat = aobilateral && aopackdepth ? (aodepthformat ? GL_RG16F : GL_RGBA8) : format;
int packfilter = upscale && aopackdepth && !aodepthformat ? 0 : 1; int packfilter = upscale && aopackdepth && !aodepthformat ? 0 : 1;
loopi(upscale ? 3 : 2) loopi(upscale ? 3 : 2)
@ -258,7 +256,7 @@ VAR(debugao, 0, 0, 1);
void initao() void initao()
{ {
aodepthformat = aofloatdepth && hasTRG && hasTF ? aofloatdepth : 0; aodepthformat = aofloatdepth;
} }
void viewao() void viewao()
@ -484,16 +482,13 @@ void initgbuffer()
msaamaxsamples = msaamaxdepthtexsamples = msaamaxcolortexsamples = msaaminsamples = msaasamples = msaalight = 0; msaamaxsamples = msaamaxdepthtexsamples = msaamaxcolortexsamples = msaaminsamples = msaasamples = msaalight = 0;
msaapositions.setsize(0); msaapositions.setsize(0);
if(hasFBMS && hasFBB && hasTMS) GLint val;
{ glGetIntegerv(GL_MAX_SAMPLES, &val);
GLint val; msaamaxsamples = val;
glGetIntegerv(GL_MAX_SAMPLES, &val); glGetIntegerv(GL_MAX_DEPTH_TEXTURE_SAMPLES, &val);
msaamaxsamples = val; msaamaxdepthtexsamples = val;
glGetIntegerv(GL_MAX_DEPTH_TEXTURE_SAMPLES, &val); glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &val);
msaamaxdepthtexsamples = val; msaamaxcolortexsamples = val;
glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &val);
msaamaxcolortexsamples = val;
}
int maxsamples = min(msaamaxsamples, msaamaxcolortexsamples), reqsamples = min(msaa, maxsamples); int maxsamples = min(msaamaxsamples, msaamaxcolortexsamples), reqsamples = min(msaa, maxsamples);
if(reqsamples >= 2) if(reqsamples >= 2)
@ -513,18 +508,17 @@ void initgbuffer()
else if(msaalineardepth >= 0) lineardepth = msaalineardepth; else if(msaalineardepth >= 0) lineardepth = msaalineardepth;
} }
if(lineardepth > 1 && (!hasAFBO || !hasTF || !hasTRG)) gdepthformat = 1; gdepthformat = lineardepth;
else gdepthformat = lineardepth;
if(msaaminsamples) if(msaaminsamples)
{ {
ghasstencil = (msaadepthstencil > 1 || (msaadepthstencil && gdepthformat)) && hasDS ? 2 : (msaastencil ? 1 : 0); ghasstencil = (msaadepthstencil > 1 || (msaadepthstencil && gdepthformat)) ? 2 : (msaastencil ? 1 : 0);
checkmsaasamples(); checkmsaasamples();
if(msaapreserve >= 0) msaalight = hasMSS ? 3 : (msaasamples==2 ? 2 : msaapreserve); if(msaapreserve >= 0) msaalight = 3;
} }
else ghasstencil = (gdepthstencil > 1 || (gdepthstencil && gdepthformat)) && hasDS ? 2 : (gstencil ? 1 : 0); else ghasstencil = (gdepthstencil > 1 || (gdepthstencil && gdepthformat)) ? 2 : (gstencil ? 1 : 0);
initao(); initao();
} }
@ -623,7 +617,7 @@ void setupmsbuffer(int w, int h)
{ {
if(!msglowtex) glGenTextures(1, &msglowtex); if(!msglowtex) glGenTextures(1, &msglowtex);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, msglowtex); glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, msglowtex);
glTexImage2DMultisample_(GL_TEXTURE_2D_MULTISAMPLE, msaasamples, hasAFBO ? hdrformat : GL_RGBA8, w, h, GL_TRUE); glTexImage2DMultisample_(GL_TEXTURE_2D_MULTISAMPLE, msaasamples, hdrformat, w, h, GL_TRUE);
} }
bindmsdepth(); bindmsdepth();
@ -634,7 +628,7 @@ void setupmsbuffer(int w, int h)
if(glCheckFramebufferStatus_(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) if(glCheckFramebufferStatus_(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
{ {
if(msaalight && hasAFBO) if(msaalight)
{ {
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, msglowtex); glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, msglowtex);
glTexImage2DMultisample_(GL_TEXTURE_2D_MULTISAMPLE, msaasamples, GL_RGBA8, w, h, GL_TRUE); glTexImage2DMultisample_(GL_TEXTURE_2D_MULTISAMPLE, msaasamples, GL_RGBA8, w, h, GL_TRUE);
@ -794,7 +788,7 @@ void setupgbuffer()
createtexture(gcolortex, gw, gh, NULL, 3, 0, GL_RGBA8, GL_TEXTURE_RECTANGLE); createtexture(gcolortex, gw, gh, NULL, 3, 0, GL_RGBA8, GL_TEXTURE_RECTANGLE);
createtexture(gnormaltex, gw, gh, NULL, 3, 0, GL_RGBA8, GL_TEXTURE_RECTANGLE); createtexture(gnormaltex, gw, gh, NULL, 3, 0, GL_RGBA8, GL_TEXTURE_RECTANGLE);
createtexture(gglowtex, gw, gh, NULL, 3, 0, hasAFBO ? hdrformat : GL_RGBA8, GL_TEXTURE_RECTANGLE); createtexture(gglowtex, gw, gh, NULL, 3, 0, hdrformat, GL_TEXTURE_RECTANGLE);
bindgdepth(); bindgdepth();
glFramebufferTexture2D_(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE, gcolortex, 0); glFramebufferTexture2D_(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE, gcolortex, 0);
@ -804,14 +798,10 @@ void setupgbuffer()
if(glCheckFramebufferStatus_(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) if(glCheckFramebufferStatus_(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
{ {
if(hasAFBO) createtexture(gglowtex, gw, gh, NULL, 3, 0, GL_RGBA8, GL_TEXTURE_RECTANGLE);
{ glFramebufferTexture2D_(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_RECTANGLE, gglowtex, 0);
createtexture(gglowtex, gw, gh, NULL, 3, 0, GL_RGBA8, GL_TEXTURE_RECTANGLE); if(glCheckFramebufferStatus_(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
glFramebufferTexture2D_(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_RECTANGLE, gglowtex, 0); fatal("failed allocating g-buffer!");
if(glCheckFramebufferStatus_(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
fatal("failed allocating g-buffer!");
}
else fatal("failed allocating g-buffer!");
} }
glClearColor(0, 0, 0, 0); glClearColor(0, 0, 0, 0);
@ -1145,7 +1135,7 @@ void processhdr(GLuint outfbo, int aa)
{ {
glBindBuffer_(GL_PIXEL_PACK_BUFFER, bloompbo); glBindBuffer_(GL_PIXEL_PACK_BUFFER, bloompbo);
glPixelStorei(GL_PACK_ALIGNMENT, 1); glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, 4, 1, hasTRG ? GL_RED : GL_RGB, hasTF ? GL_FLOAT : GL_UNSIGNED_SHORT, NULL); glReadPixels(0, 0, 4, 1, GL_RED, GL_FLOAT, NULL);
glBindBuffer_(GL_PIXEL_PACK_BUFFER, 0); glBindBuffer_(GL_PIXEL_PACK_BUFFER, 0);
} }
@ -1156,7 +1146,7 @@ void processhdr(GLuint outfbo, int aa)
{ {
gle::bindvbo(bloompbo); gle::bindvbo(bloompbo);
gle::enablecolor(); gle::enablecolor();
gle::colorpointer(hasTF ? sizeof(GLfloat) : sizeof(GLushort), (const void *)0, hasTF ? GL_FLOAT : GL_UNSIGNED_SHORT, 1); gle::colorpointer(sizeof(GLfloat), (const void *)0, GL_FLOAT, 1);
gle::clearvbo(); gle::clearvbo();
} }
@ -1389,7 +1379,7 @@ void clearrhshaders()
void setupradiancehints() void setupradiancehints()
{ {
GLenum rhformat = hasTF && rhprec >= 1 ? GL_RGBA16F : GL_RGBA8; GLenum rhformat = rhprec >= 1 ? GL_RGBA16F : GL_RGBA8;
loopi(!rhrect && rhcache ? 8 : 4) loopi(!rhrect && rhcache ? 8 : 4)
{ {
@ -1714,8 +1704,8 @@ static inline void setsmcomparemode() // use embedded shadow cmp
} }
extern int usetexgather; extern int usetexgather;
static inline bool usegatherforsm() { return smfilter > 1 && smgather && hasTG && usetexgather; } static inline bool usegatherforsm() { return smfilter > 1 && smgather && usetexgather; }
static inline bool usesmcomparemode() { return !usegatherforsm() || (hasTG && hasGPU5 && usetexgather > 1); } static inline bool usesmcomparemode() { return !usegatherforsm() || (usetexgather > 1); }
void viewshadowatlas() void viewshadowatlas()
{ {

View File

@ -345,7 +345,7 @@ VAR(oqwait, 0, 1, 1);
static inline GLenum querytarget() static inline GLenum querytarget()
{ {
return oqany && hasOQ2 ? (oqany > 1 && hasES3 ? GL_ANY_SAMPLES_PASSED_CONSERVATIVE : GL_ANY_SAMPLES_PASSED) : GL_SAMPLES_PASSED; return oqany ? (oqany > 1 && hasES3 ? GL_ANY_SAMPLES_PASSED_CONSERVATIVE : GL_ANY_SAMPLES_PASSED) : GL_SAMPLES_PASSED;
} }
void startquery(occludequery *query) void startquery(occludequery *query)

View File

@ -109,182 +109,17 @@ static void showglslinfo(GLenum type, GLuint obj, const char *name, const char *
} }
} }
static const char *finddecls(const char *line)
{
for(;;)
{
const char *start = line + strspn(line, " \t\r");
switch(*start)
{
case '\n':
line = start + 1;
continue;
case '#':
do
{
start = strchr(start + 1, '\n');
if(!start) return NULL;
} while(start[-1] == '\\');
line = start + 1;
continue;
case '/':
switch(start[1])
{
case '/':
start = strchr(start + 2, '\n');
if(!start) return NULL;
line = start + 1;
continue;
case '*':
start = strstr(start + 2, "*/");
if(!start) return NULL;
line = start + 2;
continue;
}
// fall-through
default:
return line;
}
}
}
extern int amd_eal_bug;
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");
char *modsource = NULL; const char *parts[] = {
const char *parts[16]; "#version 400\n",
int numparts = 0; "#define textureRect(sampler, coords) texture(sampler, coords)\n"
static const struct { int version; const char * const header; } glslversions[] = "#define textureRectProj(sampler, coords) textureProj(sampler, coords)\n"
{ "#define textureRectOffset(sampler, coords, offset) textureOffset(sampler, coords, offset)\n",
{ 400, "#version 400\n" }, source
{ 330, "#version 330\n" },
{ 150, "#version 150\n" },
{ 140, "#version 140\n" },
{ 130, "#version 130\n" },
{ 120, "#version 120\n" }
}; };
loopi(sizeof(glslversions)/sizeof(glslversions[0])) if(glslversion >= glslversions[i].version) GLsizei numparts = sizeof(parts) / sizeof(void *);
{
parts[numparts++] = glslversions[i].header;
break;
}
if(glslversion < 140)
{
parts[numparts++] = "#extension GL_ARB_texture_rectangle : enable\n";
if(hasEGPU4)
parts[numparts++] = "#extension GL_EXT_gpu_shader4 : enable\n";
}
if(glslversion < 150 && hasTMS)
parts[numparts++] = "#extension GL_ARB_texture_multisample : enable\n";
if(glslversion >= 150 && glslversion < 330 && hasEAL && !amd_eal_bug)
parts[numparts++] = "#extension GL_ARB_explicit_attrib_location : enable\n";
if(glslversion < 400)
{
if(hasTG) parts[numparts++] = "#extension GL_ARB_texture_gather : enable\n";
if(hasGPU5) parts[numparts++] = "#extension GL_ARB_gpu_shader5 : enable\n";
}
if(glslversion >= 130)
{
if(type == GL_VERTEX_SHADER) parts[numparts++] =
"#define attribute in\n"
"#define varying out\n";
else if(type == GL_FRAGMENT_SHADER)
{
parts[numparts++] = "#define varying in\n";
parts[numparts++] = (glslversion >= 330 || (glslversion >= 150 && hasEAL)) && !amd_eal_bug ?
"#define fragdata(loc) layout(location = loc) out\n"
"#define fragblend(loc) layout(location = loc, index = 1) out\n" :
"#define fragdata(loc) out\n"
"#define fragblend(loc) out\n";
if(glslversion < 150)
{
const char *decls = finddecls(source);
if(decls)
{
static const char * const prec = "precision highp float;\n";
if(decls != source)
{
static const int preclen = strlen(prec);
int beforelen = int(decls-source), afterlen = strlen(decls);
modsource = newstring(beforelen + preclen + afterlen);
memcpy(modsource, source, beforelen);
memcpy(&modsource[beforelen], prec, preclen);
memcpy(&modsource[beforelen + preclen], decls, afterlen);
modsource[beforelen + preclen + afterlen] = '\0';
}
else parts[numparts++] = prec;
}
}
}
parts[numparts++] =
"#define texture1D(sampler, coords) texture(sampler, coords)\n"
"#define texture2D(sampler, coords) texture(sampler, coords)\n"
"#define texture2DOffset(sampler, coords, offset) textureOffset(sampler, coords, offset)\n"
"#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";
if(glslversion >= 140)
{
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";
extern int mesa_texrectoffset_bug;
parts[numparts++] = mesa_texrectoffset_bug ?
"#define texture2DRectOffset(sampler, coords, offset) texture(sampler, coords + vec2(offset))\n"
"#define shadow2DRectOffset(sampler, coords, offset) texture(sampler, coords + vec2(offset))\n" :
"#define texture2DRectOffset(sampler, coords, offset) textureOffset(sampler, coords, offset)\n"
"#define shadow2DRectOffset(sampler, coords, offset) textureOffset(sampler, coords, offset)\n";
}
}
if(glslversion < 130 && hasEGPU4) parts[numparts++] = "#define uint unsigned int\n";
else if(glslversion < 140 && !hasEGPU4)
{
if(glslversion < 130) parts[numparts++] = "#define flat\n";
parts[numparts++] =
"#define texture2DRectOffset(sampler, coords, offset) texture2DRect(sampler, coords + vec2(offset))\n"
"#define shadow2DRectOffset(sampler, coords, offset) shadow2DRect(sampler, coords + vec2(offset))\n";
}
if(glslversion < 130 && type == GL_FRAGMENT_SHADER)
{
if(hasEGPU4)
{
parts[numparts++] =
"#define fragdata(loc) varying out\n"
"#define fragblend(loc) varying out\n";
}
else
{
loopv(s.fragdatalocs)
{
FragDataLoc &d = s.fragdatalocs[i];
if(d.index) continue;
if(i >= 4) break;
static string defs[4];
const char *swizzle = "";
switch(d.format)
{
case GL_UNSIGNED_INT_VEC2:
case GL_INT_VEC2:
case GL_FLOAT_VEC2: swizzle = ".rg"; break;
case GL_UNSIGNED_INT_VEC3:
case GL_INT_VEC3:
case GL_FLOAT_VEC3: swizzle = ".rgb"; break;
case GL_UNSIGNED_INT:
case GL_INT:
case GL_FLOAT: swizzle = ".r"; break;
}
formatstring(defs[i], "#define %s gl_FragData[%d]%s\n", d.name, d.loc, swizzle);
parts[numparts++] = defs[i];
}
}
}
parts[numparts++] = modsource ? modsource : 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);
@ -297,8 +132,6 @@ static void compileglslshader(Shader &s, GLenum type, GLuint &obj, const char *d
obj = 0; obj = 0;
} }
else if(dbgshader > 1 && msg) showglslinfo(type, obj, name, parts, numparts); else if(dbgshader > 1 && msg) showglslinfo(type, obj, name, parts, numparts);
if(modsource) delete[] modsource;
} }
VAR(dbgubo, 0, 0, 1); VAR(dbgubo, 0, 0, 1);
@ -306,7 +139,7 @@ VAR(dbgubo, 0, 0, 1);
static void bindglsluniform(Shader &s, UniformLoc &u) static void bindglsluniform(Shader &s, UniformLoc &u)
{ {
u.loc = glGetUniformLocation_(s.program, u.name); u.loc = glGetUniformLocation_(s.program, u.name);
if(!u.blockname || !hasUBO) return; if(!u.blockname) return;
GLuint bidx = glGetUniformBlockIndex_(s.program, u.blockname); GLuint bidx = glGetUniformBlockIndex_(s.program, u.blockname);
GLuint uidx = GL_INVALID_INDEX; GLuint uidx = GL_INVALID_INDEX;
glGetUniformIndices_(s.program, 1, &u.name, &uidx); glGetUniformIndices_(s.program, 1, &u.name, &uidx);
@ -362,15 +195,6 @@ static void linkglslprogram(Shader &s, bool msg = true)
attribs |= 1<<a.loc; attribs |= 1<<a.loc;
} }
loopi(gle::MAXATTRIBS) if(!(attribs&(1<<i))) glBindAttribLocation_(s.program, i, gle::attribnames[i]); loopi(gle::MAXATTRIBS) if(!(attribs&(1<<i))) glBindAttribLocation_(s.program, i, gle::attribnames[i]);
if(hasGPU4 && ((glslversion < 330 && (glslversion < 150 || !hasEAL)) || amd_eal_bug)) loopv(s.fragdatalocs)
{
FragDataLoc &d = s.fragdatalocs[i];
if(d.index)
{
if(maxdualdrawbufs) glBindFragDataLocationIndexed_(s.program, d.loc, d.index, d.name);
}
else glBindFragDataLocation_(s.program, d.loc, d.name);
}
glLinkProgram_(s.program); glLinkProgram_(s.program);
glGetProgramiv_(s.program, GL_LINK_STATUS, &success); glGetProgramiv_(s.program, GL_LINK_STATUS, &success);
} }
@ -400,71 +224,6 @@ static void linkglslprogram(Shader &s, bool msg = true)
} }
} }
static void findfragdatalocs(Shader &s, char *ps, const char *macroname, int index)
{
int macrolen = strlen(macroname);
bool clear = glslversion < 130 && !hasEGPU4;
while((ps = strstr(ps, macroname)))
{
char *start = ps;
int loc = strtol(ps + macrolen, (char **)&ps, 0);
if(loc < 0 || loc > 3) continue;
ps += strspn(ps, ") \t\r\n");
const char *type = ps;
ps += strcspn(ps, "; \t\r\n");
GLenum format = GL_FLOAT_VEC4;
switch(type[0])
{
case 'v':
if(matchstring(type, ps-type, "vec3")) format = GL_FLOAT_VEC3;
else if(matchstring(type, ps-type, "vec2")) format = GL_FLOAT_VEC2;
break;
case 'f':
if(matchstring(type, ps-type, "float")) format = GL_FLOAT;
break;
case 'i':
if(matchstring(type, ps-type, "ivec4")) format = GL_INT_VEC4;
else if(matchstring(type, ps-type, "ivec3")) format = GL_INT_VEC3;
else if(matchstring(type, ps-type, "ivec2")) format = GL_INT_VEC2;
else if(matchstring(type, ps-type, "int")) format = GL_INT;
break;
case 'u':
if(matchstring(type, ps-type, "uvec4")) format = GL_UNSIGNED_INT_VEC4;
else if(matchstring(type, ps-type, "uvec3")) format = GL_UNSIGNED_INT_VEC3;
else if(matchstring(type, ps-type, "uvec2")) format = GL_UNSIGNED_INT_VEC2;
else if(matchstring(type, ps-type, "uint")) format = GL_UNSIGNED_INT;
break;
}
ps += strspn(ps, " \t\r\n");
const char *name = ps;
ps += strcspn(ps, "; \t\r\n");
if(ps > name)
{
char end = *ps;
*ps = '\0';
s.fragdatalocs.add(FragDataLoc(getshaderparamname(name), loc, format, index));
*ps = end;
}
if(clear)
{
ps += strspn(ps, "; \t\r\n");
memset(start, ' ', ps - start);
}
}
}
void findfragdatalocs(Shader &s, char *psstr)
{
if(!psstr || ((glslversion >= 330 || (glslversion >= 150 && hasEAL)) && !amd_eal_bug)) return;
findfragdatalocs(s, psstr, "fragdata(", 0);
if(maxdualdrawbufs) findfragdatalocs(s, psstr, "fragblend(", 1);
}
int getlocalparam(const char *name) int getlocalparam(const char *name)
{ {
return localparams.access(name, int(localparams.numelems)); return localparams.access(name, int(localparams.numelems));
@ -819,7 +578,6 @@ Shader *newshader(int type, const char *name, const char *vs, const char *ps, Sh
genuniformlocs(s, vs, ps, s.reusevs, s.reuseps); genuniformlocs(s, vs, ps, s.reusevs, s.reuseps);
s.fragdatalocs.setsize(0); s.fragdatalocs.setsize(0);
if(s.reuseps) s.fragdatalocs = s.reuseps->fragdatalocs; if(s.reuseps) s.fragdatalocs = s.reuseps->fragdatalocs;
else findfragdatalocs(s, s.psstr);
if(!s.compile()) if(!s.compile())
{ {
s.cleanup(true); s.cleanup(true);
@ -902,7 +660,7 @@ static void genfogshader(vector<char> &vsbuf, vector<char> &psbuf, const char *v
if(!strstr(vs, "lineardepth")) if(!strstr(vs, "lineardepth"))
{ {
vsbuf.put(vs, vsmain - vs); vsbuf.put(vs, vsmain - vs);
const char *fogparams = "\nuniform vec2 lineardepthscale;\nvarying float lineardepth;\n"; const char *fogparams = "\nuniform vec2 lineardepthscale;\nout float lineardepth;\n";
vsbuf.put(fogparams, strlen(fogparams)); vsbuf.put(fogparams, strlen(fogparams));
vsbuf.put(vsmain, vsend - vsmain); vsbuf.put(vsmain, vsend - vsmain);
const char *vsfog = "\nlineardepth = dot(lineardepthscale, gl_Position.zw);\n"; const char *vsfog = "\nlineardepth = dot(lineardepthscale, gl_Position.zw);\n";
@ -916,7 +674,7 @@ static void genfogshader(vector<char> &vsbuf, vector<char> &psbuf, const char *v
psbuf.put(ps, psmain - ps); psbuf.put(ps, psmain - ps);
if(!strstr(ps, "lineardepth")) if(!strstr(ps, "lineardepth"))
{ {
const char *foginterp = "\nvarying float lineardepth;\n"; const char *foginterp = "\nin float lineardepth;\n";
psbuf.put(foginterp, strlen(foginterp)); psbuf.put(foginterp, strlen(foginterp));
} }
const char *fogparams = const char *fogparams =
@ -978,56 +736,50 @@ void setupshaders()
maxvsuniforms = val/4; maxvsuniforms = val/4;
glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &val); glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &val);
maxfsuniforms = val/4; maxfsuniforms = val/4;
if(hasGPU4)
{ glGetIntegerv(GL_MIN_PROGRAM_TEXEL_OFFSET, &val);
glGetIntegerv(GL_MIN_PROGRAM_TEXEL_OFFSET, &val); mintexoffset = val;
mintexoffset = val; glGetIntegerv(GL_MAX_PROGRAM_TEXEL_OFFSET, &val);
glGetIntegerv(GL_MAX_PROGRAM_TEXEL_OFFSET, &val); maxtexoffset = val;
maxtexoffset = val;
} mintexrectoffset = mintexoffset;
else mintexoffset = maxtexoffset = 0; maxtexrectoffset = maxtexoffset;
if(glslversion >= 140 || hasEGPU4)
{
mintexrectoffset = mintexoffset;
maxtexrectoffset = maxtexoffset;
}
else mintexrectoffset = maxtexrectoffset = 0;
standardshaders = true; standardshaders = true;
nullshader = newshader(0, "<init>null", nullshader = newshader(0, "<init>null",
"attribute vec4 vvertex;\n" "in vec4 vvertex;\n"
"void main(void) {\n" "void main(void) {\n"
" gl_Position = vvertex;\n" " gl_Position = vvertex;\n"
"}\n", "}\n",
"fragdata(0) vec4 fragcolor;\n" "layout(location = 0) out vec4 fragcolor;\n"
"void main(void) {\n" "void main(void) {\n"
" fragcolor = vec4(1.0, 0.0, 1.0, 1.0);\n" " fragcolor = vec4(1.0, 0.0, 1.0, 1.0);\n"
"}\n"); "}\n");
hudshader = newshader(0, "<init>hud", hudshader = newshader(0, "<init>hud",
"attribute vec4 vvertex, vcolor;\n" "in vec4 vvertex, vcolor;\n"
"attribute vec2 vtexcoord0;\n" "in vec2 vtexcoord0;\n"
"uniform mat4 hudmatrix;\n" "uniform mat4 hudmatrix;\n"
"varying vec2 texcoord0;\n" "out vec2 texcoord0;\n"
"varying vec4 colorscale;\n" "out vec4 colorscale;\n"
"void main(void) {\n" "void main(void) {\n"
" gl_Position = hudmatrix * vvertex;\n" " gl_Position = hudmatrix * vvertex;\n"
" texcoord0 = vtexcoord0;\n" " texcoord0 = vtexcoord0;\n"
" colorscale = vcolor;\n" " colorscale = vcolor;\n"
"}\n", "}\n",
"uniform sampler2D tex0;\n" "uniform sampler2D tex0;\n"
"varying vec2 texcoord0;\n" "in vec2 texcoord0;\n"
"varying vec4 colorscale;\n" "in vec4 colorscale;\n"
"fragdata(0) 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",
"attribute vec4 vvertex, vcolor;\n" "in vec4 vvertex, vcolor;\n"
"attribute vec2 vtexcoord0;\n" "in vec2 vtexcoord0;\n"
"uniform mat4 hudmatrix;\n" "uniform mat4 hudmatrix;\n"
"varying vec2 texcoord0;\n" "out vec2 texcoord0;\n"
"varying vec4 colorscale;\n" "out vec4 colorscale;\n"
"void main(void) {\n" "void main(void) {\n"
" gl_Position = hudmatrix * vvertex;\n" " gl_Position = hudmatrix * vvertex;\n"
" texcoord0 = vtexcoord0;\n" " texcoord0 = vtexcoord0;\n"
@ -1035,25 +787,25 @@ void setupshaders()
"}\n", "}\n",
"uniform sampler2D tex0;\n" "uniform sampler2D tex0;\n"
"uniform vec4 textparams;\n" "uniform vec4 textparams;\n"
"varying vec2 texcoord0;\n" "in vec2 texcoord0;\n"
"varying vec4 colorscale;\n" "in vec4 colorscale;\n"
"fragdata(0) 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"
"}\n"); "}\n");
hudnotextureshader = newshader(0, "<init>hudnotexture", hudnotextureshader = newshader(0, "<init>hudnotexture",
"attribute vec4 vvertex, vcolor;\n" "in vec4 vvertex, vcolor;\n"
"uniform mat4 hudmatrix;" "uniform mat4 hudmatrix;"
"varying vec4 color;\n" "out vec4 color;\n"
"void main(void) {\n" "void main(void) {\n"
" gl_Position = hudmatrix * vvertex;\n" " gl_Position = hudmatrix * vvertex;\n"
" color = vcolor;\n" " color = vcolor;\n"
"}\n", "}\n",
"varying vec4 color;\n" "in vec4 color;\n"
"fragdata(0) vec4 fragcolor;\n" "layout(location = 0) out vec4 fragcolor;\n"
"void main(void) {\n" "void main(void) {\n"
" fragcolor = color;\n" " fragcolor = color;\n"
"}\n"); "}\n");

View File

@ -706,9 +706,9 @@ GLenum compressedformat(GLenum format, int w, int h, int force = 0)
case GL_RGB5_A1: return usetexcompress > 1 ? GL_COMPRESSED_RGBA_S3TC_DXT1_EXT : GL_COMPRESSED_RGBA; case GL_RGB5_A1: return usetexcompress > 1 ? GL_COMPRESSED_RGBA_S3TC_DXT1_EXT : GL_COMPRESSED_RGBA;
case GL_RGBA: return usetexcompress > 1 ? GL_COMPRESSED_RGBA_S3TC_DXT5_EXT : GL_COMPRESSED_RGBA; case GL_RGBA: return usetexcompress > 1 ? GL_COMPRESSED_RGBA_S3TC_DXT5_EXT : GL_COMPRESSED_RGBA;
case GL_RED: case GL_RED:
case GL_R8: return hasRGTC ? (usetexcompress > 1 ? GL_COMPRESSED_RED_RGTC1 : GL_COMPRESSED_RED) : (usetexcompress > 1 ? GL_COMPRESSED_RGB_S3TC_DXT1_EXT : GL_COMPRESSED_RGB); case GL_R8: return(usetexcompress > 1 ? GL_COMPRESSED_RED_RGTC1 : GL_COMPRESSED_RED);
case GL_RG: case GL_RG:
case GL_RG8: return hasRGTC ? (usetexcompress > 1 ? GL_COMPRESSED_RG_RGTC2 : GL_COMPRESSED_RG) : (usetexcompress > 1 ? GL_COMPRESSED_RGBA_S3TC_DXT5_EXT : GL_COMPRESSED_RGBA); case GL_RG8: return (usetexcompress > 1 ? GL_COMPRESSED_RG_RGTC2 : GL_COMPRESSED_RG);
case GL_LUMINANCE: case GL_LUMINANCE:
case GL_LUMINANCE8: return hasLATC ? (usetexcompress > 1 ? GL_COMPRESSED_LUMINANCE_LATC1_EXT : GL_COMPRESSED_LUMINANCE) : (usetexcompress > 1 ? GL_COMPRESSED_RGB_S3TC_DXT1_EXT : GL_COMPRESSED_RGB); case GL_LUMINANCE8: return hasLATC ? (usetexcompress > 1 ? GL_COMPRESSED_LUMINANCE_LATC1_EXT : GL_COMPRESSED_LUMINANCE) : (usetexcompress > 1 ? GL_COMPRESSED_RGB_S3TC_DXT1_EXT : GL_COMPRESSED_RGB);
case GL_LUMINANCE_ALPHA: case GL_LUMINANCE_ALPHA:
@ -903,7 +903,7 @@ void setuptexparameters(int tnum, const void *pixels, int clamp, int filter, GLe
(bilinear ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_LINEAR) : (bilinear ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_LINEAR) :
(bilinear ? GL_LINEAR_MIPMAP_NEAREST : GL_NEAREST_MIPMAP_NEAREST)) : (bilinear ? GL_LINEAR_MIPMAP_NEAREST : GL_NEAREST_MIPMAP_NEAREST)) :
(filter && bilinear ? GL_LINEAR : GL_NEAREST)); (filter && bilinear ? GL_LINEAR : GL_NEAREST));
if(swizzle && hasTRG && hasTSW) if(swizzle)
{ {
const GLint *mask = swizzlemask(format); const GLint *mask = swizzlemask(format);
if(mask) glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, mask); if(mask) glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, mask);
@ -1085,8 +1085,8 @@ static GLenum texformat(int bpp, bool swizzle = false)
{ {
switch(bpp) switch(bpp)
{ {
case 1: return hasTRG && (hasTSW || !glcompat || !swizzle) ? GL_RED : GL_LUMINANCE; case 1: return GL_RED;
case 2: return hasTRG && (hasTSW || !glcompat || !swizzle) ? GL_RG : GL_LUMINANCE_ALPHA; case 2: return GL_RG;
case 3: return GL_RGB; case 3: return GL_RGB;
case 4: return GL_RGBA; case 4: return GL_RGBA;
default: return 0; default: return 0;
@ -1167,12 +1167,6 @@ static Texture *newtexture(Texture *t, const char *rname, ImageData &s, int clam
{ {
format = texformat(s.bpp, swizzle); format = texformat(s.bpp, swizzle);
t->bpp = s.bpp; t->bpp = s.bpp;
if(swizzle && hasTRG && !hasTSW && swizzlemask(format))
{
swizzleimage(s);
format = texformat(s.bpp, swizzle);
t->bpp = s.bpp;
}
} }
if(alphaformat(format)) t->type |= Texture::ALPHA; if(alphaformat(format)) t->type |= Texture::ALPHA;
t->w = t->xs = s.w; t->w = t->xs = s.w;
@ -2813,12 +2807,6 @@ Texture *cubemaploadwildcard(Texture *t, const char *name, bool mipit, bool msg,
{ {
format = texformat(surface[0].bpp, true); format = texformat(surface[0].bpp, true);
t->bpp = surface[0].bpp; t->bpp = surface[0].bpp;
if(hasTRG && !hasTSW && swizzlemask(format))
{
loopi(6) swizzleimage(surface[i]);
format = texformat(surface[0].bpp, true);
t->bpp = surface[0].bpp;
}
} }
if(alphaformat(format)) t->type |= Texture::ALPHA; if(alphaformat(format)) t->type |= Texture::ALPHA;
t->mipmap = mipit; t->mipmap = mipit;
@ -2975,35 +2963,18 @@ GLuint genenvmap(const vec &o, int envmapsize, int blur, bool onlysky)
} }
for(int level = 0, lsize = texsize;; level++) for(int level = 0, lsize = texsize;; level++)
{ {
if(hasFBB) glBindFramebuffer_(GL_READ_FRAMEBUFFER, emfbo[0]);
{ glBindFramebuffer_(GL_DRAW_FRAMEBUFFER, emfbo[2]);
glBindFramebuffer_(GL_READ_FRAMEBUFFER, emfbo[0]); glFramebufferTexture2D_(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, side.target, tex, level);
glBindFramebuffer_(GL_DRAW_FRAMEBUFFER, emfbo[2]); glBlitFramebuffer_(0, 0, lsize, lsize, 0, 0, lsize, lsize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
glFramebufferTexture2D_(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, side.target, tex, level);
glBlitFramebuffer_(0, 0, lsize, lsize, 0, 0, lsize, lsize, GL_COLOR_BUFFER_BIT, GL_NEAREST);
}
else
{
glBindFramebuffer_(GL_FRAMEBUFFER, emfbo[0]);
glBindTexture(GL_TEXTURE_CUBE_MAP, tex);
glCopyTexSubImage2D(side.target, level, 0, 0, 0, 0, lsize, lsize);
}
if(lsize <= 1) break; if(lsize <= 1) break;
int dsize = lsize/2; int dsize = lsize/2;
if(hasFBB)
{ glBindFramebuffer_(GL_READ_FRAMEBUFFER, emfbo[0]);
glBindFramebuffer_(GL_READ_FRAMEBUFFER, emfbo[0]); glBindFramebuffer_(GL_DRAW_FRAMEBUFFER, emfbo[1]);
glBindFramebuffer_(GL_DRAW_FRAMEBUFFER, emfbo[1]); glBlitFramebuffer_(0, 0, lsize, lsize, 0, 0, dsize, dsize, GL_COLOR_BUFFER_BIT, GL_LINEAR);
glBlitFramebuffer_(0, 0, lsize, lsize, 0, 0, dsize, dsize, GL_COLOR_BUFFER_BIT, GL_LINEAR);
}
else
{
glBindFramebuffer_(GL_FRAMEBUFFER, emfbo[1]);
glBindTexture(GL_TEXTURE_RECTANGLE, emtex[0]);
glViewport(0, 0, dsize, dsize);
SETSHADER(scalelinear);
screenquad(lsize, lsize);
}
lsize = dsize; lsize = dsize;
swap(emfbo[0], emfbo[1]); swap(emfbo[0], emfbo[1]);
swap(emtex[0], emtex[1]); swap(emtex[0], emtex[1]);
@ -3406,12 +3377,12 @@ bool loaddds(const char *filename, ImageData &image, int force)
if((supported = hasS3TC) || force) format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; if((supported = hasS3TC) || force) format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
break; break;
case FOURCC_ATI1: case FOURCC_ATI1:
if((supported = hasRGTC) || force) format = GL_COMPRESSED_RED_RGTC1; supported = true;
else if((supported = hasLATC)) format = GL_COMPRESSED_LUMINANCE_LATC1_EXT; format = GL_COMPRESSED_RED_RGTC1;
break; break;
case FOURCC_ATI2: case FOURCC_ATI2:
if((supported = hasRGTC) || force) format = GL_COMPRESSED_RG_RGTC2; supported = true;
else if((supported = hasLATC)) format = GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT; format = GL_COMPRESSED_RG_RGTC2;
break; break;
} }
} }

View File

@ -1,8 +1,5 @@
#include "cube.h" #include "cube.h"
extern int glversion;
extern int intel_mapbufferrange_bug;
namespace gle namespace gle
{ {
struct attribinfo struct attribinfo
@ -48,8 +45,6 @@ namespace gle
{ {
quadsenabled = true; quadsenabled = true;
if(glversion < 300) return;
if(quadindexes) if(quadindexes)
{ {
glBindBuffer_(GL_ELEMENT_ARRAY_BUFFER, quadindexes); glBindBuffer_(GL_ELEMENT_ARRAY_BUFFER, quadindexes);
@ -76,19 +71,12 @@ namespace gle
{ {
quadsenabled = false; quadsenabled = false;
if(glversion < 300) return;
glBindBuffer_(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer_(GL_ELEMENT_ARRAY_BUFFER, 0);
} }
void drawquads(int offset, int count) void drawquads(int offset, int count)
{ {
if(count <= 0) return; if(count <= 0) return;
if(glversion < 300)
{
glDrawArrays(GL_QUADS, offset*4, count*4);
return;
}
if(offset + count > MAXQUADS) if(offset + count > MAXQUADS)
{ {
if(offset >= MAXQUADS) return; if(offset >= MAXQUADS) return;
@ -216,21 +204,18 @@ namespace gle
void begin(GLenum mode, int numverts) void begin(GLenum mode, int numverts)
{ {
primtype = mode; primtype = mode;
if(glversion >= 300 && !intel_mapbufferrange_bug) int len = numverts * vertexsize;
if(vbooffset + len >= MAXVBOSIZE)
{ {
int len = numverts * vertexsize; len = min(len, MAXVBOSIZE);
if(vbooffset + len >= MAXVBOSIZE) if(!vbo) glGenBuffers_(1, &vbo);
{ glBindBuffer_(GL_ARRAY_BUFFER, vbo);
len = min(len, MAXVBOSIZE); glBufferData_(GL_ARRAY_BUFFER, MAXVBOSIZE, NULL, GL_STREAM_DRAW);
if(!vbo) glGenBuffers_(1, &vbo); vbooffset = 0;
glBindBuffer_(GL_ARRAY_BUFFER, vbo);
glBufferData_(GL_ARRAY_BUFFER, MAXVBOSIZE, NULL, GL_STREAM_DRAW);
vbooffset = 0;
}
else if(!lastvertexsize) glBindBuffer_(GL_ARRAY_BUFFER, vbo);
void *buf = glMapBufferRange_(GL_ARRAY_BUFFER, vbooffset, len, GL_MAP_WRITE_BIT|GL_MAP_INVALIDATE_RANGE_BIT|GL_MAP_UNSYNCHRONIZED_BIT);
if(buf) attribbuf.reset((uchar *)buf, len);
} }
else if(!lastvertexsize) glBindBuffer_(GL_ARRAY_BUFFER, vbo);
void *buf = glMapBufferRange_(GL_ARRAY_BUFFER, vbooffset, len, GL_MAP_WRITE_BIT|GL_MAP_INVALIDATE_RANGE_BIT|GL_MAP_UNSYNCHRONIZED_BIT);
if(buf) attribbuf.reset((uchar *)buf, len);
} }
void multidraw() void multidraw()
@ -257,38 +242,36 @@ namespace gle
return 0; return 0;
} }
int start = 0; int start = 0;
if(glversion >= 300)
if(buf == attribdata)
{ {
if(buf == attribdata) if(vbooffset + attribbuf.length() >= MAXVBOSIZE)
{ {
if(vbooffset + attribbuf.length() >= MAXVBOSIZE) if(!vbo) glGenBuffers_(1, &vbo);
{ glBindBuffer_(GL_ARRAY_BUFFER, vbo);
if(!vbo) glGenBuffers_(1, &vbo); glBufferData_(GL_ARRAY_BUFFER, MAXVBOSIZE, NULL, GL_STREAM_DRAW);
glBindBuffer_(GL_ARRAY_BUFFER, vbo); vbooffset = 0;
glBufferData_(GL_ARRAY_BUFFER, MAXVBOSIZE, NULL, GL_STREAM_DRAW);
vbooffset = 0;
}
else if(!lastvertexsize) glBindBuffer_(GL_ARRAY_BUFFER, vbo);
void *dst = intel_mapbufferrange_bug ? NULL :
glMapBufferRange_(GL_ARRAY_BUFFER, vbooffset, attribbuf.length(), GL_MAP_WRITE_BIT|GL_MAP_INVALIDATE_RANGE_BIT|GL_MAP_UNSYNCHRONIZED_BIT);
if(dst)
{
memcpy(dst, attribbuf.getbuf(), attribbuf.length());
glUnmapBuffer_(GL_ARRAY_BUFFER);
}
else glBufferSubData_(GL_ARRAY_BUFFER, vbooffset, attribbuf.length(), attribbuf.getbuf());
} }
else glUnmapBuffer_(GL_ARRAY_BUFFER); else if(!lastvertexsize) glBindBuffer_(GL_ARRAY_BUFFER, vbo);
buf = (uchar *)0 + vbooffset; void *dst = glMapBufferRange_(GL_ARRAY_BUFFER, vbooffset, attribbuf.length(), GL_MAP_WRITE_BIT|GL_MAP_INVALIDATE_RANGE_BIT|GL_MAP_UNSYNCHRONIZED_BIT);
if(vertexsize == lastvertexsize && buf >= lastbuf) if(dst)
{ {
start = int(buf - lastbuf)/vertexsize; memcpy(dst, attribbuf.getbuf(), attribbuf.length());
if(primtype == GL_QUADS && (start%4 || start + attribbuf.length()/vertexsize >= 4*MAXQUADS)) glUnmapBuffer_(GL_ARRAY_BUFFER);
start = 0;
else buf = lastbuf;
} }
vbooffset += attribbuf.length(); else glBufferSubData_(GL_ARRAY_BUFFER, vbooffset, attribbuf.length(), attribbuf.getbuf());
} }
else glUnmapBuffer_(GL_ARRAY_BUFFER);
buf = (uchar *)0 + vbooffset;
if(vertexsize == lastvertexsize && buf >= lastbuf)
{
start = int(buf - lastbuf)/vertexsize;
if(primtype == GL_QUADS && (start%4 || start + attribbuf.length()/vertexsize >= 4*MAXQUADS))
start = 0;
else buf = lastbuf;
}
vbooffset += attribbuf.length();
setattribs(buf); setattribs(buf);
int numvertexes = attribbuf.length()/vertexsize; int numvertexes = attribbuf.length()/vertexsize;
if(primtype == GL_QUADS) if(primtype == GL_QUADS)
@ -318,16 +301,14 @@ namespace gle
numlastattribs = lastattribmask = lastvertexsize = 0; numlastattribs = lastattribmask = lastvertexsize = 0;
lastbuf = NULL; lastbuf = NULL;
if(quadsenabled) disablequads(); if(quadsenabled) disablequads();
if(glversion >= 300) glBindBuffer_(GL_ARRAY_BUFFER, 0); glBindBuffer_(GL_ARRAY_BUFFER, 0);
} }
void setup() void setup()
{ {
if(glversion >= 300) if(!defaultvao) glGenVertexArrays_(1, &defaultvao);
{ glBindVertexArray_(defaultvao);
if(!defaultvao) glGenVertexArrays_(1, &defaultvao);
glBindVertexArray_(defaultvao);
}
attribdata = new uchar[MAXVBOSIZE]; attribdata = new uchar[MAXVBOSIZE];
attribbuf.reset(attribdata, MAXVBOSIZE); attribbuf.reset(attribdata, MAXVBOSIZE);
} }