Project

General

Profile

« Previous | Next » 

Revision d333eb6b

Added by Leszek Koltunski almost 8 years ago

Add license

View differences:

src/main/res/raw/main_vertex_shader.glsl
1
uniform vec3 u_bmpD;            // half of object width x half of object height X half the depth; 
2
                                // point (0,0,0) is the center of the object
1
//////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                          //
3
//                                                                                          //
4
// This file is part of Distorted.                                                          //
5
//                                                                                          //
6
// Distorted is free software: you can redistribute it and/or modify                        //
7
// it under the terms of the GNU General Public License as published by                     //
8
// the Free Software Foundation, either version 2 of the License, or                        //
9
// (at your option) any later version.                                                      //
10
//                                                                                          //
11
// Distorted is distributed in the hope that it will be useful,                             //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                           //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                            //
14
// GNU General Public License for more details.                                             //
15
//                                                                                          //
16
// You should have received a copy of the GNU General Public License                        // 
17
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                       //
18
//////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
uniform vec3 u_bmpD;                      // half of object width x half of object height X half the depth; 
21
                                          // point (0,0,0) is the center of the object
3 22

  
4
uniform float u_Depth;          // max absolute value of v.z ; beyond that the vertex would be culled by the near or far planes.
5
                                // I read OpenGL ES has a built-in uniform variable gl_DepthRange.near = n, .far = f, .diff = f-n so maybe u_Depth is redundant
6
                                // Update: this struct is only available in fragment shaders
23
uniform float u_Depth;                    // max absolute value of v.z ; beyond that the vertex would be culled by the near or far planes.
24
                                          // I read OpenGL ES has a built-in uniform variable gl_DepthRange.near = n, 
25
                                          // .far = f, .diff = f-n so maybe u_Depth is redundant
26
                                          // Update: this struct is only available in fragment shaders
7 27
                                
8
uniform mat4 u_MVPMatrix;		// A constant representing the combined model/view/projection matrix.      		       
9
uniform mat4 u_MVMatrix;		// A constant representing the combined model/view matrix.       		
28
uniform mat4 u_MVPMatrix;                 // A constant representing the combined model/view/projection matrix.      		       
29
uniform mat4 u_MVMatrix;                  // A constant representing the combined model/view matrix.       		
10 30
		 
11
attribute vec3 a_Position;		// Per-vertex position information we will pass in.   				
12
attribute vec4 a_Color;			// Per-vertex color information we will pass in. 				
13
attribute vec3 a_Normal;		// Per-vertex normal information we will pass in.      
14
attribute vec2 a_TexCoordinate; // Per-vertex texture coordinate information we will pass in. 		
31
attribute vec3 a_Position;                // Per-vertex position information we will pass in.   				
32
attribute vec4 a_Color;                   // Per-vertex color information we will pass in. 				
33
attribute vec3 a_Normal;                  // Per-vertex normal information we will pass in.      
34
attribute vec2 a_TexCoordinate;           // Per-vertex texture coordinate information we will pass in. 		
15 35
		  
16
varying vec3 v_Position;		//      		
17
varying vec4 v_Color;			// Those will be passed into the fragment shader.          		
18
varying vec3 v_Normal;			//  
19
varying vec2 v_TexCoordinate;   //  		
36
varying vec3 v_Position;                  //      		
37
varying vec4 v_Color;                     // Those will be passed into the fragment shader.          		
38
varying vec3 v_Normal;                    //  
39
varying vec2 v_TexCoordinate;             //  		
20 40

  
21 41
uniform int vNumEffects;                  // total number of vertex effects
22 42

  
23 43
#if NUM_VERTEX>0
24 44
uniform int vType[NUM_VERTEX];            // their types.
25
uniform vec3 vUniforms[3*NUM_VERTEX];     // i-th effect is 3 consecutive vec3's: [3*i], [3*i+1], [3*i+2]. first 3 float are the Interpolated values,
45
uniform vec3 vUniforms[3*NUM_VERTEX];     // i-th effect is 3 consecutive vec3's: [3*i], [3*i+1], [3*i+2]. 
46
                                          // The first 3 floats are the Interpolated values,
26 47
                                          // next 4 are the Region, next 2 are the Point. 
27 48
#endif
28 49

  
......
329 350
  v_TexCoordinate = a_TexCoordinate;                                         
330 351
  v_Normal        = normalize(vec3(u_MVMatrix*n));
331 352
  gl_Position     = u_MVPMatrix*v;      
332
  }                               
353
  }                               

Also available in: Unified diff