0
\$\begingroup\$

Other questione releated to my ray tracer implementation for iPad.

If I have a polygon that has a texture and a material, how do I calculate the color using Phong lighting model? Is the texture used in substitution of some of the component (diffuse?)? Or if there's a texture I need to just ignore the material and get only the texture color?

\$\endgroup\$
0
\$\begingroup\$

I don't exactly understand how would ray-tracing change anything, here is how it usually goes:

You can have a texture for any parameter you like, but the most common is a diffuse(color) map, so you just sample this based on the texture coordinates and use the texture in place of the single-color diffuse. You could also combine the texture with an arbitrary color, tinting the given element.

Other common textures include normal maps, reflection maps, which replace their respective counterparts. Normal maps can be a bit tricky, because they specify the rotation relative to the surface, so you need to construct a Tangent Bitangent Normal matrix, which will do the transformation for you.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.