tutorial_206_20-_20lighting
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial_206_20-_20lighting [2018/04/13 22:41] – Added syntax highlighting richardrussell | tutorial_206_20-_20lighting [2024/01/05 00:21] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 41: | Line 41: | ||
===== Rendering the Lights in the Pixel Shader ===== | ===== Rendering the Lights in the Pixel Shader ===== | ||
\\ Once we have all the data set up and the shader properly fed with data, we can compute the lambertian lighting term on each pixel from the light sources. We'll be using the dot product rule discussed previously.\\ \\ Once we've taken the dot product of the light versus the normal, it can then be multiplied with the color of the light to calculate the effect of that light. That value is passed through the saturate function, which converts the range to [0, 1]. Finally, the results from the two separate lights are summed together to create the final pixel color.\\ \\ Consider that the material of the surface itself is not factored into this light calculation. The final color of the surface is a result of the light' | \\ Once we have all the data set up and the shader properly fed with data, we can compute the lambertian lighting term on each pixel from the light sources. We'll be using the dot product rule discussed previously.\\ \\ Once we've taken the dot product of the light versus the normal, it can then be multiplied with the color of the light to calculate the effect of that light. That value is passed through the saturate function, which converts the range to [0, 1]. Finally, the results from the two separate lights are summed together to create the final pixel color.\\ \\ Consider that the material of the surface itself is not factored into this light calculation. The final color of the surface is a result of the light' | ||
+ | <code glsl> | ||
// | // | ||
// Pixel Shader | // Pixel Shader | ||
Line 55: | Line 56: | ||
return finalColor; | return finalColor; | ||
} | } | ||
+ | </ | ||
\\ Once through the pixel shader, the pixels will be modulated by the lights, and you can see the effect of each light on the cube surface. Note that the light in this case looks flat because pixels on the same surface will have the same normal. Diffuse is a very simple and easy lighting model to compute. You can use more complex lighting models to achieve richer and more realistic materials. | \\ Once through the pixel shader, the pixels will be modulated by the lights, and you can see the effect of each light on the cube surface. Note that the light in this case looks flat because pixels on the same surface will have the same normal. Diffuse is a very simple and easy lighting model to compute. You can use more complex lighting models to achieve richer and more realistic materials. |
tutorial_206_20-_20lighting.1523659262.txt.gz · Last modified: 2024/01/05 00:16 (external edit)