GP1 Software Rasterization Pipeline PDF

Summary

This document provides a high-level overview of the GP1 software rasterization pipeline. It details the different stages involved, including projection, rasterization, and pixel shading. The document emphasizes vertex attributes and their transformations through the stages. It is intended as a guide or overview, rather than an exhaustive set of instructions; it directs the reader to additional resources for a more detailed understanding.

Full Transcript

GP1 – Software Rasterization Pipeline (High-Level)...

GP1 – Software Rasterization Pipeline (High-Level) INPUT (Interpolated Vertex Attributes for Pixel) INPUT (VERTEX_IN) INPUT Position : Vector4 Vertices (in World Space) Vertices (in β€˜NDC’ space) (X & Y > ScreenSpace || Z > Interpolated Normalized Depth || W > Interpolated Camera-Space Depth) Each Vertex has at least a POSITION attribute, but can be decorated with extra attributes such as COLOR, UV,... Each Vertex has at least a POSITION attribute, but can be decorated with extra attributes such as COLOR, UV,... Interpolated Color : ColorRGB Interpolated UV : Vector2 Interpolated Normal : Vector3 Interpolated Tangent : Vector3 PROJECTION STAGE RASTERIZATION STAGE Interpolated ViewDirection : Vector3 [All vertices] [Each Triangle > Iterate Pixels] PIXEL SHADING STAGE [Positions] Frustum Culling (+ Clipping) [Calculate Color for given Pixel] Model(space) > NDC(space) (NDC) Vertex inside Camera Frustum? X & Y between [-1,1] Z between [0.1] CONSTANTS (Directional Light) Every Pixel that passed the Depth Test Multiply vertex positions with WVP matrix Ignore Triangle if not in Frustum World > Model Transformation LightDirection > {.577f, -.577f,.577f } View > Camera Transformation LightIntensity > 7.f Every Vertex Projection > Projection based on AspectRatio & FOV NDC (space) > Raster/Screen (space) Optimization > Calculate Triangle Every Triangle Specular Shininess > 25.f + Apply Perspective Divide BoundingBox (BB) in Rasterspace > See slides for formula. After this transformation your Position X & Y should be in ScreenSpace (2D raster coordinates). Only iterate the pixels covered by this BB. NORMAL MAPPING (Normal Texture) [Normals & Tangents] Calculate TangentSpaceAxis, multiply with sampled normal from Model(space) > World(space) NormalMap > Use this resulting Normal as new Normal PIXEL inside TRIANGLE? Multiply Normals & Tangents with (3x3) World matrix Cross product between each Triangle edge and Vertex-2-Pixel vectors (2D Barycentric Coordinates (We only want to rotate them, so cast (4x4) World matrix to a (3x3) vectors) > IF signs of all cross-product results are the same THEN pixel is DIFFUSE (Diffuse Texture) matrix [FMatrix3] > Discards the translational component) inside the Triangle. Cross Product Results can be Basic Lambert Diffuse used to calculate Every Pixel interpolation weights for [ViewDirection] Depth Interpolation + Depth Test SPECULAR (Specular + Gloss Texture) Depth & Attribute Phong Specular (similar to RayTracer) Correct β€˜Depth Interpolation’ > LAB 3 Interpolation. Normalize(WorldPosition – CameraPosition) WorldPosition > ModelSpace position multiplied with (4x4) World matrix Vertex Attribute Interpolation + See LAB 3 for β€˜correct’ Depth & Vertex Interpolation AMBIENT (optional) Solid Color > RGB{.025f,.025f,.025f } Correct β€˜Attribute Interpolation’ > LAB 3 OUTPUT (VERTEX_OUT) Vertices (in β€˜NDC’ space) OUTPUT (Only if DepthTest succeeds) OUTPUT > Final Pixel Color (Diffuse + Specular + Ambient) Positions are Projected, Normals & Tangents are transformed, ViewDirection is calculated, other attributes are (Normalize Color before writing to backbuffer) passed through Position X & Y > NDC (Range [-1,1] ) Single VERTEX_OUT structure containing interpolated attributes Position Z > NDC (Range [0,1] ] (Position, Color, UV, Normal, Tangent, ViewDirection) Position W > ViewSpace (Distance from camera) CULL MODE Depends on the cross-product sign * This is only a High-Level overview/guide! > Use the slides for deeper explanation & All Negative vs All Positive == FrontFace proper implementation guidelines. vs BackFace culling

Use Quizgecko on...
Browser
Browser