Revision 86c352e0
Added by Leszek Koltunski almost 6 years ago
src/main/java/org/distorted/library/main/EffectQueueMatrix.java | ||
---|---|---|
43 | 43 |
private static float mMiny; |
44 | 44 |
private static float mMaxy; |
45 | 45 |
|
46 |
private static int mObjDH; // This is a handle to half a Object dimensions |
|
47 |
private static int mMVPMatrixH; // the transformation matrix |
|
48 |
private static int mMVMatrixH; // the modelview matrix. |
|
49 |
|
|
50 |
private static int mObjDOITH; // |
|
51 |
private static int mMVPMatrixOITH; // Same like above, but in main OIT program. |
|
52 |
private static int mMVMatrixOITH; // |
|
46 |
private static int[] mObjDH = new int[Distorted.MAIN_VARIANTS]; |
|
47 |
private static int[] mMVPMatrixH = new int[Distorted.MAIN_VARIANTS]; |
|
48 |
private static int[] mMVMatrixH = new int[Distorted.MAIN_VARIANTS]; |
|
53 | 49 |
|
54 | 50 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
55 | 51 |
|
... | ... | |
105 | 101 |
|
106 | 102 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
107 | 103 |
|
108 |
static void getUniforms(int mProgramH) |
|
109 |
{ |
|
110 |
mObjDH = GLES31.glGetUniformLocation(mProgramH, "u_objD"); |
|
111 |
mMVPMatrixH= GLES31.glGetUniformLocation(mProgramH, "u_MVPMatrix"); |
|
112 |
mMVMatrixH = GLES31.glGetUniformLocation(mProgramH, "u_MVMatrix"); |
|
113 |
} |
|
114 |
|
|
115 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
116 |
|
|
117 |
static void getUniformsOIT(int mProgramH) |
|
104 |
static void getUniforms(int mProgramH, int variant) |
|
118 | 105 |
{ |
119 |
mObjDOITH = GLES31.glGetUniformLocation(mProgramH, "u_objD");
|
|
120 |
mMVPMatrixOITH= GLES31.glGetUniformLocation(mProgramH, "u_MVPMatrix");
|
|
121 |
mMVMatrixOITH = GLES31.glGetUniformLocation(mProgramH, "u_MVMatrix");
|
|
106 |
mObjDH[variant] = GLES31.glGetUniformLocation(mProgramH, "u_objD");
|
|
107 |
mMVPMatrixH[variant]= GLES31.glGetUniformLocation(mProgramH, "u_MVPMatrix");
|
|
108 |
mMVMatrixH[variant] = GLES31.glGetUniformLocation(mProgramH, "u_MVMatrix");
|
|
122 | 109 |
} |
123 | 110 |
|
124 | 111 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
158 | 145 |
|
159 | 146 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
160 | 147 |
|
161 |
void send(DistortedOutputSurface projection, float halfX, float halfY, float halfZ, float marginInPixels) |
|
162 |
{ |
|
163 |
Matrix.setIdentityM(mViewMatrix, 0); |
|
164 |
Matrix.translateM(mViewMatrix, 0, -projection.mWidth/2, projection.mHeight/2, -projection.mDistance); |
|
165 |
float mipmap = projection.mMipmap; |
|
166 |
if( mipmap!=1 ) Matrix.scaleM(mViewMatrix, 0, mipmap, mipmap, mipmap); |
|
167 |
|
|
168 |
for(int i=0; i<mNumEffects; i++) ((MatrixEffect)mEffects[i]).apply(mViewMatrix,mUniforms,i); |
|
169 |
|
|
170 |
Matrix.translateM(mViewMatrix, 0, halfX,-halfY,-halfZ); |
|
171 |
if( marginInPixels!=0 ) magnify(projection,halfX,halfY,halfZ, marginInPixels); |
|
172 |
Matrix.multiplyMM(mMVPMatrix, 0, projection.mProjectionMatrix, 0, mViewMatrix, 0); |
|
173 |
|
|
174 |
GLES31.glUniform3f( mObjDH , halfX, halfY, halfZ); |
|
175 |
GLES31.glUniformMatrix4fv(mMVMatrixH , 1, false, mViewMatrix, 0); |
|
176 |
GLES31.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPMatrix , 0); |
|
177 |
} |
|
178 |
|
|
179 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
180 |
|
|
181 |
void sendOIT(DistortedOutputSurface projection, float halfX, float halfY, float halfZ, float marginInPixels) |
|
148 |
void send(DistortedOutputSurface projection, float halfX, float halfY, float halfZ, float marginInPixels, int variant) |
|
182 | 149 |
{ |
183 | 150 |
Matrix.setIdentityM(mViewMatrix, 0); |
184 | 151 |
Matrix.translateM(mViewMatrix, 0, -projection.mWidth/2, projection.mHeight/2, -projection.mDistance); |
... | ... | |
191 | 158 |
if( marginInPixels!=0 ) magnify(projection,halfX,halfY,halfZ, marginInPixels); |
192 | 159 |
Matrix.multiplyMM(mMVPMatrix, 0, projection.mProjectionMatrix, 0, mViewMatrix, 0); |
193 | 160 |
|
194 |
GLES31.glUniform3f( mObjDOITH , halfX, halfY, halfZ);
|
|
195 |
GLES31.glUniformMatrix4fv(mMVMatrixOITH , 1, false, mViewMatrix, 0);
|
|
196 |
GLES31.glUniformMatrix4fv(mMVPMatrixOITH, 1, false, mMVPMatrix , 0);
|
|
161 |
GLES31.glUniform3f( mObjDH[variant] , halfX, halfY, halfZ);
|
|
162 |
GLES31.glUniformMatrix4fv(mMVMatrixH[variant] , 1, false, mViewMatrix, 0);
|
|
163 |
GLES31.glUniformMatrix4fv(mMVPMatrixH[variant], 1, false, mMVPMatrix , 0);
|
|
197 | 164 |
} |
198 | 165 |
} |
Also available in: Unified diff
Some progress with not-postprocessed OIT.