Logo by HPDZ - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Did you know ? you can use LaTex inside Postings on fractalforums.com!
 
*
Welcome, Guest. Please login or register. April 25, 2024, 11:12:31 PM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: 1 [2]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: GPU FractalScreensaver  (Read 6242 times)
0 Members and 1 Guest are viewing this topic.
keldor314
Guest
« Reply #15 on: July 16, 2008, 02:43:48 AM »

Well, I got my computer up and running again!  With a brand new geforce GTX 280!  Adaptive supersampling now maintains a smooth framerate even with some of the worst case formulas.
 afro

Anyway, I'll see about putting up a updated version which *hopefully* will work sometime later tonight.  Cross your fingers that my guess is on target concerning why it's not working on your computer. wink
Logged
keldor314
Guest
« Reply #16 on: July 16, 2008, 04:09:08 AM »

Version 1.23 is up!

http://downloads.sourceforge.net/gpujuliascreens/Julia_1_23_DX9.zip?use_mirror=voxel&filesize=47669

Let me know if this solves the problems.

 smiley
Logged
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #17 on: July 16, 2008, 09:42:29 AM »

jipii, thank you, now it works nicely and runs smooth on my 1650x1024 display ...

thank you and great work !

is there an option for auto slide the fractal types ??!?!?

and, can you make me a file with an external compiled hlsl file ? so that i can show you the alternating method, you will be astonished !
 evil

and it is right that the saver has to be exited with ESC ? huh?

great coloring options cheesy
« Last Edit: July 16, 2008, 09:48:16 AM by Trifox » Logged

---

divide and conquer - iterate and rule - chaos is No random!
keldor314
Guest
« Reply #18 on: July 17, 2008, 03:32:30 AM »

Alright!  I'm glad to hear that it finally works! cheesy

BTW, you don't have to hit ESC to exit the saver - any input other than just moving the mouse should do the trick.  The reason that I have it ignoring mouse movement is that switching screen modes (i.e. when the saver starts) sends spurious mouse movement messages, so the saver would instantly exit as soon as it started.  I suppose I could add a timer or something, but it annoys me when I'm watching the screensaver, and accidently bump the table...

What do you mean by an external compiled hlsl file?
Logged
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #19 on: July 17, 2008, 11:46:31 AM »

hi, i thought the hlsl effect you execute, for rendering the fractal could be an external hlsl file, compiled at runtime, so that i could try some things out, to show you some things...
Logged

---

divide and conquer - iterate and rule - chaos is No random!
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #20 on: July 18, 2008, 03:49:48 PM »

hi there, a few notes and wishes:

1. let the user choose a screen resolution, right now you take the current desktop resolution, i have a 1650x1028 pixels display, which slows down the calculation a lot
2. a timer for switching the current fractal

 afro afro afro
Logged

---

divide and conquer - iterate and rule - chaos is No random!
keldor314
Guest
« Reply #21 on: July 20, 2008, 11:57:52 AM »

