Genetic Programming for Shader Simplification (UVA TR CS-2011-03) - - PowerPoint PPT Presentation

genetic programming for shader simplification
SMART_READER_LITE
LIVE PREVIEW

Genetic Programming for Shader Simplification (UVA TR CS-2011-03) - - PowerPoint PPT Presentation

Genetic Programming for Shader Simplification (UVA TR CS-2011-03) Pitchaya Sitthi-amorn, Nick Modly, Jason Lawrence, Westley Weimer Motivation: Real-Time Rendering Motivation: Pixel Shaders Most effects and computations occur at the pixel


slide-1
SLIDE 1

Genetic Programming for Shader Simplification

(UVA TR CS-2011-03)

Pitchaya Sitthi-amorn, Nick Modly, Jason Lawrence, Westley Weimer

slide-2
SLIDE 2

Motivation: Real-Time Rendering

slide-3
SLIDE 3

Motivation: Pixel Shaders

▸ Most effects and computations occur at the pixel level ▸ Pixel shader: a user program that executes at each

pixel

[Crysis 2]

  • Fog
  • Lighting
  • Water ripples
  • Soft shadows
  • Environment

reflection mapping

slide-4
SLIDE 4

Motivation: Shader Complexity

[Norman Rubin]

slide-5
SLIDE 5

Motivation: Shader Run Time

▸ Pixel shaders are executed several times to avoid

aliasing

1 sample 256 samples 16 samples

slide-6
SLIDE 6

▸ Most shaders can be simplified with an acceptable

loss in detail

▸ Output is consumed by human eyes

Key Insight

slide-7
SLIDE 7

Problem Statement

▸ Generate a sequence of simplified shaders

slide-8
SLIDE 8

Problem Statement

▸ Generate sequence of simplified shaders

Error Rendering Time

slide-9
SLIDE 9

Problem Statement

▸ Generate sequence of simplified shaders

Error Rendering Time

slide-10
SLIDE 10

Previous Work

Olano et. al [2003] Pellacini [2005]

slide-11
SLIDE 11

Multi-Objective Genetic Programming (NSGA-II): Error Rendering Time

Initialize Sort Select Pairs Crossover Mutate-Evaluate Select Rank 1 Rank 3 Rank 2

Pareto Frontier

Crowding Heuristic

Rank 4

slide-12
SLIDE 12

Mutation Operator: Insert

1.float Fresnel (float th, float n) {

  • 2. float cosi = cos (th);
  • 3. float R = 1.0f;
  • 4. float n12 = 1.0f / n;
  • 5. float sint = n12 * sqrt (1 - (cosi * cosi));
  • 6. if (sint < 1.0f) {
  • 7. float cost = sqrt (1.0 - (sint * sint));
  • 8. float r_ortho = (cosi - n * cost)
  • 9. / (cosi + n * cost);
  • 10. float r_par = (cost - n * cosi)
  • 11. / (cost + n * cosi);
  • 12. R=(r_ortho * r_ortho + r_par * r_par)/2;
  • 13. }
  • 14. return R;

15.}

slide-13
SLIDE 13

Mutation Operator: Insert

1.float Fresnel (float th, float n) {

  • 2. float cosi = cos (th);
  • 3. float R = 1.0f;
  • 4. float n12 = 1.0f / n;
  • 5. float sint = n12 * sqrt (1 - (cosi * cosi));
  • 6. if (sint < 1.0f) {
  • 7. float cost = sqrt (1.0 - (sint * sint));
  • 8. float r_ortho = (cosi - n * cost)
  • 9. / (cosi + n * cost);
  • 10. float r_par = (cost - n * cosi)
  • 11. / (cost + n * cosi) - (cosi * cosi);
  • 12. R=(r_ortho * r_ortho + r_par * r_par)/2;
  • 13. }
  • 14. return R;

15.}

slide-14
SLIDE 14

Mutation Operator: Delete

1.float Fresnel (float th, float n) {

  • 2. float cosi = cos (th);
  • 3. float R = 1.0f;
  • 4. float n12 = 1.0f / n;
  • 5. float sint = n12 * sqrt (1 - (cosi * cosi));
  • 6. if (sint < 1.0f) {
  • 7. float cost = sqrt (1.0 - (sint * sint));
  • 8. float r_ortho = (cosi - n * cost)
  • 9. / (cosi + n * cost);
  • 10. float r_par = (cost - n * cosi)
  • 11. / (cost + n * cosi);
  • 12. R=(r_ortho * r_ortho + r_par * r_par)/2;
  • 13. }
  • 14. return R;

15.}

slide-15
SLIDE 15

Mutation Operator: Delete

