1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "nel/3d/noise_3d.h"
19 #include "nel/3d/driver.h"
21 using namespace NLMISC
;
30 // ------------------------------------------------------------------------------------------------
31 CNoise3d::CNoise3d (IDriver
*pDriver
)
38 _IsDriverSupportCloudSinglePass
= pDriver
->supportCloudRenderSinglePass();
41 // ------------------------------------------------------------------------------------------------
42 CNoise3d::~CNoise3d ()
44 // delete _Mem; // done by CTertureMem destructor
49 // ------------------------------------------------------------------------------------------------
50 void CNoise3d::init (uint32 w
, uint32 h
, uint32 d
)
57 w
= raiseToNextPowerOf2 (w
);
58 h
= raiseToNextPowerOf2 (h
);
59 d
= raiseToNextPowerOf2 (d
);
69 uint32 vdpo2
= getPowerOf2(_Depth
);
71 _NbSliceW
= 1 << (vdpo2
/ 2);
73 _NbSliceH
= 2 << (vdpo2
/ 2);
75 _NbSliceH
= 1 << (vdpo2
/ 2);
77 _ScaleW
= 1.0f
/ _NbSliceW
;
78 _ScaleH
= 1.0f
/ _NbSliceH
;
80 _Mem
= new uint8
[w
*h
*d
];
82 // Create initial noise
83 for (i
= 0; i
< (w
*h
*d
); i
++)
84 _Mem
[i
] = (uint8
)(256.0f
*rand()/RAND_MAX
);
86 _OffS
= new CUV
[_Depth
];
87 for (i
= 0; i
< _Depth
; i
++)
89 _OffS
[i
].U
= ((float)rand())/RAND_MAX
;
90 _OffS
[i
].V
= ((float)rand())/RAND_MAX
;
93 _Tex
= new CTextureMem (_Mem
, _Width
*_NbSliceW
*_Height
*_NbSliceH
, true, false, _Width
*_NbSliceW
, _Height
*_NbSliceH
,
95 _Tex
->setWrapS(ITexture::Repeat
);
96 _Tex
->setWrapT(ITexture::Repeat
);
97 _Tex
->setFilterMode(ITexture::Linear
, ITexture::LinearMipMapOff
);
101 if (_IsDriverSupportCloudSinglePass
)
103 _Mat
= new CMaterial();
105 _Mat
->setShader (CMaterial::Cloud
);
106 _Mat
->setTexture (0, _Tex
);
107 _Mat
->setTexture (1, _Tex
);
108 _Mat
->setColor (CRGBA(255,255,255,255));
109 _Mat
->setBlend (true);
110 _Mat
->setBlendFunc(CMaterial::one
, CMaterial::one
);
111 _Mat
->setZFunc (CMaterial::always
);
112 _Mat
->setZWrite (false);
113 _VertexBuffer
.setVertexFormat (CVertexBuffer::PositionFlag
| CVertexBuffer::PrimaryColorFlag
|
114 CVertexBuffer::TexCoord0Flag
| CVertexBuffer::TexCoord1Flag
);
118 _Mat
= new CMaterial();
120 _Mat
->setShader (CMaterial::Normal
);
121 _Mat
->setTexture (0, _Tex
);
122 _Mat
->setColor (CRGBA(255,255,255,255));
123 _Mat
->setBlend (true);
124 _Mat
->setBlendFunc(CMaterial::one
, CMaterial::one
);
125 _Mat
->setZFunc (CMaterial::always
);
126 _Mat
->setZWrite (false);
127 _VertexBuffer
.setVertexFormat (CVertexBuffer::PositionFlag
| CVertexBuffer::PrimaryColorFlag
|
128 CVertexBuffer::TexCoord0Flag
);
132 // ------------------------------------------------------------------------------------------------
133 void CNoise3d::render2passes (CQuadUV
&qc
, float wpos
, float alpha
)
135 // For the moment we do it in 2 passes : because wpos is a position between slice we have to do :
136 // [ At0*wpos+At1*(1-wpos) ] * alpha
137 // this is done like that :
138 // At0*[wpos*alpha] + At1*[(1-wpos)*alpha]
140 wpos
= fmodf (wpos
, 1.0f
);
141 uint32 nSlice1
= (uint32
)(wpos
* _Depth
), nSlice2
;
142 if (nSlice1
== (_Depth
-1))
145 nSlice2
= 1 + nSlice1
;
146 // If wpos is just on slice1 alpha must be one
147 float alphaPos
= 1.0f
- _Depth
*(wpos
- (((float)nSlice1
) / _Depth
));
149 if (_NbVertices
== _VertexBuffer
.getNumVertices())
151 _VertexBuffer
.setNumVertices(_NbVertices
+8);
154 CVertexBufferReadWrite vba
;
155 _VertexBuffer
.lock (vba
);
157 uint32 nVSize
= _VertexBuffer
.getVertexSize ();
158 CVector
*pVertices
= vba
.getVertexCoordPointer(_NbVertices
);
159 *pVertices
= qc
.V0
; pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
160 *pVertices
= qc
.V1
; pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
161 *pVertices
= qc
.V2
; pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
162 *pVertices
= qc
.V3
; pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
163 *pVertices
= qc
.V0
; pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
164 *pVertices
= qc
.V1
; pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
165 *pVertices
= qc
.V2
; pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
168 CUV
*pUV
= vba
.getTexCoordPointer (_NbVertices
, 0);
169 *pUV
= CUV(qc
.Uv0
.U
*_ScaleW
+_OffS
[nSlice1
].U
, qc
.Uv0
.V
*_ScaleH
+_OffS
[nSlice1
].V
);
170 pUV
= (CUV
*)( ((uint8
*)pUV
) + nVSize
);
171 *pUV
= CUV(qc
.Uv1
.U
*_ScaleW
+_OffS
[nSlice1
].U
, qc
.Uv1
.V
*_ScaleH
+_OffS
[nSlice1
].V
);
172 pUV
= (CUV
*)( ((uint8
*)pUV
) + nVSize
);
173 *pUV
= CUV(qc
.Uv2
.U
*_ScaleW
+_OffS
[nSlice1
].U
, qc
.Uv2
.V
*_ScaleH
+_OffS
[nSlice1
].V
);
174 pUV
= (CUV
*)( ((uint8
*)pUV
) + nVSize
);
175 *pUV
= CUV(qc
.Uv3
.U
*_ScaleW
+_OffS
[nSlice1
].U
, qc
.Uv3
.V
*_ScaleH
+_OffS
[nSlice1
].V
);
176 pUV
= (CUV
*)( ((uint8
*)pUV
) + nVSize
);
178 *pUV
= CUV(qc
.Uv0
.U
*_ScaleW
+_OffS
[nSlice2
].U
, qc
.Uv0
.V
*_ScaleH
+_OffS
[nSlice2
].V
);
179 pUV
= (CUV
*)( ((uint8
*)pUV
) + nVSize
);
180 *pUV
= CUV(qc
.Uv1
.U
*_ScaleW
+_OffS
[nSlice2
].U
, qc
.Uv1
.V
*_ScaleH
+_OffS
[nSlice2
].V
);
181 pUV
= (CUV
*)( ((uint8
*)pUV
) + nVSize
);
182 *pUV
= CUV(qc
.Uv2
.U
*_ScaleW
+_OffS
[nSlice2
].U
, qc
.Uv2
.V
*_ScaleH
+_OffS
[nSlice2
].V
);
183 pUV
= (CUV
*)( ((uint8
*)pUV
) + nVSize
);
184 *pUV
= CUV(qc
.Uv3
.U
*_ScaleW
+_OffS
[nSlice2
].U
, qc
.Uv3
.V
*_ScaleH
+_OffS
[nSlice2
].V
);
186 uint8 finalAlpha
= (uint8
)(255*alphaPos
*alpha
);
188 // todo hulud d3d vertex color RGBA / BGRA
189 uint8
*pColA
= (uint8
*)vba
.getColorPointer(_NbVertices
) + 3;
190 *pColA
= finalAlpha
; pColA
= ((uint8
*)pColA
) + nVSize
;
191 *pColA
= finalAlpha
; pColA
= ((uint8
*)pColA
) + nVSize
;
192 *pColA
= finalAlpha
; pColA
= ((uint8
*)pColA
) + nVSize
;
193 *pColA
= finalAlpha
; pColA
= ((uint8
*)pColA
) + nVSize
;
195 finalAlpha
= (uint8
)(255*(1.0f
-alphaPos
)*alpha
);
197 *pColA
= finalAlpha
; pColA
= ((uint8
*)pColA
) + nVSize
;
198 *pColA
= finalAlpha
; pColA
= ((uint8
*)pColA
) + nVSize
;
199 *pColA
= finalAlpha
; pColA
= ((uint8
*)pColA
) + nVSize
;
205 // ------------------------------------------------------------------------------------------------
206 void CNoise3d::render (CQuadUV
&qc
, float wpos
, float intensity
)
208 // [ At0*wpos+At1*(1-wpos) ] * alpha
210 if (!_IsDriverSupportCloudSinglePass
)
212 render2passes (qc
, wpos
, intensity
);
216 _Intensity
= intensity
;
218 wpos
= wpos
- floorf (wpos
);
219 uint32 nSlice1
= (uint32
)(wpos
* _Depth
), nSlice2
;
220 if (nSlice1
== (_Depth
-1))
223 nSlice2
= 1 + nSlice1
;
224 // If wpos is just on slice1 alpha must be one
225 float alphaPos
= 1.0f
- _Depth
*(wpos
- (((float)nSlice1
) / _Depth
));
227 uint8 nAlphaPos
= (uint8
)(255*alphaPos
);
229 uint32 nVSize
= _VertexBuffer
.getVertexSize ();
231 if (_NbVertices
== _VertexBuffer
.getNumVertices())
233 _VertexBuffer
.setNumVertices (_NbVertices
+4);
236 CVertexBufferReadWrite vba
;
237 _VertexBuffer
.lock (vba
);
239 CVector
*pVertices
= vba
.getVertexCoordPointer(_NbVertices
);
240 *pVertices
= qc
.V0
; pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
241 *pVertices
= qc
.V1
; pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
242 *pVertices
= qc
.V2
; pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
245 CUV
*pUV
= vba
.getTexCoordPointer (_NbVertices
, 0);
246 *pUV
= CUV(qc
.Uv0
.U
/_NbSliceW
+_OffS
[nSlice1
].U
, qc
.Uv0
.V
*_ScaleH
+_OffS
[nSlice1
].V
);
247 pUV
= (CUV
*)( ((uint8
*)pUV
) + nVSize
);
248 *pUV
= CUV(qc
.Uv1
.U
/_NbSliceW
+_OffS
[nSlice1
].U
, qc
.Uv1
.V
*_ScaleH
+_OffS
[nSlice1
].V
);
249 pUV
= (CUV
*)( ((uint8
*)pUV
) + nVSize
);
250 *pUV
= CUV(qc
.Uv2
.U
/_NbSliceW
+_OffS
[nSlice1
].U
, qc
.Uv2
.V
*_ScaleH
+_OffS
[nSlice1
].V
);
251 pUV
= (CUV
*)( ((uint8
*)pUV
) + nVSize
);
252 *pUV
= CUV(qc
.Uv3
.U
/_NbSliceW
+_OffS
[nSlice1
].U
, qc
.Uv3
.V
*_ScaleH
+_OffS
[nSlice1
].V
);
254 pUV
= vba
.getTexCoordPointer (_NbVertices
, 1);
255 *pUV
= CUV(qc
.Uv0
.U
*_ScaleW
+_OffS
[nSlice2
].U
, qc
.Uv0
.V
*_ScaleH
+_OffS
[nSlice2
].V
);
256 pUV
= (CUV
*)( ((uint8
*)pUV
) + nVSize
);
257 *pUV
= CUV(qc
.Uv1
.U
*_ScaleW
+_OffS
[nSlice2
].U
, qc
.Uv1
.V
*_ScaleH
+_OffS
[nSlice2
].V
);
258 pUV
= (CUV
*)( ((uint8
*)pUV
) + nVSize
);
259 *pUV
= CUV(qc
.Uv2
.U
*_ScaleW
+_OffS
[nSlice2
].U
, qc
.Uv2
.V
*_ScaleH
+_OffS
[nSlice2
].V
);
260 pUV
= (CUV
*)( ((uint8
*)pUV
) + nVSize
);
261 *pUV
= CUV(qc
.Uv3
.U
*_ScaleW
+_OffS
[nSlice2
].U
, qc
.Uv3
.V
*_ScaleH
+_OffS
[nSlice2
].V
);
263 // todo hulud d3d vertex color RGBA / BGRA
264 uint8
*pColA
= (uint8
*)vba
.getColorPointer(_NbVertices
) + 3;
265 *pColA
= nAlphaPos
; pColA
= ((uint8
*)pColA
) + nVSize
;
266 *pColA
= nAlphaPos
; pColA
= ((uint8
*)pColA
) + nVSize
;
267 *pColA
= nAlphaPos
; pColA
= ((uint8
*)pColA
) + nVSize
;
273 // ------------------------------------------------------------------------------------------------
274 void CNoise3d::renderGrid (uint32 nbw
, uint32 nbh
, uint32 w
, uint32 h
,
275 float UStart
, float VStart
, float WStart
, float dU
, float dV
, float dW
, float intensity
)
278 if (!_IsDriverSupportCloudSinglePass
)
280 renderGrid2passes (nbw
, nbh
, w
, h
, UStart
, VStart
, WStart
, dU
, dV
, dW
, intensity
);
284 _Intensity
= intensity
;
286 uint32 i
, j
, nSlice1
, nSlice2
;
287 float wpos
, oneOverNbWNbH
= 1.0f
/ (nbw
*nbh
);
290 uint8
*pColA
, nAlphaPos
;
291 uint32 nVSize
= _VertexBuffer
.getVertexSize ();
293 if (_VertexBuffer
.getNumVertices() < nbw
*nbh
*4)
295 _VertexBuffer
.setNumVertices (nbw
*nbh
*4);
298 dU
= (UStart
+dU
) /_NbSliceW
;
299 dV
= (VStart
+dV
) /_NbSliceH
;
300 UStart
= UStart
/ _NbSliceW
;
301 VStart
= VStart
/ _NbSliceH
;
303 CVertexBufferReadWrite vba
;
304 _VertexBuffer
.lock (vba
);
306 pVertices
= vba
.getVertexCoordPointer(0);
307 pUV0
= vba
.getTexCoordPointer (0, 0);
308 pUV1
= vba
.getTexCoordPointer (0, 1);
309 // todo hulud d3d vertex color RGBA / BGRA
310 pColA
= (uint8
*)vba
.getColorPointer(0) + 3;
312 for (j
= 0; j
< nbh
; ++j
)
314 for (i
= 0; i
< nbw
; ++i
)
316 wpos
= (float)WStart
+dW
*(i
+(float)j
*nbw
)*oneOverNbWNbH
;
317 wpos
= wpos
- floorf (wpos
);
318 nSlice1
= (uint32
)(wpos
* _Depth
);
319 if (nSlice1
== (_Depth
-1))
322 nSlice2
= 1 + nSlice1
;
323 // If wpos is just on slice1 alpha must be one
324 nAlphaPos
= (uint8
)( 255*(1.0f
- _Depth
*(wpos
- (((float)nSlice1
) / _Depth
))) );
326 *pVertices
= CVector((float)i
*w
, (float)j
*h
, 0.0f
); pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
327 *pVertices
= CVector((float)(i
+1)*w
, (float)j
*h
, 0.0f
); pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
328 *pVertices
= CVector((float)(i
+1)*w
, (float)(j
+1)*h
, 0.0f
); pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
329 *pVertices
= CVector((float)i
*w
, (float)(j
+1)*h
, 0.0f
); pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
331 pUV0
->U
= UStart
+_OffS
[nSlice1
].U
; pUV0
->V
= VStart
+_OffS
[nSlice1
].V
; pUV0
= (CUV
*)( ((uint8
*)pUV0
) + nVSize
);
332 pUV0
->U
= dU
+_OffS
[nSlice1
].U
; pUV0
->V
= VStart
+_OffS
[nSlice1
].V
; pUV0
= (CUV
*)( ((uint8
*)pUV0
) + nVSize
);
333 pUV0
->U
= dU
+_OffS
[nSlice1
].U
; pUV0
->V
= dV
+_OffS
[nSlice1
].V
; pUV0
= (CUV
*)( ((uint8
*)pUV0
) + nVSize
);
334 pUV0
->U
= UStart
+_OffS
[nSlice1
].U
; pUV0
->V
= dV
+_OffS
[nSlice1
].V
; pUV0
= (CUV
*)( ((uint8
*)pUV0
) + nVSize
);
336 pUV1
->U
= UStart
+_OffS
[nSlice2
].U
; pUV1
->V
= VStart
+_OffS
[nSlice2
].V
; pUV1
= (CUV
*)( ((uint8
*)pUV1
) + nVSize
);
337 pUV1
->U
= dU
+_OffS
[nSlice2
].U
; pUV1
->V
= VStart
+_OffS
[nSlice2
].V
; pUV1
= (CUV
*)( ((uint8
*)pUV1
) + nVSize
);
338 pUV1
->U
= dU
+_OffS
[nSlice2
].U
; pUV1
->V
= dV
+_OffS
[nSlice2
].V
; pUV1
= (CUV
*)( ((uint8
*)pUV1
) + nVSize
);
339 pUV1
->U
= UStart
+_OffS
[nSlice2
].U
; pUV1
->V
= dV
+_OffS
[nSlice2
].V
; pUV1
= (CUV
*)( ((uint8
*)pUV1
) + nVSize
);
341 *pColA
= nAlphaPos
; pColA
= ((uint8
*)pColA
) + nVSize
;
342 *pColA
= nAlphaPos
; pColA
= ((uint8
*)pColA
) + nVSize
;
343 *pColA
= nAlphaPos
; pColA
= ((uint8
*)pColA
) + nVSize
;
344 *pColA
= nAlphaPos
; pColA
= ((uint8
*)pColA
) + nVSize
;
348 _NbVertices
= nbw
*nbh
*4;
351 // ------------------------------------------------------------------------------------------------
352 void CNoise3d::renderGrid2passes (uint32 nbw
, uint32 nbh
, uint32 w
, uint32 h
,
353 float UStart
, float VStart
, float WStart
, float dU
, float dV
, float dW
, float intensity
)
355 uint32 i
, j
, nSlice1
, nSlice2
;
356 float wpos
, oneOverNbWNbH
= 1.0f
/ (nbw
*nbh
);
359 uint8
*pColA
, nFinalAlpha
;
360 uint32 nVSize
= _VertexBuffer
.getVertexSize ();
362 if (_VertexBuffer
.getNumVertices() < 2*nbw
*nbh
*4)
364 _VertexBuffer
.setNumVertices (2*nbw
*nbh
*4);
367 dU
= (UStart
+dU
) /_NbSliceW
;
368 dV
= (VStart
+dV
) /_NbSliceH
;
369 UStart
= UStart
/ _NbSliceW
;
370 VStart
= VStart
/ _NbSliceH
;
372 CVertexBufferReadWrite vba
;
373 _VertexBuffer
.lock (vba
);
375 pVertices
= vba
.getVertexCoordPointer(0);
376 pUV0
= vba
.getTexCoordPointer (0, 0);
377 // todo hulud d3d vertex color RGBA / BGRA
378 pColA
= (uint8
*)vba
.getColorPointer(0) + 3;
380 for (j
= 0; j
< nbh
; ++j
)
382 for (i
= 0; i
< nbw
; ++i
)
384 wpos
= (float)WStart
+dW
*(i
+(float)j
*nbw
)*oneOverNbWNbH
;
385 wpos
= fmodf (wpos
, 1.0f
);
386 nSlice1
= (uint32
)(wpos
* _Depth
);
387 if (nSlice1
== (_Depth
-1))
390 nSlice2
= 1 + nSlice1
;
391 // If wpos is just on slice1 alpha must be one
392 float alphaPos
= 1.0f
- _Depth
*(wpos
- (((float)nSlice1
) / _Depth
));
394 *pVertices
= CVector((float)i
*w
, (float)j
*h
, 0.0f
); pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
395 *pVertices
= CVector((float)(i
+1)*w
, (float)j
*h
, 0.0f
); pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
396 *pVertices
= CVector((float)(i
+1)*w
, (float)(j
+1)*h
, 0.0f
); pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
397 *pVertices
= CVector((float)i
*w
, (float)(j
+1)*h
, 0.0f
); pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
398 *pVertices
= CVector((float)i
*w
, (float)j
*h
, 0.0f
); pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
399 *pVertices
= CVector((float)(i
+1)*w
, (float)j
*h
, 0.0f
); pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
400 *pVertices
= CVector((float)(i
+1)*w
, (float)(j
+1)*h
, 0.0f
); pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
401 *pVertices
= CVector((float)i
*w
, (float)(j
+1)*h
, 0.0f
); pVertices
= (CVector
*)( ((uint8
*)pVertices
) + nVSize
);
403 pUV0
->U
= UStart
+_OffS
[nSlice1
].U
; pUV0
->V
= VStart
+_OffS
[nSlice1
].V
; pUV0
= (CUV
*)( ((uint8
*)pUV0
) + nVSize
);
404 pUV0
->U
= dU
+_OffS
[nSlice1
].U
; pUV0
->V
= VStart
+_OffS
[nSlice1
].V
; pUV0
= (CUV
*)( ((uint8
*)pUV0
) + nVSize
);
405 pUV0
->U
= dU
+_OffS
[nSlice1
].U
; pUV0
->V
= dV
+_OffS
[nSlice1
].V
; pUV0
= (CUV
*)( ((uint8
*)pUV0
) + nVSize
);
406 pUV0
->U
= UStart
+_OffS
[nSlice1
].U
; pUV0
->V
= dV
+_OffS
[nSlice1
].V
; pUV0
= (CUV
*)( ((uint8
*)pUV0
) + nVSize
);
408 pUV0
->U
= UStart
+_OffS
[nSlice2
].U
; pUV0
->V
= VStart
+_OffS
[nSlice2
].V
; pUV0
= (CUV
*)( ((uint8
*)pUV0
) + nVSize
);
409 pUV0
->U
= dU
+_OffS
[nSlice2
].U
; pUV0
->V
= VStart
+_OffS
[nSlice2
].V
; pUV0
= (CUV
*)( ((uint8
*)pUV0
) + nVSize
);
410 pUV0
->U
= dU
+_OffS
[nSlice2
].U
; pUV0
->V
= dV
+_OffS
[nSlice2
].V
; pUV0
= (CUV
*)( ((uint8
*)pUV0
) + nVSize
);
411 pUV0
->U
= UStart
+_OffS
[nSlice2
].U
; pUV0
->V
= dV
+_OffS
[nSlice2
].V
; pUV0
= (CUV
*)( ((uint8
*)pUV0
) + nVSize
);
413 nFinalAlpha
= (uint8
)(255*alphaPos
*intensity
);
415 *pColA
= nFinalAlpha
; pColA
= ((uint8
*)pColA
) + nVSize
;
416 *pColA
= nFinalAlpha
; pColA
= ((uint8
*)pColA
) + nVSize
;
417 *pColA
= nFinalAlpha
; pColA
= ((uint8
*)pColA
) + nVSize
;
418 *pColA
= nFinalAlpha
; pColA
= ((uint8
*)pColA
) + nVSize
;
420 nFinalAlpha
= (uint8
)(255*(1.0f
-alphaPos
)*intensity
);
422 *pColA
= nFinalAlpha
; pColA
= ((uint8
*)pColA
) + nVSize
;
423 *pColA
= nFinalAlpha
; pColA
= ((uint8
*)pColA
) + nVSize
;
424 *pColA
= nFinalAlpha
; pColA
= ((uint8
*)pColA
) + nVSize
;
425 *pColA
= nFinalAlpha
; pColA
= ((uint8
*)pColA
) + nVSize
;
428 _NbVertices
= 2*4*nbw
*nbh
;
431 // ------------------------------------------------------------------------------------------------
432 void CNoise3d::flush ()
434 if (!_IsDriverSupportCloudSinglePass
)
440 _Mat
->setColor(CRGBA(0,0,0,(uint8
)(255*_Intensity
)));
441 _Driver
->activeVertexBuffer (_VertexBuffer
);
442 _Driver
->renderRawQuads (*_Mat
, 0, _NbVertices
/4);
446 // ------------------------------------------------------------------------------------------------
447 void CNoise3d::flush2passes ()
449 _Driver
->activeVertexBuffer (_VertexBuffer
);
450 _Driver
->renderRawQuads (*_Mat
, 0, _NbVertices
/4);
455 // ------------------------------------------------------------------------------------------------
456 uint32
CNoise3d::getWidth ()
461 // ------------------------------------------------------------------------------------------------
462 uint32
CNoise3d::getHeight ()
467 // ------------------------------------------------------------------------------------------------
468 uint32
CNoise3d::getDepth ()