2014/11/10

Add texture in Metal

There is a sample code named ‘MetalTextureQuad’ by Apple, you can find how to make textured object in Metal. So I tried this, but…

Wrongly textured robot

No, something is wrong. Perhaps I made robot data wrongly in Blender? So I tried to show this using OpenGL ES.

Textured robot in OpenGL ES

Looks good. The data is right. Somewhere code to make texture may be wrong.

This is code which makes texture flip :
{
    CGContextTranslateCTM(pContext, width, height);
    CGContextScaleCTM(pContext, -1.0, -1.0);
}
Well, this code makes an image flip vertically and horizontally. This may be right in the sample code, but I thought the image should be flipped only vertically?
So I changed code like this :
{
    CGContextTranslateCTM(pContext, 0.0, height);
    CGContextScaleCTM(pContext, 1.0, -1.0);
}
The result is here :

Textured robot

Good, but he looks a little bit dark. Something, normal information, is wrong? To be continued.


Continued : Brightness by inner product of normal and light vectors / iPhone App Development Memo

Develop | Comments(2) | Trackback(0)
Comment
Comment is pending approval.
Comment is pending blog author's approval.
Comment is pending approval.
Comment is pending blog author's approval.

管理者のみに表示