Revision 33b0fad7
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java | ||
---|---|---|
153 | 153 |
|
154 | 154 |
buffer.setAsOutput(); |
155 | 155 |
|
156 |
float w1 = buffer.getWidth();
|
|
157 |
float h1 = buffer.getHeight();
|
|
158 |
float near= 1.0f - buffer.getNear();
|
|
156 |
float w= buffer.getWidth(); |
|
157 |
float h= buffer.getHeight(); |
|
158 |
float n= 1.0f - buffer.getNear(); |
|
159 | 159 |
|
160 | 160 |
int radius = (int)(uniforms[index]*mQualityScale); |
161 | 161 |
if( radius>=MAX_HALO ) radius = MAX_HALO-1; |
... | ... | |
163 | 163 |
|
164 | 164 |
int offset = radius + radius*radius/4; |
165 | 165 |
radius = (radius+1)/2; |
166 |
GLES30.glViewport(0, 0, (int)w1, (int)h1);
|
|
166 |
GLES30.glViewport(0, 0, (int)w, (int)h);
|
|
167 | 167 |
|
168 | 168 |
// horizontal blur |
169 |
for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]/w1;
|
|
169 |
for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]/w; |
|
170 | 170 |
|
171 | 171 |
mProgram1.useProgram(); |
172 | 172 |
buffer.bindForOutput(1); |
173 | 173 |
buffer.setAsInput(0); |
174 | 174 |
|
175 |
GLES30.glUniform1f ( mProgram1.mUniform[0] , near);
|
|
175 |
GLES30.glUniform1f ( mProgram1.mUniform[0] , n );
|
|
176 | 176 |
GLES30.glUniform1i ( mProgram1.mUniform[1] , 0 ); |
177 | 177 |
GLES30.glUniform1fv( mProgram1.mUniform[2] , radius+1, mOffsets,0); |
178 | 178 |
GLES30.glUniform1fv( mProgram1.mUniform[3] , radius+1, weightsCache,offset); |
... | ... | |
182 | 182 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4); |
183 | 183 |
|
184 | 184 |
// vertical blur |
185 |
for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]/h1;
|
|
185 |
for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]/h; |
|
186 | 186 |
|
187 | 187 |
mProgram2.useProgram(); |
188 | 188 |
buffer.bindForOutput(0); |
... | ... | |
192 | 192 |
GLES30.glClearColor(0.0f,0.0f,0.0f,0.0f); |
193 | 193 |
GLES30.glClear(GLES30.GL_COLOR_BUFFER_BIT); |
194 | 194 |
|
195 |
GLES30.glUniform1f ( mProgram2.mUniform[0] , near);
|
|
195 |
GLES30.glUniform1f ( mProgram2.mUniform[0] , n );
|
|
196 | 196 |
GLES30.glUniform1i ( mProgram2.mUniform[1] , 0 ); |
197 | 197 |
GLES30.glUniform1fv( mProgram2.mUniform[2] , radius+1, mOffsets,0); |
198 | 198 |
GLES30.glUniform1fv( mProgram2.mUniform[3] , radius+1, weightsCache,offset); |
src/main/java/org/distorted/library/effect/PostprocessEffectGlow.java | ||
---|---|---|
156 | 156 |
DistortedFramebuffer inBuffer = buffers[0]; |
157 | 157 |
DistortedFramebuffer outBuffer = buffers[mQualityLevel]; |
158 | 158 |
|
159 |
float w1 = outBuffer.getWidth(); |
|
160 |
float h1 = outBuffer.getHeight(); |
|
161 |
float w2 = inBuffer.getWidth(); |
|
162 |
float h2 = inBuffer.getHeight(); |
|
163 |
float near= 1.0f - outBuffer.getNear(); |
|
159 |
float w= outBuffer.getWidth(); |
|
160 |
float h= outBuffer.getHeight(); |
|
161 |
float n= 1.0f - outBuffer.getNear(); |
|
164 | 162 |
|
165 | 163 |
int radius = (int)(uniforms[index]*mQualityScale); |
166 | 164 |
if( radius>=MAX_HALO ) radius = MAX_HALO-1; |
... | ... | |
170 | 168 |
radius = (radius+1)/2; |
171 | 169 |
|
172 | 170 |
outBuffer.setAsOutput(); |
173 |
GLES30.glViewport(0, 0, (int)w1, (int)h1);
|
|
171 |
GLES30.glViewport(0, 0, (int)w, (int)h);
|
|
174 | 172 |
|
175 | 173 |
// horizontal glow |
176 |
for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]/w1;
|
|
174 |
for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]/w; |
|
177 | 175 |
|
178 | 176 |
mProgram1.useProgram(); |
179 | 177 |
outBuffer.bindForOutput(1); |
180 | 178 |
inBuffer.setAsInput(0); |
181 | 179 |
|
182 |
GLES30.glUniform1f ( mProgram1.mUniform[0] , near);
|
|
180 |
GLES30.glUniform1f ( mProgram1.mUniform[0] , n );
|
|
183 | 181 |
GLES30.glUniform1i ( mProgram1.mUniform[1] , 0 ); |
184 | 182 |
GLES30.glUniform1fv( mProgram1.mUniform[2] , radius+1, mOffsets,0); |
185 | 183 |
GLES30.glUniform1fv( mProgram1.mUniform[3] , radius+1, weightsCache,offset); |
... | ... | |
190 | 188 |
GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4); |
191 | 189 |
|
192 | 190 |
// vertical glow |
193 |
for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]/h1;
|
|
191 |
for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]/h; |
|
194 | 192 |
|
195 | 193 |
mProgram2.useProgram(); |
196 | 194 |
outBuffer.bindForOutput(0); |
197 | 195 |
outBuffer.setAsInput(1); |
198 | 196 |
|
199 |
GLES30.glUniform1f ( mProgram2.mUniform[0] , near);
|
|
197 |
GLES30.glUniform1f ( mProgram2.mUniform[0] , n );
|
|
200 | 198 |
GLES30.glUniform1i ( mProgram2.mUniform[1] , 0 ); |
201 | 199 |
GLES30.glUniform1fv( mProgram2.mUniform[2] , radius+1, mOffsets,0); |
202 | 200 |
GLES30.glUniform1fv( mProgram2.mUniform[3] , radius+1, weightsCache,offset); |
Also available in: Unified diff
Minor.