Computer graphics in Game development - summer 2023
Computer graphics in Game development - summer 2023
After vertex shader stage we have an NDC coordinates of each vertex of the triangle.
Next steps:
Could be done in homogeneous coordinates or cartesian
Mss=width00x0−height0height+y00100001
where x and y are offsets from the screen space (0,0) [1]
Let’s take two points (X,Y) and (X+dx,Y+dy) on an edge
Then, define an edge function:
E(x,y)=(x−X)dy−(y−Y)dx
[2]
If E(x,y)>0 then (x,y) on the “right” side
If E(x,y)<0 then (x,y) on the “left” side
If E(x,y)=0 then (x,y) on the edge
[2]
Input: interpolated vertex attributes
Output: result pixel color
The pixel shader should be provided by graphics programmer [4]
Principles: create an image in the most effective way
Laws: -
Variables: num of shaded pixels
cg::renderer::rasterizer::edge_function
methodpixel_shader
lambda for the instance of cg::renderer::rasterizer
Rasterization
and Pixel shader
stages to draw
method of cg::renderer::rasterizer
TODO: Lab: 1.05 Triangle rasterization
Measure how a rendering time depends on a num of shaded pixels
1. Satran M., Jacobs M. The Direct3D transformation pipeline [Electronic resource]. 2019. URL: https://docs.microsoft.com/en-us/windows/win32/dxtecharts/the-direct3d-transformation-pipeline.
2. Pineda J. A parallel algorithm for polygon rasterization // Proceedings of the 15th annual conference on computer graphics and interactive techniques. 1988. P. 17–20.
3. Rasterization: A practical implementation [Electronic resource]. 2015. URL: https://www.scratchapixel.com/lessons/3d-basic-rendering/rasterization-practical-implementation/rasterization-stage.
4. Satran M. et al. Pixel shader stage [Electronic resource]. 2020. URL: https://docs.microsoft.com/en-us/windows/win32/direct3d11/pixel-shader-stage.