Skip to content

Commit ede19ee

Browse files
committed
More gles fixes
1 parent 57b9a94 commit ede19ee

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

base/shaders/std/conetrace.glsl

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11

2-
const int voxelgi_resolution = 256;
3-
const vec3 voxelgi_half_extents = vec3(1, 1, 1);
2+
const float voxelgi_resolution = 256.0;
3+
const vec3 voxelgi_half_extents = vec3(1.0, 1.0, 1.0);
44
const float voxelgi_occ = 1.0;
55
const float voxelgi_step = 1.0;
66
const float voxelgi_range = 2.0;
77
const float MAX_DISTANCE = 1.73205080757 * voxelgi_range;
88
const float VOXEL_SIZE = (2.0 / voxelgi_resolution) * voxelgi_step;
99

1010
vec3 tangent(const vec3 n) {
11-
vec3 t1 = cross(n, vec3(0, 0, 1));
12-
vec3 t2 = cross(n, vec3(0, 1, 0));
11+
vec3 t1 = cross(n, vec3(0.0, 0.0, 1.0));
12+
vec3 t2 = cross(n, vec3(0.0, 1.0, 0.0));
1313
if (length(t1) > length(t2)) return normalize(t1);
1414
else return normalize(t2);
1515
}
@@ -23,9 +23,9 @@ float trace_cone_ao(sampler3D voxels, const vec3 origin, vec3 dir, const float a
2323
while (sample_col < 1.0 && dist < max_dist) {
2424
sample_pos = dir * dist + origin;
2525
float mip = max(log2(diam * voxelgi_resolution), 0.0);
26-
float mip_sample = textureLod(voxels, sample_pos * 0.5 + vec3(0.5, 0.5, 0.5), mip).r;
26+
float mip_sample = textureLod(voxels, sample_pos * vec3(0.5, 0.5, 0.5) + vec3(0.5, 0.5, 0.5), mip).r;
2727
sample_col += (1 - sample_col) * mip_sample;
28-
dist += max(diam / 2, VOXEL_SIZE);
28+
dist += max(diam / 2.0, VOXEL_SIZE);
2929
diam = dist * aperture;
3030
}
3131
return sample_col;
@@ -36,12 +36,12 @@ float trace_shadow(sampler3D voxels, const vec3 origin, const vec3 dir) {
3636
}
3737

3838
float trace_ao(const vec3 origin, const vec3 normal, sampler3D voxels) {
39-
const float angle_mix = 0.5f;
39+
const float angle_mix = 0.5;
4040
const float aperture = 0.55785173935;
4141
vec3 o1 = normalize(tangent(normal));
4242
vec3 o2 = normalize(cross(o1, normal));
43-
vec3 c1 = 0.5f * (o1 + o2);
44-
vec3 c2 = 0.5f * (o1 - o2);
43+
vec3 c1 = vec3(0.5, 0.5, 0.5) * (o1 + o2);
44+
vec3 c2 = vec3(0.5, 0.5, 0.5) * (o1 - o2);
4545

4646
#ifdef HLSL
4747
const float factor = voxelgi_occ * 0.93;
@@ -55,6 +55,4 @@ float trace_ao(const vec3 origin, const vec3 normal, sampler3D voxels) {
5555
col += trace_cone_ao(voxels, origin, mix(normal, -c1, angle_mix), aperture, MAX_DISTANCE);
5656
col += trace_cone_ao(voxels, origin, mix(normal, -c2, angle_mix), aperture, MAX_DISTANCE);
5757
return (col / 5.0) * factor;
58-
59-
return 0.0;
6058
}

base/shaders/std/deferred_light.glsl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ vec3 sample_light(const vec3 p, const vec3 n, const vec3 v, const float dotnv, c
213213
direct *= clamp(dotnl + 2.0 * occ * occ - 1.0, 0.0, 1.0); // Micro shadowing
214214

215215
#ifdef _Voxel
216-
direct *= 1.0 - trace_shadow(voxels, voxpos, l);
216+
float voxshadow = 1.0 - trace_shadow(voxels, voxpos, l);
217+
direct *= vec3(voxshadow, voxshadow, voxshadow);
217218
#endif
218219

219220
return direct;
@@ -262,7 +263,8 @@ void main() {
262263

263264
#ifdef _Voxel
264265
vec3 voxpos = p / voxelgi_half_extents;
265-
envl.rgb *= 1.0 - trace_ao(voxpos, n, voxels);
266+
float voxao = 1.0 - trace_ao(voxpos, n, voxels);
267+
envl.rgb *= vec3(voxao, voxao, voxao);
266268
#endif
267269

268270
frag_color.rgb = envl;

0 commit comments

Comments
 (0)