Revision 5b1c0f47
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/library/EffectQueueVertex.java | ||
---|---|---|
157 | 157 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
158 | 158 |
// Do various post-processing on already computed effects. |
159 | 159 |
// 1) here unlike in the fragment queue, we don't have to multiply the points by ModelView matrix because that gets done in the shader. |
160 |
// 2) in case of swirl, pre-compute the sine and cosine of its rotation angle |
|
161 |
// 3) likewise in case of wave |
|
160 |
// 2) in case of SWIRL, switch the angle from degrees to radians |
|
161 |
// 3) likewise in case of WAVE |
|
162 |
// 4) In case of DISTORT, invert the Y-axis |
|
162 | 163 |
|
163 | 164 |
void postprocess(int effect) |
164 | 165 |
{ |
165 |
double d; |
|
166 |
|
|
167 | 166 |
if( mName[effect]==EffectNames.SWIRL.ordinal() ) |
168 | 167 |
{ |
169 |
d = Math.PI*mUniforms[NUM_UNIFORMS*effect]/180; |
|
170 |
mUniforms[NUM_UNIFORMS*effect ] = (float)Math.sin(d); |
|
171 |
mUniforms[NUM_UNIFORMS*effect+4] = (float)Math.cos(d); |
|
168 |
mUniforms[NUM_UNIFORMS*effect ] = (float)(Math.PI*mUniforms[NUM_UNIFORMS*effect ]/180); |
|
172 | 169 |
} |
173 | 170 |
if( mName[effect]==EffectNames.WAVE.ordinal() ) |
174 | 171 |
{ |
175 |
d = Math.PI*mUniforms[NUM_UNIFORMS*effect+1]/180; |
|
176 |
mUniforms[NUM_UNIFORMS*effect+1] = (float)Math.sin(d); |
|
177 |
mUniforms[NUM_UNIFORMS*effect+4] = (float)Math.cos(d); |
|
178 |
d = Math.PI*mUniforms[NUM_UNIFORMS*effect+3]/180; |
|
179 |
mUniforms[NUM_UNIFORMS*effect+3] = (float)Math.sin(d); |
|
180 |
mUniforms[NUM_UNIFORMS*effect+5] = (float)Math.cos(d); |
|
172 |
mUniforms[NUM_UNIFORMS*effect+1] = (float)(Math.PI*mUniforms[NUM_UNIFORMS*effect+1]/180); |
|
173 |
mUniforms[NUM_UNIFORMS*effect+3] = (float)(Math.PI*mUniforms[NUM_UNIFORMS*effect+3]/180); |
|
181 | 174 |
} |
182 | 175 |
if( mName[effect]==EffectNames.DISTORT.ordinal() ) |
183 | 176 |
{ |
Also available in: Unified diff
Switch off the pre-compulting of sin and cos in CPU as it turns out that those two are single-instruction functions on any modern GPU ( http://www.gamedev.net/topic/322422-number-of-gpu-cycles-for-cos-and-sin-functions/ - link form 2005 ! )