News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

MAthArt: 32 / 64 bit demo program ...

Started by rrr314159, May 09, 2015, 05:51:55 PM

Previous topic - Next topic

rrr314159

This project started from this Trig thread, where we made sin/cos routines for FPU, SSE and AVX instruction sets, and for double and single precision. To aid in version control I've made a set of macros to do SSE / AVX, single / double, with one algo. They're called "orthogonal" macros, meaning same instruction works with all different data. For instance, "radd" adds SSE / AVX registers containing 4 or 8 byte reals. 4 different pieces of code are generated at compile time from one algo, so each runs at full speed.

But it has evolved in two ways, as indicated by the post's title. One, to demonstrate the use of orthogonal macros required much more complex (no pun intended) algos than just sin/cos. (35 instructions, plus supporting macros). So I put in a Complex Rational Polynomial algorithm ... one thing led to another and it became "MathArt". It produces cool art bmp's based on the math algos - fun to play with, I think. Of course that required some sort of input capability ... it's 2000 lines, 5 times bigger than expected.

It also evolved into a 32 / 64 bit demo: the code compiles seamlessly as 32 or 64. Almost all of it functions either way, very few lines apply to only one or the other. This grew out of converting 32 bit code; it's easy to get it running as 64-bit with a few utility macros and a few changed instructions. I put that in the title because it seems there's a lot of interest these days. Admittedly, you wind up with a few superfluous prefixes in the 32-bit code. BTW (as long as we're discussing negatives) there are some bugs in this prog, guaranteed. Please let me know what they are when you run into them.

MathArt (MA) has two modes, "hobby" and "Lab". Hobby: just makes pictures, for fun. Lab: provides timing and other data for all 8 varieties of Instruction Sets, so u can compare them. So it's for two very different types of user - please just skip any para's here (and in the help file) which are not for you.

HOBBY MODE: here is a gallery showing a few pictures you can make; much more variety is possible. They can be made any size from 1 * 1 to 6000 * 4000. The interface s**ks, involves editing a text file to change input parameters. Hey, it's free. Here are the inputs you can modify - sample inputs.txt contents, and descriptions of what they do:

Quote from: MAthArt help fileri1920 rj1080 sx.4 sy2 cx50.34 cy20 ra0 fl0 at3 po0 sd250 la0.5 tz0 ct2 sm1 rv0 gr0 rl1

World Variables: relation of "real-world" scenario to screen
ri, rj    integer. resolution of screen, or just the size of the bmp you want.
sx, sy   real. scale: sx is overall scale, smaller brings picture nearer; sy is skew
cx, cj   real. center: where world origin (0,0) is on screen. 50 (%), 50 means center.

Algorithm Variables: Easy to see the effect of these.
at   0 to 3. algorithm type, sets overall characteristics.
po   0 to 7. Polynomial number: puts objects in different places.
da   real. Denominator adjustment. larger reduces center detail. Neg is interesting.
la   real. "Lamdba" parameter; larger increases overall detail. Neg same as pos.
tz   0 or 1. toggles between two types of objects, roots and poles, which each poly has.

Color Variables: Affects picture characteristics.
ct   0 to 7. coloring type. Needs no description, effect is obvious.
sm   0 to 3. Makes overall picture smoother.
rv   0 or 1. Reverse colors.
gr   0 or 1. Grayify.
rl   0 to 3. Rotate pixel bits. Makes picture more complicated.

How to use it:

Quote from: MAthArt help fileYou spend most of your time modifying inputs.txt and saving it. I leave it open on my desktop and use CTRL-S (or File-Save). No need to keep closing it and re-opening. The example inputs.txt files make it obvious where you write your new values.

The directory has a sub-directory "savebmps", this is where the picture appears. If absent u'll hear 3 notes. I leave it open, setting view to large or medium icons so I can see the new picture pop up. They will never over-write an old picture if any parameter was changed, so they can accumulate quickly as you play with it. Copy them to other directories, or delete them. I never let more than a few pile up in savebmps, gets very confusing seeing which is the one you just did.

What's cool (I think) is, the name of the .bmp is the input file contents. So you never have to save that separately. Later suppose you want that same picture but at different size or something. Just copy and paste its title into inputs.txt.

LAB MODE:

Read the help file, included in zip. SSE means, generally, SSE2; AVX does not include AVX2. Here are sample runs, 32 and 64-bit, from Intel i5 3330 2.94 Ghz:

C:\mathart>MathArt32
Polynomial Roots / Poles: 4
  -120,-320,2; 580,100,1;
  -120,440,-2; 340,-60,-1;
===============================================
     32-bit MathArt Picture Generator
===============================================
Real4 SSE Complex Rational Polynomial Algorithm
===============================================
Target Pixel Answers Real and Imaginary:
xmm2: -0.136438 -0.144815 -0.153202 -0.161598
xmm3: -1.22747 -1.23028 -1.23307 -1.23582

Target Pixel RBG Values:
fe3b1723 fe3b1525 fe3b1327 fe3d1329

Cycles                  1.674e+007
MilliSeconds            5.726
===============================================
Real8 SSE Complex Rational Polynomial Algorithm
===============================================
Target Pixel Answers Real and Imaginary:
xmm2: -0.136438 -0.144815
xmm3: -1.22747 -1.23028

Target Pixel RBG Values:
fe3b1723 fe3b1525 fe3b1327 fe3d1329

Cycles                  2.95e+007
MilliSeconds            10.09
===============================================
Real4 AVX Complex Rational Polynomial Algorithm
===============================================
Target Pixel Answers Real and Imaginary:
ymm2: -0.103037 -0.111371 -0.119716 -0.128072 -0.136438 -0.144815 -0.153202 -0
61598
ymm3: -1.21592 -1.21885 -1.22176 -1.22463 -1.22747 -1.23028 -1.23307 -1.23582

Target Pixel RBG Values:
fe371d19 fe371b1b fe39191f fe391921 fe3b1723 fe3b1525 fe3b1327 fe3d1329

Cycles                  1.254e+007
MilliSeconds            4.29
===============================================
Real8 AVX Complex Rational Polynomial Algorithm
===============================================
Target Pixel Answers Real and Imaginary:
ymm2: -0.136438 -0.144815 -0.153202 -0.161598
ymm3: -1.22747 -1.23028 -1.23307 -1.23582

Target Pixel RBG Values:
fe371d19 fe371b1b fe39191f fe391921 fe3b1723 fe3b1525 fe3b1327 fe3d1329

Cycles                  1.745e+007
MilliSeconds            5.97
===============================================

C:\mathart>MathArt64
Read 21 Input Tokens from inputs.txt
Polynomial Roots / Poles: 4
  -120,-320,2; 580,100,1;
  -120,440,-2; 340,-60,-1;
===============================================
     64-bit MathArt Picture Generator
===============================================
Real4 SSE Complex Rational Polynomial Algorithm
===============================================
Target Pixel Answers Real and Imaginary:
xmm2: -0.136438 -0.144815 -0.153202 -0.161598
xmm3: -1.22747 -1.23028 -1.23307 -1.23582

Target Pixel RBG Values:
fe3b1723 fe3b1525 fe3b1327 fe3d1329

Cycles                  1.721e+007
MilliSeconds            5.886
===============================================
Real8 SSE Complex Rational Polynomial Algorithm
===============================================
Target Pixel Answers Real and Imaginary:
xmm2: -0.136438 -0.144815
xmm3: -1.22747 -1.23028

Target Pixel RBG Values:
fe3b1723 fe3b1525 fe3b1327 fe3d1329

Cycles                  2.992e+007
MilliSeconds            10.24
===============================================
Real4 AVX Complex Rational Polynomial Algorithm
===============================================
Target Pixel Answers Real and Imaginary:
ymm2: -0.103037 -0.111371 -0.119716 -0.128072 -0.136438 -0.144815 -0.153202 -0.161598
ymm3: -1.21592 -1.21885 -1.22176 -1.22463 -1.22747 -1.23028 -1.23307 -1.23582

Target Pixel RBG Values:
fe371d19 fe371b1b fe39191f fe391921 fe3b1723 fe3b1525 fe3b1327 fe3d1329

Cycles                  1.296e+007
MilliSeconds            4.432
===============================================
Real8 AVX Complex Rational Polynomial Algorithm
===============================================
Target Pixel Answers Real and Imaginary:
ymm2: -0.136438 -0.144815 -0.153202 -0.161598
ymm3: -1.22747 -1.23028 -1.23307 -1.23582

Target Pixel RBG Values:
fe371d19 fe371b1b fe39191f fe391921 fe3b1723 fe3b1525 fe3b1327 fe3d1329

Cycles                  1.969e+007
MilliSeconds            6.734
===============================================


On my AMD machine it's similar but of course slower.

The zip contains:

help.txt: Yes there's a help file! With many more details

MathArt32.exe
MathArt64.exe

doMA32.bat: "make" files
doMA64.bat

MAthArt.asm: exec program, no math
RatPoly_algo.asm: Complex Rational Polynomial algos
ComplextoRGB.asm: pixelizing algos

Ortho_macs.asm: "Orthogonal" instruction macros
support_macs.asm: lots of standard macros, do both 32/64 bit
invoke_macros.asm: identical to post 3 months ago in 64-bit forum

header3264.inc: enables 32 / 64 converting, only 4k
MathArt.inc: just some supporting includes for MathArt

inputs.txt: inputs text file
sample inputs.txt: a few sample inputs.txt files

savebmps: empty folder where bmps are created

Sample pictures, reduced. The real ones are much better.

I am NaN ;)

