webgl vertex coordinates after projection (after vertex shader run) are 1000x larger…
- User
webgl vertex coordinates after projection (after vertex shader run) are 1000x larger than they should be. what could be the cause? Projection matrix is 100% correct, vertex data is as well (also properly loaded in the shader, checked by displaying it)
- Assistant
The 1000x scaling suggests a systematic issue rather than a small error. Here are the most likely causes:
Canvas/Viewport Size Mismatch Check if your canvas element's actual size differs from its CSS size:
// Make sure these match canvas.width = canvas.clientWidth; canvas.height = canvas.clientHeight; gl.viewport(0, 0, canvas.width, canvas.height);Device Pixel Ratio High DPI displays can cause scaling issues:
const devicePixelRatio = window.devicePixelRatio || 1; canvas.width = canvas.clientWidth * devicePixelRatio; canvas.height = canvas.clientHeight * devicePixelRatio;Matrix Multiplication Order Even with correct individual matrices, verify the multiplication order in your vertex shader:
// Should be: projection * view * model * position gl_Position = u_projectionMatrix * u_viewMatrix * u_modelMatrix * a_position;Hidden Scaling in Model/View Matrix Double-check that your model or view matrix doesn't contain unexpected scaling:
// Log the matrices to verify no hidden scaling console.log('Model matrix:', modelMatrix); console.log('View matrix:', viewMatrix);Coordinate System Units Verify you're not mixing coordinate systems - for example, using pixel coordinates where normalized device coordinates are expected.
The quickest debug is to temporarily set your projection matrix to identity and see if the scaling persists - this will isolate whether it's a projection issue or something in the rendering pipeline.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.