Skip to content

Commit

Permalink
use r8 and rgba32 images for voxelsOut/B and use a constant multiplie…
Browse files Browse the repository at this point in the history
…r of 100 for envMapStrength
  • Loading branch information
e2002e committed Jul 23, 2024
1 parent 6ddd2e4 commit b837159
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 33 deletions.
8 changes: 4 additions & 4 deletions Shaders/voxel_offsetprev/voxel_offsetprev.comp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in;
#include "std/voxels_constants.glsl"

#ifdef _VoxelGI
uniform layout(rgba16) image3D voxelsB;
uniform layout(rgba16) image3D voxelsOut;
uniform layout(rgba8) image3D voxelsB;
uniform layout(rgba8) image3D voxelsOut;
#else
uniform layout(r16) image3D voxelsB;
uniform layout(r16) image3D voxelsOut;
uniform layout(r8) image3D voxelsB;
uniform layout(r8) image3D voxelsOut;
#endif

uniform int clipmapLevel;
Expand Down
2 changes: 1 addition & 1 deletion Shaders/voxel_resolve_ao/voxel_resolve_ao.comp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void main() {
n.xy = n.z >= 0.0 ? g0.xy : octahedronWrap(g0.xy);
n = normalize(n);

float occ = traceAO(P, n, voxels, clipmaps);
float occ = 1.0 - traceAO(P, n, voxels, clipmaps);

imageStore(voxels_ao, ivec2(pixel), vec4(occ));
}
4 changes: 2 additions & 2 deletions Shaders/voxel_sdf_jumpflood/voxel_sdf_jumpflood.comp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ THE SOFTWARE.

#include "compiled.inc"

uniform layout(r16) image3D input_sdf;
uniform layout(r16) image3D output_sdf;
uniform layout(r8) image3D input_sdf;
uniform layout(r8) image3D output_sdf;

uniform float jump_size;
uniform int clipmapLevel;
Expand Down
17 changes: 8 additions & 9 deletions Shaders/voxel_temporal/voxel_temporal.comp.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ uniform sampler3D voxelsSampler;
uniform sampler3D voxelsSDFSampler;
uniform layout(r32ui) uimage3D voxels;
uniform layout(r32ui) uimage3D voxelsLight;
uniform layout(rgba16) image3D voxelsB;
uniform layout(rgba16) image3D voxelsOut;
uniform layout(rgba16) image3D voxelsBounce;
uniform layout(rgba8) image3D voxelsB;
uniform layout(rgba8) image3D voxelsOut;
#ifdef _ShadowMap
uniform sampler2DShadow shadowMap;
uniform sampler2DShadow shadowMapSpot;
Expand Down Expand Up @@ -77,15 +76,15 @@ uniform vec3 eye;
uniform vec3 eyeLook;
uniform vec3 viewRay;
uniform vec2 cameraProj;
uniform layout(r16) image3D SDF;
uniform layout(r8) image3D SDF;
#else
#ifdef _VoxelAOvar
#ifdef _VoxelShadow
uniform layout(r16) image3D SDF;
uniform layout(r8) image3D SDF;
#endif
uniform layout(r32ui) uimage3D voxels;
uniform layout(r16) image3D voxelsB;
uniform layout(r16) image3D voxelsOut;
uniform layout(r8) image3D voxelsB;
uniform layout(r8) image3D voxelsOut;
#endif
#endif

Expand Down Expand Up @@ -208,15 +207,15 @@ void main() {
envl.rgb *= backgroundCol * (f0 * envBRDF.x + envBRDF.y);
#endif
#endif
envl *= envmapStrength;
envl *= envmapStrength * 100;
#else
vec3 envl = vec3(0.0);
#endif

radiance = basecol;
vec4 trace = traceDiffuse(wposition, wnormal, voxelsSampler, clipmaps);
vec3 diffuse_indirect = trace.rgb + envl * (1.0 - trace.a);
radiance.rgb *= max(light, envmapStrength * trace.a) / PI * diffuse_indirect;
radiance.rgb *= light / PI + diffuse_indirect;
radiance.rgb += emission.rgb;
#else
opac = float(imageLoad(voxels, src)) / 255;
Expand Down
6 changes: 3 additions & 3 deletions Sources/armory/renderpath/Inc.hx
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ class Inc {
}
else {
if (t.name == "voxelsSDF" || t.name == "voxelsSDFtmp") {
t.format = "R16";
t.format = "R8";
t.width = res;
t.height = res * Main.voxelgiClipmapCount;
t.depth = res;
Expand All @@ -584,7 +584,7 @@ class Inc {
#if (rp_voxels == "Voxel AO")
{
if (t.name == "voxelsOut" || t.name == "voxelsOutB") {
t.format = "R16";
t.format = "R8";
t.width = res * (6 + 16);
t.height = res * Main.voxelgiClipmapCount;
t.depth = res;
Expand All @@ -599,7 +599,7 @@ class Inc {
#else
{
if (t.name == "voxelsOut" || t.name == "voxelsOutB") {
t.format = "RGBA64";
t.format = "RGBA32";
t.width = res * (6 + 16);
t.height = res * Main.voxelgiClipmapCount;
t.depth = res;
Expand Down
12 changes: 3 additions & 9 deletions Sources/armory/renderpath/RenderPathDeferred.hx
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,7 @@ class RenderPathDeferred {

Inc.computeVoxelsBegin();

if (iron.RenderPath.pre_clear == true)
{
if (iron.RenderPath.pre_clear == true) {
#if (rp_voxels == "Voxel GI")
path.clearImage("voxelsLight", 0x00000000);
#end
Expand All @@ -583,17 +582,11 @@ class RenderPathDeferred {
#end
iron.RenderPath.pre_clear = false;
}
else
{
else {
#if (rp_voxels == "Voxel GI")
path.clearImage("voxelsLight", 0x00000000);
#end
path.clearImage("voxels", 0x00000000);
path.clearImage("voxelsOutB", 0x00000000);
#if (arm_voxelgi_shadows || rp_voxels == "Voxel GI")
path.clearImage("voxelsSDF", 0x00000000);
path.clearImage("voxelsSDFtmp", 0x00000000);
#end
Inc.computeVoxelsOffsetPrev();
}

Expand All @@ -606,6 +599,7 @@ class RenderPathDeferred {
#if (rp_voxels == "Voxel GI")
Inc.computeVoxelsLight();
#end

Inc.computeVoxelsTemporal();

#if (arm_voxelgi_shadows || rp_voxels == "Voxel GI")
Expand Down
5 changes: 0 additions & 5 deletions Sources/armory/renderpath/RenderPathForward.hx
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,6 @@ class RenderPathForward {
path.clearImage("voxelsLight", 0x00000000);
#end
path.clearImage("voxels", 0x00000000);
path.clearImage("voxelsOutB", 0x00000000);
#if (arm_voxelgi_shadows || rp_voxels == "Voxel GI")
path.clearImage("voxelsSDF", 0x00000000);
path.clearImage("voxelsSDFtmp", 0x00000000);
#end
Inc.computeVoxelsOffsetPrev();
}

Expand Down

0 comments on commit b837159

Please sign in to comment.