reze-engine 0.54.4 → 0.54.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shaders/id-api.d.ts.map +1 -1
- package/dist/shaders/id-api.js +24 -6
- package/package.json +1 -1
- package/src/shaders/id-api.ts +24 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id-api.d.ts","sourceRoot":"","sources":["../../src/shaders/id-api.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"id-api.d.ts","sourceRoot":"","sources":["../../src/shaders/id-api.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CA0CzE"}
|
package/dist/shaders/id-api.js
CHANGED
|
@@ -43,18 +43,36 @@ fn rzMaterialAt(uv: vec2f) -> u32 { return 0u; }
|
|
|
43
43
|
return /* wgsl */ `
|
|
44
44
|
@group(${group}) @binding(${binding}) var _rzIdTex: texture_multisampled_2d<u32>;
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* uv to a texel of the id attachment, AND THE Y FLIP IS THE POINT.
|
|
48
|
+
*
|
|
49
|
+
* An effect's uv is origin BOTTOM-LEFT — shadertoy's convention, and what every
|
|
50
|
+
* mount hands the author. A texture's rows run the other way, and the field
|
|
51
|
+
* shader's own derivation says so: uv.y is 1 - fx.y/h. (No backticks in this
|
|
52
|
+
* comment — the whole block is a TS template literal and one would end it.)
|
|
53
|
+
* Multiplying that uv straight into texel coordinates reads the frame upside
|
|
54
|
+
* down.
|
|
55
|
+
*
|
|
56
|
+
* It did, from the day these accessors were written until the first effect
|
|
57
|
+
* actually called one. Nothing caught it because nothing used it — the comment
|
|
58
|
+
* above this pair said as much: the id buffer was written every frame and read
|
|
59
|
+
* by nobody. The first effect to mask by silhouette got her mirrored top to
|
|
60
|
+
* bottom, which draws as blocky shadow in the wrong half of the frame.
|
|
61
|
+
*/
|
|
62
|
+
fn _rzIdTexel(uv: vec2f) -> vec2<i32> {
|
|
63
|
+
let sz = vec2f(textureDimensions(_rzIdTex));
|
|
64
|
+
let flipped = vec2f(clamp(uv.x, 0.0, 1.0), 1.0 - clamp(uv.y, 0.0, 1.0));
|
|
65
|
+
return clamp(vec2<i32>(flipped * sz), vec2<i32>(0), vec2<i32>(sz) - vec2<i32>(1));
|
|
66
|
+
}
|
|
67
|
+
|
|
46
68
|
/** Which OBJECT drew this pixel — compare against rzSubjectId(i). 0 = nothing. */
|
|
47
69
|
fn rzObjectAt(uv: vec2f) -> u32 {
|
|
48
|
-
|
|
49
|
-
let p = vec2<i32>(clamp(uv, vec2f(0.0), vec2f(1.0)) * sz);
|
|
50
|
-
return textureLoad(_rzIdTex, clamp(p, vec2<i32>(0), vec2<i32>(sz) - vec2<i32>(1)), 0).y;
|
|
70
|
+
return textureLoad(_rzIdTex, _rzIdTexel(uv), 0).y;
|
|
51
71
|
}
|
|
52
72
|
|
|
53
73
|
/** Which MATERIAL drew it, within that object. 0 = nothing. */
|
|
54
74
|
fn rzMaterialAt(uv: vec2f) -> u32 {
|
|
55
|
-
|
|
56
|
-
let p = vec2<i32>(clamp(uv, vec2f(0.0), vec2f(1.0)) * sz);
|
|
57
|
-
return textureLoad(_rzIdTex, clamp(p, vec2<i32>(0), vec2<i32>(sz) - vec2<i32>(1)), 0).x;
|
|
75
|
+
return textureLoad(_rzIdTex, _rzIdTexel(uv), 0).x;
|
|
58
76
|
}
|
|
59
77
|
`;
|
|
60
78
|
}
|
package/package.json
CHANGED
package/src/shaders/id-api.ts
CHANGED
|
@@ -44,18 +44,36 @@ fn rzMaterialAt(uv: vec2f) -> u32 { return 0u; }
|
|
|
44
44
|
return /* wgsl */ `
|
|
45
45
|
@group(${group}) @binding(${binding}) var _rzIdTex: texture_multisampled_2d<u32>;
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* uv to a texel of the id attachment, AND THE Y FLIP IS THE POINT.
|
|
49
|
+
*
|
|
50
|
+
* An effect's uv is origin BOTTOM-LEFT — shadertoy's convention, and what every
|
|
51
|
+
* mount hands the author. A texture's rows run the other way, and the field
|
|
52
|
+
* shader's own derivation says so: uv.y is 1 - fx.y/h. (No backticks in this
|
|
53
|
+
* comment — the whole block is a TS template literal and one would end it.)
|
|
54
|
+
* Multiplying that uv straight into texel coordinates reads the frame upside
|
|
55
|
+
* down.
|
|
56
|
+
*
|
|
57
|
+
* It did, from the day these accessors were written until the first effect
|
|
58
|
+
* actually called one. Nothing caught it because nothing used it — the comment
|
|
59
|
+
* above this pair said as much: the id buffer was written every frame and read
|
|
60
|
+
* by nobody. The first effect to mask by silhouette got her mirrored top to
|
|
61
|
+
* bottom, which draws as blocky shadow in the wrong half of the frame.
|
|
62
|
+
*/
|
|
63
|
+
fn _rzIdTexel(uv: vec2f) -> vec2<i32> {
|
|
64
|
+
let sz = vec2f(textureDimensions(_rzIdTex));
|
|
65
|
+
let flipped = vec2f(clamp(uv.x, 0.0, 1.0), 1.0 - clamp(uv.y, 0.0, 1.0));
|
|
66
|
+
return clamp(vec2<i32>(flipped * sz), vec2<i32>(0), vec2<i32>(sz) - vec2<i32>(1));
|
|
67
|
+
}
|
|
68
|
+
|
|
47
69
|
/** Which OBJECT drew this pixel — compare against rzSubjectId(i). 0 = nothing. */
|
|
48
70
|
fn rzObjectAt(uv: vec2f) -> u32 {
|
|
49
|
-
|
|
50
|
-
let p = vec2<i32>(clamp(uv, vec2f(0.0), vec2f(1.0)) * sz);
|
|
51
|
-
return textureLoad(_rzIdTex, clamp(p, vec2<i32>(0), vec2<i32>(sz) - vec2<i32>(1)), 0).y;
|
|
71
|
+
return textureLoad(_rzIdTex, _rzIdTexel(uv), 0).y;
|
|
52
72
|
}
|
|
53
73
|
|
|
54
74
|
/** Which MATERIAL drew it, within that object. 0 = nothing. */
|
|
55
75
|
fn rzMaterialAt(uv: vec2f) -> u32 {
|
|
56
|
-
|
|
57
|
-
let p = vec2<i32>(clamp(uv, vec2f(0.0), vec2f(1.0)) * sz);
|
|
58
|
-
return textureLoad(_rzIdTex, clamp(p, vec2<i32>(0), vec2<i32>(sz) - vec2<i32>(1)), 0).x;
|
|
76
|
+
return textureLoad(_rzIdTex, _rzIdTexel(uv), 0).x;
|
|
59
77
|
}
|
|
60
78
|
`
|
|
61
79
|
}
|