# BBC BASIC Programmers' Reference

### Site Tools

tutorial_206_20-_20lighting

# Differences

This shows you the differences between two versions of the page.

 tutorial_206_20-_20lighting [2018/04/13 22:41]richardrussell Added syntax highlighting tutorial_206_20-_20lighting [2018/04/17 19:13] (current)tbest3112 Added syntax highlighting for HLSL (using glsl as close enough) Both sides previous revision Previous revision 2018/04/17 19:13 tbest3112 Added syntax highlighting for HLSL (using glsl as close enough)2018/04/13 22:41 richardrussell Added syntax highlighting2018/03/31 13:19 external edit 2018/04/17 19:13 tbest3112 Added syntax highlighting for HLSL (using glsl as close enough)2018/04/13 22:41 richardrussell Added syntax highlighting2018/03/31 13:19 external edit 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'​s colors.\\ \\ \\  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'​s colors.\\ \\ + // // // 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.txt ยท Last modified: 2018/04/17 19:13 by tbest3112