Project

General

Profile

« Previous | Next » 

Revision 5b1c0f47

Added by Leszek Koltunski over 7 years ago

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 ! )

View differences:

src/main/res/raw/main_vertex_shader.glsl
336 336
  vec4 SO = vUniforms[effect+2];
337 337
  float d1_circle = degree_region(SO,PS);
338 338
  float d1_bitmap = degree_bitmap(center,PS);
339
  float sinA = vUniforms[effect  ].x;                          // sin(A) precomputed in EffectListVertex.postprocess
340
  float cosA = vUniforms[effect+1].x;                          // cos(A) precomputed in EffectListVertex.postprocess
339

  
340
  float alpha = vUniforms[effect].x;
341
  float sinA = sin(alpha);
342
  float cosA = cos(alpha);
343

  
341 344
  vec2 PS2 = vec2( PS.x*cosA+PS.y*sinA,-PS.x*sinA+PS.y*cosA ); // vector PS rotated by A radians clockwise around center.
342 345
  vec4 SG = (1.0-d1_circle)*SO;                                // coordinates of the dilated circle P is going to get rotated around
343 346
  float d2 = max(0.0,degree(SG,center,PS2));                   // make it a max(0,deg) because otherwise when center=left edge of the
......
401 404
// d) compute the above and see that this is equal precisely to SX from (**).
402 405
// e) repeat points b,c,d in direction Y and come up with (***).
403 406
//
407
//////////////////////////////////////////////////////////////////////////////////////////////
404 408
// Note: we should avoid passing certain combinations of parameters to this function. One such known
405 409
// combination is ( A: small but positive, B: any, amplitude >= length ).
406 410
// In this case, certain 'unlucky' points have their normals almost horizontal (they got moved by (almost!)
......
421 425

  
422 426
  if( deg != 0.0 && length != 0.0 )
423 427
    {
424
    float sinA = vUniforms[effect  ].y;
425
    float cosA = vUniforms[effect+1].x;
426
    float sinB = vUniforms[effect  ].w;
427
    float cosB = vUniforms[effect+1].y;
428
    float alpha = vUniforms[effect].y;
429
    float beta  = vUniforms[effect].w;
430

  
431
    float sinA = sin(alpha);
432
    float cosA = cos(alpha);
433
    float sinB = sin(beta);
434
    float cosB = cos(beta);
428 435

  
429 436
    float angle= 1.578*(ps.x*cosB-ps.y*sinB) / length;
430 437

  

Also available in: Unified diff