From the course: Learning OpenGL

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Combining lighting and textures

Combining lighting and textures - OpenGL Tutorial

From the course: Learning OpenGL

Start my 1-month free trial

Combining lighting and textures

- [Voiceover] Let's see if we can send all the vertex attributes over to the shader that we've discussed so far. This includes position, normal, color, and texture. We're going to make a cube, that spins, with lighting, and texture. Let's get started. Our shader code now has four attributes to it: a vec four for position, a vec three for normal, a vec four for color, and a vec two texture coordinate. We also have a projection view model and normal matrices. We have some varying data that we'd like to send on to the fragment shader. Namely, the texture coordinate and also a floating point value for the diffuse quotient. We're going to use this diffuse float to adjust our texture color in our fragment shader. Here when we call due color, instead of creating a color there, we're just returning a floating point value. We use that floating point value here to weigh the color value of the texture. We just want to weigh the RGB value not the alpha value. We can create a vec four by looking…

Contents