4/21/2024 0 Comments Light intensity equation exponentIf the light ray is perpendicular to the object's surface the light has the greatest impact. We need to measure at what angle the light ray touches the fragment. To the left we find a light source with a light ray targeted at a single fragment of our object. To give you a better understanding of diffuse lighting take a look at the following image: Diffuse lighting gives the object more brightness the closer its fragments are aligned to the light rays from a light source. It should look something like this:Īmbient lighting by itself doesn't produce the most interesting results, but diffuse lighting however will start to give a significant visual impact on the object. The object is quite dark, but not completely since ambient lighting is applied (note that the light cube is unaffected because we use a different shader). If you'd now run the program, you'll notice that the first stage of lighting is now successfully applied to the object. Vec3 ambient = ambientStrength * lightColor We take the light's color, multiply it with a small constant ambient factor, multiply this with the object's color, and use that as the fragment's color in the cube object's shader: As you've seen in the previous section we use a small constant (light) color that we add to the final resulting color of the object's fragments, thus making it look like there is always some scattered light even when there's not a direct light source.Īdding ambient lighting to the scene is really easy. Since we're not big fans of complicated and expensive algorithms we'll start by using a very simplistic model of global illumination, namely ambient lighting. Algorithms that take this into consideration are called global illumination algorithms, but these are complicated and expensive to calculate. One of the properties of light is that it can scatter and bounce in many directions, reaching spots that aren't directly visible light can thus reflect on other surfaces and have an indirect impact on the lighting of an object. Light usually does not come from a single light source, but from many light sources scattered all around us, even when they're not immediately visible. We'll start with the simplest one: ambient lighting. To create visually interesting scenes we want to at least simulate these 3 lighting components. Specular highlights are more inclined to the color of the light than the color of the object. Specular lighting: simulates the bright spot of a light that appears on shiny objects.The more a part of an object faces the light source, the brighter it becomes. This is the most visually significant component of the lighting model. Diffuse lighting: simulates the directional impact a light object has on an object.To simulate this we use an ambient lighting constant that always gives the object some color. Ambient lighting: even when it is dark there is usually still some light somewhere in the world (the moon, a distant light) so objects are almost never completely dark.Below you can see what these lighting components look like on their own and combined: The major building blocks of the Phong lighting model consist of 3 components: ambient, diffuse and specular lighting. One of those models is called the Phong lighting model. These lighting models are based on the physics of light as we understand it. Lighting in OpenGL is therefore based on approximations of reality using simplified models that are much easier to process and look relatively similar. Lighting in the real world is extremely complicated and depends on way too many factors, something we can't afford to calculate on the limited processing power we have.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |