13.07.2015 Views

Mali GPU User Interface Engine Application Development Guide

Mali GPU User Interface Engine Application Development Guide

Mali GPU User Interface Engine Application Development Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Tutorial on Drawing 3D ShapesExample 4-34 Load the assets for bump mapping...SceneAsset* scene = proxy.getSceneAsset("cube.mba");GeometryAsset* teapot =static_cast(scene->getAsset(Asset::TYPE_GEOMETRY, 0));Texture2D *diffuseTexture =proxy.getTexture2DAsset("rock_t.png")->getTexture2D();...Texture2D *normalMap =proxy.getTexture2DAsset("rock_n.png")->getTexture2D();4. The two .png files shown in Figure 4-9 contain the texture and the normal information:Figure 4-9 Contents of rock texture and normal filesNoteThe normal file in Figure 4-9 can be displayed as a colored graphic, but the pixels actuallyrepresent three-element vectors. The x, y, and z values for the vectors are determined bythe intensity of the red, green, and blue colors at that point.5. The vertex shader computes the location for the fragment, but it also computes the anglesas shown in Example 4-35:Example 4-35 bumpmapping.vert contentsuniform mat4 WORLD_VIEW_PROJECTION;uniform mat3 WORLD;// the light and camera positions are constant for this primitive shapeuniform vec3 LIGHT_POSITION;uniform vec3 CAMERA_POSITION;// the vectors are interpolated for this location on the primitive shapeattribute vec4 POSITION;attribute vec3 NORMAL;attribute vec3 TANGENT;attribute vec3 BINORMAL;attribute vec3 TEXCOORD0;// texture coordinate to pass to fragment shader to look up the color for the fragmentvarying vec2 vTexCoord;// pass the fragment shader the light and camera vectors to this point// these are used to calculate the effects of diffuse and specular lightingARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 4-26ID070710Non-Confidential - Draft - Beta

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!