Skip to content

Commit 2a9711e

Browse files
committed
Add Copyright note to HierarchicalSampleWarping
1 parent 18a2e5d commit 2a9711e

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/org/lwjgl/demo/util/HierarchicalSampleWarping.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/*
2+
* Copyright LWJGL. All rights reserved.
3+
* License terms: https://www.lwjgl.org/license
4+
*/
15
package org.lwjgl.demo.util;
26

37
import org.joml.Vector2f;
@@ -27,22 +31,20 @@ private static int idx(int x, int y, int lod) {
2731
private static float mix(float a, float b, float v) {
2832
return a*(1-v) + b*v;
2933
}
30-
private static float step(float edge, float x) {
31-
return x < edge ? 0 : 1;
34+
private static float step(float edge, float v) {
35+
return v < edge ? 0 : 1;
3236
}
3337

3438
public static Vector2i sample(float[][] levels, Vector2f u, float[] pdf) {
3539
int x = 0, y = 0;
3640
pdf[0] = 1.0f;
3741
for (int lod = 0; lod < levels.length; lod++) {
3842
// here, lod=0 is the _highest_ lod level (with the smallest image dimension)
43+
// so we "ascend" the lod levels from the coarsest to the finest/biggest level.
3944
x <<= 1; y <<= 1;
40-
float s0 = levels[lod][idx(x ,y ,lod)];
41-
float s1 = levels[lod][idx(x+1,y ,lod)];
42-
float s2 = levels[lod][idx(x ,y+1,lod)];
43-
float s3 = levels[lod][idx(x+1,y+1,lod)];
44-
float left = s0 + s2;
45-
float right = s1 + s3;
45+
float s0 = levels[lod][idx(x ,y ,lod)], s1 = levels[lod][idx(x+1,y ,lod)];
46+
float s2 = levels[lod][idx(x ,y+1,lod)], s3 = levels[lod][idx(x+1,y+1,lod)];
47+
float left = s0 + s2, right = s1 + s3;
4648
float pLeft = left / (left + right);
4749
float uxFactor = step(pLeft, u.x);
4850
float pLower = mix(s0 / left, s1 / right, uxFactor);

0 commit comments

Comments
 (0)