OctaCore/config/glsl/gi.cfg

314 lines
8.5 KiB
INI

////////////////////////////////////////////////
//
// radiance hints
//
////////////////////////////////////////////////
lazyshader 0 "rsmsky" [
in vec4 vvertex;
uniform mat4 rsmmatrix;
void main(void)
{
gl_Position = rsmmatrix * vvertex;
}
] [
layout(location = 0) out vec4 gcolor;
layout(location = 1) out vec4 gnormal;
void main(void)
{
gcolor = vec4(0.0, 0.0, 0.0, 1.0);
gnormal = vec4(0.5, 0.5, 0.5, 0.0);
}
]
rhtapoffsets12 = [
"0.0565813, 0.61211, 0.763359"
"0.375225, 0.285592, 0.987915"
"0.615192, 0.668996, 0.604938"
"0.963195, 0.355937, 0.175787"
"0.0295724, 0.484268, 0.265694"
"0.917783, 0.88702, 0.201972"
"0.408948, 0.0675985, 0.427564"
"0.19071, 0.923612, 0.0553606"
"0.968078, 0.403943, 0.847224"
"0.384503, 0.922269, 0.990844"
"0.480605, 0.342418, 0.00195318"
"0.956664, 0.923643, 0.915799"
]
rhtapoffsets20 = [
"0.0540788, 0.411725, 0.134068"
"0.0163579, 0.416211, 0.992035"
"0.692068, 0.549272, 0.886502"
"0.305795, 0.781854, 0.571337"
"0.791681, 0.139042, 0.247047"
"0.83929, 0.973663, 0.460982"
"0.0336314, 0.0867641, 0.582324"
"0.148198, 0.961974, 0.0378124"
"0.948729, 0.0713828, 0.916379"
"0.586413, 0.591845, 0.031251"
"0.00189215, 0.973968, 0.932981"
"0.435865, 0.0853603, 0.995148"
"0.36848, 0.820612, 0.942717"
"0.500107, 0.0658284, 0.623005"
"0.580187, 0.4485, 0.379223"
"0.258614, 0.0201422, 0.241005"
"0.987152, 0.441664, 0.43318"
"0.925108, 0.917203, 0.921506"
"0.988372, 0.822047, 0.12479"
"0.330393, 0.43611, 0.762566"
]
rhtapoffsets32 = [
"0.0553911, 0.675924, 0.22129"
"0.562975, 0.508286, 0.549883"
"0.574816, 0.703452, 0.0513016"
"0.981017, 0.930479, 0.243873"
"0.889309, 0.133091, 0.319071"
"0.329112, 0.00759911, 0.472213"
"0.314463, 0.985839, 0.54442"
"0.407697, 0.202643, 0.985748"
"0.998169, 0.760369, 0.792932"
"0.0917692, 0.0666829, 0.0169683"
"0.0157781, 0.632954, 0.740806"
"0.938139, 0.235878, 0.87936"
"0.442305, 0.184942, 0.0901212"
"0.578051, 0.863948, 0.799554"
"0.0698569, 0.259194, 0.667592"
"0.872494, 0.576312, 0.344157"
"0.10123, 0.930082, 0.959929"
"0.178594, 0.991302, 0.046205"
"0.690176, 0.527543, 0.930509"
"0.982025, 0.389447, 0.0344554"
"0.033845, 0.0156865, 0.963866"
"0.655293, 0.154271, 0.640553"
"0.317881, 0.598621, 0.97998"
"0.247261, 0.398206, 0.121586"
"0.822626, 0.985076, 0.655232"
"0.00201422, 0.434278, 0.388348"
"0.511399, 0.977416, 0.278695"
"0.32371, 0.540147, 0.361187"
"0.365856, 0.41493, 0.758232"
"0.792871, 0.979217, 0.0309763"
"0.0509049, 0.459151, 0.996277"
"0.0305185, 0.13422, 0.306009"
]
rsmtapoffsets12 = [
"0.031084, 0.572114"
"0.040671, 0.95653"
"0.160921, 0.367819"
"0.230518, 0.134321"
"0.247078, 0.819415"
"0.428665, 0.440522"
"0.49846, 0.80717"
"0.604285, 0.0307766"
"0.684075, 0.283001"
"0.688304, 0.624171"
"0.833995, 0.832414"
"0.975397, 0.189911"
]
rsmtapoffsets20 = [
"0.00240055, 0.643992"
"0.0356464, 0.851616"
"0.101733, 0.21876"
"0.166119, 0.0278085"
"0.166438, 0.474999"
"0.24991, 0.766405"
"0.333714, 0.130407"
"0.400681, 0.374781"
"0.424067, 0.888211"
"0.448511, 0.678962"
"0.529383, 0.213568"
"0.608569, 0.47715"
"0.617996, 0.862528"
"0.631784, 0.0515881"
"0.740969, 0.20753"
"0.788203, 0.41923"
"0.794066, 0.615141"
"0.834504, 0.836612"
"0.89446, 0.0677863"
"0.975609, 0.446056"
]
rsmtapoffsets32 = [
"0.0262032, 0.215221"
"0.0359769, 0.0467256"
"0.0760799, 0.713481"
"0.115087, 0.461431"
"0.119488, 0.927444"
"0.22346, 0.319747"
"0.225964, 0.679227"
"0.238626, 0.0618425"
"0.243326, 0.535066"
"0.29832, 0.90826"
"0.335208, 0.212103"
"0.356438, 0.751969"
"0.401021, 0.478664"
"0.412027, 0.0245297"
"0.48477, 0.320659"
"0.494311, 0.834621"
"0.515007, 0.165552"
"0.534574, 0.675536"
"0.585357, 0.432483"
"0.600102, 0.94139"
"0.650182, 0.563571"
"0.672336, 0.771816"
"0.701811, 0.187078"
"0.734207, 0.359024"
"0.744775, 0.924466"
"0.763628, 0.659075"
"0.80735, 0.521281"
"0.880585, 0.107684"
"0.898505, 0.904047"
"0.902536, 0.718989"
"0.928022, 0.347802"
"0.971243, 0.504885"
]
radiancehintsshader = [
numtaps = (cond [> $arg1 20] 32 [> $arg1 12] 20 12)
shader 0 [radiancehints@arg1] [
in vec4 vvertex;
in vec3 vtexcoord0;
uniform mat4 rsmtcmatrix;
out vec3 rhcenter;
out vec2 rsmcenter;
void main(void)
{
gl_Position = vvertex;
rhcenter = vtexcoord0;
rsmcenter = (rsmtcmatrix * vec4(vtexcoord0, 1.0)).xy;
}
] [
uniform sampler2DRect tex0, tex1, tex2;
uniform mat4 rsmworldmatrix;
uniform vec2 rsmspread;
uniform float rhatten, rhspread, rhaothreshold, rhaoatten, rhaoheight;
uniform vec3 rsmdir;
in vec3 rhcenter;
in vec2 rsmcenter;
layout(location = 0) out vec4 rhr;
layout(location = 1) out vec4 rhg;
layout(location = 2) out vec4 rhb;
layout(location = 3) out vec4 rha;
void calcrhsample(vec3 rhtap, vec2 rsmtap, inout vec4 shr, inout vec4 shg, inout vec4 shb, inout vec4 sha)
{
vec3 rhpos = rhcenter + rhtap*rhspread;
vec2 rsmtc = rsmcenter + rsmtap*rsmspread;
float rsmdepth = textureRect(tex0, rsmtc).x;
vec3 rsmcolor = textureRect(tex1, rsmtc).rgb;
vec3 rsmnormal = textureRect(tex2, rsmtc).xyz*2.0 - 1.0;
vec3 rsmpos = (rsmworldmatrix * vec4(rsmtc, rsmdepth, 1.0)).xyz;
vec3 dir = rhpos - rsmpos;
sha += step(rhaothreshold, dir.z) * vec4(normalize(vec3(dir.xy, min(dot(dir.xy, dir.xy) * rhaoatten - rhaoheight, 0.0))), 1.0);
float dist = dot(dir, dir);
if(dist > 0.000049) dir = normalize(dir);
float atten = clamp(dot(dir, rsmnormal), 0.0, 1.0) / (0.1 + dist*rhatten);
rsmcolor *= atten;
shr += vec4(rsmcolor.r*dir, rsmcolor.r);
shg += vec4(rsmcolor.g*dir, rsmcolor.g);
shb += vec4(rsmcolor.b*dir, rsmcolor.b);
}
void main(void)
{
vec4 shr = vec4(0.0), shg = vec4(0.0), shb = vec4(0.0), sha = vec4(0.0);
@(loopconcat i $numtaps [result [
calcrhsample(vec3(@(at $[rhtapoffsets@numtaps] $i))*2.0 - 1.0, vec2(@(at $[rsmtapoffsets@numtaps] $i))*2.0 - 1.0, shr, shg, shb, sha);
]])
rhr = shr * (vec4(0.5, 0.5, 0.5, 1.0)/@(+f $numtaps)) + vec4(0.5, 0.5, 0.5, 0.0);
rhg = shg * (vec4(0.5, 0.5, 0.5, 1.0)/@(+f $numtaps)) + vec4(0.5, 0.5, 0.5, 0.0);
rhb = shb * (vec4(0.5, 0.5, 0.5, 1.0)/@(+f $numtaps)) + vec4(0.5, 0.5, 0.5, 0.0);
rha = sha * (vec4(0.5, 0.5, 0.5, 1.0)/@(+f $numtaps)) + vec4(0.5, 0.5, 0.5, 0.0);
}
]
]
lazyshader 0 radiancehintsborder [
in vec4 vvertex;
in vec3 vtexcoord0;
out vec3 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
uniform sampler3D tex3, tex4, tex5, tex6;
uniform vec3 bordercenter, borderrange, borderscale;
in vec3 texcoord0;
layout(location = 0) out vec4 rhr;
layout(location = 1) out vec4 rhg;
layout(location = 2) out vec4 rhb;
layout(location = 3) out vec4 rha;
void main(void)
{
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));
rhr = mix(texture(tex3, 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(texture(tex5, 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 [
in vec4 vvertex;
in vec3 vtexcoord0;
out vec3 texcoord0;
void main(void)
{
gl_Position = vvertex;
texcoord0 = vtexcoord0;
}
] [
uniform sampler3D tex7, tex8, tex9, tex10;
in vec3 texcoord0;
layout(location = 0) out vec4 rhr;
layout(location = 1) out vec4 rhg;
layout(location = 2) out vec4 rhb;
layout(location = 3) out vec4 rha;
void main(void)
{
rhr = texture(tex7, texcoord0);
rhg = texture(tex8, texcoord0);
rhb = texture(tex9, texcoord0);
rha = texture(tex10, texcoord0);
}
]
lazyshader 0 radiancehintsdisable [
in vec4 vvertex;
uniform vec3 rhcenter;
uniform float rhbounds;
void main(void)
{
gl_Position = vec4((vvertex.xy - rhcenter.xy)/rhbounds, vvertex.zw);
}
] [
layout(location = 0) out vec4 rhr;
layout(location = 1) out vec4 rhg;
layout(location = 2) out vec4 rhb;
layout(location = 3) out vec4 rha;
void main(void)
{
rhr = vec4(0.5, 0.5, 0.5, 0.0);
rhg = vec4(0.5, 0.5, 0.5, 0.0);
rhb = vec4(0.5, 0.5, 0.5, 0.0);
rha = vec4(0.5, 0.5, 0.5, 0.0);
}
]