Compare commits

..

No commits in common. "e2002e" and "main" have entirely different histories.
e2002e ... main

25 changed files with 931 additions and 925 deletions

View File

@ -20,7 +20,7 @@ uniform sampler2D gbuffer0;
uniform sampler2D gbuffer1; uniform sampler2D gbuffer1;
#ifdef _gbuffer2 #ifdef _gbuffer2
//!uniform sampler2D gbuffer2; uniform sampler2D gbuffer2;
#endif #endif
#ifdef _EmissionShaded #ifdef _EmissionShaded
uniform sampler2D gbufferEmission; uniform sampler2D gbufferEmission;
@ -286,7 +286,7 @@ void main() {
#ifdef _VoxelGI #ifdef _VoxelGI
vec4 indirect_diffuse = textureLod(voxels_diffuse, texCoord, 0.0); vec4 indirect_diffuse = textureLod(voxels_diffuse, texCoord, 0.0);
fragColor.rgb = (indirect_diffuse.rgb + envl.rgb * (1.0 - indirect_diffuse.a)) * albedo * voxelgiDiff; fragColor.rgb = (indirect_diffuse.rgb * albedo + envl.rgb * (1.0 - indirect_diffuse.a)) * voxelgiDiff;
if(roughness < 1.0 && occspec.y > 0.0) if(roughness < 1.0 && occspec.y > 0.0)
fragColor.rgb += textureLod(voxels_specular, texCoord, 0.0).rgb * occspec.y * voxelgiRefl; fragColor.rgb += textureLod(voxels_specular, texCoord, 0.0).rgb * occspec.y * voxelgiRefl;
#endif #endif
@ -380,7 +380,7 @@ void main() {
#endif #endif
#ifdef _VoxelShadow #ifdef _VoxelShadow
svisibility *= (1.0 - traceShadow(p, n, voxels, voxelsSDF, sunDir, clipmaps, gl_FragCoord.xy, g2.rg).r) * voxelgiShad; svisibility *= (1.0 - traceShadow(p, n, voxels, voxelsSDF, sunDir, clipmaps, gl_FragCoord.xy).r) * voxelgiShad;
#endif #endif
#ifdef _SSRS #ifdef _SSRS

View File

@ -92,7 +92,7 @@ void main() {
vec3 viewNormal = V3 * n; vec3 viewNormal = V3 * n;
vec3 viewPos = getPosView(viewRay, d, cameraProj); vec3 viewPos = getPosView(viewRay, d, cameraProj);
vec3 reflected = reflect(normalize(viewPos), viewNormal); vec3 reflected = reflect(viewPos, viewNormal);
hitCoord = viewPos; hitCoord = viewPos;
#ifdef _CPostprocess #ifdef _CPostprocess

View File

@ -62,12 +62,9 @@ vec4 rayCast(vec3 dir) {
for (int i = 0; i < maxSteps; i++) { for (int i = 0; i < maxSteps; i++) {
hitCoord += dir; hitCoord += dir;
ddepth = getDeltaDepth(hitCoord); ddepth = getDeltaDepth(hitCoord);
if (ddepth > 0.0) if (ddepth > 0.0) return binarySearch(dir);
return binarySearch(dir);
} }
// No hit — fallback to projecting the ray to UV space return vec4(texCoord, 0.0, 1.0);
vec2 fallbackUV = getProjectedCoord(hitCoord);
return vec4(fallbackUV, 0.0, 0.5); // We set .w lower to indicate fallback
} }
void main() { void main() {
@ -77,7 +74,7 @@ void main() {
float ior = gr.x; float ior = gr.x;
float opac = gr.y; float opac = gr.y;
float d = textureLod(gbufferD, texCoord, 0.0).r * 2.0 - 1.0; float d = textureLod(gbufferD, texCoord, 0.0).r * 2.0 - 1.0;
if (d == 0.0 || opac == 1.0 || ior == 1.0) { if (d == 0.0 || d == 1.0 || opac == 1.0 || ior == 1.0) {
fragColor.rgb = textureLod(tex1, texCoord, 0.0).rgb; fragColor.rgb = textureLod(tex1, texCoord, 0.0).rgb;
return; return;
} }

View File

@ -166,7 +166,7 @@ vec4 traceDiffuse(const vec3 origin, const vec3 normal, const sampler3D voxels,
} }
vec4 traceSpecular(const vec3 origin, const vec3 normal, const sampler3D voxels, const sampler3D voxelsSDF, const vec3 viewDir, const float roughness, const float clipmaps[voxelgiClipmapCount * 10], const vec2 pixel, const vec2 velocity) { vec4 traceSpecular(const vec3 origin, const vec3 normal, const sampler3D voxels, const sampler3D voxelsSDF, const vec3 viewDir, const float roughness, const float clipmaps[voxelgiClipmapCount * 10], const vec2 pixel, const vec2 velocity) {
vec3 specularDir = reflect(normalize(-viewDir), normal); vec3 specularDir = reflect(-viewDir, normal);
vec3 P = origin + specularDir * ((BayerMatrix8[int(pixel.x + velocity.x) % 8][int(pixel.y + velocity.y) % 8] - 0.5)) * voxelgiStep; vec3 P = origin + specularDir * ((BayerMatrix8[int(pixel.x + velocity.x) % 8][int(pixel.y + velocity.y) % 8] - 0.5)) * voxelgiStep;
vec4 amount = traceCone(voxels, voxelsSDF, P, normal, specularDir, 0, true, roughness, voxelgiStep, clipmaps); vec4 amount = traceCone(voxels, voxelsSDF, P, normal, specularDir, 0, true, roughness, voxelgiStep, clipmaps);
@ -176,9 +176,9 @@ vec4 traceSpecular(const vec3 origin, const vec3 normal, const sampler3D voxels,
return amount * voxelgiOcc; return amount * voxelgiOcc;
} }
vec4 traceRefraction(const vec3 origin, const vec3 normal, sampler3D voxels, sampler3D voxelsSDF, const vec3 viewDir, const float ior, const float roughness, const float clipmaps[voxelgiClipmapCount * 10], const vec2 pixel, const vec2 velocity, const float opacity) { vec4 traceRefraction(const vec3 origin, const vec3 normal, sampler3D voxels, sampler3D voxelsSDF, const vec3 viewDir, const float ior, const float roughness, const float clipmaps[voxelgiClipmapCount * 10], const vec2 pixel, const vec2 velocity) {
const float transmittance = 1.0 - opacity; const float transmittance = 1.0;
vec3 refractionDir = refract(normalize(-viewDir), normal, 1.0 / ior); vec3 refractionDir = refract(-viewDir, normal, 1.0 / ior);
vec3 P = origin + refractionDir * (BayerMatrix8[int(pixel.x + velocity.x) % 8][int(pixel.y + velocity.y) % 8] - 0.5) * voxelgiStep; vec3 P = origin + refractionDir * (BayerMatrix8[int(pixel.x + velocity.x) % 8][int(pixel.y + velocity.y) % 8] - 0.5) * voxelgiStep;
vec4 amount = transmittance * traceCone(voxels, voxelsSDF, P, normal, refractionDir, 0, true, roughness, voxelgiStep, clipmaps); vec4 amount = transmittance * traceCone(voxels, voxelsSDF, P, normal, refractionDir, 0, true, roughness, voxelgiStep, clipmaps);
@ -328,8 +328,8 @@ float traceConeShadow(const sampler3D voxels, const sampler3D voxelsSDF, const v
} }
float traceShadow(const vec3 origin, const vec3 normal, const sampler3D voxels, const sampler3D voxelsSDF, const vec3 dir, const float clipmaps[voxelgiClipmapCount * 10], const vec2 pixel, const vec2 velocity) { float traceShadow(const vec3 origin, const vec3 normal, const sampler3D voxels, const sampler3D voxelsSDF, const vec3 dir, const float clipmaps[voxelgiClipmapCount * 10], const vec2 pixel) {
vec3 P = origin + dir * (BayerMatrix8[int(pixel.x + velocity.x) % 8][int(pixel.y + velocity.y) % 8] - 0.5) * voxelgiStep; vec3 P = origin + dir * (BayerMatrix8[int(pixel.x) % 8][int(pixel.y) % 8] - 0.5) * voxelgiStep;
float amount = traceConeShadow(voxels, voxelsSDF, P, normal, dir, DIFFUSE_CONE_APERTURE, voxelgiStep, clipmaps); float amount = traceConeShadow(voxels, voxelsSDF, P, normal, dir, DIFFUSE_CONE_APERTURE, voxelgiStep, clipmaps);
amount = clamp(amount, 0.0, 1.0); amount = clamp(amount, 0.0, 1.0);
return amount * voxelgiOcc; return amount * voxelgiOcc;

View File

@ -9,9 +9,7 @@
#endif #endif
#ifdef _VoxelShadow #ifdef _VoxelShadow
#include "std/conetrace.glsl" #include "std/conetrace.glsl"
#endif //!uniform sampler2D voxels_shadows;
#ifdef _gbuffer2
uniform sampler2D gbuffer2;
#endif #endif
#ifdef _LTC #ifdef _LTC
#include "std/ltc.glsl" #include "std/ltc.glsl"
@ -148,8 +146,7 @@ vec3 sampleLight(const vec3 p, const vec3 n, const vec3 v, const float dotNV, co
#endif #endif
#ifdef _VoxelShadow #ifdef _VoxelShadow
vec4 g2 = textureLod(gbuffer2, gl_FragCoord.xy, 0.0); direct *= (1.0 - traceShadow(p, n, voxels, voxelsSDF, l, clipmaps, gl_FragCoord.xy).r) * voxelgiShad;
direct *= (1.0 - traceShadow(p, n, voxels, voxelsSDF, l, clipmaps, gl_FragCoord.xy, g2.rg).r) * voxelgiShad;
#endif #endif
#ifdef _LTC #ifdef _LTC

View File

@ -87,6 +87,40 @@ float lpToDepth(vec3 lp, const vec2 lightProj) {
return zcomp * 0.5 + 0.5; return zcomp * 0.5 + 0.5;
} }
#ifndef _ShadowMapAtlas
vec3 PCFCube(samplerCubeShadow shadowMapCube, samplerCube shadowMapCubeTransparent, vec3 lp, vec3 ml, float bias, vec2 lightProj, vec3 n, const bool transparent) {
const float s = shadowmapCubePcfSize;
float compare = lpToDepth(lp, lightProj) - bias * 1.5;
ml = ml + n * bias * 20;
#ifdef _InvY
ml.y = -ml.y;
#endif
float shadowFactor = 0.0;
shadowFactor = texture(shadowMapCube, vec4(ml, compare));
shadowFactor += texture(shadowMapCube, vec4(ml + vec3(s, s, s), compare));
shadowFactor += texture(shadowMapCube, vec4(ml + vec3(-s, s, s), compare));
shadowFactor += texture(shadowMapCube, vec4(ml + vec3(s, -s, s), compare));
shadowFactor += texture(shadowMapCube, vec4(ml + vec3(s, s, -s), compare));
shadowFactor += texture(shadowMapCube, vec4(ml + vec3(-s, -s, s), compare));
shadowFactor += texture(shadowMapCube, vec4(ml + vec3(s, -s, -s), compare));
shadowFactor += texture(shadowMapCube, vec4(ml + vec3(-s, s, -s), compare));
shadowFactor += texture(shadowMapCube, vec4(ml + vec3(-s, -s, -s), compare));
shadowFactor /= 9.0;
vec3 result = vec3(shadowFactor);
if (transparent == false) {
vec4 shadowmap_transparent = texture(shadowMapCubeTransparent, ml);
if (shadowmap_transparent.a < compare)
result *= shadowmap_transparent.rgb;
}
return result;
}
#endif
#ifdef _ShadowMapAtlas
vec3 PCFCube(samplerCubeShadow shadowMapCube, samplerCube shadowMapCubeTransparent, const vec3 lp, vec3 ml, const float bias, const vec2 lightProj, const vec3 n, const bool transparent) { vec3 PCFCube(samplerCubeShadow shadowMapCube, samplerCube shadowMapCubeTransparent, const vec3 lp, vec3 ml, const float bias, const vec2 lightProj, const vec3 n, const bool transparent) {
const float s = shadowmapCubePcfSize; // TODO: incorrect... const float s = shadowmapCubePcfSize; // TODO: incorrect...
float compare = lpToDepth(lp, lightProj) - bias * 1.5; float compare = lpToDepth(lp, lightProj) - bias * 1.5;
@ -115,7 +149,7 @@ vec3 PCFCube(samplerCubeShadow shadowMapCube, samplerCube shadowMapCubeTranspare
return result; return result;
} }
#ifdef _ShadowMapAtlas
// transform "out-of-bounds" coordinates to the correct face/coordinate system // transform "out-of-bounds" coordinates to the correct face/coordinate system
// https://www.khronos.org/opengl/wiki/File:CubeMapAxes.png // https://www.khronos.org/opengl/wiki/File:CubeMapAxes.png
vec2 transformOffsetedUV(const int faceIndex, out int newFaceIndex, vec2 uv) { vec2 transformOffsetedUV(const int faceIndex, out int newFaceIndex, vec2 uv) {

View File

@ -33,7 +33,6 @@ uniform layout(r32ui) uimage3D voxelsLight;
#ifdef _ShadowMap #ifdef _ShadowMap
uniform sampler2DShadow shadowMap; uniform sampler2DShadow shadowMap;
uniform sampler2D shadowMapTransparent;
uniform sampler2DShadow shadowMapSpot; uniform sampler2DShadow shadowMapSpot;
#ifdef _ShadowMapAtlas #ifdef _ShadowMapAtlas
uniform sampler2DShadow shadowMapPoint; uniform sampler2DShadow shadowMapPoint;
@ -87,22 +86,27 @@ float lpToDepth(vec3 lp, const vec2 lightProj) {
void main() { void main() {
int res = voxelgiResolution.x; int res = voxelgiResolution.x;
for (int i = 0; i < 6; i++) {
ivec3 dst = ivec3(gl_GlobalInvocationID.xyz); ivec3 dst = ivec3(gl_GlobalInvocationID.xyz);
dst.y += clipmapLevel * res;
vec3 P = (gl_GlobalInvocationID.xyz + 0.5) / voxelgiResolution; vec3 P = (gl_GlobalInvocationID.xyz + 0.5) / voxelgiResolution;
P = P * 2.0 - 1.0; P = P * 2.0 - 1.0;
P *= clipmaps[int(clipmapLevel * 10)];
P *= voxelgiResolution;
P += vec3(clipmaps[int(clipmapLevel * 10 + 4)], clipmaps[int(clipmapLevel * 10 + 5)], clipmaps[int(clipmapLevel * 10 + 6)]);
float visibility; vec3 visibility;
vec3 lp = lightPos - P; vec3 lp = lightPos - P;
vec3 l; vec3 l;
if (lightType == 0) { l = lightDir; visibility = 1.0; } if (lightType == 0) { l = lightDir; visibility = vec3(1.0); }
else { l = normalize(lp); visibility = attenuate(distance(P, lightPos)); } else { l = normalize(lp); visibility = vec3(attenuate(distance(P, lightPos))); }
#ifdef _ShadowMap #ifdef _ShadowMap
if (lightShadow == 1) { if (lightShadow == 1) {
vec4 lightPosition = LVP * vec4(P, 1.0); vec4 lightPosition = LVP * vec4(P, 1.0);
vec3 lPos = lightPosition.xyz / lightPosition.w; vec3 lPos = lightPosition.xyz / lightPosition.w;
visibility = texture(shadowMap, vec3(lPos.xy, lPos.z - shadowsBias)).r; visibility = texture(shadowMap, vec3(lPos.xy, lPos.z - shadowsBias)).rrr;
} }
else if (lightShadow == 2) { else if (lightShadow == 2) {
vec4 lightPosition = LVP * vec4(P, 1.0); vec4 lightPosition = LVP * vec4(P, 1.0);
@ -124,14 +128,11 @@ void main() {
visibility *= texture(shadowMapPoint, vec4(-l, lpToDepth(lp, lightProj) - shadowsBias)).r; visibility *= texture(shadowMapPoint, vec4(-l, lpToDepth(lp, lightProj) - shadowsBias)).r;
#endif #endif
} }
#endif #endif
vec3 uvw_light = (P - vec3(clipmaps[int(clipmapLevel * 10 + 4)], clipmaps[int(clipmapLevel * 10 + 5)], clipmaps[int(clipmapLevel * 10 + 6)])) / (float(clipmaps[int(clipmapLevel * 10)]) * voxelgiResolution);
uvw_light = (uvw_light * 0.5 + 0.5);
if (any(notEqual(uvw_light, clamp(uvw_light, 0.0, 1.0)))) return;
vec3 writecoords_light = floor(uvw_light * voxelgiResolution);
imageAtomicMax(voxelsLight, ivec3(writecoords_light), uint(visibility * lightColor.r * 255)); vec3 light = visibility * lightColor;
imageAtomicMax(voxelsLight, ivec3(writecoords_light) + ivec3(0, 0, voxelgiResolution.x), uint(visibility * lightColor.g * 255));
imageAtomicMax(voxelsLight, ivec3(writecoords_light) + ivec3(0, 0, voxelgiResolution.x * 2), uint(visibility * lightColor.b * 255)); imageAtomicAdd(voxelsLight, dst + ivec3(0, 0, 0), uint(light.r * 255));
} imageAtomicAdd(voxelsLight, dst + ivec3(0, 0, voxelgiResolution.x), uint(light.g * 255));
imageAtomicAdd(voxelsLight, dst + ivec3(0, 0, voxelgiResolution.x * 2), uint(light.b * 255));
} }

View File

@ -33,7 +33,7 @@ layout (local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
uniform sampler3D voxels; uniform sampler3D voxels;
uniform sampler2D gbufferD; uniform sampler2D gbufferD;
uniform sampler2D gbuffer0; uniform sampler2D gbuffer0;
uniform layout(r16) image2D voxels_ao; uniform layout(r8) image2D voxels_ao;
uniform float clipmaps[voxelgiClipmapCount * 10]; uniform float clipmaps[voxelgiClipmapCount * 10];
uniform mat4 InvVP; uniform mat4 InvVP;

View File

@ -33,7 +33,7 @@ layout (local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
uniform sampler3D voxels; uniform sampler3D voxels;
uniform sampler2D gbufferD; uniform sampler2D gbufferD;
uniform sampler2D gbuffer0; uniform sampler2D gbuffer0;
uniform layout(rgba16) image2D voxels_diffuse; uniform layout(rgba8) image2D voxels_diffuse;
uniform float clipmaps[voxelgiClipmapCount * 10]; uniform float clipmaps[voxelgiClipmapCount * 10];
uniform mat4 InvVP; uniform mat4 InvVP;
@ -46,7 +46,7 @@ void main() {
const vec2 pixel = gl_GlobalInvocationID.xy; const vec2 pixel = gl_GlobalInvocationID.xy;
vec2 uv = (pixel + 0.5) / postprocess_resolution; vec2 uv = (pixel + 0.5) / postprocess_resolution;
#ifdef _InvY #ifdef _InvY
uv.y = 1.0 - uv.y; uv.y = 1.0 - uv.y
#endif #endif
float depth = textureLod(gbufferD, uv, 0.0).r * 2.0 - 1.0; float depth = textureLod(gbufferD, uv, 0.0).r * 2.0 - 1.0;

View File

@ -34,7 +34,7 @@ uniform sampler2D gbufferD;
uniform sampler2D gbuffer0; uniform sampler2D gbuffer0;
uniform sampler3D voxels; uniform sampler3D voxels;
uniform sampler3D voxelsSDF; uniform sampler3D voxelsSDF;
uniform layout(rgba16) image2D voxels_specular; uniform layout(rgba8) image2D voxels_specular;
uniform float clipmaps[voxelgiClipmapCount * 10]; uniform float clipmaps[voxelgiClipmapCount * 10];
uniform mat4 InvVP; uniform mat4 InvVP;
@ -71,7 +71,7 @@ void main() {
vec2 velocity = -textureLod(sveloc, uv, 0.0).rg; vec2 velocity = -textureLod(sveloc, uv, 0.0).rg;
vec3 color = traceSpecular(P, n, voxels, voxelsSDF, normalize(eye - P), g0.z * g0.z, clipmaps, pixel, velocity).rgb; vec3 color = traceSpecular(P, n, voxels, voxelsSDF, normalize(eye - P), g0.z, clipmaps, pixel, velocity).rgb;
imageStore(voxels_specular, ivec2(pixel), vec4(color, 1.0)); imageStore(voxels_specular, ivec2(pixel), vec4(color, 1.0));
} }

View File

@ -23,8 +23,8 @@ THE SOFTWARE.
#include "compiled.inc" #include "compiled.inc"
uniform layout(r8) image3D input_sdf; uniform layout(r16) image3D input_sdf;
uniform layout(r8) image3D output_sdf; uniform layout(r16) image3D output_sdf;
uniform float jump_size; uniform float jump_size;
uniform int clipmapLevel; uniform int clipmapLevel;

View File

@ -46,15 +46,15 @@ uniform layout(r32ui) uimage3D voxels;
uniform layout(r32ui) uimage3D voxelsLight; uniform layout(r32ui) uimage3D voxelsLight;
uniform layout(rgba8) image3D voxelsB; uniform layout(rgba8) image3D voxelsB;
uniform layout(rgba8) image3D voxelsOut; uniform layout(rgba8) image3D voxelsOut;
uniform layout(r8) image3D SDF; uniform layout(r16) image3D SDF;
#else #else
#ifdef _VoxelAOvar #ifdef _VoxelAOvar
#ifdef _VoxelShadow #ifdef _VoxelShadow
uniform layout(r8) image3D SDF; uniform layout(r16) image3D SDF;
#endif #endif
uniform layout(r32ui) uimage3D voxels; uniform layout(r32ui) uimage3D voxels;
uniform layout(r8) image3D voxelsB; uniform layout(r16) image3D voxelsB;
uniform layout(r8) image3D voxelsOut; uniform layout(r16) image3D voxelsOut;
#endif #endif
#endif #endif
@ -80,6 +80,7 @@ void main() {
light.r = float(imageLoad(voxelsLight, src)) / 255; light.r = float(imageLoad(voxelsLight, src)) / 255;
light.g = float(imageLoad(voxelsLight, src + ivec3(0, 0, voxelgiResolution.x))) / 255; light.g = float(imageLoad(voxelsLight, src + ivec3(0, 0, voxelgiResolution.x))) / 255;
light.b = float(imageLoad(voxelsLight, src + ivec3(0, 0, voxelgiResolution.x * 2))) / 255; light.b = float(imageLoad(voxelsLight, src + ivec3(0, 0, voxelgiResolution.x * 2))) / 255;
light /= 3;
#endif #endif
for (int i = 0; i < 6 + DIFFUSE_CONE_COUNT; i++) for (int i = 0; i < 6 + DIFFUSE_CONE_COUNT; i++)
@ -124,7 +125,7 @@ void main() {
envl.g = float(imageLoad(voxels, src + ivec3(0, 0, voxelgiResolution.x * 10))) / 255; envl.g = float(imageLoad(voxels, src + ivec3(0, 0, voxelgiResolution.x * 10))) / 255;
envl.b = float(imageLoad(voxels, src + ivec3(0, 0, voxelgiResolution.x * 11))) / 255; envl.b = float(imageLoad(voxels, src + ivec3(0, 0, voxelgiResolution.x * 11))) / 255;
envl /= 3; envl /= 3;
envl *= 100;
//clipmap to world //clipmap to world
vec3 wposition = (gl_GlobalInvocationID.xyz + 0.5) / voxelgiResolution.x; vec3 wposition = (gl_GlobalInvocationID.xyz + 0.5) / voxelgiResolution.x;
@ -136,7 +137,7 @@ void main() {
radiance = basecol; radiance = basecol;
vec4 trace = traceDiffuse(wposition, wnormal, voxelsSampler, clipmaps); vec4 trace = traceDiffuse(wposition, wnormal, voxelsSampler, clipmaps);
vec3 indirect = trace.rgb + envl.rgb * (1.0 - trace.a); vec3 indirect = trace.rgb + envl.rgb * (1.0 - trace.a);
radiance.rgb *= light / PI + indirect; radiance.rgb *= light + indirect;
radiance.rgb += emission.rgb; radiance.rgb += emission.rgb;
#else #else

View File

@ -75,17 +75,16 @@ vec4 binarySearch(vec3 dir) {
} }
vec4 rayCast(vec3 dir) { vec4 rayCast(vec3 dir) {
float ddepth; #ifdef _CPostprocess
dir *= ss_refractionRayStep; dir *= PPComp9.x;
#else
dir *= ssrRayStep;
#endif
for (int i = 0; i < maxSteps; i++) { for (int i = 0; i < maxSteps; i++) {
hitCoord += dir; hitCoord += dir;
ddepth = getDeltaDepth(hitCoord); if (getDeltaDepth(hitCoord) > 0.0) return binarySearch(dir);
if (ddepth > 0.0)
return binarySearch(dir);
} }
// No hit — fallback to projecting the ray to UV space return vec4(0.0);
vec2 fallbackUV = getProjectedCoord(hitCoord);
return vec4(fallbackUV, 0.0, 0.5); // We set .w lower to indicate fallback
} }
#endif //SSR #endif //SSR

View File

@ -77,9 +77,6 @@ class Inc {
#if (rp_voxels == "Voxel GI") #if (rp_voxels == "Voxel GI")
static var voxel_sh5:kha.compute.Shader = null; static var voxel_sh5:kha.compute.Shader = null;
static var voxel_ta5:kha.compute.TextureUnit; static var voxel_ta5:kha.compute.TextureUnit;
static var voxel_te5:kha.compute.TextureUnit;
static var voxel_tf5:kha.compute.TextureUnit;
static var voxel_tg5:kha.compute.TextureUnit;
static var voxel_ca5:kha.compute.ConstantLocation; static var voxel_ca5:kha.compute.ConstantLocation;
static var voxel_cb5:kha.compute.ConstantLocation; static var voxel_cb5:kha.compute.ConstantLocation;
static var voxel_cc5:kha.compute.ConstantLocation; static var voxel_cc5:kha.compute.ConstantLocation;
@ -680,7 +677,7 @@ class Inc {
} }
else { else {
if (t.name == "voxelsSDF" || t.name == "voxelsSDFtmp") { if (t.name == "voxelsSDF" || t.name == "voxelsSDFtmp") {
t.format = "R8"; t.format = "R16";
t.width = res; t.width = res;
t.height = res * Main.voxelgiClipmapCount; t.height = res * Main.voxelgiClipmapCount;
t.depth = res; t.depth = res;
@ -689,7 +686,7 @@ class Inc {
#if (rp_voxels == "Voxel AO") #if (rp_voxels == "Voxel AO")
{ {
if (t.name == "voxelsOut" || t.name == "voxelsOutB") { if (t.name == "voxelsOut" || t.name == "voxelsOutB") {
t.format = "R8"; t.format = "R16";
t.width = res * (6 + 16); t.width = res * (6 + 16);
t.height = res * Main.voxelgiClipmapCount; t.height = res * Main.voxelgiClipmapCount;
t.depth = res; t.depth = res;
@ -895,9 +892,7 @@ class Inc {
{ {
voxel_sh5 = path.getComputeShader("voxel_light"); voxel_sh5 = path.getComputeShader("voxel_light");
voxel_ta5 = voxel_sh5.getTextureUnit("voxelsLight"); voxel_ta5 = voxel_sh5.getTextureUnit("voxelsLight");
voxel_te5 = voxel_sh5.getTextureUnit("voxels");
voxel_tf5 = voxel_sh5.getTextureUnit("voxelsSampler");
voxel_tg5 = voxel_sh5.getTextureUnit("voxelsSDFSampler");
voxel_ca5 = voxel_sh5.getConstantLocation("clipmaps"); voxel_ca5 = voxel_sh5.getConstantLocation("clipmaps");
voxel_cb5 = voxel_sh5.getConstantLocation("clipmapLevel"); voxel_cb5 = voxel_sh5.getConstantLocation("clipmapLevel");
@ -1218,7 +1213,7 @@ class Inc {
kha.compute.Compute.setSampledTexture(voxel_td4, rts.get("voxelsSDF").image); kha.compute.Compute.setSampledTexture(voxel_td4, rts.get("voxelsSDF").image);
kha.compute.Compute.setTexture(voxel_te4, rts.get("voxels_specular").image, kha.compute.Access.Write); kha.compute.Compute.setTexture(voxel_te4, rts.get("voxels_specular").image, kha.compute.Access.Write);
kha.compute.Compute.setSampledTexture(voxel_tf4, rts.get("gbuffer2").image); //kha.compute.Compute.setSampledTexture(voxel_tf4, rts.get("gbuffer2").image);
var fa:Float32Array = new Float32Array(Main.voxelgiClipmapCount * 10); var fa:Float32Array = new Float32Array(Main.voxelgiClipmapCount * 10);
for (i in 0...Main.voxelgiClipmapCount) { for (i in 0...Main.voxelgiClipmapCount) {
@ -1293,9 +1288,7 @@ class Inc {
kha.compute.Compute.setShader(voxel_sh5); kha.compute.Compute.setShader(voxel_sh5);
kha.compute.Compute.setTexture(voxel_ta5, rts.get("voxelsLight").image, kha.compute.Access.Write); kha.compute.Compute.setTexture(voxel_ta5, rts.get("voxelsLight").image, kha.compute.Access.Write);
kha.compute.Compute.setTexture(voxel_te5, rts.get("voxels").image, kha.compute.Access.Read);
kha.compute.Compute.setSampledTexture(voxel_tf5, rts.get("voxelsOut").image);
kha.compute.Compute.setSampledTexture(voxel_tg5, rts.get("voxelsSDF").image);
var fa:Float32Array = new Float32Array(Main.voxelgiClipmapCount * 10); var fa:Float32Array = new Float32Array(Main.voxelgiClipmapCount * 10);
for (i in 0...Main.voxelgiClipmapCount) { for (i in 0...Main.voxelgiClipmapCount) {
fa[i * 10] = clipmaps[i].voxelSize; fa[i * 10] = clipmaps[i].voxelSize;

View File

@ -368,7 +368,7 @@ class RenderPathDeferred {
t.scale = Inc.getSuperSampling(); t.scale = Inc.getSuperSampling();
path.createRenderTarget(t); path.createRenderTarget(t);
// holds background color // holds background depth
var t = new RenderTargetRaw(); var t = new RenderTargetRaw();
t.name = "refr"; t.name = "refr";
t.width = 0; t.width = 0;
@ -473,13 +473,6 @@ class RenderPathDeferred {
} }
#end #end
#if rp_ssrefr
{
path.setTarget("gbuffer_refraction");
path.clearTarget(0xffffff00);
}
#end
RenderPathCreator.setTargetMeshes(); RenderPathCreator.setTargetMeshes();
#if rp_dynres #if rp_dynres
@ -844,7 +837,7 @@ class RenderPathDeferred {
{ {
path.bindTarget("voxelsOut", "voxels"); path.bindTarget("voxelsOut", "voxels");
path.bindTarget("voxelsSDF", "voxelsSDF"); path.bindTarget("voxelsSDF", "voxelsSDF");
path.bindTarget("gbuffer2", "gbuffer2"); path.bindTarget("gbuffer2", "sveloc");
} }
#end #end

View File

@ -522,17 +522,6 @@ class RenderPathForward {
path.setTarget("lbuffer0", ["lbuffer1", "gbuffer_refraction"]); path.setTarget("lbuffer0", ["lbuffer1", "gbuffer_refraction"]);
#if rp_shadowmap
{
#if lnx_shadowmap_atlas
Inc.bindShadowMapAtlas();
#else
Inc.bindShadowMap();
#end
}
#end
#if (rp_voxels != "Off") #if (rp_voxels != "Off")
path.bindTarget("voxelsOut", "voxels"); path.bindTarget("voxelsOut", "voxels");
path.bindTarget("voxelsSDF", "voxelsSDF"); path.bindTarget("voxelsSDF", "voxelsSDF");

View File

@ -41,11 +41,7 @@ class Starter {
try { try {
#end #end
kha.System.start({title: Main.projectName, width: c.window_w, height: c.window_h, window: { kha.System.start({title: Main.projectName, width: c.window_w, height: c.window_h, window: {mode: windowMode, windowFeatures: windowFeatures}, framebuffer: {samplesPerPixel: c.window_msaa, verticalSync: c.window_vsync}}, function(window: kha.Window) {
#if lnx_render_viewport
visible: false,
#end
mode: windowMode, windowFeatures: windowFeatures}, framebuffer: {samplesPerPixel: c.window_msaa, verticalSync: c.window_vsync}}, function(window: kha.Window) {
iron.App.init(function() { iron.App.init(function() {
#if lnx_loadscreen #if lnx_loadscreen

View File

@ -306,8 +306,8 @@ def build():
assets.add_khafile_def('rp_ssgi={0}'.format(rpdat.rp_ssgi)) assets.add_khafile_def('rp_ssgi={0}'.format(rpdat.rp_ssgi))
if rpdat.rp_ssgi != 'Off': if rpdat.rp_ssgi != 'Off':
if rpdat.rp_ssgi == 'SSAO':
wrd.world_defs += '_SSAO' wrd.world_defs += '_SSAO'
if rpdat.rp_ssgi == 'SSAO':
assets.add_shader_pass('ssao_pass') assets.add_shader_pass('ssao_pass')
assets.add_shader_pass('blur_edge_pass') assets.add_shader_pass('blur_edge_pass')
else: else:
@ -456,7 +456,7 @@ def build():
if ignoreIrr: if ignoreIrr:
wrd.world_defs += '_IgnoreIrr' wrd.world_defs += '_IgnoreIrr'
gbuffer2 = '_Veloc' in wrd.world_defs or '_IgnoreIrr' in wrd.world_defs or '_VoxelGI' in wrd.world_defs or '_VoxelShadow' in wrd.world_defs gbuffer2 = '_Veloc' in wrd.world_defs or '_IgnoreIrr' in wrd.world_defs
if gbuffer2: if gbuffer2:
assets.add_khafile_def('rp_gbuffer2') assets.add_khafile_def('rp_gbuffer2')
wrd.world_defs += '_gbuffer2' wrd.world_defs += '_gbuffer2'

View File

@ -331,6 +331,9 @@ def parse_sky_hosekwilkie(node: bpy.types.ShaderNodeTexSky, state: ParserState)
world = state.world world = state.world
curshader = state.curshader curshader = state.curshader
# Match to cycles
world.lnx_envtex_strength *= 0.1
assets.add_khafile_def('lnx_hosek') assets.add_khafile_def('lnx_hosek')
curshader.add_uniform('vec3 A', link="_hosekA") curshader.add_uniform('vec3 A', link="_hosekA")
curshader.add_uniform('vec3 B', link="_hosekB") curshader.add_uniform('vec3 B', link="_hosekB")

View File

@ -102,9 +102,9 @@ def write(vert: shader.Shader, frag: shader.Shader):
if '_MicroShadowing' in wrd.world_defs and not is_mobile: if '_MicroShadowing' in wrd.world_defs and not is_mobile:
frag.write('\t, occlusion') frag.write('\t, occlusion')
if '_SSRS' in wrd.world_defs: if '_SSRS' in wrd.world_defs:
frag.add_uniform('sampler2D gbufferD', top=True)
frag.add_uniform('mat4 invVP', '_inverseViewProjectionMatrix') frag.add_uniform('mat4 invVP', '_inverseViewProjectionMatrix')
frag.add_uniform('vec3 eye', '_cameraPosition') frag.add_uniform('vec3 eye', '_cameraPosition')
frag.add_uniform('sampler2D gbufferD', link='_gbufferD', top=True)
frag.write(', gbufferD, invVP, eye') frag.write(', gbufferD, invVP, eye')
frag.write(');') frag.write(');')

View File

@ -609,11 +609,9 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False):
frag.write_attrib('float dotNV = max(dot(n, vVec), 0.0);') frag.write_attrib('float dotNV = max(dot(n, vVec), 0.0);')
sh = tese if tese is not None else vert sh = tese if tese is not None else vert
sh.add_uniform('mat4 W', '_worldMatrix')
sh.write_attrib('vec3 wposition = vec4(W * spos).xyz;')
sh.add_out('vec3 eyeDir') sh.add_out('vec3 eyeDir')
sh.add_uniform('vec3 eye', '_cameraPosition') sh.add_uniform('vec3 eye', '_cameraPosition')
sh.write('eyeDir = eye - wposition;') sh.write('eyeDir = eye - spos.xyz;')
frag.add_include('std/light.glsl') frag.add_include('std/light.glsl')
is_shadows = '_ShadowMap' in wrd.world_defs is_shadows = '_ShadowMap' in wrd.world_defs
@ -668,23 +666,17 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False):
frag.write('envl *= envmapStrength * occlusion;') frag.write('envl *= envmapStrength * occlusion;')
if '_VoxelAOvar' in wrd.world_defs or '_VoxelGI' in wrd.world_defs: if '_VoxelAOvar' in wrd.world_defs or '_VoxelGI' in wrd.world_defs:
if parse_opacity or '_VoxelShadow' in wrd.world_defs:
frag.add_include('std/conetrace.glsl') frag.add_include('std/conetrace.glsl')
frag.add_uniform('sampler3D voxels') frag.add_uniform('sampler3D voxels')
frag.add_uniform('sampler3D voxelsSDF') frag.add_uniform('sampler3D voxelsSDF')
frag.add_uniform('vec3 eye', '_cameraPosition') frag.add_uniform('vec3 eye', "_cameraPosition")
frag.add_uniform('float clipmaps[10 * voxelgiClipmapCount]', '_clipmaps') frag.add_uniform('float clipmaps[10 * voxelgiClipmapCount]', '_clipmaps')
vert.add_out('vec4 wvpposition') vert.add_out('vec4 wvpposition')
vert.write('wvpposition = gl_Position;') vert.write('wvpposition = gl_Position;')
frag.write('vec2 texCoord = (wvpposition.xy / wvpposition.w) * 0.5 + 0.5;') frag.write('vec2 texCoord = (wvpposition.xy / wvpposition.w) * 0.5 + 0.5;')
if '_VoxelGI' in wrd.world_defs or '_VoxelShadow' in wrd.world_defs or '_VoxelRefract' in wrd.world_defs: if '_VoxelAOvar' in wrd.world_defs and not parse_opacity:
frag.add_uniform('sampler2D gbuffer2', included=True)
frag.write('vec2 velocity = -textureLod(gbuffer2, gl_FragCoord.xy, 0.0).rg;')
if '_VoxelAOvar' in wrd.world_defs:
if parse_opacity:
frag.write('envl *= 1.0 - traceAO(wposition, n, voxels, clipmaps);')
else:
frag.add_uniform("sampler2D voxels_ao"); frag.add_uniform("sampler2D voxels_ao");
frag.write('envl *= textureLod(voxels_ao, texCoord, 0.0).rrr;') frag.write('envl *= textureLod(voxels_ao, texCoord, 0.0).rrr;')
@ -695,10 +687,12 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False):
if '_VoxelGI' in wrd.world_defs: if '_VoxelGI' in wrd.world_defs:
if parse_opacity: if parse_opacity:
frag.write('vec4 indirect_diffuse = traceDiffuse(wposition, n, voxels, clipmaps);') frag.write('vec4 trace = traceDiffuse(wposition, wnormal, voxels, clipmaps);')
frag.write('indirect = (indirect_diffuse.rgb * albedo + envl.rgb * (1.0 - indirect_diffuse.a)) * voxelgiDiff;') frag.write('indirect = ((trace.rgb * albedo + envl * (1.0 - trace.a)) * voxelgiDiff);')
frag.write('if (roughness < 1.0 && specular > 0.0) {') frag.write('if (roughness < 1.0 && specular > 0.0){')
frag.write(' indirect += traceSpecular(wposition, n, voxels, voxelsSDF, vVec, roughness * roughness, clipmaps, gl_FragCoord.xy, velocity).rgb * specular * voxelgiRefl; }') frag.add_uniform('sampler2D sveloc')
frag.write(' vec2 velocity = -textureLod(sveloc, gl_FragCoord.xy, 0.0).rg;')
frag.write(' indirect += traceSpecular(wposition, n, voxels, voxelsSDF, vVec, roughness, clipmaps, gl_FragCoord.xy, velocity).rgb * specular * voxelgiRefl;}')
else: else:
frag.add_uniform("sampler2D voxels_diffuse") frag.add_uniform("sampler2D voxels_diffuse")
frag.add_uniform("sampler2D voxels_specular") frag.add_uniform("sampler2D voxels_specular")
@ -752,7 +746,7 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False):
else: else:
frag.write(f'svisibility = PCF({shadowmap_sun}, {shadowmap_sun_tr}, lPos.xy, lPos.z - shadowsBias, smSize, false);') frag.write(f'svisibility = PCF({shadowmap_sun}, {shadowmap_sun_tr}, lPos.xy, lPos.z - shadowsBias, smSize, false);')
if '_VoxelShadow' in wrd.world_defs: if '_VoxelShadow' in wrd.world_defs:
frag.write('svisibility *= (1.0 - traceShadow(wposition, n, voxels, voxelsSDF, sunDir, clipmaps, gl_FragCoord.xy, velocity).r) * voxelgiShad;') frag.write('svisibility *= (1.0 - traceShadow(wposition, n, voxels, voxelsSDF, sunDir, clipmaps, gl_FragCoord.xy).r) * voxelgiShad;')
frag.write('}') # receiveShadow frag.write('}') # receiveShadow
frag.write('direct += (lambertDiffuseBRDF(albedo, sdotNL) + specularBRDF(f0, roughness, sdotNL, sdotNH, dotNV, sdotVH) * specular) * sunCol * svisibility;') frag.write('direct += (lambertDiffuseBRDF(albedo, sdotNL) + specularBRDF(f0, roughness, sdotNL, sdotNH, dotNV, sdotVH) * specular) * sunCol * svisibility;')
# sun # sun
@ -806,9 +800,10 @@ def make_forward_base(con_mesh, parse_opacity=False, transluc_pass=False):
if '_VoxelRefract' in wrd.world_defs and parse_opacity: if '_VoxelRefract' in wrd.world_defs and parse_opacity:
frag.write('if (opacity < 1.0) {') frag.write('if (opacity < 1.0) {')
frag.write(' vec3 refraction = traceRefraction(wposition, n, voxels, voxelsSDF, vVec, ior, roughness, clipmaps, gl_FragCoord.xy, velocity, opacity).rgb * voxelgiRefr;') frag.write(' vec2 velocity = -textureLod(sveloc, gl_FragCoord.xy, 0.0).rg;')
frag.write(' indirect = mix(refraction, indirect, opacity);') frag.write(' vec3 refraction = traceRefraction(wposition, n, voxels, voxelsSDF, vVec, ior, roughness, clipmaps, gl_FragCoord.xy,velocity).rgb;')
frag.write(' direct = mix(refraction, direct, opacity);') frag.write(' indirect = mix(refraction, indirect, opacity) * voxelgiRefr;')
frag.write(' direct = mix(refraction, direct, opacity) * voxelgiRefr;')
frag.write('}') frag.write('}')
def _write_material_attribs_default(frag: shader.Shader, parse_opacity: bool): def _write_material_attribs_default(frag: shader.Shader, parse_opacity: bool):

View File

@ -143,7 +143,6 @@ def make_gi(context_id):
geom.add_out('vec4 lightPosition') geom.add_out('vec4 lightPosition')
geom.add_out('vec4 spotPosition') geom.add_out('vec4 spotPosition')
geom.add_out('vec4 wvpposition') geom.add_out('vec4 wvpposition')
geom.add_out('vec3 eyeDir')
if con_voxel.is_elem('col'): if con_voxel.is_elem('col'):
geom.add_out('vec3 vcolor') geom.add_out('vec3 vcolor')
@ -186,7 +185,6 @@ def make_gi(context_id):
geom.write('mposition = mpositionGeom[i];') geom.write('mposition = mpositionGeom[i];')
if export_bpos: if export_bpos:
geom.write('bposition = bpositionGeom[i];') geom.write('bposition = bpositionGeom[i];')
geom.write(' eyeDir = eyeDirGeom[i];')
geom.write(' gl_Position = voxposition[i];') geom.write(' gl_Position = voxposition[i];')
geom.write(' EmitVertex();') geom.write(' EmitVertex();')
geom.write('}') geom.write('}')
@ -211,9 +209,8 @@ def make_gi(context_id):
frag.write('vec3 albedo = surfaceAlbedo(basecol, metallic);') frag.write('vec3 albedo = surfaceAlbedo(basecol, metallic);')
frag.write('vec3 f0 = surfaceF0(basecol, metallic);') frag.write('vec3 f0 = surfaceF0(basecol, metallic);')
vert.add_uniform('vec3 eye', '_cameraPosition') frag.add_uniform('vec3 eye', '_cameraPosition')
vert.add_out('vec3 eyeDirGeom') frag.write('vec3 eyeDir = eye - wposition;')
vert.write('eyeDirGeom = eye - pos.xyz;')
if '_Brdf' in wrd.world_defs: if '_Brdf' in wrd.world_defs:
frag.add_uniform('sampler2D senvmapBrdf', link='$brdf.png') frag.add_uniform('sampler2D senvmapBrdf', link='$brdf.png')
@ -222,7 +219,7 @@ def make_gi(context_id):
if '_Irr' in wrd.world_defs: if '_Irr' in wrd.world_defs:
frag.add_include('std/shirr.glsl') frag.add_include('std/shirr.glsl')
frag.add_uniform('vec4 shirr[7]', link='_envmapIrradiance') frag.add_uniform('vec4 shirr[7]', link='_envmapIrradiance')
frag.write('vec3 envl = shIrradiance(voxnormal, shirr);') frag.write('vec3 envl = shIrradiance(n, shirr);')
if '_EnvTex' in wrd.world_defs: if '_EnvTex' in wrd.world_defs:
frag.write('envl /= PI;') frag.write('envl /= PI;')
else: else:
@ -231,7 +228,7 @@ def make_gi(context_id):
if '_Rad' in wrd.world_defs: if '_Rad' in wrd.world_defs:
frag.add_uniform('sampler2D senvmapRadiance', link='_envmapRadiance') frag.add_uniform('sampler2D senvmapRadiance', link='_envmapRadiance')
frag.add_uniform('int envmapNumMipmaps', link='_envmapNumMipmaps') frag.add_uniform('int envmapNumMipmaps', link='_envmapNumMipmaps')
frag.write('vec3 reflectionWorld = reflect(-normalize(eyeDir), voxnormal);') frag.write('vec3 reflectionWorld = reflect(-eyeDir, n);')
frag.write('float lod = getMipFromRoughness(roughness, envmapNumMipmaps);') frag.write('float lod = getMipFromRoughness(roughness, envmapNumMipmaps);')
frag.write('vec3 prefilteredColor = textureLod(senvmapRadiance, envMapEquirect(reflectionWorld), lod).rgb;') frag.write('vec3 prefilteredColor = textureLod(senvmapRadiance, envMapEquirect(reflectionWorld), lod).rgb;')
@ -254,7 +251,7 @@ def make_gi(context_id):
frag.write('envl *= envmapStrength * occlusion;') frag.write('envl *= envmapStrength * occlusion;')
frag.write('if (direction_weights.x > 0) {') frag.write('if (direction_weights.x > 0) {')
frag.write(' vec4 basecol_direction = vec4(basecol * direction_weights.x, 1.0);') frag.write(' vec4 basecol_direction = vec4(min(basecol * direction_weights.x, vec3(1.0)), 1.0);')
frag.write(' vec3 emission_direction = emissionCol * direction_weights.x;') frag.write(' vec3 emission_direction = emissionCol * direction_weights.x;')
frag.write(' vec2 normal_direction = encode_oct(N * direction_weights.x) * 0.5 + 0.5;') frag.write(' vec2 normal_direction = encode_oct(N * direction_weights.x) * 0.5 + 0.5;')
frag.write(' vec3 envl_direction = envl * direction_weights.x;') frag.write(' vec3 envl_direction = envl * direction_weights.x;')
@ -273,7 +270,7 @@ def make_gi(context_id):
frag.write('}') frag.write('}')
frag.write('if (direction_weights.y > 0) {') frag.write('if (direction_weights.y > 0) {')
frag.write(' vec4 basecol_direction = vec4(basecol * direction_weights.y, 1.0);') frag.write(' vec4 basecol_direction = vec4(min(basecol * direction_weights.y, vec3(1.0)), 1.0);')
frag.write(' vec3 emission_direction = emissionCol * direction_weights.y;') frag.write(' vec3 emission_direction = emissionCol * direction_weights.y;')
frag.write(' vec2 normal_direction = encode_oct(N * direction_weights.y) * 0.5 + 0.5;') frag.write(' vec2 normal_direction = encode_oct(N * direction_weights.y) * 0.5 + 0.5;')
frag.write(' vec3 envl_direction = envl * direction_weights.y;') frag.write(' vec3 envl_direction = envl * direction_weights.y;')
@ -292,7 +289,7 @@ def make_gi(context_id):
frag.write('}') frag.write('}')
frag.write('if (direction_weights.z > 0) {') frag.write('if (direction_weights.z > 0) {')
frag.write(' vec4 basecol_direction = vec4(basecol * direction_weights.z, 1.0);') frag.write(' vec4 basecol_direction = vec4(min(basecol * direction_weights.z, vec3(1.0)), 1.0);')
frag.write(' vec3 emission_direction = emissionCol * direction_weights.z;') frag.write(' vec3 emission_direction = emissionCol * direction_weights.z;')
frag.write(' vec2 normal_direction = encode_oct(n * direction_weights.z) * 0.5 + 0.5;') frag.write(' vec2 normal_direction = encode_oct(n * direction_weights.z) * 0.5 + 0.5;')
frag.write(' vec3 envl_direction = envl * direction_weights.z;') frag.write(' vec3 envl_direction = envl * direction_weights.z;')

View File

@ -291,7 +291,6 @@ def init_properties():
name="Assertion Level", description="Ignore all assertions below this level (assertions are turned off completely for published builds)", default='Warning', update=assets.invalidate_compiler_cache) name="Assertion Level", description="Ignore all assertions below this level (assertions are turned off completely for published builds)", default='Warning', update=assets.invalidate_compiler_cache)
bpy.types.World.lnx_assert_quit = BoolProperty(name="Quit On Assertion Fail", description="Whether to close the game when an 'Error' level assertion fails", default=False, update=assets.invalidate_compiler_cache) bpy.types.World.lnx_assert_quit = BoolProperty(name="Quit On Assertion Fail", description="Whether to close the game when an 'Error' level assertion fails", default=False, update=assets.invalidate_compiler_cache)
bpy.types.World.lnx_live_patch = BoolProperty(name="Live Patch", description="Live patching for Krom", default=False) bpy.types.World.lnx_live_patch = BoolProperty(name="Live Patch", description="Live patching for Krom", default=False)
bpy.types.World.lnx_render_viewport = BoolProperty(name="Viewport Render", description="Viewport rendering", default=False)
bpy.types.World.lnx_clear_on_compile = BoolProperty(name="Clear Console", description="Clears the system console on compile", default=False) bpy.types.World.lnx_clear_on_compile = BoolProperty(name="Clear Console", description="Clears the system console on compile", default=False)
bpy.types.World.lnx_play_camera = EnumProperty( bpy.types.World.lnx_play_camera = EnumProperty(
items=[('Scene', 'Scene', 'Scene'), items=[('Scene', 'Scene', 'Scene'),

View File

@ -65,7 +65,7 @@ def update_preset(self, context):
rpdat.rp_background = 'World' rpdat.rp_background = 'World'
rpdat.rp_stereo = False rpdat.rp_stereo = False
rpdat.rp_voxelgi_resolution = '32' rpdat.rp_voxelgi_resolution = '32'
rpdat.lnx_voxelgi_size = 0.125 rpdat.lnx_voxelgi_size = 0.25
rpdat.rp_voxels = 'Voxel AO' rpdat.rp_voxels = 'Voxel AO'
rpdat.rp_render_to_texture = True rpdat.rp_render_to_texture = True
rpdat.rp_supersampling = '1' rpdat.rp_supersampling = '1'
@ -142,8 +142,8 @@ def update_preset(self, context):
rpdat.rp_stereo = False rpdat.rp_stereo = False
rpdat.rp_voxels = 'Voxel GI' rpdat.rp_voxels = 'Voxel GI'
rpdat.rp_voxelgi_resolution = '64' rpdat.rp_voxelgi_resolution = '64'
rpdat.lnx_voxelgi_size = 0.125 rpdat.lnx_voxelgi_size = 0.25
rpdat.lnx_voxelgi_step = 0.01 rpdat.lnx_voxelgi_step = 0.25
rpdat.lnx_voxelgi_revoxelize = False rpdat.lnx_voxelgi_revoxelize = False
rpdat.lnx_voxelgi_camera = False rpdat.lnx_voxelgi_camera = False
rpdat.rp_voxelgi_emission = False rpdat.rp_voxelgi_emission = False
@ -531,7 +531,7 @@ class LnxRPListItem(bpy.types.PropertyGroup):
lnx_voxelgi_shad: FloatProperty(name="Shadows", description="Contrast for voxels shadows", default=1.0, update=assets.invalidate_shader_cache) lnx_voxelgi_shad: FloatProperty(name="Shadows", description="Contrast for voxels shadows", default=1.0, update=assets.invalidate_shader_cache)
lnx_voxelgi_occ: FloatProperty(name="Occlusion", description="", default=1.0, update=assets.invalidate_shader_cache) lnx_voxelgi_occ: FloatProperty(name="Occlusion", description="", default=1.0, update=assets.invalidate_shader_cache)
lnx_voxelgi_size: FloatProperty(name="Size", description="Voxel size", default=0.25, update=assets.invalidate_shader_cache) lnx_voxelgi_size: FloatProperty(name="Size", description="Voxel size", default=0.25, update=assets.invalidate_shader_cache)
lnx_voxelgi_step: FloatProperty(name="Step", description="Step size", default=1.0, update=assets.invalidate_shader_cache) lnx_voxelgi_step: FloatProperty(name="Step", description="Step size", default=0.25, update=assets.invalidate_shader_cache)
lnx_voxelgi_range: FloatProperty(name="Range", description="Maximum range", default=100.0, update=assets.invalidate_shader_cache) lnx_voxelgi_range: FloatProperty(name="Range", description="Maximum range", default=100.0, update=assets.invalidate_shader_cache)
lnx_voxelgi_offset: FloatProperty(name="Offset", description="Multiplicative Offset for dealing with self occlusion", default=1.0, update=assets.invalidate_shader_cache) lnx_voxelgi_offset: FloatProperty(name="Offset", description="Multiplicative Offset for dealing with self occlusion", default=1.0, update=assets.invalidate_shader_cache)
lnx_voxelgi_aperture: FloatProperty(name="Aperture", description="Cone aperture for shadow trace", default=0.0, update=assets.invalidate_shader_cache) lnx_voxelgi_aperture: FloatProperty(name="Aperture", description="Cone aperture for shadow trace", default=0.0, update=assets.invalidate_shader_cache)

View File

@ -207,8 +207,6 @@ project.addSources('Sources');
# get instantiated # get instantiated
khafile.write("""project.addParameter("--macro include('leenkx.logicnode')");\n""") khafile.write("""project.addParameter("--macro include('leenkx.logicnode')");\n""")
if wrd.lnx_render_viewport:
assets.add_khafile_def('lnx_render_viewport')
import_traits = list(set(import_traits)) import_traits = list(set(import_traits))
for i in range(0, len(import_traits)): for i in range(0, len(import_traits)):
khafile.write("project.addParameter('" + import_traits[i] + "');\n") khafile.write("project.addParameter('" + import_traits[i] + "');\n")
@ -626,12 +624,26 @@ def write_compiledglsl(defs, make_variants):
idx_emission = 2 idx_emission = 2
idx_refraction = 2 idx_refraction = 2
if '_gbuffer2' in wrd.world_defs: if '_gbuffer2' in wrd.world_defs:
f.write('#define GBUF_IDX_2 2\n') f.write('#define GBUF_IDX_2 2\n')
idx_emission += 1 idx_emission += 1
idx_refraction += 1 idx_refraction += 1
# Special case for WebGL with both TAA and SSRefraction
webgl_with_taa_refr = ('_kha_webgl' in wrd.world_defs and
('_SSRefraction' in wrd.world_defs or '_VoxelRefract' in wrd.world_defs) and
('_TAA' in wrd.world_defs or '_SMAA' in wrd.world_defs))
if webgl_with_taa_refr:
# WebGL needs refraction to come before emission for correct rendering
if '_SSRefraction' in wrd.world_defs or '_VoxelRefract' in wrd.world_defs:
f.write(f'#define GBUF_IDX_REFRACTION {idx_emission}\n')
idx_emission += 1
if '_EmissionShaded' in wrd.world_defs:
f.write(f'#define GBUF_IDX_EMISSION {idx_emission}\n')
else:
# Standard order for all other platforms
if '_EmissionShaded' in wrd.world_defs: if '_EmissionShaded' in wrd.world_defs:
f.write(f'#define GBUF_IDX_EMISSION {idx_emission}\n') f.write(f'#define GBUF_IDX_EMISSION {idx_emission}\n')
idx_refraction += 1 idx_refraction += 1