Guest User

Untitled

a guest
Apr 24th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. for each v in vertices {
  2. n_accum = vec3(0,0,0);
  3. for each f in faces {
  4. count = 0;
  5. if(v is in f){
  6. n_accum += f.normal;
  7. count++;
  8. }
  9. }
  10. n = n_accum / count;
  11. v.normal = n;
  12. }
  13.  
  14. //with theshold:
  15.  
  16. thredshold = degtorad(60.0)
  17. for each f1 in faces {
  18. for each v in f1 {
  19. n_accum = vec3(0,0,0);
  20. for each f2 in faces {
  21. count = 0;
  22. if(v is in f2 && dot(f2.normal, f1.normal) < thredshold){
  23. n_accum += f2.normal;
  24. count++;
  25. }
  26. }
  27. n = n_accum / count;
  28. v.normal = n;
  29. }
  30. }
Add Comment
Please, Sign In to add comment