Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : The Great Colour Maximite 2 Octahedron Prize Challenge
Page 9 of 11 | |||||
Author | Message | ||||
LeoNicolas Guru Joined: 07/10/2020 Location: CanadaPosts: 450 |
Very cool Vegipete I copied your icosahedron data to my program. This is the result: icosahedron.bas.zip |
||||
PeteCotton Guru Joined: 13/08/2020 Location: CanadaPosts: 316 |
Interesting. Although my program is slower than your guys, it does show that there might be some value in the face and vertex symmetry calcs that I put in. I get 1982ms with the Icosahedron. However if I take out my symmetry calculations it goes up to 2302ms, showing that with primitives with higher vertex/face counts, it does produce a significant reduction in processing time. Leo, I notice my 650 calcs are different than yours? Not sure why, but the end image looks identical. |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1085 |
I should have posted my vertex coords: 1517.073 Vertex coordinates at iteration 650: -226.049588 -81.73546929 -70.80887545 -174.2594685 175.3899975 -40.80424503 174.2594685 -175.3899975 40.80424503 226.049588 81.73546929 70.80887545 -4.803232082 -200.1405105 -150.7106666 -78.76718797 -214.7664928 102.2941039 78.76718797 214.7664928 -102.2941039 4.803232082 200.1405105 150.7106666 -64.36396153 40.82022139 -238.7131961 183.7148904 -17.21920455 -169.5445017 -183.7148904 17.21920455 169.5445017 64.36396153 -40.82022139 238.7131961 My coords look similar to yours, PeteCotton, except maybe out by 1 iteration. I looked at your opposite face idea a bit. Interesting! Does it survive the encounter with perspective? After the perspective transformation, opposite faces that were parallel generally will no longer be parallel. At certain angles, both opposite faces will not be visible. I also notice that your guys never spend the 1/2 millisec or so to actually display iteration 0, before any rotation starts! Good work all! Visit Vegipete's *Mite Library for cool programs. |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8605 |
All Thanks for all your efforts on this - it has been fascinating and has certainly helped evolve the firmware. I'll evaluate the programs ASAP and then announce the result. I'll then need an address to send the prize. If whoever wins doesn't need another CMM2 then I hope they can find a youngster who might be interested. |
||||
LeoNicolas Guru Joined: 07/10/2020 Location: CanadaPosts: 450 |
Pete, the difference is caused by the INC issue. Today evening I will run it again using the new firmware beta with the INC command fix |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8605 |
And the results are in There are no disqualifications or other penalties to be applied. Once I modified PeteCotton's code to print after the 650th (651st?) iteration everyone had identical coordinates and everyone ended with the octahedron correctly orientated. Only vegipete's code will run on RC18 as the others use the INC statement so I've run the three programs on V5.05.06RC22 and V5.06.00b2 and the results are: V5.05.06RC22 V5.06.00b2 V5.05.06RC18 PeteCotton 1052 1052 vegipete 715 717 732 LeoNicolas 980 984 So the clear winner is vegipete who achieved the remarkable result of > 1 iteration per millisecond on my 480MHz CMM2 with the latest firmware Please send me your address by PM and I'll get a signed CMM2 on its way to Canada |
||||
LeoNicolas Guru Joined: 07/10/2020 Location: CanadaPosts: 450 |
Congratulations Vegipete, amazing time |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3678 |
Wow! Very good work by everyone. Special congrats to vegipete. John |
||||
PeteCotton Guru Joined: 13/08/2020 Location: CanadaPosts: 316 |
Brilliant job VegiPete! That is an outstanding time! And thanks MatherP for running the competition. |
||||
PeteCotton Guru Joined: 13/08/2020 Location: CanadaPosts: 316 |
Thanks. Yes, the opposite face algorithm is stored at the object level (i.e. before any transformations and perspectives). Even with perspective, it holds true that with any pair of parallel planes, only one can be visible at a time. With the mirrored vertices (mirrored across the center of the object), I do all of the transformations first, using the mirror logic to quickly work out the mirrored vertices (i.e. negate all of the values in the opposite vertice) and then apply the perspective to the transformed points (otherwise, as you pointed out, they would not match). In Elite they used a slightly different approach, they mirrored the vertices across the center axis (i.e. only one dimension), as most models in the game were symetrical along this axis. This works for complex models such as the Elite ships, however I figured using the mirrors across the 3D center of the object would be more generic (it works for all primitives with 6 or more sides). In Elite they encoded this symmetry into the model specification (and only had to store ~half the data points), but I figured it would be far more intuitive to store the full model and calculate the points of symmetry at load time (and also we don't need to be as frugle with the bytes as Elite did). |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1085 |
Wow! Awesome! Thank you! Thank you for the contest, not so much for the prize but for the motivation and challenge of writing some fast yet useful code. I started with only a general knowledge of the math involved, now it is grokked much better. Thank you also to PeteCotton and LeoNicolas, fellow Canajiens, eh. And to other commenters on this thread. Little comments here and there set my mind whirring, resulting in my program above. I just looked at my first versions of the program - version 4 was my first one that actually drew the coloured octahedron and it needed almost 2.5 seconds to complete the task. I could not have reduced that by over 60% without the rest of you, both with comments/hints and with a goal to aim for. PeteCotton had some great times out of the gate and I had to strain my brain to figure out how to get close. And LeoNicolas kept getting better and better too. I had to break out the text books to compete with these guys. So thank you to all! Let the programming fun continue... Visit Vegipete's *Mite Library for cool programs. |
||||
LeoNicolas Guru Joined: 07/10/2020 Location: CanadaPosts: 450 |
Now I'm back to the 3D API with a lot of experience in optimization. Thank you guy for all tips and help. If you have interest to contribute with the it I can add you as contributors in the API GitHub repo. |
||||
PeteCotton Guru Joined: 13/08/2020 Location: CanadaPosts: 316 |
I'm working on a generic mapping algorithm, i.e. throw any 3 sided or more shape on to the screen with any source shape (with the same number of sides, but not neccesarily the same shape) and it will texture map it. The algorithm is almost there. But still having a weird little glitch that I cannot wrap my head around. |
||||
panky Guru Joined: 02/10/2012 Location: AustraliaPosts: 1099 |
@vegipete Can I include your winning code in the Graphics Programming Manual please as an example of 3D optimisation techniques? I will, of course, include the appropriate accreditation, Regards, Doug. ... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |
||||
LeoNicolas Guru Joined: 07/10/2020 Location: CanadaPosts: 450 |
Panky, maybe it will be nice including the 3 codes. Each one is using different techniques to reach optimal performance. What do you think? |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1085 |
LeoNicolas is correct that all three versions are interesting. Let me see about making a 'speed sequence' that shows the refinement from general code to highly speed optimized. My octahedron code (and variations) is free for whatever use anyone sees fit. Visit Vegipete's *Mite Library for cool programs. |
||||
panky Guru Joined: 02/10/2012 Location: AustraliaPosts: 1099 |
@Leo, Happy to include all three if you and the 2 Pete's are OK with that. Doug. ... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |
||||
LeoNicolas Guru Joined: 07/10/2020 Location: CanadaPosts: 450 |
Yes, feel free to use it. It's a pleasure to help the community with this small contribution. And let me know if you want other examples. |
||||
PeteCotton Guru Joined: 13/08/2020 Location: CanadaPosts: 316 |
Absolutely. I would be honoured. This would be very interesting to see, and I think, highly educational for new users to see the process that is required to work out the best optimisations. With the (amazing) rapid changes to the firmware, the individual optimisations might cease to be relevant (the hex numbers vs decimal for example), however the techniques for finding them will always be applicable. |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8605 |
Guys I'm starting to convert in C so please can you check my math. Below is the Basic program that loads up the initial state of a 3D object - surprise, surprise it is an octahedron. Then below that is the diagnostic print from the firmware. First it confirms I've stored the coordinates correctly. Then it prints out details for each face, the vertex numbers, the calculated positions of the centroids of each triangle (to be used for Painters) and finally the calculated surface normals for each face based on the 1st point-2nd and 3rd-2nd. It is this latter that I really need to be sure of before I go any further. option explicit option default float dim integer nv=6, nf=8 ' octahedron has 6 vertices and 8 faces 'array to hold vertices dim v(2,nv-1)=(0,250,0, 250,0,0, -250,0,0, 0,-250,0, 0,0,250, 0,0,-250) ' array to hold number of vertices for each face dim integer fc(nf-1) =(3, 3, 3, 3, 3, 3, 3, 3) 'array to hold vertices for each face dim integer fv(math(sum fc())-1)=(0,5,2, 0,1,5, 0,2,4, 0,4,1, 3,2,5, 3,5,1, 3,1,4, 3,4,2 ) draw3d create 1, nv, nf, v(), fc(), fv() draw3d close all 6 vertices, 8 faces X, 0.0000,Y, 250.0000,Z, 0.0000 X, 250.0000,Y, 0.0000,Z, 0.0000 X, -250.0000,Y, 0.0000,Z, 0.0000 X, 0.0000,Y, -250.0000,Z, 0.0000 X, 0.0000,Y, 0.0000,Z, 250.0000 X, 0.0000,Y, 0.0000,Z, -250.0000 Face 0 vertices , 0, 5, 2, -83.3333, 83.3333, -83.3333, 0.5774, -0.5774, 0.5774 Face 1 vertices , 0, 1, 5, 83.3333, 83.3333, -83.3333, -0.5774, -0.5774, 0.5774 Face 2 vertices , 0, 2, 4, -83.3333, 83.3333, 83.3333, 0.5774, -0.5774, -0.5774 Face 3 vertices , 0, 4, 1, 83.3333, 83.3333, 83.3333, -0.5774, -0.5774, -0.5774 Face 4 vertices , 3, 2, 5, -83.3333, -83.3333, -83.3333, 0.5774, 0.5774, 0.5774 Face 5 vertices , 3, 5, 1, 83.3333, -83.3333, -83.3333, -0.5774, 0.5774, 0.5774 Face 6 vertices , 3, 1, 4, 83.3333, -83.3333, 83.3333, -0.5774, 0.5774, -0.5774 Face 7 vertices , 3, 4, 2, -83.3333, -83.3333, 83.3333, 0.5774, 0.5774, -0.5774 |
||||
Page 9 of 11 |
Print this page |