Revision 24804c15
Added by Leszek Koltunski over 3 years ago
src/main/res/raw/main_vertex_shader.glsl | ||
---|---|---|
20 | 20 |
precision highp float; |
21 | 21 |
precision highp int; |
22 | 22 |
|
23 |
in vec3 a_Position; // Per-vertex position. |
|
24 |
in vec3 a_Normal; // Per-vertex normal vector. |
|
25 |
in vec3 a_Inflate; // This vector describes the direction this vertex needs to go when we 'inflate' the whole mesh. |
|
26 |
// If the mesh is locally smooth, this is equal to the normal vector. Otherwise (on sharp edges) - no. |
|
27 |
in vec2 a_TexCoordinate; // Per-vertex texture coordinate. |
|
28 |
in float a_Component; // The component a vertex belongs to. |
|
29 |
// to a vertex effect. An effect will only be active on a vertex iff (a_Association & vAssociation[effect]) != 0. |
|
30 |
// ( see VertexEffect.retSection() ) |
|
31 |
|
|
32 |
out vec3 v_Position; // |
|
33 |
out vec3 v_endPosition; // for Transform Feedback only |
|
23 |
in vec3 a_Position; // Per-vertex position.
|
|
24 |
in vec3 a_Normal; // Per-vertex normal vector.
|
|
25 |
in vec3 a_Inflate; // This vector describes the direction this vertex needs to go when we 'inflate' the whole mesh.
|
|
26 |
// If the mesh is locally smooth, this is equal to the normal vector. Otherwise (on sharp edges) - no.
|
|
27 |
in vec2 a_TexCoordinate; // Per-vertex texture coordinate.
|
|
28 |
in float a_Component; // The component a vertex belongs to.
|
|
29 |
// to a vertex effect. An effect will only be active on a vertex iff (a_Association & vAssociation[effect]) != 0.
|
|
30 |
// ( see VertexEffect.retSection() )
|
|
31 |
|
|
32 |
out vec3 v_Position; //
|
|
33 |
out vec3 v_endPosition; // for Transform Feedback only
|
|
34 | 34 |
|
35 | 35 |
#ifdef PREAPPLY |
36 |
out vec3 v_Inflate; // Transform Feedback for preapply effects |
|
36 |
out vec3 v_Inflate; // Transform Feedback for preapply effects
|
|
37 | 37 |
#endif |
38 | 38 |
|
39 |
out vec3 v_Normal; // |
|
40 |
out vec2 v_TexCoordinate; // |
|
39 |
out vec3 v_Normal; //
|
|
40 |
out vec2 v_TexCoordinate; //
|
|
41 | 41 |
|
42 |
uniform mat4 u_MVPMatrix; // u_MVMatrixP * projection. |
|
43 |
uniform mat4 u_MVMatrixP; // the combined model/view matrix. (for points) |
|
44 |
uniform mat4 u_MVMatrixV; // the combined model/view matrix. (for vectors) |
|
45 |
// which need to work differently on points and vectors |
|
46 |
uniform float u_Inflate; // how much should we inflate (>0.0) or deflate (<0.0) the mesh. |
|
47 |
uniform int u_TransformFeedback; // are we doing the transform feedback now? |
|
42 |
uniform mat4 u_MVPMatrix; // u_MVMatrixP * projection.
|
|
43 |
uniform mat4 u_MVMatrixP; // the combined model/view matrix. (for points)
|
|
44 |
uniform mat4 u_MVMatrixV; // the combined model/view matrix. (for vectors)
|
|
45 |
// which need to work differently on points and vectors
|
|
46 |
uniform float u_Inflate; // how much should we inflate (>0.0) or deflate (<0.0) the mesh.
|
|
47 |
uniform int u_TransformFeedback; // are we doing the transform feedback now?
|
|
48 | 48 |
|
49 | 49 |
#if NUM_VERTEX>0 |
50 |
uniform int vNumEffects; // total number of vertex effects |
|
51 |
uniform int vName[NUM_VERTEX]; // their names. |
|
52 |
uniform int vEffAndAssoc[NUM_VERTEX];// Associations of the vertex effects. Those are used to connect an effect to a Mesh component. |
|
53 |
uniform int vEffEquAssoc[NUM_VERTEX];// Components the vertex effects work on. Likewise used to connect an effect to a Mesh component. |
|
50 |
uniform int vNumEffects; // total number of vertex effects |
|
51 |
uniform ivec4 vProperties[NUM_VERTEX];// their properties, 4 ints: |
|
52 |
// 1: name of the effect |
|
53 |
// 2: effect's AND association |
|
54 |
// 3: reserved int (probably another AND assoc in the future) |
|
55 |
// 4: effect's EQU association |
|
54 | 56 |
|
55 |
uniform vec4 vUniforms[3*NUM_VERTEX];// i-th effect is 3 consecutive vec4's: [3*i], [3*i+1], [3*i+2]. |
|
56 |
// The first vec4 is the Interpolated values, |
|
57 |
// second vec4: first float - cache, next 3: Center, the third - the Region. |
|
57 |
uniform vec4 vUniforms[3*NUM_VERTEX]; // i-th effect is 3 consecutive vec4's: [3*i], [3*i+1], [3*i+2].
|
|
58 |
// The first vec4 is the Interpolated values,
|
|
59 |
// second vec4: first float - cache, next 3: Center, the third - the Region.
|
|
58 | 60 |
|
59 | 61 |
layout (std140, binding=3) uniform meshAssociation |
60 | 62 |
{ |
61 |
ivec4 vComAssoc[MAX_COMPON]; // component Associations |
|
63 |
ivec4 vComAssoc[MAX_COMPON]; // component Associations, 4 ints: |
|
64 |
// 1: component's AND association |
|
65 |
// 2: reserved. Probably another AND assoc in the future. |
|
66 |
// 3: component's EQU association |
|
67 |
// 4: reserved |
|
62 | 68 |
}; |
63 | 69 |
|
64 | 70 |
////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
118 | 124 |
|
119 | 125 |
for(int i=0; i<vNumEffects; i++) |
120 | 126 |
{ |
121 |
if( ((vComAssoc[component].x & vEffAndAssoc[i]) != 0) || (vComAssoc[component].z == vEffEquAssoc[i]) )
|
|
127 |
if( ((vComAssoc[component].x & vProperties[i].y) != 0) || (vComAssoc[component].z == vProperties[i].w) )
|
|
122 | 128 |
{ |
123 | 129 |
// ENABLED EFFECTS WILL BE INSERTED HERE |
124 | 130 |
|
Also available in: Unified diff
Turn the vName, vEffAnd and vEffEqu integer array uniforms into a one ivec4.
The point: ivec4s are always packed tightly in UBOs (which is going to be the next step)