Siekmanski

Creative coders use backward thinking techniques as a strategy.

jj2007

Impressive, rrr :t
(the artwork and, even more, the fact that the sources assemble in 32 and 64 bits)

dedndave


Siekmanski

This reminds me of my amiga demo coding days, we called it texture deformations.
The idea was to generate all kind of funny math formulas and put the calculated x and y values in a LUT.
Then walk thru the LUT to create animated shapes like whirlpools, black holes, flowers, tunnels etc.
The pixel colors were retrieved from a squared, seamless picture.
Creative coders use backward thinking techniques as a strategy.

FORTRANS

Hi rrr314159,

   Very nice pictures.

Congrats,

Steve N.

rrr314159

Thanks all,

hope you enjoy it, if u get around to playing with it,

Quote from: siekmanskiwe called it texture deformations

sure, I'm interested in doing textures with it one of these days, that's why I intend to study your 3d library when I find time. But I want to animate the textures for real not just scan thru a LUT
I am NaN ;)

tworedsquirrels

This is some impressive work. I shall have to try it out.

Thanks

rrr314159

Thanks tworedsquirrels (I love that handle), must admit I think it's a pretty cool prog also

Here are more images can be created with the approach used in MathArt. Click on the thumbnail pic to see a larger version. These are selected to make very small .png's, and to show the extreme variety possible. Even the large versions are less than 50k, but the originals are in most cases megabytes and much more colorful and detailed. Remember, the program compiles in 32 or 64 bit with exactly the same source, uses SSE, AVX, single or double precision as chosen - can make a huge variety of pictures - if you want to learn 64 bit programming, this is the fun way to do it







I am NaN ;)

tworedsquirrels

These are all very interesting in different ways. I create art for book covers and CD's so I have an eye for a good visual. I'll have to get this program installed on my machine soon

anunitu

Thats very cool NaN,how did I miss this from before??

rrr314159

Thanks anunitu, this was a stealth posting, easy to miss. In the meantime I've turned it into a dynamic program (MathMovie instead of MathArt, up to 100+ FPS), controlled by GUI: menus, combo boxes, mouse, instead of a text file u have to edit by hand. W/ many new features and pictures. Looks even cooler in motion!
I am NaN ;)