project-navigation
Personal tools

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - fhstoica

Pages: [1]
1
Mapping / Re: Procedural water - why not?
« on: February 19, 2013, 12:22:33 pm »
Hi,

The attachment is a (zipped) animation of the surface waves that can be generated with the code (surface_waves.tar.gz) I posed at:
http://ufoai.org/forum/index.php/topic,7472.15.html

Let me know if this is what you are looking for.

2
Artwork / Re: Tools to generate textures
« 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.

3
Artwork / Re: Tools to generate textures
« 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.

4
Artwork / Re: Tools to generate textures
« on: February 07, 2013, 01:31:42 pm »
Well, done! You got it working now. The two diagrams you posted explain the flow of the texture generation process very well. You basically wrote the documentation for it.

Time to go a bit more into the details:

First, in the povray.ini file the line:
+W1024 +H1024
controls the width and height of the rendered image, in pixels. As it stands it is set to 1024x1024.

You will notice in the Generate_Texture.py script in line 128:

outstring += 'object{surfface scale<1.33, 1, 1>}\n'

This scales the surface horizontally (the x-z plane is the horizontal, y is the vertical) so that the final texture has the same numbers of pixels horizontally and vertically. I found the 1.33 value by trial and error.
Feel free to modify the parameters in this line if you want to get a different shape, but it is a good idea to keep the value for the y-direction to 1:

scale<x_scale, 1, z_scale>

At the moment the surface is shifted and scaled vertically so that it takes values between 0 and 1 along the y-direction. This way it appears flat when seen from a narrow-angle camera located high above the surface (line 88 in Generate_Texture.py). Changing the y_scale can make perspective effects visible, so it is better to leave that value unchanged.

As for the color_map, at the moment it is defined as:

        self.color_map       = \
"""[0.0  color Green]
[0.125  color Blue]
[0.25  color Red]
[0.375  color Orange]
[0.5  color Sienna]
[0.625  color SteelBlue]
[0.75  color Cyan]
[0.875  color Yellow]
[1.0  color Magenta]"""

It specifies at each contour level (between 0 and 1) which color to use. POV-RAY will interpolate the RGB values between these levels. The predefined colors are specified in the colors.inc file of the POV-RAY installation. They can also be found here:
http://www.buckosoft.com/~dick/pov/colors.php

