@quake2ts/engine 0.0.857 → 0.0.860
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/esm/index.js
CHANGED
|
@@ -10744,7 +10744,7 @@ var SpriteRenderer2 = class {
|
|
|
10744
10744
|
};
|
|
10745
10745
|
|
|
10746
10746
|
// raw-loader:/home/runner/work/quake2/quake2/quake2ts/packages/engine/src/render/webgpu/shaders/skybox.wgsl
|
|
10747
|
-
var skybox_default = "// Skybox shader using full-screen triangle approach\n// This avoids the w\u22480 issue with cube geometry at diagonal view angles\n// by computing the world-space direction analytically per-pixel\n\nstruct Uniforms {\n // Inverse view rotation matrix (view\u2192world transform for directions)\n // Stored as 3 vec4s due to std140 padding\n inverseViewRotation_col0: vec4<f32>,\n inverseViewRotation_col1: vec4<f32>,\n inverseViewRotation_col2: vec4<f32>,\n tanHalfFov: f32,\n aspect: f32,\n scroll: vec2<f32>,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: Uniforms;\n@group(0) @binding(1) var t_skybox: texture_cube<f32>;\n@group(0) @binding(2) var s_skybox: sampler;\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n}\n\n@vertex\nfn vertexMain(@location(0) position: vec2<f32>) -> VertexOutput {\n var output: VertexOutput;\n\n // Position is already in NDC space (-1 to 1)\n output.position = vec4<f32>(position, 0.999, 1.0); // z near 1.0 for far plane\n\n return output;\n}\n\n// Hard-coded screen size for now (should be passed as uniform)\nconst SCREEN_SIZE: vec2<f32> = vec2<f32>(256.0, 256.0);\n\n@fragment\nfn fragmentMain(@builtin(position) fragCoord: vec4<f32>) -> @location(0) vec4<f32> {\n // Compute NDC from fragment coordinates\n // fragCoord.xy is in framebuffer coordinates (0 to width, 0 to height)\n // NDC.x: 0 -> -1, width -> +1\n // NDC.y: 0 -> +1, height -> -1 (Y is flipped in WebGPU framebuffer)\n let ndc = vec2<f32>(\n (fragCoord.x / SCREEN_SIZE.x) * 2.0 - 1.0,\n 1.0 - (fragCoord.y / SCREEN_SIZE.y) * 2.0\n );\n // Get columns directly from uniforms\n let col0 = uniforms.inverseViewRotation_col0.xyz;\n let col1 = uniforms.inverseViewRotation_col1.xyz;\n let col2 = uniforms.inverseViewRotation_col2.xyz;\n\n // Compute view-space direction from NDC\n // The view-space ray direction for a pixel at NDC (x, y) with perspective projection:\n // viewDir = normalize(vec3(x * aspect * tanHalfFov, y * tanHalfFov, -1.0))\n // Note: -1.0 for Z because we look down -Z in view space\n let viewDir = normalize(vec3<f32>(\n ndc.x * uniforms.aspect * uniforms.tanHalfFov,\n ndc.y * uniforms.tanHalfFov,\n -1.0\n ));\n\n // Transform view-space direction to world-space (Quake coordinates)\n // Manually unroll: worldDir = col0 * viewDir.x + col1 * viewDir.y + col2 * viewDir.z\n var worldDir = col0 * viewDir.x + col1 * viewDir.y + col2 * viewDir.z;\n\n //
|
|
10747
|
+
var skybox_default = "// Skybox shader using full-screen triangle approach\n// This avoids the w\u22480 issue with cube geometry at diagonal view angles\n// by computing the world-space direction analytically per-pixel\n\nstruct Uniforms {\n // Inverse view rotation matrix (view\u2192world transform for directions)\n // Stored as 3 vec4s due to std140 padding\n inverseViewRotation_col0: vec4<f32>,\n inverseViewRotation_col1: vec4<f32>,\n inverseViewRotation_col2: vec4<f32>,\n tanHalfFov: f32,\n aspect: f32,\n scroll: vec2<f32>,\n}\n\n@group(0) @binding(0) var<uniform> uniforms: Uniforms;\n@group(0) @binding(1) var t_skybox: texture_cube<f32>;\n@group(0) @binding(2) var s_skybox: sampler;\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n}\n\n@vertex\nfn vertexMain(@location(0) position: vec2<f32>) -> VertexOutput {\n var output: VertexOutput;\n\n // Position is already in NDC space (-1 to 1)\n output.position = vec4<f32>(position, 0.999, 1.0); // z near 1.0 for far plane\n\n return output;\n}\n\n// Hard-coded screen size for now (should be passed as uniform)\nconst SCREEN_SIZE: vec2<f32> = vec2<f32>(256.0, 256.0);\n\n@fragment\nfn fragmentMain(@builtin(position) fragCoord: vec4<f32>) -> @location(0) vec4<f32> {\n // Compute NDC from fragment coordinates\n // fragCoord.xy is in framebuffer coordinates (0 to width, 0 to height)\n // NDC.x: 0 -> -1, width -> +1\n // NDC.y: 0 -> +1, height -> -1 (Y is flipped in WebGPU framebuffer)\n let ndc = vec2<f32>(\n (fragCoord.x / SCREEN_SIZE.x) * 2.0 - 1.0,\n 1.0 - (fragCoord.y / SCREEN_SIZE.y) * 2.0\n );\n // Get columns directly from uniforms\n let col0 = uniforms.inverseViewRotation_col0.xyz;\n let col1 = uniforms.inverseViewRotation_col1.xyz;\n let col2 = uniforms.inverseViewRotation_col2.xyz;\n\n // Compute view-space direction from NDC\n // The view-space ray direction for a pixel at NDC (x, y) with perspective projection:\n // viewDir = normalize(vec3(x * aspect * tanHalfFov, y * tanHalfFov, -1.0))\n // Note: -1.0 for Z because we look down -Z in view space\n let viewDir = normalize(vec3<f32>(\n ndc.x * uniforms.aspect * uniforms.tanHalfFov,\n ndc.y * uniforms.tanHalfFov,\n -1.0\n ));\n\n // Transform view-space direction to world-space (Quake coordinates)\n // Manually unroll: worldDir = col0 * viewDir.x + col1 * viewDir.y + col2 * viewDir.z\n var worldDir = col0 * viewDir.x + col1 * viewDir.y + col2 * viewDir.z;\n\n // Transform from Quake coordinates to GL/WebGPU cubemap coordinates\n // Quake: +X forward, +Y left, +Z up\n // GL cubemap: +X right, +Y up, -Z forward\n var cubemapDir: vec3<f32>;\n cubemapDir.x = -worldDir.y; // Quake +Y (left) \u2192 GL -X (left)\n cubemapDir.y = worldDir.z; // Quake +Z (up) \u2192 GL +Y (up)\n cubemapDir.z = -worldDir.x; // Quake +X (forward) \u2192 GL -Z (forward)\n\n // Apply skybox scroll by rotating the cubemap around the vertical (Y) axis\n // This rotates the entire skybox, scrolling textures while maintaining face relationships\n // Rotation around Y axis: newX = X*cos(\u03B8) - Z*sin(\u03B8), newZ = X*sin(\u03B8) + Z*cos(\u03B8)\n // For 2 checkerboard squares (90\xB0 rotation): need ~1.57 radians at scroll=2.0\n let scrollAngle = uniforms.scroll.x * 0.8; // Scale to radians\n let cosAngle = cos(scrollAngle);\n let sinAngle = sin(scrollAngle);\n\n let rotatedX = cubemapDir.x * cosAngle - cubemapDir.z * sinAngle;\n let rotatedZ = cubemapDir.x * sinAngle + cubemapDir.z * cosAngle;\n\n cubemapDir.x = rotatedX;\n cubemapDir.z = rotatedZ;\n // cubemapDir.y unchanged - rotation around Y axis\n\n return textureSample(t_skybox, s_skybox, cubemapDir);\n}\n";
|
|
10748
10748
|
|
|
10749
10749
|
// src/render/types/coordinates.ts
|
|
10750
10750
|
var CoordinateSystem = /* @__PURE__ */ ((CoordinateSystem2) => {
|