Skip to content

Commit

Permalink
fix: depth downsampling on Android (#20)
Browse files Browse the repository at this point in the history
* Ignore .idea IDE folder

* Fix GLSL array construction
  • Loading branch information
StrandedKitty authored Dec 14, 2023
1 parent ae0bbe1 commit fc8fd2c
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
.parcel-cache
.vscode
.idea
*.DS_Store
17 changes: 10 additions & 7 deletions dist/N8AO.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/N8AO.js.map

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions example/N8AO.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/N8AO.js.map

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions example_postprocessing/N8AO.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example_postprocessing/N8AO.js.map

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions src/DepthDownSample.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,11 @@ const DepthDownSample = {
void main() {
vec2 uv = vUv - vec2(0.5) / resolution;
vec2 pixelSize = vec2(1.0) / resolution;
vec2[] uvSamples = vec2[4](
uv,
uv + vec2(pixelSize.x, 0.0),
uv + vec2(0.0, pixelSize.y),
uv + pixelSize
);
vec2[4] uvSamples;
uvSamples[0] = uv;
uvSamples[1] = uv + vec2(pixelSize.x, 0.0);
uvSamples[2] = uv + vec2(0.0, pixelSize.y);
uvSamples[3] = uv + pixelSize;
float depth00 = texture2D(sceneDepth, uvSamples[0]).r;
float depth10 = texture2D(sceneDepth, uvSamples[1]).r;
float depth01 = texture2D(sceneDepth, uvSamples[2]).r;
Expand All @@ -102,7 +101,11 @@ const DepthDownSample = {
targetDepth = maxDepth;
}
int chosenIndex = 0;
float[] samples = float[4](depth00, depth10, depth01, depth11);
float[4] samples;
samples[0] = depth00;
samples[1] = depth10;
samples[2] = depth01;
samples[3] = depth11;
for(int i = 0; i < 4; ++i) {
if (samples[i] == targetDepth) {
chosenIndex = i;
Expand Down

0 comments on commit fc8fd2c

Please sign in to comment.