Creating the Sun

The Sun will be rendered as a textured sphere. However, it's not shaded with front and back sides like our Earth. We need to render it unlit or rather unshaded. This means we need to create the UnlitTextureMaterial.

We have a texture file for the Sun, too (and all the planets as well).We won't show all of them in the chapter although they're included with the downloadable files for the book.

Drag a copy of the sun_tex.png file onto your res/drawable/ folder.

Unlit texture shaders

As we've seen earlier in this book, unlit shaders are much simpler than ones with lighting. In your res/raw/ folder, create files for unlit_tex_vertex.shader and unlit_tex_fragment.shader, and then define them, as follows.

File: unlit_tex_vertex.shader

uniform ...

Get Cardboard VR Projects for Android now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.