Materials

We're going to discuss materials in this section. So, let's first understand what a material is and why would you use it. In the real world, you have objects that are made out of different materials. You have objects that are made out of metals, wood, plastic, and other stuff. As a result, these materials, these objects, react differently to light depending on what they're made out of. Generally speaking, something that's made out of metal will be shinier than something that's made out of wood. Wood generally isn't shiny. Obviously, it is if you apply some sort of varnish to it, but again, that would be an additional layer to the object that's not wood. It'd be something more than wood that is applied on top of it that provides some sort of shine to it. You have glossy materials, and you have some more matte materials. Simply put, materials in OpenGL will allow us to create objects that react differently to light, and as a result, create more realistic and varied effects in our game or application. And that's why you would use it, to get a more varied and realistic representation of the objects you are trying to create.

So, let's get started...

As few prerequisites. This section is using the source code from the previous section, which was covering basic lighting. If you haven't got the code for that, feel free to check out the GitHub link in the preface for the code files. The other thing we want to mention is that these chapters are based on the work of learnopengl.com and open.gl. They're using a fantastic illustrations to explain what we're doing. Also, feel free to check out their pages because they've got some great information. They go into really great depth into the code that we have discussed in all the chapters. So, it's just a great way of enhancing the knowledge you already know.

What we're going to do in this section is make the cube cycle through various different materials. We'll begin by updating the shader files. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset