Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
Perlin.cpp
Go to the documentation of this file.
1/*
2--------------------------------------------------------------------------------
3This source file is part of Hydrax.
4Visit ---
5
6Copyright (C) 2008 Xavier Vergu�n Gonz�lez <xavierverguin@hotmail.com>
7 <xavyiy@gmail.com>
8
9This program is free software; you can redistribute it and/or modify it under
10the terms of the GNU Lesser General Public License as published by the Free Software
11Foundation; either version 2 of the License, or (at your option) any later
12version.
13
14This program is distributed in the hope that it will be useful, but WITHOUT
15ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17
18You should have received a copy of the GNU Lesser General Public License along with
19this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21http://www.gnu.org/copyleft/lesser.txt.
22--------------------------------------------------------------------------------
23
24Based on the perlin noise code from Claes Johanson thesis:
25http://graphics.cs.lth.se/theses/projects/projgrid/
26--------------------------------------------------------------------------------
27*/
28
29#include <Perlin.h>
30
31#include <Hydrax.h>
32
33#define _def_PackedNoise true
34
35namespace Hydrax{namespace Noise
36{
38 : Noise("Perlin", true)
39 , time(0)
40 , r_noise(0)
41 , magnitude(n_dec_magn * 0.085f)
42 , mGPUNormalMapManager(0)
43 {
44 }
45
47 : Noise("Perlin", true)
48 , mOptions(Options)
49 , time(0)
50 , r_noise(0)
51 , magnitude(n_dec_magn * Options.Scale)
52 , mGPUNormalMapManager(0)
53 {
54 }
55
57 {
58 remove();
59
60 HydraxLOG(getName() + " destroyed.");
61 }
62
64 {
65 if (isCreated())
66 {
67 return;
68 }
69
71 _initNoise();
72 }
73
75 {
77 {
79 }
80
81 if (!isCreated())
82 {
83 return;
84 }
85
86 time = 0;
87
89 }
90
92 {
93 if (isCreated())
94 {
95 int Octaves_ = Options.Octaves;
97 mOptions.Octaves = Octaves_;
98
100 {
102 getTechnique(0)->getPass(0)->
103 getVertexProgramParameters()->
104 setNamedConstant("uScale", Options.Scale);
105
107 getTechnique(0)->getPass(0)->
108 getFragmentProgramParameters()->
109 setNamedConstant("uStrength", Options.GPU_Strength);
110
112 getTechnique(0)->getPass(0)->
113 getFragmentProgramParameters()->
114 setNamedConstant("uLODParameters", Options.GPU_LODParameters);
115 }
116 }
117 else
118 {
121 }
122
124 }
125
127 {
129 {
130 return false;
131 }
132
134
135 // Create our perlin textures
136 Ogre::TexturePtr mPerlinTexture0
137 = Ogre::TextureManager::getSingleton().
138 createManual("_Hydrax_Perlin_Noise0",
139 Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
140 Ogre::TEX_TYPE_2D,
141 np_size, np_size, 0,
142 Ogre::PF_L16,
143 Ogre::TU_DYNAMIC_WRITE_ONLY);
144
145 Ogre::TexturePtr mPerlinTexture1
146 = Ogre::TextureManager::getSingleton().
147 createManual("_Hydrax_Perlin_Noise1",
148 Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
149 Ogre::TEX_TYPE_2D,
150 np_size, np_size, 0,
151 Ogre::PF_L16,
152 Ogre::TU_DYNAMIC_WRITE_ONLY);
153
154 mGPUNormalMapManager->addTexture(mPerlinTexture0);
155 mGPUNormalMapManager->addTexture(mPerlinTexture1);
156
157 // Create our normal map generator material
158
159 MaterialManager *mMaterialManager = g->getHydrax()->getMaterialManager();
160
161 Ogre::String VertexProgramData, FragmentProgramData;
162 Ogre::GpuProgramParametersSharedPtr VP_Parameters, FP_Parameters;
163 Ogre::String EntryPoints[2] = {"main_vp", "main_fp"};
164 Ogre::String GpuProgramsData[2]; Ogre::String GpuProgramNames[2];
165
166 // Vertex program
167
168 switch (g->getHydrax()->getShaderMode())
169 {
171 {
172 VertexProgramData +=
173 Ogre::String(
174 "void main_vp(\n") +
175 // IN
176 "float4 iPosition : POSITION,\n" +
177 // OUT
178 "out float4 oPosition : POSITION,\n" +
179 "out float3 oPosition_ : TEXCOORD0,\n" +
180 "out float4 oWorldUV : TEXCOORD1,\n" +
181 "out float oScale : TEXCOORD2,\n" +
182 "out float3 oCameraPos : TEXCOORD3,\n" +
183 "out float3 oCameraToPixel : TEXCOORD4,\n" +
184 // UNIFORM
185 "uniform float4x4 uWorldViewProj,\n" +
186 "uniform float4x4 uWorld, \n" +
187 "uniform float3 uCameraPos,\n"+
188 "uniform float uScale)\n" +
189 "{\n" +
190 "oPosition = mul(uWorldViewProj, iPosition);\n" +
191 "oPosition_ = iPosition.xyz;\n" +
192 "float2 Scale = uScale*mul(uWorld, iPosition).xz*0.0078125;\n" +
193 "oWorldUV.xy = Scale;\n" +
194 "oWorldUV.zw = Scale*16;\n" +
195 "oScale = uScale;\n" +
196 "oCameraPos = uCameraPos,\n" +
197 "oCameraToPixel = iPosition - uCameraPos;\n"+
198 "}\n";
199 }
200 break;
201
203 {}
204 break;
205 }
206
207 // Fragment program
208
209 switch (g->getHydrax()->getShaderMode())
210 {
212 {
213 FragmentProgramData +=
214 Ogre::String(
215 "void main_fp(\n") +
216 // IN
217 "float3 iPosition : TEXCOORD0,\n" +
218 "float4 iWorldCoord : TEXCOORD1,\n" +
219 "float iScale : TEXCOORD2,\n" +
220 "float3 iCameraPos : TEXCOORD3,\n" +
221 "float3 iCameraToPixel : TEXCOORD4,\n" +
222 // OUT
223 "out float4 oColor : COLOR,\n" +
224 // UNIFORM
225 "uniform float uStrength,\n" +
226 "uniform float3 uLODParameters,\n" + // x: Initial derivation, y: Final derivation, z: Step
227 "uniform float3 uCameraPos,\n" +
228 "uniform sampler2D uNoise0 : register(s0),\n" +
229 "uniform sampler2D uNoise1 : register(s1))\n" +
230 "{\n" +
231 "float Distance = length(iCameraToPixel);\n" +
232 "float Attenuation = saturate(Distance/uLODParameters.z);\n" +
233
234 "uLODParameters.x += (uLODParameters.y-uLODParameters.x)*Attenuation;\n"+
235 "uLODParameters.x *= iScale;\n" +
236
237 "float AngleAttenuation = 1/abs(normalize(iCameraToPixel).y);\n"+
238 "uLODParameters.x *= AngleAttenuation;\n"+
239
240 "float2 dx = float2(uLODParameters.x*0.0078125, 0);\n" +
241 "float2 dy = float2(0, dx.x);\n" +
242
243 "float3 p_dx, m_dx, p_dy, m_dy;\n" +
244
245 "p_dx = float3(\n" +
246 // x+
247 "iPosition.x+uLODParameters.x,\n" +
248 // y+
249 "tex2D(uNoise0, iWorldCoord.xy+dx).x + tex2D(uNoise1, iWorldCoord.zw+dx*16).x,\n" +
250 // z
251 "iPosition.z);\n" +
252
253 "m_dx = float3(\n" +
254 // x-
255 "iPosition.x-uLODParameters.x,\n" +
256 // y-
257 "tex2D(uNoise0, iWorldCoord.xy-dx).x + tex2D(uNoise1, iWorldCoord.zw-dx*16).x,\n" +
258 // z
259 "iPosition.z);\n" +
260
261 "p_dy = float3(\n" +
262 // x
263 "iPosition.x,\n" +
264 // y+
265 "tex2D(uNoise0, iWorldCoord.xy+dy).x + tex2D(uNoise1, iWorldCoord.zw+dy*16).x,\n" +
266 // z+
267 "iPosition.z+uLODParameters.x);\n" +
268
269 "m_dy = float3(\n" +
270 // x
271 "iPosition.x,\n" +
272 // y-
273 "tex2D(uNoise0, iWorldCoord.xy-dy).x + tex2D(uNoise1, iWorldCoord.zw-dy*16).x,\n" +
274 // z-
275 "iPosition.z-uLODParameters.x);\n" +
276
277 "uStrength *= (1-Attenuation);\n" +
278 "p_dx.y *= uStrength; m_dx.y *= uStrength;\n" +
279 "p_dy.y *= uStrength; m_dy.y *= uStrength;\n" +
280
281 "float3 normal = normalize(cross(p_dx-m_dx, p_dy-m_dy));\n" +
282
283 "oColor = float4(saturate(1-(0.5+0.5*normal)),1);\n" +
284 "}\n";
285
286 }
287 break;
288
290 {}
291 break;
292 }
293
294 // Build our material
295
296 Ogre::MaterialPtr &mNormalMapMaterial = mGPUNormalMapManager->getNormalMapMaterial();
297 mNormalMapMaterial = Ogre::MaterialManager::getSingleton().create("_Hydrax_GPU_Normal_Map_Material", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
298
299 Ogre::Pass *Technique0_Pass0 = mNormalMapMaterial->getTechnique(0)->getPass(0);
300
301 Technique0_Pass0->setLightingEnabled(false);
302 Technique0_Pass0->setCullingMode(Ogre::CULL_NONE);
303 Technique0_Pass0->setDepthWriteEnabled(true);
304 Technique0_Pass0->setDepthCheckEnabled(true);
305
306 GpuProgramsData[0] = VertexProgramData; GpuProgramsData[1] = FragmentProgramData;
307 GpuProgramNames[0] = "_Hydrax_GPU_Normal_Map_VP"; GpuProgramNames[1] = "_Hydrax_GPU_Normal_Map_FP";
308
309 mMaterialManager->fillGpuProgramsToPass(Technique0_Pass0, GpuProgramNames, g->getHydrax()->getShaderMode(), EntryPoints, GpuProgramsData);
310
311 VP_Parameters = Technique0_Pass0->getVertexProgramParameters();
312
313 VP_Parameters->setNamedAutoConstant("uWorldViewProj", Ogre::GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX);
314 VP_Parameters->setNamedAutoConstant("uWorld", Ogre::GpuProgramParameters::ACT_WORLD_MATRIX);
315 VP_Parameters->setNamedAutoConstant("uCameraPos", Ogre::GpuProgramParameters::ACT_CAMERA_POSITION_OBJECT_SPACE);
316 VP_Parameters->setNamedConstant("uScale", mOptions.Scale);
317
318 FP_Parameters = Technique0_Pass0->getFragmentProgramParameters();
319
320 FP_Parameters->setNamedConstant("uStrength", mOptions.GPU_Strength);
321 FP_Parameters->setNamedConstant("uLODParameters", mOptions.GPU_LODParameters);
322
323 Technique0_Pass0->createTextureUnitState(mGPUNormalMapManager->getTexture(0)->getName(), 0)
324 ->setTextureAddressingMode(Ogre::TextureUnitState::TAM_MIRROR);
325 Technique0_Pass0->createTextureUnitState(mGPUNormalMapManager->getTexture(1)->getName(), 1)
326 ->setTextureAddressingMode(Ogre::TextureUnitState::TAM_MIRROR);
327
328 mNormalMapMaterial->load();
329
331
332 return true;
333 }
334
335 void Perlin::saveCfg(Ogre::String &Data)
336 {
337 Noise::saveCfg(Data);
338
339 Data += CfgFileManager::_getCfgString("Perlin_Octaves", mOptions.Octaves);
340 Data += CfgFileManager::_getCfgString("Perlin_Scale", mOptions.Scale);
341 Data += CfgFileManager::_getCfgString("Perlin_Falloff", mOptions.Falloff);
342 Data += CfgFileManager::_getCfgString("Perlin_Animspeed", mOptions.Animspeed);
343 Data += CfgFileManager::_getCfgString("Perlin_Timemulti", mOptions.Timemulti);
344 Data += CfgFileManager::_getCfgString("Perlin_GPU_Strength", mOptions.GPU_Strength);
345 Data += CfgFileManager::_getCfgString("Perlin_GPU_LODParameters", mOptions.GPU_LODParameters); Data += "\n";
346 }
347
348 bool Perlin::loadCfg(Ogre::ConfigFile &CfgFile)
349 {
350 if (!Noise::loadCfg(CfgFile))
351 {
352 return false;
353 }
354
356 Options(CfgFileManager::_getIntValue(CfgFile,"Perlin_Octaves"),
357 CfgFileManager::_getFloatValue(CfgFile,"Perlin_Scale"),
358 CfgFileManager::_getFloatValue(CfgFile,"Perlin_Falloff"),
359 CfgFileManager::_getFloatValue(CfgFile,"Perlin_Animspeed"),
360 CfgFileManager::_getFloatValue(CfgFile,"Perlin_Timemulti"),
361 CfgFileManager::_getFloatValue(CfgFile,"Perlin_GPU_Strength"),
362 CfgFileManager::_getVector3Value(CfgFile,"Perlin_GPU_LODParameters")));
363
364 return true;
365 }
366
367 void Perlin::update(const Ogre::Real &timeSinceLastFrame)
368 {
369 time += timeSinceLastFrame*mOptions.Animspeed;
371
373 {
375 }
376 }
377
379 {
380 unsigned short *Data;
381 int Offset;
382 Ogre::HardwarePixelBufferSharedPtr PixelBuffer;
383
384 for (int k = 0; k < 2; k++)
385 {
386 Offset = np_size_sq*k;
387 PixelBuffer = mGPUNormalMapManager->getTexture(k)->getBuffer();
388
389 PixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD);
390 const Ogre::PixelBox& PixelBox = PixelBuffer->getCurrentLock();
391
392 Data = reinterpret_cast<unsigned short*>(PixelBox.data);
393
394 for (int u = 0; u < np_size_sq; u++)
395 {
396 Data[u] = 32768+p_noise[u+Offset];//std::cout << p_noise[u+Offset] << std::endl;
397 }
398
399 PixelBuffer->unlock();
400 }
401 }
402
403 float Perlin::getValue(const float &x, const float &y)
404 {
405 return _getHeigthDual(x, y);
406 }
407
409 {
410 // Create noise (uniform)
411 float tempnoise[n_size_sq*noise_frames], temp;
412
413 int i, frame, v, u,
414 v0, v1, v2, u0, u1, u2, f;
415
416 for(i=0; i<(n_size_sq*noise_frames); i++)
417 {
418 temp = static_cast<float>(rand())/RAND_MAX;
419 tempnoise[i] = 4*(temp - 0.5f);
420 }
421
422 for(frame=0; frame<noise_frames; frame++)
423 {
424 for(v=0; v<n_size; v++)
425 {
426 for(u=0; u<n_size; u++)
427 {
428 v0 = ((v-1)&n_size_m1)*n_size;
429 v1 = v*n_size;
430 v2 = ((v+1)&n_size_m1)*n_size;
431 u0 = ((u-1)&n_size_m1);
432 u1 = u;
433 u2 = ((u+1)&n_size_m1);
434 f = frame*n_size_sq;
435
436 temp = (1.0f/14.0f) *
437 (tempnoise[f + v0 + u0] + tempnoise[f + v0 + u1] + tempnoise[f + v0 + u2] +
438 tempnoise[f + v1 + u0] + 6.0f*tempnoise[f + v1 + u1] + tempnoise[f + v1 + u2] +
439 tempnoise[f + v2 + u0] + tempnoise[f + v2 + u1] + tempnoise[f + v2 + u2]);
440
441 noise[frame*n_size_sq + v*n_size + u] = noise_magnitude*temp;
442 }
443 }
444 }
445 }
446
448 {
449 int i, o, v, u,
450 multitable[max_octaves],
451 amount[3],
452 iImage;
453
454 unsigned int image[3];
455
456 float sum = 0.0f,
457 f_multitable[max_octaves];
458
459 double dImage, fraction;
460
461 // calculate the strength of each octave
462 for(i=0; i<mOptions.Octaves; i++)
463 {
464 f_multitable[i] = powf(mOptions.Falloff,1.0f*i);
465 sum += f_multitable[i];
466 }
467
468 for(i=0; i<mOptions.Octaves; i++)
469 {
470 f_multitable[i] /= sum;
471 }
472
473 for(i=0; i<mOptions.Octaves; i++)
474 {
475 multitable[i] = scale_magnitude*f_multitable[i];
476 }
477
478 double r_timemulti = 1.0;
479 const float PI_3 = Ogre::Math::PI/3;
480
481 for(o=0; o<mOptions.Octaves; o++)
482 {
483 fraction = modf(time*r_timemulti,&dImage);
484 iImage = static_cast<int>(dImage);
485
486 amount[0] = scale_magnitude*f_multitable[o]*(pow(sin((fraction+2)*PI_3),2)/1.5);
487 amount[1] = scale_magnitude*f_multitable[o]*(pow(sin((fraction+1)*PI_3),2)/1.5);
488 amount[2] = scale_magnitude*f_multitable[o]*(pow(sin((fraction )*PI_3),2)/1.5);
489
490 image[0] = (iImage ) & noise_frames_m1;
491 image[1] = (iImage+1) & noise_frames_m1;
492 image[2] = (iImage+2) & noise_frames_m1;
493
494 for (i=0; i<n_size_sq; i++)
495 {
496 o_noise[i + n_size_sq*o] = (
497 ((amount[0] * noise[i + n_size_sq * image[0]])>>scale_decimalbits) +
498 ((amount[1] * noise[i + n_size_sq * image[1]])>>scale_decimalbits) +
499 ((amount[2] * noise[i + n_size_sq * image[2]])>>scale_decimalbits));
500 }
501
502 r_timemulti *= mOptions.Timemulti;
503 }
504
506 {
507 int octavepack = 0;
508 for(o=0; o<mOptions.Octaves; o+=n_packsize)
509 {
510 for(v=0; v<np_size; v++)
511 {
512 for(u=0; u<np_size; u++)
513 {
514 p_noise[v*np_size+u+octavepack*np_size_sq] = o_noise[(o+3)*n_size_sq + (v&n_size_m1)*n_size + (u&n_size_m1)];
515 p_noise[v*np_size+u+octavepack*np_size_sq] += _mapSample( u, v, 3, o);
516 p_noise[v*np_size+u+octavepack*np_size_sq] += _mapSample( u, v, 2, o+1);
517 p_noise[v*np_size+u+octavepack*np_size_sq] += _mapSample( u, v, 1, o+2);
518 }
519 }
520
521 octavepack++;
522 }
523 }
524 }
525
526 int Perlin::_readTexelLinearDual(const int &u, const int &v,const int &o)
527 {
528 int iu, iup, iv, ivp, fu, fv,
529 ut01, ut23, ut;
530
531 iu = (u>>n_dec_bits)&np_size_m1;
532 iv = ((v>>n_dec_bits)&np_size_m1)*np_size;
533
534 iup = ((u>>n_dec_bits) + 1)&np_size_m1;
535 ivp = (((v>>n_dec_bits) + 1)&np_size_m1)*np_size;
536
537 fu = u & n_dec_magn_m1;
538 fv = v & n_dec_magn_m1;
539
540 ut01 = ((n_dec_magn-fu)*r_noise[iv + iu] + fu*r_noise[iv + iup])>>n_dec_bits;
541 ut23 = ((n_dec_magn-fu)*r_noise[ivp + iu] + fu*r_noise[ivp + iup])>>n_dec_bits;
542 ut = ((n_dec_magn-fv)*ut01 + fv*ut23) >> n_dec_bits;
543
544 return ut;
545 }
546
547 float Perlin::_getHeigthDual(float u, float v)
548 {
549 // Pointer to the current noise source octave
551
552 int ui = u*magnitude,
553 vi = v*magnitude,
554 i,
555 value = 0,
556 hoct = mOptions.Octaves / n_packsize;
557
558 for(i=0; i<hoct; i++)
559 {
560 value += _readTexelLinearDual(ui,vi,0);
561 ui = ui << n_packsize;
562 vi = vi << n_packsize;
564 }
565
566 return static_cast<float>(value)/noise_magnitude;
567 }
568
569 int Perlin::_mapSample(const int &u, const int &v, const int &upsamplepower, const int &octave)
570 {
571 int magnitude = 1<<upsamplepower,
572
573 pu = u >> upsamplepower,
574 pv = v >> upsamplepower,
575
576 fu = u & (magnitude-1),
577 fv = v & (magnitude-1),
578
579 fu_m = magnitude - fu,
580 fv_m = magnitude - fv,
581
582 o = fu_m*fv_m*o_noise[octave*n_size_sq + ((pv) &n_size_m1)*n_size + ((pu) &n_size_m1)] +
583 fu* fv_m*o_noise[octave*n_size_sq + ((pv) &n_size_m1)*n_size + ((pu+1)&n_size_m1)] +
584 fu_m*fv* o_noise[octave*n_size_sq + ((pv+1)&n_size_m1)*n_size + ((pu) &n_size_m1)] +
585 fu* fv* o_noise[octave*n_size_sq + ((pv+1)&n_size_m1)*n_size + ((pu+1)&n_size_m1)];
586
587 return o >> (upsamplepower+upsamplepower);
588 }
589}}
#define HydraxLOG(msg)
Definition Application.h:60
#define _def_PackedNoise
Definition Perlin.cpp:33
static Ogre::String _getCfgString(const Ogre::String &Name, const int &Value)
static Ogre::Vector3 _getVector3Value(Ogre::ConfigFile &CfgFile, const Ogre::String Name)
Get vector3 value.
static Ogre::Real _getFloatValue(Ogre::ConfigFile &CfgFile, const Ogre::String Name)
Get float value.
static int _getIntValue(Ogre::ConfigFile &CfgFile, const Ogre::String Name)
Get int value.
Class to manager GPU normal maps.
Ogre::TexturePtr & getTexture(const int &Index)
Get a texture.
Hydrax * getHydrax()
Get the Hydrax parent pointer.
void addTexture(Ogre::TexturePtr &Texture)
Create a texture.
Ogre::MaterialPtr & getNormalMapMaterial()
Get the normal map material.
const MaterialManager::ShaderMode & getShaderMode() const
Get current shader mode.
Definition Hydrax.h:405
MaterialManager * getMaterialManager()
Get Hydrax::MaterialManager.
Definition Hydrax.h:325
Material/Shader manager class.
bool fillGpuProgramsToPass(Ogre::Pass *Pass, const Ogre::String GpuProgramNames[2], const ShaderMode &SM, const Ogre::String EntryPoints[2], const Ogre::String Data[2])
Fill GPU vertex and fragment program to a pass.
Base noise class, Override it for create different ways of create water noise.
Definition Noise.h:43
virtual void remove()
Remove.
Definition Noise.cpp:47
const Ogre::String & getName() const
Get noise name.
Definition Noise.h:92
const bool & areGPUNormalMapResourcesCreated() const
Are GPU normal map resources created?
Definition Noise.h:116
virtual bool createGPUNormalMapResources(GPUNormalMapManager *g)
Create GPUNormalMap resources.
Definition Noise.cpp:52
virtual bool loadCfg(Ogre::ConfigFile &CfgFile)
Load config.
Definition Noise.cpp:87
const bool & isGPUNormalMapSupported() const
Is GPU Normal map generation supported.
Definition Noise.h:108
virtual void removeGPUNormalMapResources(GPUNormalMapManager *g)
Remove GPUNormalMap resources.
Definition Noise.cpp:71
virtual void saveCfg(Ogre::String &Data)
Save config.
Definition Noise.cpp:81
virtual void create()
Create.
Definition Noise.cpp:42
const bool & isCreated() const
Is created() called?
Definition Noise.h:100
void update(const Ogre::Real &timeSinceLastFrame)
Call it each frame.
Definition Perlin.cpp:367
void _updateGPUNormalMapResources()
Update gpu normal map resources.
Definition Perlin.cpp:378
int _mapSample(const int &u, const int &v, const int &upsamplepower, const int &octave)
Map sample.
Definition Perlin.cpp:569
bool loadCfg(Ogre::ConfigFile &CfgFile)
Load config.
Definition Perlin.cpp:348
void create()
Create.
Definition Perlin.cpp:63
~Perlin()
Destructor.
Definition Perlin.cpp:56
void saveCfg(Ogre::String &Data)
Save config.
Definition Perlin.cpp:335
float getValue(const float &x, const float &y)
Get the especified x/y noise value.
Definition Perlin.cpp:403
float _getHeigthDual(float u, float v)
Read texel linear.
Definition Perlin.cpp:547
Perlin()
Default constructor.
Definition Perlin.cpp:37
void remove()
Remove.
Definition Perlin.cpp:74
int noise[n_size_sq *noise_frames]
Perlin noise variables.
Definition Perlin.h:269
double time
Elapsed time.
Definition Perlin.h:276
void _initNoise()
Initialize noise.
Definition Perlin.cpp:408
int p_noise[np_size_sq *(max_octaves > >(n_packsize-1))]
Definition Perlin.h:271
int _readTexelLinearDual(const int &u, const int &v, const int &o)
Read texel linear dual.
Definition Perlin.cpp:526
GPUNormalMapManager * mGPUNormalMapManager
GPUNormalMapManager pointer.
Definition Perlin.h:279
Options mOptions
Perlin noise options.
Definition Perlin.h:282
int o_noise[n_size_sq *max_octaves]
Definition Perlin.h:270
bool createGPUNormalMapResources(GPUNormalMapManager *g)
Create GPUNormalMap resources.
Definition Perlin.cpp:126
void setOptions(const Options &Options)
Set/Update perlin noise options.
Definition Perlin.cpp:91
void _calculeNoise()
Calcule noise.
Definition Perlin.cpp:447
#define noise_magnitude
Definition Perlin.h:64
#define scale_decimalbits
Definition Perlin.h:66
#define max_octaves
Definition Perlin.h:58
#define noise_frames_m1
Definition Perlin.h:61
#define n_dec_magn
Definition Perlin.h:55
#define scale_magnitude
Definition Perlin.h:67
#define np_size
Definition Perlin.h:49
#define n_dec_magn_m1
Definition Perlin.h:56
#define np_size_sq
Definition Perlin.h:51
#define n_size_sq
Definition Perlin.h:43
#define n_size_m1
Definition Perlin.h:42
#define n_dec_bits
Definition Perlin.h:54
#define np_size_m1
Definition Perlin.h:50
#define n_size
Definition Perlin.h:41
#define n_packsize
Definition Perlin.h:46
#define noise_frames
Definition Perlin.h:60
Struct wich contains Perlin noise module options.
Definition Perlin.h:79
Ogre::Vector3 GPU_LODParameters
LOD Parameters, in order to obtain a smooth normal map we need to decrease the detail level when the ...
Definition Perlin.h:103
float Animspeed
Animspeed.
Definition Perlin.h:87
float GPU_Strength
GPU Normal map generator parameters Only if GPU normal map generation is active.
Definition Perlin.h:95
float Timemulti
Timemulti.
Definition Perlin.h:89