Welcome to Fractal Forums

Fractal Software => Programming => Topic started by: kronikel on October 10, 2011, 02:25:50 AM




Title: Graphics
Post by: kronikel on October 10, 2011, 02:25:50 AM
I'm just recently getting into graphics because my usual "Bitmap.SetPixel" type graphics aren't cutting it for me anymore.
I'm wondering what kind of graphics to get into if you have fractals/terrain in mind (eventually hoping to make a procedural planet)
I normally program in C#
I'm wanting to render in real time, and wondering if it would be possible to do that if right now a frame takes about 6 seconds to render (about one million polygons)
I tried out DirectX and couldn't really get it to work.
Now I'm reading up on XNA and it might be more fit, but I know nothing about graphics so I'm looking for a little help.

Edit:
I can't run XNA on my graphics card... that's a real bummer. Any way around this?


Title: Re: Graphics
Post by: eiffie on October 11, 2011, 05:37:11 PM
I don't have a concrete answer - there are lots of directions to go - here are some ideas.

Look at Boxplorer code. It isn't C# but it is a straight forward c program that uses OpenGL shader 2 (hopefully your graphics card can handle that). This will get you near realtime as it uses the GPU for calculations.

Another choice is sticking with C# and using lockbits to write directly to memory (much faster than SetPixel but you won't get realtime). Make use of multiple cores if you have them.

If you can't use XNA I doubt you can use OpenCL but maybe if you upgrade your GPU you can look into this.

That's about all I know.  You don't need an expensive machine for this. I use a $300 eMachines from WalMart and have no trouble producing a 5 minute video overnight.


Title: Re: Graphics
Post by: cKleinhuis on October 11, 2011, 05:59:48 PM
it seems your graphics card is massively undervalued for your plans ....

problem with XNA is that it is limited for x-box compatiblity, i think it is directx10 max .... meaning most interesting shader stuff cant be done using xna ....

generally the hardware gives you possibilities for optimizing your rendering process .... like storing just indexed vertex buffer directly on gpu memory ....

so you could do realtime flyby of a static landscape

hi-res landscape data can be rendered with respect do level of detail, meaning that only near plane is rendered at full detail, and the farer-away parts of the terrain use far less vertex data.... this algorithm can be a pain in the ass to implement from ground off .... but be sure you need some kind of dynamic level of detail to achieve realtime effect ....

so, and when it comes to dynamically recreate your terrain data, just forget to efficently create it using plain CPU, in my eyes calculating the map for your heightmap has to be done one gpu hardware, to achieve maximum efficency .... because calculating of the landscape map data is just halve of the work, after that comes rendering it - level of detail - with the gpu

so, in my eyes - my eyes right here right now - would suggest you try to implement it hardcore on gpu, meaning you would use direct11 or opengl2.x dynamic tesselation feature to directly create the whole desired mesh completely on gpu

have fun ;)


Title: Re: Graphics
Post by: fractower on October 11, 2011, 06:13:25 PM
I started Opengl programming with GLUI. It is a relatively simple GUI interface that targets Opengl. More importantly it comes with examples which make it easy to start rendering triangles.



Title: Re: Graphics
Post by: kronikel on October 11, 2011, 06:17:17 PM
I'm currently using lockbits on a bitmap. Helps out a bit but I'm ready for better.

But I got directX working great now. Even got a realtime terrain rotation (though it is a small and simple terrain as of now)

GPU might be a while off because I have no money, but no doubt I'd like to get into that.
Also when I say 6 seconds to render a frame I mean calculating brand new values for the sky, coloration, land, water, and also rendering it, including my own version of shading and ray tracing.
So it's looking like realtime is easily possible.