Comments (5)
The triangle is a rainbow because the GPU interpolates the values between the vertices in a process known as rasterization.
As far as getting access to the pixel coordinate inside the triangle you can use the @builtin(position)
decorator on a vec4
to get the pixels coordinates in screen space. It's basically the same as gl_FragPosition
in OpenGL.
from learn-wgpu.
when using @builtin(position)
as input for the fragment shader, what's the coordinates system we're getting there ? is it possible to transform them in clip space ?
from learn-wgpu.
The coordinate system of @builtin(position)
is in screen space, or in other words it uses the pixel coordinates of the viewport. You can transform them back to clip space, but it's simpler to just pass the clip space coords into the fragment shader from the vertex shader.
from learn-wgpu.
For a little more context in the @builtin(position)
, the top left corner of the viewport is (0,0) and the bottme right corner is (viewport_width, viewport_height). I believe the z component is the depth/array layer, though I'm not sure.
from learn-wgpu.
Thanks so much for your explanations 🙏
from learn-wgpu.
Related Issues (20)
- Safety note for create_surface appears off HOT 2
- Viewing Old Versions HOT 2
- OPENGL_TO_WGPU_MATRIX constant for NDC conversion is incorrect HOT 2
- dark theme / use mdBook HOT 1
- a correction is needed
- What is the purpose of "window_id == state.window().id()"?
- Code for `learn-wgpu/code/beginner/tutorial3-pipeline/src/challenge.wgsl` doesn't work HOT 3
- `bytemuck` isn't listed in dependencies for "Learn Wgpu" but is used HOT 1
- The "Color Correction" paragraph is incorrect (or misleading) HOT 2
- compiler error HOT 4
- More about compute shader HOT 2
- Update to 0.17 HOT 1
- There are two tutorial thirteens HOT 2
- Alpha mode HOT 2
- wgpu and winit update tracker HOT 8
- [tutorial9-models] Texture coords are not flipped vertically HOT 4
- HDR demo not working when I have WebGPU flag enabled on chrome HOT 3
- Error: Cannot find module `demo.js` HOT 1
- Wrong view projection matrices HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from learn-wgpu.