You can specify the colors in rgb format, for example "color rgb<1, 0, 0>" or rgbf format, for example:

        color_map {
          [0.00, 0.33 color rgb <0, 0, 1>
                      color rgb <0, 0, 1>]
          [0.33, 0.66 color rgbf <1, 1, 1, 1>
                      color rgbf <1, 1, 1, 1>]
          [0.66, 1.00 color rgb <0, 0, 1>
                      color rgb <0, 0, 1>]

Again, very good documentation (for pigments, in general) can be found here:

http://www.povray.org/documentation/view/3.6.1/77/

I still have to rewrite Generate_Texture.py to include the FFT as well.

5
Artwork / Re: Tools to generate textures
« on: February 04, 2013, 04:37:50 pm »
Hi,

I'm glad that you managed to compile the code, after a bit of digging I found that Python supports 2-dimensional FFTs directly via the numpy package:

http://docs.scipy.org/doc/numpy/reference/generated/numpy.fft.fft2.html

http://sourceforge.net/projects/numpy/files/NumPy/1.6.2/

I may be able to put everything inside a single Python script that you can run from the Command Prompt in Windows.
Anyway, I tested the executable you posted, and it works perfectly.

The roughness you are mentioning can be controlled via the last parameter, the "power". The higher the value, (2 to 5) the smoother the image. A value between 1 and 2 will result in a rough image.

I have to read a bit more about the "pick effect" you mentioned, but the low frequencies can be removed by choosing a central_freq different than zero (for example 10, to 20).

Please let me know if you encounter any problems running the Python script, it should work with Python 2.7.

6
Artwork / Re: Tools to generate textures
« on: January 18, 2013, 03:35:49 pm »
Drat, I am really sorry to hear that you cannot install Cygwin.

One possibility is for me to try and port the 2D FFT program to FFTW instead of GSL.
That is because FFTW comes with pre-compiled Windows binaries and can be used from MinGW.
You can also install Python and POV-RAY for Windows, and then there will be no need for Cygwin anymore.

In the meantime, please let me know what kind of textures you would like. Please look at the Python script Generate_Texture.py at the self.color_map definition in line 15 of the script. This will tell you which colors will be used in generating the image. You can then tell me which colors to use and I will generate some samples.

It's not ideal, but it is a way I can help, and you can tell me what changes to make, until I get a painless way for you to use the tools directly.

7
Artwork / Re: Tools to generate textures
« on: January 14, 2013, 12:27:44 pm »
Thanks, I'll wait for your feedback.
You may know this already, but just to make sure, the stock installation of Cygwin comes with GSL included.

8
Artwork / Re: Tools to generate textures
« on: January 10, 2013, 06:15:25 am »
Finally, I added the tools I mentioned. I also included a new sample texture with the tools, (I did not crop the image).

You'll have to unpack the archive and first modify the Makefile so that it points to your installation of GSL (http://www.gnu.org/software/gsl/), needed for the FFT.

If you work in Linux and have POV-RAY (http://www.povray.org/download/) installed you can uncomment the last line in the start.py file so that the same script will run POV-RAY as well. I am currently working on a Windows machine and I am running start.py under Cygwin. I have to run POV-RAY outside of Cygwin, and process the surface.pov file generated by the scripts.

The quick way to generate a texture is:

./start.py <random_seed> <central_frequency> <decay_power> <output_file>

At the moment it is set up to generate a grid of 128x128 and render the image as seen from above, making basically a contour map.

For example, the image I attached I generated with:

 ./start.py 8991 20 1 surface.png

The central frequency can be somewhere between 0 and 64 (since the grid is 128^2), and the decay power between 1 (for a rough image) and 3 (for a smooth image).  Feel free to experiment with these values. 8991 is just some value I used as seed for the random number generator.

I will write a more detailed description of what each tool does.

9
Artwork / Re: Tools to generate textures
« on: January 10, 2013, 12:16:25 am »
This week I am a bit tied up with some work, but I will post the tools. Basically you need GSL (the GNU Scientific Library) for the FFT and then you will need POV-RAY. The 2D FFT code (GSL offers only 1D FFT if I remember correctly) is written in C++ and the code for generating the POV-RAY script is written in Python.

Basically you can specify a few Fourier modes by hand (or let Python generate them for you as random numbers), so it takes very little time to generate the textures you see. The color and the grayscale ones take about 5 seconds to generate on my machine (Athlon II X4, 3GHz).  You have very granular control over each step.

The normalmap requires hand work in GIMP.

I will post a short how-to on this forum, but I will write a more detailed document on what each script/program does. Will also generate more samples, and they require no hand work, just to launch a script from the command line.

10
Artwork / Re: Tools to generate textures
« on: January 08, 2013, 12:01:32 am »
No way, I am not at the point of writing GIMP plug-ins.

Only the last image, the normal map, I generated from the grayscale image using the Normalmap GIMP plugin. I simply installed the plugin on my Linux distro using Synaptic.

I believe you can contact the original author at this URL:  http://code.google.com/p/gimp-normalmap/

I generated the images using a Fourier Transform of a 2D array of random numbers (filtering out the high-frequency noise), and plotted the resulting surface (seen from above) using POV-RAY.

11
Artwork / Tools to generate textures
« on: December 27, 2012, 11:37:26 pm »
Hi,

I have some tools that can be used to generate textures like the ones attached. I made a sample using a color map with only 3 colors, Red, Green and Blue, the same sample on grayscale only, and the normalmap, which I simply generated with the GIMP plug-in.

The colors can be changed, more can be added, the roughness can be increased or decreased. The attachments are just a sample of what can be done. Since the texture is generated using a Fast Fourier Transform, the opposite edges of the images match, and they can be easily tiled.

If anyone is interested please let me know and I will make the tools available to everybody.

12
Bugs in stable version (2.5) / Re: New on the forum, spotted some bugs
« on: August 22, 2012, 05:49:30 pm »
I am using Git under Linux. Will have the update everything, source code, maps, and do a clean build.
I will also have to include the save files and logs (I keep the stdout and stderr of every game session) in the posts.

The mailing list is the one at:  http://lists.killfile.pl/mailman/listinfo/ufoai-announces

I am including below the message I got, removing my e-mail address to avoid getting spam.
Please feel free to edit my post to remove the other e-mail addresses, in case the mailing list is
in danger of getting spammed.

====================================================================

The results of your email command are provided below. Attached is your
original message.

- Results:
    Your request has been forwarded to the list moderator for approval.

- Unprocessed:
    On 7/24/2012 6:22 AM, ufoai-request@lists.killfile.pl wrote:
    > Mailing list subscription confirmation notice for mailing list UFOAI
    >
    > We have received a request from 80.169.239.165 for subscription of
    > your email address, "<-------->", to the
    > ufoai@lists.killfile.pl mailing list.  To confirm that you want to be
    > added to this mailing list, simply reply to this message, keeping the
    > Subject: header intact.  Or visit this web page:
    >
    >      http://lists.killfile.pl/mailman/confirm/ufoai/1efd2de9280d7d779abfa28af6ec6bf91540a6ee
    >
    >
    > Or include the following line -- and only the following line -- in a
    > message to ufoai-request@lists.killfile.pl:
    >
    >      confirm 1efd2de9280d7d779abfa28af6ec6bf91540a6ee
    >
    > Note that simply sending a `reply' to this message should work from
    > most mail readers, since that usually leaves the Subject: line in the
    > right form (additional "Re:" text in the Subject: is okay).
    >
    > If you do not wish to be subscribed to this list, please simply
    > disregard this message.  If you think you are being maliciously
    > subscribed to the list, or have any other questions, send them to
    > ufoai-owner@lists.killfile.pl.

13
Bugs in stable version (2.5) / Re: New on the forum, spotted some bugs
« on: August 22, 2012, 04:20:07 pm »
Thank you!

1) I will update the code and see if the missing map problem is still there.
2) My googling haven't showed anything on this subject.
Will look over the mapping instructions, thanks for the link!

Anyway, I subscribed to the mailing list as well, and requested a digest at the end of the day,
but I haven't got any message. Should I try again? Contact a moderator directly?

14
Bugs in stable version (2.5) / New on the forum, spotted some bugs
« on: August 22, 2012, 02:59:12 pm »
Hi,

I am new on the forum, so I don't even know if this is the right place for this post (please advise).
I downloaded the source code for the 2.5 version of the game about 3 months ago, and I keep on running on 2 problems:

1) For some crashed UFOs I cannot enter the mission, I get the error:

ERROR: Couldn't load maps/bridge/br_craft_crash_scout.bsp

The dropship just hovers over the location and I have to send it back manually.

2) I had to abandon a campaign as I kept on getting errors of the type:

ERROR: CP_SetAlienTeamByInterest: no available alien team for mission 'cat7_interest27_1': interest = 27 -- category = 7

This happened for all missions (base attack, crashed or landed UFO, etc).

I also encountered (only once) the problem of "missionid" appearing as the string "^Q" in the save file, and hence unable to reload the game (for a simple campaign)

I can do some coding (mostly C++ and Python, not much using plain old C), so I would like to help fix these bugs.
I also played graphics in the past (mostly pov-ray) so maybe I can help a bit with the mapping.

Pages: [1]