O'Reilly logo

Cardboard VR Projects for Android by Matt Schoen, Jonathan Linowes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required