project-navigation
Personal tools

Author Topic: Tools to generate textures  (Read 11456 times)

Offline krilain

  • Squad Leader
  • ****
  • Posts: 171
    • View Profile
Re: Tools to generate textures
« Reply #15 on: February 07, 2013, 07:01:07 pm »
Well, done! You got it working now. (...)
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.

I still have to rewrite Generate_Texture.py to include the FFT as well.
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
« Last Edit: February 07, 2013, 07:09:55 pm by krilain »

Offline fhstoica

  • Rookie
  • ***
  • Posts: 14
    • View Profile
Re: Tools to generate textures
« Reply #16 on: February 09, 2013, 06:43:19 pm »
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.

Offline Sandro

  • Squad Leader
  • ****
  • Posts: 240
  • Maintenance guy for UFO:AI 3D engine
    • View Profile
Re: Tools to generate textures
« Reply #17 on: February 09, 2013, 09:00:05 pm »
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

Offline krilain

  • Squad Leader
  • ****
  • Posts: 171
    • View Profile
Re: Tools to generate textures
« Reply #18 on: February 10, 2013, 10:47: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.

Offline fhstoica

  • Rookie
  • ***
  • Posts: 14
    • View Profile
Re: Tools to generate textures
« Reply #19 on: February 11, 2013, 02:21:11 am »
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.