Revision 5b673c85
Added by Leszek Koltunski over 8 years ago
| src/main/java/org/distorted/library/effect/PostprocessEffectGlow.java | ||
|---|---|---|
| 180 | 180 |
GLES30.glUniform1fv( mProgram1.mUniform[2] , radius+1, mOffsets,0); |
| 181 | 181 |
GLES30.glUniform1fv( mProgram1.mUniform[3] , radius+1, weightsCache,offset); |
| 182 | 182 |
GLES30.glUniform1i ( mProgram1.mUniform[4] , radius); |
| 183 |
GLES30.glUniform4f ( mProgram1.mUniform[5] , uniforms[index+1], uniforms[index+2], uniforms[index+3], uniforms[index+4]); |
|
| 183 | 184 |
GLES30.glVertexAttribPointer(mProgram1.mAttribute[0], POS_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadPositions); |
| 184 | 185 |
GLES30.glVertexAttribPointer(mProgram1.mAttribute[1], TEX_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadTexture); |
| 185 | 186 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4); |
| ... | ... | |
| 191 | 192 |
outBuffer.bindForOutput(0); |
| 192 | 193 |
outBuffer.setAsInput(1); |
| 193 | 194 |
|
| 194 |
GLES30.glColorMask(true,true,true,true); |
|
| 195 |
GLES30.glClearColor(0.0f,0.0f,0.0f,0.0f); |
|
| 196 |
GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT); |
|
| 197 |
|
|
| 198 | 195 |
GLES30.glUniform1f ( mProgram2.mUniform[0] , near); |
| 199 | 196 |
GLES30.glUniform1i ( mProgram2.mUniform[1] , 0 ); |
| 200 | 197 |
GLES30.glUniform1fv( mProgram2.mUniform[2] , radius+1, mOffsets,0); |
| 201 | 198 |
GLES30.glUniform1fv( mProgram2.mUniform[3] , radius+1, weightsCache,offset); |
| 202 | 199 |
GLES30.glUniform1i ( mProgram2.mUniform[4] , radius); |
| 200 |
GLES30.glUniform4f ( mProgram1.mUniform[5] , uniforms[index+1], uniforms[index+2], uniforms[index+3], uniforms[index+4]); |
|
| 203 | 201 |
GLES30.glVertexAttribPointer(mProgram2.mAttribute[0], POS_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadPositions); |
| 204 | 202 |
GLES30.glVertexAttribPointer(mProgram2.mAttribute[1], TEX_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadTexture); |
| 205 | 203 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4); |
| ... | ... | |
| 241 | 239 |
"uniform float u_Offsets[MAX_BLUR]; \n"+ |
| 242 | 240 |
"uniform float u_Weights[MAX_BLUR]; \n"+ |
| 243 | 241 |
"uniform int u_Radius; \n"+ |
| 244 |
|
|
| 245 |
"void main() \n"+ |
|
| 246 |
" { \n"+
|
|
| 247 |
" vec4 pixel= texture(u_ColorTexture,v_TexCoord) * u_Weights[0]; \n"+ |
|
| 248 |
" for (int i=1; i<=u_Radius; i+=1) \n"+ |
|
| 249 |
" { \n"+
|
|
| 250 |
" pixel += ( texture(u_ColorTexture,vec2(v_TexCoord.x+u_Offsets[i],v_TexCoord.y)) + \n"+ |
|
| 251 |
" texture(u_ColorTexture,vec2(v_TexCoord.x-u_Offsets[i],v_TexCoord.y)) ) * u_Weights[i]; \n"+ |
|
| 252 |
" } \n"+ |
|
| 253 |
" fragColor = pixel; \n"+ |
|
| 242 |
"uniform vec4 u_Color; \n"+ |
|
| 243 |
|
|
| 244 |
"void main() \n"+ |
|
| 245 |
" { \n"+
|
|
| 246 |
" float alpha= texture(u_ColorTexture,v_TexCoord).a * u_Weights[0]; \n"+ |
|
| 247 |
" for (int i=1; i<=u_Radius; i+=1) \n"+ |
|
| 248 |
" { \n"+
|
|
| 249 |
" alpha += ( texture(u_ColorTexture,vec2(v_TexCoord.x+u_Offsets[i],v_TexCoord.y)).a + \n"+ |
|
| 250 |
" texture(u_ColorTexture,vec2(v_TexCoord.x-u_Offsets[i],v_TexCoord.y)).a ) * u_Weights[i]; \n"+ |
|
| 251 |
" } \n"+ |
|
| 252 |
" fragColor = vec4(u_Color.rgb,u_Color.a*alpha); \n"+ |
|
| 254 | 253 |
" }"; |
| 255 | 254 |
|
| 256 | 255 |
final String glowFragment2 = |
| ... | ... | |
| 264 | 263 |
"uniform float u_Offsets[MAX_BLUR]; \n"+ |
| 265 | 264 |
"uniform float u_Weights[MAX_BLUR]; \n"+ |
| 266 | 265 |
"uniform int u_Radius; \n"+ |
| 267 |
|
|
| 268 |
"void main() \n"+ |
|
| 269 |
" { \n"+
|
|
| 270 |
" vec4 pixel= texture(u_ColorTexture,v_TexCoord) * u_Weights[0]; \n"+ |
|
| 271 |
" for (int i=1; i<=u_Radius; i+=1) \n"+ |
|
| 272 |
" { \n"+
|
|
| 273 |
" pixel += ( texture(u_ColorTexture,vec2(v_TexCoord.x,v_TexCoord.y+u_Offsets[i])) + \n"+ |
|
| 274 |
" texture(u_ColorTexture,vec2(v_TexCoord.x,v_TexCoord.y-u_Offsets[i])) ) * u_Weights[i]; \n"+ |
|
| 275 |
" } \n"+ |
|
| 276 |
" fragColor = pixel; \n"+ |
|
| 266 |
"uniform vec4 u_Color; \n"+ |
|
| 267 |
|
|
| 268 |
"void main() \n"+ |
|
| 269 |
" { \n"+
|
|
| 270 |
" float alpha= texture(u_ColorTexture,v_TexCoord).a * u_Weights[0]; \n"+ |
|
| 271 |
" for (int i=1; i<=u_Radius; i+=1) \n"+ |
|
| 272 |
" { \n"+
|
|
| 273 |
" alpha += ( texture(u_ColorTexture,vec2(v_TexCoord.x,v_TexCoord.y+u_Offsets[i])).a + \n"+ |
|
| 274 |
" texture(u_ColorTexture,vec2(v_TexCoord.x,v_TexCoord.y-u_Offsets[i])).a ) * u_Weights[i]; \n"+ |
|
| 275 |
" } \n"+ |
|
| 276 |
" fragColor = vec4(u_Color.rgb,u_Color.a*alpha); \n"+ |
|
| 277 | 277 |
" }"; |
| 278 | 278 |
|
| 279 | 279 |
mIndex1 = PostprocessEffect.register("BLUR1", glowVertex,glowFragment1);
|
Also available in: Unified diff
Some progress with GLOW. Still does not look right :)