Brainstorming: Noise optimization
#1
Lightbulb 
As I've already sketched up in FS #337 (http://www.mc-server.org/support/index.p...ask_id=337), the noise generator could be optimized by generating an array of values at once instead of a single value. I'd like to give it a whack.

At the same time, I don't think the code in Noise.cpp that is using SSE is any good - it hasn't even been in use for as long as I've been on this project. So how about I get rid of it in favor of the new array-handling noise?

As for the arrays, I was thinking about creating several new classes. cCubicNoise would generate the same noise that cNoise now does, but for arrays. Then cPerlinNoise would combine several cCubicNoise-s to produce a Perlin noise. If found useful, a cRidgedMulti class would be written to combine two cPerlinNoise-s to produce a ridged multifractal noise.
Each of the noise classes will have functions Generate1D, Generate2D and Generate3D that will take 1D, 2D and 3D arrays of doubles, and coords for the array boundaries in the noise-space.
Because the PerlinNoise and RidgedMulti need an extra array for workspace, I'm thinking about having the possibility of providing this workspace array as an optional parameter - so that each call to GenerateND() doesn't result in a memory allocation and freeing - usually the callers will have the ability to cache and reuse these workspaces.

So these will be the main interface:
Code:
class cCubicNoise
{
public:
    void Generate1D(
        double * a_Array,                ///< Array to generate into
        int a_SizeX,                     ///< Size of the array (num doubles)
        double a_StartX, double a_EndX,  ///< Noise-space coords of the array
        double * a_Workspace = NULL      ///< Workspace that this function can use and trash, same size as a_Array
    );
    
    void Generate2D(
        double * a_Array,                ///< Array to generate into [x + a_SizeX * y]
        int a_SizeX, int a_SizeY         ///< Size of the array (num doubles), in each direction
        double a_StartX, double a_EndX,  ///< Noise-space coords of the array in the X direction
        double a_StartY, double a_EndY,  ///< Noise-space coords of the array in the Y direction
        double * a_Workspace = NULL      ///< Workspace that this function can use and trash, same size as a_Array
    );
    
    void Generate3D(
        double * a_Array,                       ///< Array to generate into [x + a_SizeX * y + a_SizeX * a_SizeY * z]
        int a_SizeX, int a_SizeY, int a_SizeZ,  ///< Size of the array (num doubles), in each direction
        double a_StartX, double a_EndX,         ///< Noise-space coords of the array in the X direction
        double a_StartY, double a_EndY,         ///< Noise-space coords of the array in the Y direction
        double a_StartZ, double a_EndZ,         ///< Noise-space coords of the array in the Z direction
        double * a_Workspace = NULL             ///< Workspace that this function can use and trash, same size as a_Array
    );
} ;

// Same interface for the other noise classes.

Anyone any thoughts about this? I'm especially interested in any reasons for keeping the SSE code in.
Reply
Thanks given by:


Messages In This Thread
Brainstorming: Noise optimization - by xoft - 03-28-2013, 05:54 AM
RE: Brainstorming: Noise optimization - by xoft - 03-28-2013, 07:29 AM
RE: Brainstorming: Noise optimization - by ThuGie - 01-15-2014, 10:29 AM
RE: Brainstorming: Noise optimization - by xoft - 01-15-2014, 10:56 PM
RE: Brainstorming: Noise optimization - by xoft - 01-16-2014, 06:18 AM
RE: Brainstorming: Noise optimization - by xoft - 01-17-2014, 05:06 AM
RE: Brainstorming: Noise optimization - by ThuGie - 01-17-2014, 07:17 AM
RE: Brainstorming: Noise optimization - by xoft - 01-18-2014, 08:13 AM
RE: Brainstorming: Noise optimization - by xoft - 01-19-2014, 01:02 AM
RE: Brainstorming: Noise optimization - by xoft - 01-19-2014, 01:20 AM
RE: Brainstorming: Noise optimization - by xoft - 01-19-2014, 01:45 AM
RE: Brainstorming: Noise optimization - by xoft - 01-19-2014, 02:05 AM
RE: Brainstorming: Noise optimization - by xoft - 01-19-2014, 07:29 AM
RE: Brainstorming: Noise optimization - by xoft - 01-19-2014, 05:14 PM
RE: Brainstorming: Noise optimization - by xoft - 01-24-2014, 06:37 PM



Users browsing this thread: 9 Guest(s)