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 mat4 u_MVP; attribute vec4 a_Position; attribute vec2 a_TexCoordinate; varying vec3 v_Position; varying vec2 v_TexCoordinate; void main() { // pass through the texture coordinate v_TexCoordinate = a_TexCoordinate; // final point in...