Revision f89a986e
Added by Leszek Koltunski over 6 years ago
src/main/java/org/distorted/library/main/DistortedEffects.java | ||
---|---|---|
399 | 399 |
GLES31.glDrawArrays(GLES31.GL_TRIANGLE_STRIP, 0, 4); |
400 | 400 |
|
401 | 401 |
|
402 |
//android.util.Log.e("effects", "bufferSize: "+mBufferSize+" numRecords: "+((mBufferSize-surface.mWidth*surface.mHeight)/3) ); |
|
402 |
//android.util.Log.e("effects", "width="+surface.mWidth+" height="+surface.mHeight+ |
|
403 |
// " bufferSize: "+mBufferSize+" numRecords: "+((mBufferSize-surface.mWidth*surface.mHeight)/3) ); |
|
403 | 404 |
} |
404 | 405 |
|
405 | 406 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/res/raw/blit_depth_fragment_shader.glsl | ||
---|---|---|
17 | 17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
18 | 18 |
////////////////////////////////////////////////////////////////////////////////////////////// |
19 | 19 |
|
20 |
precision lowp float;
|
|
20 |
precision highp float;
|
|
21 | 21 |
precision highp uint; |
22 | 22 |
|
23 | 23 |
#if __VERSION__ != 100 |
... | ... | |
60 | 60 |
{ |
61 | 61 |
uint ptr = atomicCounterIncrement(u_Counter)-1u; |
62 | 62 |
|
63 |
if( ptr<u_numRecords ) |
|
64 |
{/* |
|
65 |
uint color; |
|
66 |
vec2 c = vec2(0.0,1.0); |
|
67 |
|
|
68 |
uint rgb = ((uint(255.0*c.x))<<16u) + uint(255.0*c.y); |
|
69 |
|
|
70 |
if( rgb == 0u ) color = (255u<<24u) + (255u<<16u) + 255u; |
|
71 |
else if( (rgb&255u) == 0u ) color = (255u<<24u) + 255u; |
|
72 |
else if( (rgb&255u) <= 50u ) color = (255u<<16u) + 255u; |
|
73 |
else if( (rgb&255u) == 255u) color = (255u<<16u) + (255u<< 8u) + 255u; |
|
74 |
else color = (255u<< 8u) + 255u; |
|
75 |
*/ |
|
76 |
vec4 c= vec4(1.0,1.0,0.0,1.0); |
|
77 |
uint color = ((uint(255.0*c.r))<<24u) + ((uint(255.0*c.g))<<16u) + ((uint(255.0*c.b))<<8u) + uint(255.0*c.a); |
|
78 |
|
|
79 |
ptr = 3u*ptr + uint(u_Size.x*u_Size.y); |
|
80 |
|
|
81 |
u_Records[ptr ] = 0u; |
|
82 |
u_Records[ptr+1u] = depth; |
|
83 |
u_Records[ptr+2u] = rgba; |
|
84 |
|
|
85 |
uint index = uint(ij.x + ij.y * float(u_Size.x)); |
|
86 |
|
|
87 |
u_Records[index] = ptr; |
|
88 |
} |
|
89 |
/* |
|
90 |
uint ptr = atomicCounterIncrement(u_Counter)-1u; |
|
91 |
|
|
63 | 92 |
if( ptr<u_numRecords ) |
64 | 93 |
{ |
65 | 94 |
ptr = 3u*ptr + uint(u_Size.x*u_Size.y); |
... | ... | |
76 | 105 |
{ |
77 | 106 |
if ( curr==0u || depth > u_Records[curr+1u] ) // need to insert here |
78 | 107 |
{ |
79 |
*/ |
|
108 |
|
|
80 | 109 |
u_Records[ptr] = curr; // next of new record is curr |
81 | 110 |
memoryBarrier(); |
82 | 111 |
uint res = atomicCompSwap( u_Records[prev], curr, ptr ); |
... | ... | |
91 | 120 |
} |
92 | 121 |
} |
93 | 122 |
*/ |
94 |
} |
|
123 |
// } |
|
124 |
|
|
125 |
|
|
95 | 126 |
} |
96 | 127 |
|
97 | 128 |
////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/res/raw/blit_depth_render_fragment_shader.glsl | ||
---|---|---|
17 | 17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
18 | 18 |
////////////////////////////////////////////////////////////////////////////////////////////// |
19 | 19 |
|
20 |
precision lowp float;
|
|
20 |
precision highp float;
|
|
21 | 21 |
precision highp uint; |
22 | 22 |
|
23 | 23 |
#if __VERSION__ != 100 |
... | ... | |
66 | 66 |
void main() |
67 | 67 |
{ |
68 | 68 |
uint index = uint(v_Pixel.x + v_Pixel.y * float(u_Size.x)); |
69 |
|
|
70 |
if( u_Records[index] == 0u ) discard; |
|
71 |
else |
|
72 |
{ |
|
73 |
index = u_Records[index]; |
|
74 |
FRAG_COLOR = convert(u_Records[index+2u]); |
|
75 |
} |
|
76 |
|
|
77 |
u_Records[index] = 0u; |
|
78 |
|
|
79 |
/* |
|
80 |
uint index = uint(v_Pixel.x + v_Pixel.y * float(u_Size.x)); |
|
69 | 81 |
uint curr = u_Records[index]; |
70 | 82 |
|
71 | 83 |
if (curr == 0u) discard; |
... | ... | |
83 | 95 |
if( color.a == 0.0 ) color = vec4(0.0,1.0,0.0,1.0); |
84 | 96 |
} |
85 | 97 |
|
98 |
|
|
99 |
if( curr>0u ) |
|
100 |
{ |
|
101 |
curr = u_Records[curr]; |
|
102 |
color= convert(u_Records[curr+2u]); |
|
103 |
} |
|
104 |
|
|
86 | 105 |
gl_FragDepth = TEXTURE(u_DepthTexture, v_TexCoordinate).r; |
87 | 106 |
FRAG_COLOR = color; |
88 | 107 |
|
89 | 108 |
//else |
90 | 109 |
// FRAG_COLOR = vec4(1.0,0.0,0.0,1.0); |
110 |
*/ |
|
91 | 111 |
} |
Also available in: Unified diff
Order Independent Transparency: some progress