Vertex color lighting material and shaders

This next topic gets a bit complicated. We're going to write new vertex and fragment shaders that handle lighting and write a corresponding class extending Material that makes use of them. Don't worry though, we've already done this once before. We're just going to actually explain it this time.

Let's dive right into it. Locate the res/raw/ folder. Then, for each file, right-click on it, and go to New | File to create new files.

File: res/raw/vertex_color_lighting_vertex.shader

uniform mat4 u_Model; uniform mat4 u_MVP; uniform mat4 u_MVMatrix; uniform vec3 u_LightPos; attribute vec4 a_Position; attribute vec4 a_Color; attribute vec3 a_Normal; varying vec4 v_Color; const float ONE = 1.0; const float COEFF ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.