Development > Artwork

Tools to generate textures

<< < (4/4)

krilain:

--- Quote from: fhstoica on February 07, 2013, 01:31:42 pm ---Well, done! You got it working now. (...)

--- End quote ---
Yes, at last ;*)

Thanks for the details. Fortunately I can count on french documentation (like this page http://khayyam.developpez.com/articles/3d/povray/?page=page_8#LVIII-E-1) in the hope to understand all of that.

Before I go further into it, you may want to know what kind of texture it may help to generate and what for. From my side, the interest was not too much to use computed texture on maps. I think that there, that 's photographical textures that are needed more. But I've been from one month looking on some classical implementation of flight combat, you know like 1942 and so on. This shouldn't have been too much difficult to code a first thing, but I'm damn slow so it will probably never see the dawn of day ;_) Anyway, I'm attaching here some stuff that will show you this.


--- Quote from: fhstoica on February 07, 2013, 01:31:42 pm ---I still have to rewrite Generate_Texture.py to include the FFT as well.

--- End quote ---
Let me know when it's done. Moreover if I've time enough I will see if some tweak helps to get predictable results.


ps : if you love diagrams, using Dia I've made this topic readable in this way About psi and other stories

fhstoica:
Finally, I wrote the script that does the FFT and generates the POV-RAY file in one go:

./Generate_Texture.py --size=128 --central_freq=0 --power=1.8 --seed=90980

It requires python 2.7 and numpy. I use optparse which doesn't work with Python 3 series, but it is a trivial change to switch to argparse if you prefer the newer series.

I attached a sample image generated with this new script, the first time flattened and seen from above, the second time scaled up vertically, and seen in perspective.

With this script it is trivial to render a large grid (say, 512^2), and render it a high resolution (4k x 4k) and then cut a piece of the image, instead of tiling small texture pieces.
With the old tools you would have to change the code in a few places to update for the new size.

However, for very large grids, POV-RAY will start to use large amounts of memory, and the surface.pov file will grow like N^2. On an old machine with 512MB of RAM the practical limit for the grid size is 256^2.

Sandro:
Can you generate a good velocity field for a sinewave (or better) water? Random for every map loading? That could help a project of mine to use cheap-math wave simulator for UFO:AI water: http://ufoai.org/forum/index.php/topic,6932.0.html

krilain:

--- Quote from: krilain on February 10, 2013, 09:14:35 pm ---I've tested your fluid program - or more precisely your program about fluids ;_). That's quite impressive. It would be funny to be able to shoot in the water (after a miss for example) and see it having such movement.

--- End quote ---

fhstoica:
Regarding the waves on the water, all I have is an old simulation of a wave in 2 dimensions. It is not a proper hydrodynamics simulation, just the wave equation in 2D. I don't know if this is what you are looking for. Anyway, the code is attached.

You will find the following components:
One script for generating the initial data. At the moment it generates a Gaussian, with center and width that are user-specified. Since the grid is 128^2, I generated the initial data with:

./Initial_Data.py 64 0.07

surface_waves.cpp: The actual simulation. You can simply type "make" to compile it. The file Constant.cpp contains parameters like grid size, surface tension, lattice spacing, time step, damping, number of frames to generate and number of time steps between frames.
Running the resulting executable will produce a bunch of "frame###.txt" files following the evolution of the wave.

Finally, you can use POV-RAY to render each frame, with Plot_Frame.py, for example:

/Plot_Frame.py --in_file=frame010.txt --pov_file=frame010.pov --png_file=frame010.png

I also included the txt and png files for the initial data and one of the frames.

Navigation

[0] Message Index

[*] Previous page

Go to full version