The HLSL file (actually, several files) is embedded into the executable as a resource.  I choose to do it this way because screensavers are traditionally installed into the Windows/system32 folder, and I thought people might object to a half dozen random files being scattered in there with the saver!  Besides, trying to access files (from a screensaver - I wouldn't be surprised if those implicitly had limited permissions) into there is just asking for problems with user account permissions, so self containment was certainly the way to go.

In any case, the HLSL is pretty heavily integrated with the native code, and won't even compile without the native side passing along the appropriate defines so it can resolve which functions to iterate.  You'll want to download the entire source if you want to fiddle with things, so that you can add your functions to the settings dropdown list, for one thing. wink

http://gpujuliascreens.svn.sourceforge.net/viewvc/gpujuliascreens/

For your compiler, I'd recommend that you grab Visual C++ Express.  It's easy to use, and is the same program that I've been using, so you'll be able to just open the project up and compile/run it, rather than dealing with makefiles or command line nonsense.  Also, and most importantly, it's free. afro

http://www.microsoft.com/express/download/#webInstall

Finally, you'll need the DirectX SDK.

http://www.microsoft.com/downloads/details.aspx?FamilyID=519aae99-b701-4ca1-8495-39ddde9d7030&DisplayLang=en

Those last two are rather large (VC++ is about 150MB, DX SDK is close to 500MB!), so we'll have to figure something out if you don't have a fast internet connection.

You probably should install VC++ before you install the SDK, since when you install the SDK, I believe that it will automatically add in the appropriate directories for VC++ to know where the directX include files and such are.  If it doesn't, tell me, and I'll help you get those set up.

A final note is that there's some sort of bizarre bug where VC++ won't exit when it has this particular project open (my other projects don't have this problem...).  You'll have to force quit the thing - so make sure you save first.  Actually, it'll ask you if you want to save when you try to quit (if you haven't saved your changes), and it'll save just fine.  It just won't quit.  The oddest thing is that this bug has persisted through two different versions of VC++, which includes the conversion to the newer project format.  In any case, you don't have to worry about this bug, since the data will remain just fine.  I'm just telling you about it so you don't freak out when it hangs on save and exit. grin
Logged
keldor314
Guest
« Reply #22 on: July 24, 2008, 09:14:33 AM »

In any case, after you've gotten the compiler set up, here are instructions for adding in a new iteration function.

First, we need to decide what function to add.  In this case, let's do a simple composite function, z -> (z*z+c)*(z*z+c)+d.  This is simple f(f(z)) where f(z)=z^2+c, only with the c parameter different each time.

Let's name the function.  We'll call it "(z^2+c)^2+d".

Next, we add that into the iterations listbox.  Open up "Config Dialogue.h" and click on the listbox under the Iteration Function heading in the form designer.  It should now be selected.  Click on the little arrow that just appeared on top of the listbox.  Select edit items.  This should bring up a window with a field full of functions.  Type in "(z^2+c)^2+d" (without quotes) on its own line and hit ok.

Now it will display our new function when we compile and run the settings for the screensaver, but we still have to link it together in the program so that it can translate the string from the listbox into a #define for the shader.

Next thing to do is open "ModeList.h".  This is the header where we define names and values for functions.  The format is like this:
#define <Function Handle Name> <Value>
where <Function Handle Name> is a valid variable name in C++ (i.e. no spaces or symbols) and <Value> is some integer that's unique to the given handle.

Since the name of the handle can't have symbols in it, we can't just use the same plaintext name we have in the listbox.  Instead, I've been using a sort of shorthand that uses only letters to "spell out" the function (The name can be whatever you want, though I recommend you use some sort of shorthand to help keep the names straight!).  In this case, I would pick the name "iterateLZpow2pCRpow2pD".  Let's break this down so you can see how I'm naming it.

iterate refers to the fact that we're defining an iteration function.  Next we have "L" which is a Left parenthesis '('.  Next is Z which stands for 'z'.  Then pow, which is short for Power, and represents the exponentiation operator '^'.  Then we have the number 2, which represents 2 (note that numeric charecters are valid INSIDE the name, but NOT BEGINNING the name, hence x2 is fine but 2x is not.).  Next we have 'p' which stands for Plus, or '+'.  Then C which is 'c'.  Then R for ')', pow for '^'. 2, and pD for '+d'.  Hopefully you get the general idea.  Anyway, the line we're going to add to the bottom of the file is:
Code:
#define iterateLZpow2pCRpow2pD 48
followed by a blank line since the compiler likes to complain if the last line of the file isn't a carriage return.  We choose the number 48 since the previous line had 47.

Now we have to link these together in the code proper.  Open "Config Dialogue.cpp"

Scroll down until you reach the System::String^ encodeFunctionIndex(int functionIndex) line.  Here is where we put the function for converting from handle to string name.  Add the 2 lines:
Code:
case iterateLZpow2pCRpow2pD:
    return ("(z^2+c)^2+d");
on a new line inserted right before the comment //coloration functions.  All the functions use the same function to convert their names, so I have them broken into sections by type.  Thus we have the //iteration functions block, the //coloration functions block and the //palette functions block.

Now, scroll down some more until you get to int decodeFunctionName(System::String^ str).  At the end of the //iteration functions block, just like before, add in the lines:
Code:
if (str == "(z^2+c)^2+d")
     return iterateLZpow2pCRpow2pD;
This converts the string into the handle.

Next, open up ModeSelecter.cpp.

You'll see it's broken up into sections just like the other functions were.  Add the lines:
Code:
else if (modeName == iterateLZpow2pCRpow2pD)
{
defineSlot[0].Name = "iterateLZpow2pCRpow2pD";
defineSlot[0].Definition = "";
viewCenterR = 0.0;
viewCenterI = 0.0;
viewRadius = 1.5;
}
at the end of the Iteration functions block.  This provides the string name for the HLSL define, as well as parameters for the window size and variable ranges to use.  Since we only entered parameters for the window and the function name, our c and d parameters will simply assume default ranges.

Now we finally get to the shader code itself.  Open Iterate.fx.

Scroll down to right before the first #ifdef bailout***** line.  The iteration code is broken into two sections - one section has the defines for the actual code for each iteration, and the second section has bailout functions.  Since our function has typical bailout behavior, we can just use bailoutDefault.  Thus let's add the skeleton for the function as follows:
Code:
#ifdef iterateLZpow2pCRpow2pD
#define bailoutDefault
#define ITERATE_FUNCTION\

#endif
Notice the backslash after ITERATE_FUNCTION.  This is how you tell the preprocesser that the define goes on to the next line.  Thus, we can write our iteration function over several lines instead of cramming it all into a single line.

The last thing to do is to add in the actual code.  Note:  The code must define the variables x, y, and r, where x is the real component of the next value of z, y is the imaginary, and r is the radius squared, or x*x+y*y.  The current values of parameters are stored in cr, ci, dr, di, ect. where cr is the real part of c, ci is the imaginary part, dr is the real part of d, and so forth.  Let's write the code now.
Code:
#ifdef iterateLZpow2pCRpow2pD
#define bailoutDefault
#define ITERATE_FUNCTION\
float2 z = float2(x,y);\
float2 c = float2(cr,ci);\
float2 d = float2(dr,di);\
z = cSqr(cSqr(z)+c)+d;\
x = z.x;\
y = z.y;\
r = x*x+y*y;
#endif
First, notice the float2.  float2 is one of the base types provided by HLSL.  It is basically a vector of two floats, where the operators +-*/ are defined component wise, that is, a*b = float2(a.x*b.x,a.y*b.y).  Hence, we can use + and - straight as is, since they work the same as complex numbers would, but for anything else, we have to write our own functions... or use the functions provided in library.fx!  The names of the functions in the library are things like cSin(z) or cTan(z) or cAcoth(z), where the c in the beginning designates the functions as working on complex numbers (and, more importantly, differentiates them from built in functions like Sin and Cos).  The most important ones are cMul(z1,z2) and cDiv(z1,z2) where cMul returns z1*z2, and cDiv returns z1/z2.  All functions in the library operate on inputs of type float2.  In our case, we're only using cSqr(z) which returns z*z.

Finally, rebuild the project, and your new function should be good to go!
Logged
keldor314
Guest
« Reply #23 on: July 24, 2008, 09:32:49 AM »



I was going to post some links to the SVN where it will show you changes, so you can see exactly what I added to add the new function, but the SVN seems to be having issues at the moment.
Logged
keldor314
Guest
« Reply #24 on: July 25, 2008, 10:42:53 PM »

Here's links for viewing the relevant changes.  <3 SVN  afro

http://gpujuliascreens.svn.sourceforge.net/viewvc/gpujuliascreens/Julia%20ScreenSaver/ModeList.h?r1=25&r2=26
http://gpujuliascreens.svn.sourceforge.net/viewvc/gpujuliascreens/Julia%20ScreenSaver/Config%20Dialogue.h?r1=25&r2=26
http://gpujuliascreens.svn.sourceforge.net/viewvc/gpujuliascreens/Julia%20ScreenSaver/Config%20Dialogue.cpp?r1=24&r2=26
http://gpujuliascreens.svn.sourceforge.net/viewvc/gpujuliascreens/Julia%20ScreenSaver/ModeSelecter.cpp?r1=25&r2=26
http://gpujuliascreens.svn.sourceforge.net/viewvc/gpujuliascreens/Julia%20ScreenSaver/Iterate.fx?r1=25&r2=26
Logged
Pages: 1 [2]   Go Down
  Print  
 
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.233 seconds with 23 queries. (Pretty URLs adds 0.012s, 2q)