Simplify shader include

This commit is contained in:
Lubos Lenco 2018-01-29 23:52:42 +01:00
parent c7e77006a1
commit 9e8181edbc
14 changed files with 84 additions and 86 deletions

View file

@ -17,18 +17,18 @@
#include "std/sdf.glsl"
#endif
uniform sampler2D gbufferD;
// uniform sampler2D gbufferD;
uniform sampler2D gbuffer0;
uniform sampler2D gbuffer1;
#ifdef _VoxelGI
//!uniform sampler3D voxels;
uniform sampler3D voxels;
#endif
#ifdef _VoxelAO
//!uniform sampler3D voxels;
uniform sampler3D voxels;
#endif
#ifdef _VoxelGITemporal
//!uniform sampler3D voxelsLast;
uniform sampler3D voxelsLast;
uniform float voxelBlend;
#endif
#ifdef _VoxelGICam
@ -83,11 +83,11 @@ void main() {
vec3 albedo = surfaceAlbedo(g1.rgb, metrough.x); // g1.rgb - basecolor
#ifdef _IndPos
#ifdef _InvY // D3D
float depth = texture(gbufferD, texCoord).r * 2.0 - 1.0;
#else
// #ifdef _InvY // D3D
// float depth = texture(gbufferD, texCoord).r * 2.0 - 1.0;
// #else
float depth = (1.0 - g0.a) * 2.0 - 1.0;
#endif
// #endif
vec3 p = getPos(eye, eyeLook, viewRay, depth, cameraProj);
#endif
#ifdef _Brdf
@ -110,7 +110,7 @@ void main() {
vec4 indirectDiffuse = traceDiffuse(voxpos, n, voxels);
#endif
vec3 indirectSpecular = traceSpecular(voxpos, n, v, metrough.y);
vec3 indirectSpecular = traceSpecular(voxels, voxpos, n, v, metrough.y);
indirectSpecular *= f0 * envBRDF.x + envBRDF.y;
fragColor.rgb = indirectDiffuse.rgb * voxelgiDiff * g1.rgb + indirectSpecular * voxelgiSpec;

View file

@ -27,13 +27,13 @@
#include "std/gbuffer.glsl"
#ifdef _VoxelGIDirect
//!uniform sampler3D voxels;
uniform sampler3D voxels;
#endif
#ifdef _VoxelGICam
uniform vec3 eyeSnap;
#endif
uniform sampler2D gbufferD;
// uniform sampler2D gbufferD;
uniform sampler2D gbuffer0;
uniform sampler2D gbuffer1;
@ -42,8 +42,8 @@ uniform sampler2D gbuffer1;
#ifdef _SoftShadows
uniform sampler2D svisibility;
#else
//!uniform sampler2D shadowMap;
//!uniform samplerCube shadowMapCube;
uniform sampler2D shadowMap;
uniform samplerCube shadowMapCube;
#endif
#endif
#ifdef _DFRS
@ -137,11 +137,11 @@ void main() {
if (lightShadow == 1) {
vec4 lPos = LWVP * vec4(p + n * shadowsBias * 10, 1.0);
if (lPos.w > 0.0) {
visibility = shadowTest(lPos.xyz / lPos.w, shadowsBias, shadowmapSize);
visibility = shadowTest(shadowMap, lPos.xyz / lPos.w, shadowsBias, shadowmapSize);
}
}
else if (lightShadow == 2) { // Cube
visibility = PCFCube(lp, -l, shadowsBias, lightProj, n);
visibility = PCFCube(shadowMapCube, lp, -l, shadowsBias, lightProj, n);
}
#endif
@ -154,7 +154,7 @@ void main() {
#else
vec3 voxpos = p / voxelgiHalfExtents;
#endif
if (dotNL > 0.0) visibility = max(0, 1.0 - traceShadow(voxpos, l, 0.1, length(lp)));
if (dotNL > 0.0) visibility = max(0, 1.0 - traceShadow(voxels, voxpos, l, 0.1, length(lp)));
#endif
@ -263,6 +263,6 @@ void main() {
#else
vec3 voxposr = p / voxelgiHalfExtents;
#endif
fragColor.rgb = mix(traceRefraction(voxposr, n, -v, metrough.y), fragColor.rgb, g1.a);
fragColor.rgb = mix(traceRefraction(voxels, voxposr, n, -v, metrough.y), fragColor.rgb, g1.a);
#endif
}

View file

@ -24,7 +24,7 @@
uniform vec3 eyeSnap;
#endif
uniform sampler2D gbufferD;
// uniform sampler2D gbufferD;
uniform sampler2D gbuffer0;
uniform sampler2D gbuffer1;
@ -36,7 +36,7 @@ vec2 lightPlane;
#ifdef _SoftShadows
uniform sampler2D svisibility;
#else
//!uniform sampler2D shadowMap;
uniform sampler2D shadowMap;
#ifdef _CSM
//!uniform vec4 casData[shadowmapCascades * 4 + 4];
#else
@ -103,10 +103,10 @@ void main() {
if (lightShadow == 1) {
#ifdef _CSM
visibility = shadowTestCascade(eye, p + n * shadowsBias * 10, shadowsBias, shadowmapSize * vec2(shadowmapCascades, 1.0));
visibility = shadowTestCascade(shadowMap, eye, p + n * shadowsBias * 10, shadowsBias, shadowmapSize * vec2(shadowmapCascades, 1.0));
#else
vec4 lPos = LWVP * vec4(p + n * shadowsBias * 100, 1.0);
if (lPos.w > 0.0) visibility = shadowTest(lPos.xyz / lPos.w, shadowsBias, shadowmapSize);
if (lPos.w > 0.0) visibility = shadowTest(shadowMap, lPos.xyz / lPos.w, shadowsBias, shadowmapSize);
#endif
}
#endif
@ -118,7 +118,7 @@ void main() {
#else
vec3 voxpos = p / voxelgiHalfExtents;
#endif
if (dotNL > 0.0) visibility = max(0, 1.0 - traceShadow(voxpos, l, 0.1, 10.0));
if (dotNL > 0.0) visibility = max(0, 1.0 - traceShadow(voxels, voxpos, l, 0.1, 10.0));
#endif
// Per-light
@ -184,6 +184,6 @@ void main() {
#else
vec3 voxposr = p / voxelgiHalfExtents;
#endif
fragColor.rgb = mix(traceRefraction(voxposr, n, -v, metrough.y), fragColor.rgb, g1.a);
fragColor.rgb = mix(traceRefraction(voxels, voxposr, n, -v, metrough.y), fragColor.rgb, g1.a);
#endif
}

View file

@ -18,7 +18,7 @@
#define saturate(a) clamp(a, 0.0, 1.0)
#define round(a) floor(a + 0.5)
uniform sampler2D colorTex;
// uniform sampler2D colorTex;
uniform sampler2D edgesTex;
uniform sampler2D areaTex;

View file

@ -11,8 +11,8 @@ const float MAX_DISTANCE = 1.73205080757 * voxelgiRange;
const float VOXEL_SIZE = (2.0 / voxelgiResolution.x) * voxelgiStep;
const float blendFac = (1.0 / max(voxelgiOcc, 0.1));
uniform sampler3D voxels;
uniform sampler3D voxelsLast;
// uniform sampler3D voxels;
// uniform sampler3D voxelsLast;
vec3 orthogonal(const vec3 u) {
// Pass normalized u
@ -116,12 +116,12 @@ vec4 traceDiffuse(const vec3 origin, const vec3 normal, sampler3D voxels) {
return vec4(0.0);
}
float traceShadow(const vec3 origin, const vec3 dir, const float aperture, const float targetDistance) {
float traceShadow(sampler3D voxels, const vec3 origin, const vec3 dir, const float aperture, const float targetDistance) {
const float offset = 2 * VOXEL_SIZE * voxelgiOffsetShadow;
return traceCone(voxels, origin, dir, aperture, targetDistance, offset).a;
}
vec3 traceSpecular(const vec3 pos, const vec3 normal, const vec3 viewDir, const float roughness) {
vec3 traceSpecular(sampler3D voxels, const vec3 pos, const vec3 normal, const vec3 viewDir, const float roughness) {
float rough = max(roughness, 0.15);
float specularAperture = clamp(tan((3.14159265 / 2) * rough * 0.75), 0.0174533, 3.14159265);
vec3 specularDir = normalize(reflect(-viewDir, normal));
@ -130,7 +130,7 @@ vec3 traceSpecular(const vec3 pos, const vec3 normal, const vec3 viewDir, const
return traceCone(voxels, pos, specularDir, specularAperture, MAX_DISTANCE, offset).xyz;
}
vec3 traceRefraction(const vec3 pos, const vec3 normal, const vec3 viewDir, const float roughness) {
vec3 traceRefraction(sampler3D voxels, const vec3 pos, const vec3 normal, const vec3 viewDir, const float roughness) {
const float ior = 1.440;
const float transmittance = 1.0;
vec3 refraction = refract(viewDir, normal, 1.0 / ior);

View file

@ -1,8 +1,7 @@
#include "compiled.glsl"
uniform sampler2D shadowMap;
uniform samplerCube shadowMapCube;
// uniform sampler2D shadowMap;
// uniform samplerCube shadowMapCube;
// uniform sampler2DShadow shadowMap;
// uniform samplerCubeShadow shadowMapCube;
@ -10,35 +9,35 @@ uniform samplerCube shadowMapCube;
uniform vec4 casData[shadowmapCascades * 4 + 4];
#endif
float shadowCompare(const vec2 uv, const float compare){
float shadowCompare(sampler2D shadowMap, const vec2 uv, const float compare){
float depth = texture(shadowMap, uv).r;
return step(compare, depth);
}
float shadowLerp(const vec2 uv, const float compare, const vec2 smSize){
float shadowLerp(sampler2D shadowMap, const vec2 uv, const float compare, const vec2 smSize){
const vec2 texelSize = vec2(1.0) / smSize;
vec2 f = fract(uv * smSize + 0.5);
vec2 centroidUV = floor(uv * smSize + 0.5) / smSize;
float lb = shadowCompare(centroidUV, compare);
float lt = shadowCompare(centroidUV + texelSize * vec2(0.0, 1.0), compare);
float rb = shadowCompare(centroidUV + texelSize * vec2(1.0, 0.0), compare);
float rt = shadowCompare(centroidUV + texelSize, compare);
float lb = shadowCompare(shadowMap, centroidUV, compare);
float lt = shadowCompare(shadowMap, centroidUV + texelSize * vec2(0.0, 1.0), compare);
float rb = shadowCompare(shadowMap, centroidUV + texelSize * vec2(1.0, 0.0), compare);
float rt = shadowCompare(shadowMap, centroidUV + texelSize, compare);
float a = mix(lb, lt, f.y);
float b = mix(rb, rt, f.y);
float c = mix(a, b, f.x);
return c;
}
float PCF(const vec2 uv, const float compare, const vec2 smSize) {
float result = shadowLerp(uv + (vec2(-1.0, -1.0) / smSize), compare, smSize);
result += shadowLerp(uv + (vec2(-1.0, 0.0) / smSize), compare, smSize);
result += shadowLerp(uv + (vec2(-1.0, 1.0) / smSize), compare, smSize);
result += shadowLerp(uv + (vec2(0.0, -1.0) / smSize), compare, smSize);
result += shadowLerp(uv, compare, smSize);
result += shadowLerp(uv + (vec2(0.0, 1.0) / smSize), compare, smSize);
result += shadowLerp(uv + (vec2(1.0, -1.0) / smSize), compare, smSize);
result += shadowLerp(uv + (vec2(1.0, 0.0) / smSize), compare, smSize);
result += shadowLerp(uv + (vec2(1.0, 1.0) / smSize), compare, smSize);
float PCF(sampler2D shadowMap, const vec2 uv, const float compare, const vec2 smSize) {
float result = shadowLerp(shadowMap, uv + (vec2(-1.0, -1.0) / smSize), compare, smSize);
result += shadowLerp(shadowMap, uv + (vec2(-1.0, 0.0) / smSize), compare, smSize);
result += shadowLerp(shadowMap, uv + (vec2(-1.0, 1.0) / smSize), compare, smSize);
result += shadowLerp(shadowMap, uv + (vec2(0.0, -1.0) / smSize), compare, smSize);
result += shadowLerp(shadowMap, uv, compare, smSize);
result += shadowLerp(shadowMap, uv + (vec2(0.0, 1.0) / smSize), compare, smSize);
result += shadowLerp(shadowMap, uv + (vec2(1.0, -1.0) / smSize), compare, smSize);
result += shadowLerp(shadowMap, uv + (vec2(1.0, 0.0) / smSize), compare, smSize);
result += shadowLerp(shadowMap, uv + (vec2(1.0, 1.0) / smSize), compare, smSize);
return result / 9.0;
}
@ -49,7 +48,7 @@ float lpToDepth(vec3 lp, const vec2 lightProj) {
return zcomp * 0.5 + 0.5;
}
float PCFCube(const vec3 lp, vec3 ml, const float bias, const vec2 lightProj, const vec3 n) {
float PCFCube(samplerCube shadowMapCube, const vec3 lp, vec3 ml, const float bias, const vec2 lightProj, const vec3 n) {
// return float(texture(shadowMapCube, ml).r + bias > lpToDepth(lp, lightProj));
const float s = shadowmapCubePcfSize; // 0.001 TODO: incorrect...
// float compare = lpToDepth(lp, lightProj) - bias;
@ -68,12 +67,12 @@ float PCFCube(const vec3 lp, vec3 ml, const float bias, const vec2 lightProj, co
return result;
}
float shadowTest(const vec3 lPos, const float shadowsBias, const vec2 smSize) {
float shadowTest(sampler2D shadowMap, const vec3 lPos, const float shadowsBias, const vec2 smSize) {
// Out of bounds
if (lPos.x < 0.0 || lPos.y < 0.0 || lPos.x > 1.0 || lPos.y > 1.0) return 1.0;
return PCF(lPos.xy, lPos.z - shadowsBias, smSize);
return PCF(shadowMap, lPos.xy, lPos.z - shadowsBias, smSize);
}
#ifdef _CSM
@ -109,7 +108,7 @@ mat4 getCascadeMat(const float d, out int casi, out int casIndex) {
// ..
}
float shadowTestCascade(const vec3 eye, const vec3 p, const float shadowsBias, const vec2 smSize) {
float shadowTestCascade(sampler2D shadowMap, const vec3 eye, const vec3 p, const float shadowsBias, const vec2 smSize) {
const int c = shadowmapCascades;
float d = distance(eye, p);
@ -120,7 +119,7 @@ float shadowTestCascade(const vec3 eye, const vec3 p, const float shadowsBias, c
vec4 lPos = LWVP * vec4(p, 1.0);
float visibility = 1.0;
if (lPos.w > 0.0) visibility = shadowTest(lPos.xyz / lPos.w, shadowsBias, smSize);
if (lPos.w > 0.0) visibility = shadowTest(shadowMap, lPos.xyz / lPos.w, shadowsBias, smSize);
// Blend cascade
// https://github.com/TheRealMJP/Shadows
@ -138,7 +137,7 @@ float shadowTestCascade(const vec3 eye, const vec3 p, const float shadowsBias, c
vec4 lPos2 = LWVP2 * vec4(p, 1.0);
float visibility2 = 1.0;
if (lPos2.w > 0.0) visibility2 = shadowTest(lPos2.xyz / lPos2.w, shadowsBias, smSize);
if (lPos2.w > 0.0) visibility2 = shadowTest(shadowMap, lPos2.xyz / lPos2.w, shadowsBias, smSize);
float lerpAmt = smoothstep(0.0, blendThres, splitDist);
return mix(visibility2, visibility, lerpAmt);

View file

@ -39,7 +39,7 @@ void main() {
fragColor[0] = float(sm + shadowsBias > lPos.z);
// }
// else if (lightShadow == 2) { // Cube
// visibility = PCFCube(lp, -l, shadowsBias, lightProj, n);
// visibility = PCFCube(shadowMapCube, lp, -l, shadowsBias, lightProj, n);
// }
// Distance

View file

@ -7,8 +7,8 @@
uniform sampler2D gbufferD;
#ifndef _NoShadows
//!uniform sampler2D shadowMap;
//!uniform samplerCube shadowMapCube;
uniform sampler2D shadowMap;
uniform samplerCube shadowMapCube;
#endif
uniform sampler2D snoise;

View file

@ -7,8 +7,7 @@
uniform sampler2D gbufferD;
#ifndef _NoShadows
//!uniform sampler2D shadowMap;
//!uniform samplerCube shadowMapCube;
uniform sampler2D shadowMap;
#endif
uniform sampler2D snoise;

View file

@ -229,10 +229,10 @@ vec3 getSeaColor(vec3 p, vec3 n, vec3 l, vec3 eye, vec3 dist) {
// #ifndef _NoShadows
// float shadowTest(const vec3 lPos) {
// return PCF(lPos.xy, lPos.z - shadowsBias);
// return PCF(shadowMap, lPos.xy, lPos.z - shadowsBias);
// }
// float shadowTestCube(const vec3 lp, const vec3 l) {
// return PCFCube(lp, -l, shadowsBias, lightPlane);
// return PCFCube(shadowMapCube, lp, -l, shadowsBias, lightPlane);
// }
// #endif

View file

@ -986,7 +986,7 @@ class RenderPathCreator {
// Indirect
path.setTarget("tex");
path.bindTarget("_main", "gbufferD");
// path.bindTarget("_main", "gbufferD");
path.bindTarget("gbuffer0", "gbuffer0");
path.bindTarget("gbuffer1", "gbuffer1");
#if (rp_ssgi != "Off")
@ -1022,7 +1022,7 @@ class RenderPathCreator {
#end
path.setTarget("tex");
path.bindTarget("_main", "gbufferD");
// path.bindTarget("_main", "gbufferD");
path.bindTarget("gbuffer0", "gbuffer0");
path.bindTarget("gbuffer1", "gbuffer1");
@ -1349,7 +1349,7 @@ class RenderPathCreator {
else {
#if kha_webgl
// Bind empty map to cubemap sampler
path.bindTarget("arm_empty_cube", "shadowMapCube");
if (!path.lampIsSun()) path.bindTarget("arm_empty_cube", "shadowMapCube");
#end
path.bindTarget("shadowMap", "shadowMap");
}

View file

@ -435,7 +435,7 @@ def make_forward_mobile(con_mesh):
vert.add_uniform('mat4 LWVP', '_biasLampWorldViewProjectionMatrix')
vert.write('lampPos = LWVP * spos;')
frag.add_include('std/shadows.glsl')
frag.add_uniform('sampler2D shadowMap', included=True)
frag.add_uniform('sampler2D shadowMap')
frag.add_uniform('float shadowsBias', '_lampShadowsBias')
frag.write(' if (lampPos.w > 0.0) {')
frag.write(' vec3 lPos = lampPos.xyz / lampPos.w;')
@ -605,8 +605,8 @@ def make_forward_base(con_mesh, parse_opacity=False):
vert.write('if (lightShadow == 1) lampPos = LWVP * spos;')
frag.add_include('std/shadows.glsl')
frag.add_uniform('sampler2D shadowMap', included=True)
frag.add_uniform('samplerCube shadowMapCube', included=True)
frag.add_uniform('sampler2D shadowMap')
frag.add_uniform('samplerCube shadowMapCube')
frag.add_uniform('bool receiveShadow')
frag.add_uniform('float shadowsBias', '_lampShadowsBias')
frag.add_uniform('int lightShadow', '_lampCastShadow')
@ -636,9 +636,9 @@ def make_forward_base(con_mesh, parse_opacity=False):
frag.write(' vec3 lPos = lampPos.xyz / lampPos.w;')
frag.write(' const vec2 smSize = shadowmapSize;')
# frag.write('float bias = clamp(shadowsBias * 1.0 * tan(acos(clamp(dotNL, 0.0, 1.0))), 0.0, 0.01);')
frag.write(' visibility *= PCF(lPos.xy, lPos.z - shadowsBias, smSize);')
frag.write(' visibility *= PCF(shadowMap, lPos.xy, lPos.z - shadowsBias, smSize);')
frag.write(' }')
frag.write(' else if (lightShadow == 2) visibility *= PCFCube(lp, -l, shadowsBias, lightProj, n);')
frag.write(' else if (lightShadow == 2) visibility *= PCFCube(shadowMapCube, lp, -l, shadowsBias, lightProj, n);')
frag.write('}')
frag.write('if (lightType == 2) {')
@ -710,7 +710,7 @@ def make_forward_base(con_mesh, parse_opacity=False):
if '_VoxelGI' in wrd.world_defs or '_VoxelAO' in wrd.world_defs:
frag.add_include('std/conetrace.glsl')
frag.add_uniform('sampler3D voxels', included=True)
frag.add_uniform('sampler3D voxels')
if '_VoxelGICam' in wrd.world_defs:
frag.add_uniform('vec3 eyeSnap', link='_cameraPositionSnap')
frag.write('vec3 voxpos = (wposition - eyeSnap) / voxelgiHalfExtents;')
@ -721,6 +721,6 @@ def make_forward_base(con_mesh, parse_opacity=False):
# frag.write('indirect = vec3(1.0 - traceAO(voxpos, n, voxels));') # AO view
else:
frag.write('vec4 indirectDiffuse = traceDiffuse(voxpos, n, voxels);')
frag.write('vec3 indirectSpecular = traceSpecular(voxpos, n, vVec, roughness);')
frag.write('vec3 indirectSpecular = traceSpecular(voxels, voxpos, n, vVec, roughness);')
frag.write('indirectSpecular *= f0 * envBRDF.x + envBRDF.y;')
frag.write('indirect = indirect * voxelgiEnv + vec3(indirectDiffuse.rgb * voxelgiDiff * basecol + indirectSpecular * voxelgiSpec);')

View file

@ -53,8 +53,8 @@ def make_rect(con_rect):
frag.add_uniform('sampler2D gbuffer2')
frag.add_uniform('sampler2D gbufferD')
frag.add_uniform('sampler2D ssaotex')
frag.add_uniform('sampler2D shadowMap', included=True)
frag.add_uniform('sampler2D shadowMapCube', included=True)
frag.add_uniform('sampler2D shadowMap')
frag.add_uniform('sampler2D shadowMapCube')
frag.add_uniform('mat4 LWVP', link='_biasLampWorldViewProjectionMatrix')
frag.add_uniform('vec3 eye', link='_cameraPosition')
frag.add_uniform('vec3 eyeLook', link='_cameraLook')
@ -114,7 +114,7 @@ def make_rect(con_rect):
frag.write(' if (lPos.x > 0.0 && lPos.y > 0.0 && lPos.x < 1.0 && lPos.y < 1.0) visibility = PCF(lPos.xy, lPos.z - shadowsBias);;')
frag.write('}')
frag.write('else if (lightShadow == 2) {')
frag.write(' visibility = PCFCube(lp, -l, shadowsBias, lightProj, n);')
frag.write(' visibility = PCFCube(shadowMapCube, lp, -l, shadowsBias, lightProj, n);')
frag.write('}')
frag.write('visibility *= attenuate(distance(wposition, lightPos));')

View file

@ -68,8 +68,8 @@ def make_gi(context_id):
if is_shadows:
frag.add_include('std/shadows.glsl')
frag.add_uniform('sampler2D shadowMap', included=True)
frag.add_uniform('samplerCube shadowMapCube', included=True)
frag.add_uniform('sampler2D shadowMap')
frag.add_uniform('samplerCube shadowMapCube')
frag.add_uniform('int lightShadow', '_lampCastShadow')
frag.add_uniform('vec2 lightProj', '_lampPlaneProj')
frag.add_uniform('float shadowsBias', '_lampShadowsBias')
@ -78,7 +78,7 @@ def make_gi(context_id):
# frag.write(' if (lpos.x < 0.0 || lpos.y < 0.0 || lpos.x > 1.0 || lpos.y > 1.0) return;')
# Note: shadowmap bound for sun lamp is tight behind the camera - can cause darkening no close surfaces
frag.write(' if (texture(shadowMap, lpos.xy).r < lpos.z - shadowsBias) visibility = 0.0;')
# frag.write(' visibility = PCF(lpos.xy, lpos.z - shadowsBias);')
# frag.write(' visibility = PCF(shadowMap, lpos.xy, lpos.z - shadowsBias);')
frag.write('}')
frag.write('else if (lightShadow == 2) visibility *= float(texture(shadowMapCube, -l).r + shadowsBias > lpToDepth(lp, lightProj));')
@ -194,9 +194,9 @@ def make_gi(context_id):
if export_mpos:
geom.add_out('vec3 mposition')
geom.write('const vec3 p1 = voxpositionGeom[1] - voxpositionGeom[0];')
geom.write('const vec3 p2 = voxpositionGeom[2] - voxpositionGeom[0];')
geom.write('const vec3 p = abs(cross(p1, p2));')
geom.write('vec3 p1 = voxpositionGeom[1] - voxpositionGeom[0];')
geom.write('vec3 p2 = voxpositionGeom[2] - voxpositionGeom[0];')
geom.write('vec3 p = abs(cross(p1, p2));')
geom.write('for (uint i = 0; i < 3; ++i) {')
geom.write(' voxposition = voxpositionGeom[i];')
geom.write(' wnormal = wnormalGeom[i];')
@ -319,9 +319,9 @@ def make_ao(context_id):
geom.write_header('#extension GL_NV_geometry_shader_passthrough : require')
geom.geom_passthrough = True
# geom.add_out('vec3 voxposition')
geom.write('const vec3 p1 = voxpositionGeom[1] - voxpositionGeom[0];')
geom.write('const vec3 p2 = voxpositionGeom[2] - voxpositionGeom[0];')
geom.write('const vec3 n = abs(cross(p1, p2));')
geom.write('vec3 p1 = voxpositionGeom[1] - voxpositionGeom[0];')
geom.write('vec3 p2 = voxpositionGeom[2] - voxpositionGeom[0];')
geom.write('vec3 n = abs(cross(p1, p2));')
geom.write('gl_ViewportIndex = 1;')
geom.write_header('out int gl_ViewportIndex;')
# g4.setViewport():
@ -333,9 +333,9 @@ def make_ao(context_id):
frag.write('imageStore(voxels, ivec3(voxelgiResolution * (voxpositionGeom * 0.5 + 0.5)), vec4(1.0));')
else:
geom.add_out('vec3 voxposition')
geom.write('const vec3 p1 = voxpositionGeom[1] - voxpositionGeom[0];')
geom.write('const vec3 p2 = voxpositionGeom[2] - voxpositionGeom[0];')
geom.write('const vec3 p = abs(cross(p1, p2));')
geom.write('vec3 p1 = voxpositionGeom[1] - voxpositionGeom[0];')
geom.write('vec3 p2 = voxpositionGeom[2] - voxpositionGeom[0];')
geom.write('vec3 p = abs(cross(p1, p2));')
geom.write('for (uint i = 0; i < 3; ++i) {')
geom.write(' voxposition = voxpositionGeom[i];')
geom.write(' if (p.z > p.x && p.z > p.y) {')