1.float Fresnel (float th, float n) {

  • 2. float cosi = cos (th);
  • 3. float R = 1.0f;
  • 4. float n12 = 1.0f / n;
  • 5. float sint = n12 * sqrt (1 - (cosi * cosi));
  • 6. if (sint < 1.0f) {
  • 7. float cost = sqrt (1.0 - (sint * sint));
  • 8. float r_ortho = (cosi - n * cost)
  • 9. / (cosi + n * cost);
  • 10. float r_par = (cost - n * cosi)
  • 11. / (cost + n * cosi);
  • 12. R=(r_ortho * r_ortho + r_par * r_par)/2;
  • 13. }
  • 14. return R;

15.}

slide-16
SLIDE 16

Mutation Operator: Swap

1.float Fresnel (float th, float n) {

  • 2. float cosi = cos (th);
  • 3. float R = 1.0f;
  • 4. float n12 = 1.0f / n;
  • 5. float sint = n12 * sqrt (1 - (cosi * cosi));
  • 6. if (sint < 1.0f) {
  • 7. float cost = sqrt (1.0 - (sint * sint));
  • 8. float r_ortho = (cosi - n * cost)
  • 9. / (cosi + n * cost);
  • 10. float r_par = (cost - n * cosi)
  • 11. / (cost + n * cosi);
  • 12. R=(r_ortho * r_ortho + r_par * r_par)/2;
  • 13. }
  • 14. return R;

15.}

slide-17
SLIDE 17

Mutation Operator: Swap

1.float Fresnel (float th, float n) {

  • 2. float cosi = cos (th);
  • 3. float R = 1.0f;
  • 4. float n12 = 1.0f / n;
  • 5. float sint = n12 * sqrt (1 - (cosi * cosi));
  • 6. if (sint < 1.0f) {
  • 7. float cost = sqrt (1.0 - (sint * sint));
  • 8. float r_ortho = (cosi - n * cosi)
  • 9. / (cosi + n * cost);
  • 10. float r_par = (cost - n * cosi)
  • 11. / (cost + n * cost);
  • 12. R=(r_ortho * r_ortho + r_par * r_par)/2;
  • 13. }
  • 14. return R;

15.}

slide-18
SLIDE 18

Mutation Operator: Replacing with its average value

1.float Fresnel (float th, float n) {

  • 2. float cosi = cos (th);
  • 3. float R = 1.0f;
  • 4. float n12 = 1.0f / n;
  • 5. float sint = n12 * sqrt (1 - (cosi * cosi));
  • 6. if (sint < 1.0f) {
  • 7. float cost = sqrt (1.0 - (sint * sint));
  • 8. float r_ortho = (cosi - n * cost)
  • 9. / (cosi + n * cost);
  • 10. float r_par = (cost - n * cosi)
  • 11. / (cost + n * cosi);
  • 12. R=(r_ortho * r_ortho + r_par * r_par)/2;
  • 13. }
  • 14. return R;

15.}

slide-19
SLIDE 19

Mutation Operator: Replacing with the average value

1.float Fresnel (float th, float n) {

  • 2. float cosi = cos (th);
  • 3. float R = 1.0f;
  • 4. float n12 = 1.0f / n;
  • 5. float sint = n12 * sqrt (1 - (cosi * cosi));
  • 6. if (sint < 1.0f) {
  • 7. float cost = sqrt (1.0 - (sint * sint));
  • 8. float r_ortho = (cosi - n * cost)
  • 9. / (cosi + n * cost);
  • 10. float r_par = (cost - n * cosi)
  • 11. / (cost + n * 0.5);
  • 12. R=(r_ortho * r_ortho + r_par * r_par)/2;
  • 13. }
  • 14. return R;

15.}

slide-20
SLIDE 20

Measuring Error/Performance

Original Modified

slide-21
SLIDE 21

Approximating Error/Performance

slide-22
SLIDE 22

Approximating Error/Performance

slide-23
SLIDE 23

Approximating Error/Performance

slide-24
SLIDE 24

Error/Performance Approximation Validation

Cross correlation 0.84 and 0.95 Fitness evaluation time improvement: 100x

slide-25
SLIDE 25

Marble shader Trashcan shader

procedural noise with Blinn-Phong specular layer (75K triangles) supersampled (25) environment map (15K triangles) approximate subsurface scattering of human skin (300K triangles)

Human Head

Test Scenes and Shaders

slide-26
SLIDE 26

Marble Shader

slide-27
SLIDE 27

Marble Shader

slide-28
SLIDE 28

Trashcan Shader

slide-29
SLIDE 29

Trashcan Shader

slide-30
SLIDE 30

Human Head Shader

slide-31
SLIDE 31

Human Head Shader

slide-32
SLIDE 32

Marble Shader – SSIM & Previous Work

(Previous approaches are not well-founded on multi-pass shaders.)

slide-33
SLIDE 33

Conclusion

▸ Graphics shader software simplification ▸ “Continuous functions” ▸ Efficiency is critical ▸ Output consumed by humans ▸ Multi-objective genetic programming approach ▸ NSGA-II plus mutation, crossover, tournament k,

crowding heuristic

▸ Rapid error and runtime (fitness) approximation ▸ 2.5x better than previous work at constant error ▸ Applies to multi-pass shaders