Revision 4aa38649
Added by Leszek Koltunski over 5 years ago
src/main/res/raw/main_vertex_shader.glsl | ||
---|---|---|
43 | 43 |
uniform int vName[NUM_VERTEX]; // their names. |
44 | 44 |
uniform vec4 vUniforms[3*NUM_VERTEX];// i-th effect is 3 consecutive vec4's: [3*i], [3*i+1], [3*i+2]. |
45 | 45 |
// The first vec4 is the Interpolated values, |
46 |
// next is half cache half Center, the third - the Region.
|
|
46 |
// second vec4: first float - cache, next 3: Center, the third - the Region.
|
|
47 | 47 |
|
48 | 48 |
////////////////////////////////////////////////////////////////////////////////////////////// |
49 | 49 |
// HELPER FUNCTIONS |
... | ... | |
62 | 62 |
////////////////////////////////////////////////////////////////////////////////////////////// |
63 | 63 |
// return degree of the point as defined by the bitmap rectangle |
64 | 64 |
|
65 |
float degree_bitmap(in vec2 S, in vec2 PS)
|
|
65 |
float degree_bitmap(in vec3 S, in vec3 PS)
|
|
66 | 66 |
{ |
67 |
vec2 A = sign(PS)*u_objD.xy + S;
|
|
67 |
vec3 A = sign(PS)*u_objD + S;
|
|
68 | 68 |
|
69 |
vec2 signA = sign(A); //
|
|
70 |
vec2 signA_SQ = signA*signA; // div = PS/A if A!=0, 0 otherwise.
|
|
71 |
vec2 div = signA_SQ*PS/(A-(vec2(1,1)-signA_SQ));//
|
|
69 |
vec3 signA = sign(A); //
|
|
70 |
vec3 signA_SQ = signA*signA; // div = PS/A if A!=0, 0 otherwise.
|
|
71 |
vec3 div = signA_SQ*PS/(A-(vec3(1.0,1.0,1.0)-signA_SQ)); //
|
|
72 | 72 |
|
73 | 73 |
return 1.0-max(div.x,div.y); |
74 | 74 |
} |
... | ... | |
94 | 94 |
// where a = PS*PO/|PS| but we are really looking for d = |PX|/(|PX|+|PS|) = 1/(1+ (|PS|/|PX|) ) and |
95 | 95 |
// |PX|/|PS| = -b + sqrt(b^2 + (OX^2-PO^2)/PS^2) where b=PS*PO/|PS|^2 which can be computed with only one sqrt. |
96 | 96 |
|
97 |
float degree_region(in vec4 region, in vec2 PS)
|
|
97 |
float degree_region(in vec4 region, in vec3 PS)
|
|
98 | 98 |
{ |
99 |
vec2 PO = PS + region.xy;
|
|
100 |
float D = region.z*region.z-dot(PO,PO); // D = |OX|^2 - |PO|^2
|
|
99 |
vec3 PO = PS + region.xyz;
|
|
100 |
float D = region.w*region.w-dot(PO,PO); // D = |OX|^2 - |PO|^2
|
|
101 | 101 |
|
102 | 102 |
if( D<=0.0 ) return 0.0; |
103 | 103 |
|
... | ... | |
119 | 119 |
////////////////////////////////////////////////////////////////////////////////////////////// |
120 | 120 |
// return min(degree_bitmap,degree_region). Just like degree_region, currently only supports circles. |
121 | 121 |
|
122 |
float degree(in vec4 region, in vec2 S, in vec2 PS)
|
|
122 |
float degree(in vec4 region, in vec3 S, in vec3 PS)
|
|
123 | 123 |
{ |
124 |
vec2 PO = PS + region.xy;
|
|
125 |
float D = region.z*region.z-dot(PO,PO); // D = |OX|^2 - |PO|^2
|
|
124 |
vec3 PO = PS + region.xyz;
|
|
125 |
float D = region.w*region.w-dot(PO,PO); // D = |OX|^2 - |PO|^2
|
|
126 | 126 |
|
127 | 127 |
if( D<=0.0 ) return 0.0; |
128 | 128 |
|
129 |
vec2 A = sign(PS)*u_objD.xy + S;
|
|
130 |
vec2 signA = sign(A);
|
|
131 |
vec2 signA_SQ = signA*signA;
|
|
132 |
vec2 div = signA_SQ*PS/(A-(vec2(1,1)-signA_SQ));
|
|
129 |
vec3 A = sign(PS)*u_objD.xyz + S;
|
|
130 |
vec3 signA = sign(A);
|
|
131 |
vec3 signA_SQ = signA*signA;
|
|
132 |
vec3 div = signA_SQ*PS/(A-(vec3(1.0,1.0,1.0)-signA_SQ));
|
|
133 | 133 |
float E = 1.0-max(div.x,div.y); |
134 | 134 |
|
135 | 135 |
float ps_sq = dot(PS,PS); |
Also available in: Unified diff
Redefine the Vertex Region from (x,y,r,unused) to (x,y,z,r). This takes into account the 'Z', which makes it possible to warp only one side of a 3D Mesh like Sphere.
Also corresponding changes in applications.