Revision 1dfc9074
Added by Leszek Koltunski almost 7 years ago
src/main/java/org/distorted/library/effect/PostprocessEffect.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.library.effect; |
21 | 21 |
|
22 |
import org.distorted.library.main.DistortedFramebuffer; |
|
23 |
|
|
24 |
import java.nio.ByteBuffer; |
|
25 |
import java.nio.ByteOrder; |
|
26 |
import java.nio.FloatBuffer; |
|
27 |
|
|
22 | 28 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
23 | 29 |
// POSTPROCESSING EFFECTS. |
24 | 30 |
|
25 |
|
|
26 | 31 |
public abstract class PostprocessEffect extends Effect |
27 | 32 |
{ |
28 | 33 |
public static final int NUM_UNIFORMS = 5; // 5 per-effect interpolated values. |
29 | 34 |
|
35 |
static final int POS_DATA_SIZE= 2; // Blur Program: size of the position data in elements |
|
36 |
static final int TEX_DATA_SIZE= 2; // Blur Program: size of the texture coordinate data in elements. |
|
37 |
|
|
38 |
static final FloatBuffer mQuadPositions, mQuadTexture, mQuadTextureInv; |
|
39 |
|
|
40 |
static |
|
41 |
{ |
|
42 |
int dataLength = 4; |
|
43 |
int bytes_per_float = 4; |
|
44 |
|
|
45 |
float[] position = { -0.5f, -0.5f, -0.5f, 0.5f, 0.5f,-0.5f, 0.5f, 0.5f }; |
|
46 |
float[] textureNor= { 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f }; |
|
47 |
float[] textureInv= { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f }; |
|
48 |
|
|
49 |
mQuadPositions = ByteBuffer.allocateDirect(POS_DATA_SIZE*dataLength*bytes_per_float).order(ByteOrder.nativeOrder()).asFloatBuffer(); |
|
50 |
mQuadPositions.put(position).position(0); |
|
51 |
mQuadTexture= ByteBuffer.allocateDirect(TEX_DATA_SIZE*dataLength*bytes_per_float).order(ByteOrder.nativeOrder()).asFloatBuffer(); |
|
52 |
mQuadTexture.put(textureNor).position(0); |
|
53 |
mQuadTextureInv= ByteBuffer.allocateDirect(TEX_DATA_SIZE*dataLength*bytes_per_float).order(ByteOrder.nativeOrder()).asFloatBuffer(); |
|
54 |
mQuadTextureInv.put(textureInv).position(0); |
|
55 |
} |
|
56 |
|
|
57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
58 |
|
|
59 |
public abstract int apply(float[] uniforms, int index, float qualityScale, DistortedFramebuffer buffer); |
|
60 |
|
|
30 | 61 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
31 | 62 |
|
32 | 63 |
PostprocessEffect(EffectName name) |
Also available in: Unified diff
All knowledge about Postporcessing moved to the respective Effect classes.