Skip to content
Open
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1036589
fix: Improvement to argument usage tracking
iwoplaza Apr 10, 2026
d7926fa
refactor: Naming cleanup
iwoplaza Apr 11, 2026
4672769
impr(docs): Improve orbit camera to better behave on mouse scroll-whe…
mvanhorn Apr 12, 2026
74eaee6
@typegpu/geometry Simplify variable width lines implementation (#1935)
deluksic Apr 13, 2026
f1da8b5
Add some basic tests
aleksanderkatan Apr 13, 2026
591298f
Add more tests
aleksanderkatan Apr 13, 2026
8f27d44
Add reference tests
aleksanderkatan Apr 15, 2026
08650b3
Move snapshots higher in tests
aleksanderkatan Apr 15, 2026
52f52c0
Add a stub of implementation
aleksanderkatan Apr 16, 2026
87e3cd4
Mark assignments as modified
aleksanderkatan Apr 16, 2026
d612682
Add more tests and handle update
aleksanderkatan Apr 16, 2026
613c3ee
Handle refs
aleksanderkatan Apr 16, 2026
bcb1735
Handle js references
aleksanderkatan Apr 17, 2026
a15476b
Reorganize tests
aleksanderkatan Apr 17, 2026
f073da4
Add more tests
aleksanderkatan Apr 17, 2026
88dfb64
fix: Improvement to argument usage tracking
iwoplaza Apr 10, 2026
5b7b6eb
refactor: Naming cleanup
iwoplaza Apr 11, 2026
c1d59e7
Merge remote-tracking branch 'origin/refactor/naming-cleanup' into fe…
aleksanderkatan Apr 17, 2026
2afcfb8
refactor: Naming cleanup
iwoplaza Apr 11, 2026
4617b16
Merge remote-tracking branch 'origin/refactor/naming-cleanup' into fe…
aleksanderkatan Apr 17, 2026
6a12e46
fix: Improvement to argument usage tracking
iwoplaza Apr 10, 2026
d5d4be5
refactor: Naming cleanup
iwoplaza Apr 11, 2026
eb7008b
Update example tests
aleksanderkatan Apr 17, 2026
de529ab
Merge remote-tracking branch 'origin/refactor/naming-cleanup' into fe…
aleksanderkatan Apr 17, 2026
baa830b
Fix the weird unroll case (thx @cieplypolar)
aleksanderkatan Apr 17, 2026
d0affe8
Update some tests
aleksanderkatan Apr 20, 2026
3aaf455
Add new tests
aleksanderkatan Apr 20, 2026
b032f6f
Handle two more edge cases
aleksanderkatan Apr 20, 2026
acdca4f
Optimize string replacement
aleksanderkatan Apr 20, 2026
ec85ed1
Review fixes
aleksanderkatan Apr 20, 2026
62a097d
fix: Improvement to argument usage tracking
iwoplaza Apr 10, 2026
8517cba
refactor: Naming cleanup
iwoplaza Apr 11, 2026
45237b2
Merge remote-tracking branch 'origin/refactor/naming-cleanup' into fe…
aleksanderkatan Apr 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions apps/typegpu-docs/tests/individual-example-tests/3d-fish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('3d fish example', () => {

fn wrappedCallback(x: u32, _arg_1: u32, _arg_2: u32) {
randSeed2(vec2f(f32(x), seedUniform));
var data = ModelData(vec3f(((randFloat01() * 10f) - 5f), ((randFloat01() * 4f) - 2f), ((randFloat01() * 10f) - 5f)), vec3f(((randFloat01() * 0.1f) - 0.05f), ((randFloat01() * 0.1f) - 0.05f), ((randFloat01() * 0.1f) - 0.05f)), (0.07f * (1f + ((randFloat01() - 0.5f) * 0.8f))), randFloat01(), 1u, 1u, 1u);
let data = ModelData(vec3f(((randFloat01() * 10f) - 5f), ((randFloat01() * 4f) - 2f), ((randFloat01() * 10f) - 5f)), vec3f(((randFloat01() * 0.1f) - 0.05f), ((randFloat01() * 0.1f) - 0.05f), ((randFloat01() * 0.1f) - 0.05f)), (0.07f * (1f + ((randFloat01() - 0.5f) * 0.8f))), randFloat01(), 1u, 1u, 1u);
fish_data_0[x] = data;
fish_data_1[x] = data;
}
Expand Down Expand Up @@ -115,7 +115,7 @@ describe('3d fish example', () => {
}

fn projectPointOnLine(point: vec3f, line: Line3) -> vec3f {
var pointVector = (point - line.origin);
let pointVector = (point - line.origin);
let projection = dot(pointVector, line.dir);
return (line.origin + (line.dir * projection));
}
Expand Down Expand Up @@ -207,8 +207,8 @@ describe('3d fish example', () => {
wallRepulsion = (wallRepulsion + (repulsion * str));
}
}
var proj = projectPointOnLine((*fishData).position, mouseRay);
var diff = ((*fishData).position - proj);
let proj = projectPointOnLine((*fishData).position, mouseRay);
let diff = ((*fishData).position - proj);
const limit = 1.2;
let str = (pow(2f, clamp((limit - length(diff)), 0f, limit)) - 1f);
rayRepulsion = (normalize(diff) * str);
Expand All @@ -219,7 +219,7 @@ describe('3d fish example', () => {
direction += (wallRepulsion * 1e-4f);
direction += (rayRepulsion * 0.0015f);
direction = (normalize(direction) * clamp(length((*fishData).direction), 0f, 0.01f));
var translation = (direction * (min(999f, timePassed) / 8f));
let translation = (direction * (min(999f, timePassed) / 8f));
let nextFishData_1 = (&nextFishData[fishIndex]);
(*nextFishData_1).position = ((*fishData).position + translation);
(*nextFishData_1).direction = direction;
Expand Down Expand Up @@ -256,11 +256,11 @@ describe('3d fish example', () => {
var posMod = vec3f();
posMod.z = (sin((f32(index) + (((time / a) + vertex.position.x) / b))) / c);
let coeff = (cos((f32(index) + (((time / a) + vertex.position.x) / b))) / c);
var newOX = normalize(vec3f(1f, 0f, coeff));
var newOZ = vec3f(-(newOX.z), 0f, newOX.x);
var newNormalXZ = ((newOX * vertex.normal.x) + (newOZ * vertex.normal.z));
var wavedNormal = vec3f(newNormalXZ.x, vertex.normal.y, newNormalXZ.z);
var wavedPosition = (vertex.position + posMod);
let newOX = normalize(vec3f(1f, 0f, coeff));
let newOZ = vec3f(-(newOX.z), 0f, newOX.x);
let newNormalXZ = ((newOX * vertex.normal.x) + (newOZ * vertex.normal.z));
let wavedNormal = vec3f(newNormalXZ.x, vertex.normal.y, newNormalXZ.z);
let wavedPosition = (vertex.position + posMod);
return PosAndNormal(wavedPosition, wavedNormal);
}

Expand Down Expand Up @@ -291,29 +291,20 @@ describe('3d fish example', () => {
if (((*currentModelData).applySinWave == 1u)) {
wavedVertex = applySinWave(_arg_instanceIndex, PosAndNormal(_arg_modelPosition, _arg_modelNormal), currentTime);
}
var direction = normalize((*currentModelData).direction);
let direction = normalize((*currentModelData).direction);
let yaw = (-(atan2(direction.z, direction.x)) + 3.141592653589793f);
let pitch = asin(-(direction.y));
var scaleMatrix = mat4x4f(vec3f((*currentModelData).scale).x, 0, 0, 0, 0, vec3f((*currentModelData).scale).y, 0, 0, 0, 0, vec3f((*currentModelData).scale).z, 0, 0, 0, 0, 1);
var pitchMatrix = mat4x4f(cos(pitch), sin(pitch), 0, 0, -sin(pitch), cos(pitch), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
var yawMatrix = mat4x4f(cos(yaw), 0, -sin(yaw), 0, 0, 1, 0, 0, sin(yaw), 0, cos(yaw), 0, 0, 0, 0, 1);
var translationMatrix = mat4x4f(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, (*currentModelData).position.x, (*currentModelData).position.y, (*currentModelData).position.z, 1);
let scaleMatrix = mat4x4f(vec3f((*currentModelData).scale).x, 0, 0, 0, 0, vec3f((*currentModelData).scale).y, 0, 0, 0, 0, vec3f((*currentModelData).scale).z, 0, 0, 0, 0, 1);
let pitchMatrix = mat4x4f(cos(pitch), sin(pitch), 0, 0, -sin(pitch), cos(pitch), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
let yawMatrix = mat4x4f(cos(yaw), 0, -sin(yaw), 0, 0, 1, 0, 0, sin(yaw), 0, cos(yaw), 0, 0, 0, 0, 1);
let translationMatrix = mat4x4f(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, (*currentModelData).position.x, (*currentModelData).position.y, (*currentModelData).position.z, 1);
var worldPosition = ((((translationMatrix * yawMatrix) * pitchMatrix) * scaleMatrix) * vec4f(wavedVertex.position, 1f));
var worldNormal = normalize(((yawMatrix * pitchMatrix) * vec4f(wavedVertex.normal, 1f)).xyz);
let worldNormal = normalize(((yawMatrix * pitchMatrix) * vec4f(wavedVertex.normal, 1f)).xyz);
let worldPositionUniform = (&worldPosition);
var canvasPosition = ((camera.projection * camera.view) * (*worldPositionUniform));
let canvasPosition = ((camera.projection * camera.view) * (*worldPositionUniform));
return vertexShader_Output(worldPosition.xyz, worldNormal, canvasPosition, (*currentModelData).variant, _arg_textureUV, (*currentModelData).applySeaFog, (*currentModelData).applySeaDesaturation);
}

struct fragmentShader_Input {
@location(0) worldPosition: vec3f,
@location(1) worldNormal: vec3f,
@location(2) variant: f32,
@location(3) textureUV: vec2f,
@location(4) @interpolate(flat) applySeaFog: u32,
@location(5) @interpolate(flat) applySeaDesaturation: u32,
}

@group(0) @binding(1) var modelTexture: texture_2d<f32>;

@group(0) @binding(3) var sampler_1: sampler;
Expand Down Expand Up @@ -418,17 +409,26 @@ describe('3d fish example', () => {
return vec3f(r, g, b);
}

struct fragmentShader_Input {
@location(0) worldPosition: vec3f,
@location(1) worldNormal: vec3f,
@location(2) variant: f32,
@location(3) textureUV: vec2f,
@location(4) @interpolate(flat) applySeaFog: u32,
@location(5) @interpolate(flat) applySeaDesaturation: u32,
}

@fragment fn fragmentShader(_arg_0: fragmentShader_Input) -> @location(0) vec4f {
var textureColorWithAlpha = textureSample(modelTexture, sampler_1, _arg_0.textureUV);
var textureColor = textureColorWithAlpha.rgb;
var ambient = ((0.5f * textureColor) * vec3f(0.800000011920929, 0.800000011920929, 1));
let textureColorWithAlpha = textureSample(modelTexture, sampler_1, _arg_0.textureUV);
let textureColor = textureColorWithAlpha.rgb;
let ambient = ((0.5f * textureColor) * vec3f(0.800000011920929, 0.800000011920929, 1));
let cosTheta = dot(_arg_0.worldNormal, vec3f(-0.2357022613286972, 0.9428090453147888, -0.2357022613286972));
var diffuse = ((max(0f, cosTheta) * textureColor) * vec3f(0.800000011920929, 0.800000011920929, 1));
var viewSource = normalize((camera.position.xyz - _arg_0.worldPosition));
var reflectSource = normalize(reflect(vec3f(0.2357022613286972, -0.9428090453147888, 0.2357022613286972), _arg_0.worldNormal));
let diffuse = ((max(0f, cosTheta) * textureColor) * vec3f(0.800000011920929, 0.800000011920929, 1));
let viewSource = normalize((camera.position.xyz - _arg_0.worldPosition));
let reflectSource = normalize(reflect(vec3f(0.2357022613286972, -0.9428090453147888, 0.2357022613286972), _arg_0.worldNormal));
let specularStrength = pow(max(0f, dot(viewSource, reflectSource)), 16f);
var specular = (specularStrength * vec3f(0.800000011920929, 0.800000011920929, 1));
var lightedColor = ((ambient + diffuse) + specular);
let specular = (specularStrength * vec3f(0.800000011920929, 0.800000011920929, 1));
let lightedColor = ((ambient + diffuse) + specular);
let distanceFromCamera = length((camera.position.xyz - _arg_0.worldPosition));
var desaturatedColor = lightedColor;
if ((_arg_0.applySeaDesaturation == 1u)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('ascii filter example', () => {
@group(0) @binding(4) var<uniform> charsetExtended: u32;

fn characterFn(n: u32, p: vec2f) -> f32 {
var pos = floor(((p * vec2f(-4, 4)) + 2.5f));
let pos = floor(((p * vec2f(-4, 4)) + 2.5f));
if (((((pos.x < 0f) || (pos.x > 4f)) || (pos.y < 0f)) || (pos.y > 4f))) {
return 0f;
}
Expand All @@ -60,13 +60,13 @@ describe('ascii filter example', () => {
}

@fragment fn fragment(_arg_0: FragmentIn) -> @location(0) vec4f {
var uv2 = ((uvTransformBuffer * (_arg_0.uv - 0.5f)) + 0.5f);
var textureSize = vec2f(textureDimensions(externalTexture));
var pix = (uv2 * textureSize);
let uv2 = ((uvTransformBuffer * (_arg_0.uv - 0.5f)) + 0.5f);
let textureSize = vec2f(textureDimensions(externalTexture));
let pix = (uv2 * textureSize);
let cellSize = f32(glyphSize);
let halfCell = (cellSize * 0.5f);
var blockCoord = ((floor((pix / cellSize)) * cellSize) / textureSize);
var color = textureSampleBaseClampToEdge(externalTexture, shaderSampler, blockCoord);
let blockCoord = ((floor((pix / cellSize)) * cellSize) / textureSize);
let color = textureSampleBaseClampToEdge(externalTexture, shaderSampler, blockCoord);
let rawGray = (((0.3f * color.x) + (0.59f * color.y)) + (0.11f * color.z));
let gray = pow(rawGray, gammaCorrection);
var n = 4096u;
Expand Down Expand Up @@ -221,7 +221,7 @@ describe('ascii filter example', () => {
n = 11512810u;
}
}
var p = vec2f((((pix.x / halfCell) % 2f) - 1f), (((pix.y / halfCell) % 2f) - 1f));
let p = vec2f((((pix.x / halfCell) % 2f) - 1f), (((pix.y / halfCell) % 2f) - 1f));
let charValue = characterFn(n, p);
var resultColor = vec3f(1);
if ((displayMode == 0u)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ describe('bitonic sort example', () => {
return fullScreenTriangle_Output(vec4f(pos[vertexIndex], 0, 1), uv[vertexIndex]);
}

@group(0) @binding(0) var<storage, read> data_1: array<u32>;

struct fragmentFn_Input {
@location(0) uv: vec2f,
}

@group(0) @binding(0) var<storage, read> data_1: array<u32>;

@fragment fn fragmentFn(_arg_0: fragmentFn_Input) -> @location(0) vec4f {
let data = (&data_1);
let arrayLength_1 = arrayLength(&(*data));
Expand Down
12 changes: 6 additions & 6 deletions apps/typegpu-docs/tests/individual-example-tests/blur.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ describe('blur example', () => {
@compute @workgroup_size(32, 1, 1) fn computeFn(@builtin(workgroup_id) wid: vec3u, @builtin(local_invocation_id) lid: vec3u) {
let settings = (&settingsUniform);
let filterOffset = i32((f32(((*settings).filterDim - 1i)) / 2f));
var dims = vec2i(textureDimensions(inTexture));
var baseIndex = (vec2i(((wid.xy * vec2u((*settings).blockDim, 4u)) + (lid.xy * vec2u(4, 1)))) - vec2i(filterOffset, 0i));
let dims = vec2i(textureDimensions(inTexture));
let baseIndex = (vec2i(((wid.xy * vec2u((*settings).blockDim, 4u)) + (lid.xy * vec2u(4, 1)))) - vec2i(filterOffset, 0i));
// unrolled iteration #0
{
// unrolled iteration #0
Expand Down Expand Up @@ -470,14 +470,14 @@ describe('blur example', () => {
return fullScreenTriangle_Output(vec4f(pos[vertexIndex], 0, 1), uv[vertexIndex]);
}

struct renderFragment_Input {
@location(0) uv: vec2f,
}

@group(0) @binding(0) var renderView: texture_2d<f32>;

@group(0) @binding(1) var sampler_1: sampler;

struct renderFragment_Input {
@location(0) uv: vec2f,
}

@fragment fn renderFragment(_arg_0: renderFragment_Input) -> @location(0) vec4f {
return textureSample(renderView, sampler_1, _arg_0.uv);
}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('boids example', () => {
cohesion /= f32(cohesionCount);
cohesion -= self_1.position;
}
var velocity = (((paramsBuffer.separationStrength * separation) + (paramsBuffer.alignmentStrength * alignment)) + (paramsBuffer.cohesionStrength * cohesion));
let velocity = (((paramsBuffer.separationStrength * separation) + (paramsBuffer.alignmentStrength * alignment)) + (paramsBuffer.cohesionStrength * cohesion));
self_1.velocity += velocity;
self_1.velocity = (clamp(length(self_1.velocity), 0f, 0.01f) * normalize(self_1.velocity));
self_1.position += self_1.velocity;
Expand Down Expand Up @@ -108,9 +108,9 @@ describe('boids example', () => {

@vertex fn mainVert(@location(0) _arg_v: vec2f, @location(1) _arg_center: vec2f, @location(2) _arg_velocity: vec2f) -> mainVert_Output {
let angle = getRotationFromVelocity(_arg_velocity);
var rotated = rotate(_arg_v, angle);
var pos = vec4f((rotated + _arg_center), 0f, 1f);
var color = vec4f(((sin((colorPalette + angle)) * 0.45f) + 0.45f), 1f);
let rotated = rotate(_arg_v, angle);
let pos = vec4f((rotated + _arg_center), 0f, 1f);
let color = vec4f(((sin((colorPalette + angle)) * 0.45f) + 0.45f), 1f);
return mainVert_Output(pos, color);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ describe('box raytracing example', () => {
}

@vertex fn mainVertex(_arg_0: VertexIn) -> VertexOut {
var pos = array<vec2f, 3>(vec2f(-1), vec2f(3, -1), vec2f(-1, 3));
var rayWorldOrigin = (uniforms.invViewMatrix * vec4f(0, 0, 0, 1)).xyz;
let pos = array<vec2f, 3>(vec2f(-1), vec2f(3, -1), vec2f(-1, 3));
let rayWorldOrigin = (uniforms.invViewMatrix * vec4f(0, 0, 0, 1)).xyz;
return VertexOut(vec4f(pos[_arg_0.vertexIndex], 0f, 1f), rayWorldOrigin);
}

Expand Down Expand Up @@ -136,13 +136,13 @@ describe('box raytracing example', () => {
}

@fragment fn fragmentFunction(_arg_0: FragmentIn) -> @location(0) vec4f {
var boxSize3 = vec3f(uniforms.boxSize);
var halfBoxSize3 = (0.5f * boxSize3);
var halfCanvasDims = (0.5f * uniforms.canvasDims);
let boxSize3 = vec3f(uniforms.boxSize);
let halfBoxSize3 = (0.5f * boxSize3);
let halfCanvasDims = (0.5f * uniforms.canvasDims);
let minDim = min(uniforms.canvasDims.x, uniforms.canvasDims.y);
var viewCoords = ((_arg_0.position.xy - halfCanvasDims) / minDim);
var ray = Ray(_arg_0.rayWorldOrigin, (uniforms.invViewMatrix * vec4f(normalize(vec3f(viewCoords, 1f)), 0f)).xyz);
var bigBoxIntersection = getBoxIntersection(AxisAlignedBounds((-1f * halfBoxSize3), (vec3f(7) + halfBoxSize3)), ray);
let viewCoords = ((_arg_0.position.xy - halfCanvasDims) / minDim);
let ray = Ray(_arg_0.rayWorldOrigin, (uniforms.invViewMatrix * vec4f(normalize(vec3f(viewCoords, 1f)), 0f)).xyz);
let bigBoxIntersection = getBoxIntersection(AxisAlignedBounds((-1f * halfBoxSize3), (vec3f(7) + halfBoxSize3)), ray);
if (!bigBoxIntersection.intersects) {
discard;;
return vec4f();
Expand All @@ -156,8 +156,8 @@ describe('box raytracing example', () => {
if ((boxMatrix[i][j][k].isActive == 0u)) {
continue;
}
var ijkScaled = vec3f(f32(i), f32(j), f32(k));
var intersection = getBoxIntersection(AxisAlignedBounds((ijkScaled - halfBoxSize3), (ijkScaled + halfBoxSize3)), ray);
let ijkScaled = vec3f(f32(i), f32(j), f32(k));
let intersection = getBoxIntersection(AxisAlignedBounds((ijkScaled - halfBoxSize3), (ijkScaled + halfBoxSize3)), ray);
if (intersection.intersects) {
let boxDensity = (max(0f, (intersection.tMax - intersection.tMin)) * pow(uniforms.materialDensity, 2f));
density += boxDensity;
Expand All @@ -167,10 +167,10 @@ describe('box raytracing example', () => {
}
}
}
var linear = (1f / invColor);
var srgb = linearToSrgb(linear);
let linear = (1f / invColor);
let srgb = linearToSrgb(linear);
const gamma = 2.2;
var corrected = pow(srgb, vec3f((1f / gamma)));
let corrected = pow(srgb, vec3f((1f / gamma)));
if (intersectionFound) {
return (min(density, 1f) * vec4f(min(corrected, vec3f(1)), 1f));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ describe('camera thresholding example', () => {
return fullScreenTriangle_Output(vec4f(pos[vertexIndex], 0, 1), uv[vertexIndex]);
}

struct mainFrag_Input {
@location(0) uv: vec2f,
}

@group(0) @binding(0) var<uniform> uvTransformUniform: mat2x2f;

@group(1) @binding(0) var inputTexture: texture_external;
Expand All @@ -48,11 +44,15 @@ describe('camera thresholding example', () => {

@group(0) @binding(3) var<uniform> thresholdBuffer: f32;

struct mainFrag_Input {
@location(0) uv: vec2f,
}

@fragment fn mainFrag(_arg_0: mainFrag_Input) -> @location(0) vec4f {
var uv2 = ((uvTransformUniform * (_arg_0.uv - 0.5f)) + 0.5f);
let uv2 = ((uvTransformUniform * (_arg_0.uv - 0.5f)) + 0.5f);
var col = textureSampleBaseClampToEdge(inputTexture, sampler_1, uv2);
var ycbcr = (col.rgb * rgbToYcbcrMatrix);
var colycbcr = (colorUniform * rgbToYcbcrMatrix);
let ycbcr = (col.rgb * rgbToYcbcrMatrix);
let colycbcr = (colorUniform * rgbToYcbcrMatrix);
let crDiff = abs((ycbcr.y - colycbcr.y));
let cbDiff = abs((ycbcr.z - colycbcr.z));
let distance_1 = length(vec2f(crDiff, cbDiff));
Expand Down
Loading
Loading