Fractal surface
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/06/2010 at 17:56, xxxxxxxx wrote:
can someone provide me an example of layering noise functions. many resources mention that it is important to layer noise functions. I am not entirely sure what is exactly meant by that. Could someone elaborate?
Thanks,
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/06/2010 at 21:42, xxxxxxxx wrote:
there are many ways how you can mix some noises. for example:
Vector someNoise = 0; someNoise.x = RidgedMultifractal(arr, 1 + points[i]*factor.x, 20, 0, 1)*strength.x; someNoise.y = RidgedMultifractal(arr, 2 + points[i]*factor.y, 20, 0, 1)*strength.y; someNoise.z = RidgedMultifractal(arr, 3 + points[i]*factor.z, 20, 0, 1)*strength.z; Vector anotherNoise = 0; anotherNoise.x = Turbulence(points[i]*anotherFactor.x,20, false) * anotherStrength.x; anotherNoise.y = Turbulence(points[i]*anotherFactor.y,20, false) * anotherStrength.y; anotherNoise.z = Turbulence(points[i]*anotherFactor.z,20, false) * anotherStrength.z; Vector myNoise = Mix (someNoise,anotherNoise,mix);
where mix is a user value or jet another noise...
or you could multiply
Vector myNoise = someNoise * anotherNoise;or add
Vector myNoise = someNoise + anotherNoise;or just try anything out.. there are just too many things you can do
hope it helps..
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/06/2010 at 15:51, xxxxxxxx wrote:
Okay that's easy enough.,. thanks a lot. ello!
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/06/2010 at 04:16, xxxxxxxx wrote:
Originally posted by xxxxxxxx
..btw, i could think that it would be a good idea to take the normal direction into account. i'd share my normal calculation code with you, but its only for faces and point normals are not really working.
As an aside, here is some Normal info...
For faces, you can simply do:
Vector *padr = ToPoly(op)->GetPointW(); CPolygon *polys = ToPoly(op)->GetPolygonW(); Vector vNorm = CalcFaceNormal(padr, polys[poly_of_interest]);
For Point Normals, I created a helper structure, similar to how the UVWStruct is used...
struct NormalStruct { NormalStruct(_DONTCONSTRUCT dc) : a(DC), b(DC), c(DC), d(DC) { } NormalStruct(void) {} NormalStruct(const Vector &t;_a, const Vector &t;_b, const Vector &t;_c, const Vector &t;_d) { a=t_a; b=t_b; c=t_c; d=t_d; } NormalStruct(const Vector &t;_a, const Vector &t;_b, const Vector &t;_c) { a=t_a; b=t_b; c=t_c; } Vector a,b,c,d; };
...for Point Normals, you want "a normal for every vertex/point of every polygon" (ie. not just one per point) - this allows for Phong Edge-Breaks in the shading. So, assuming that the mesh _has_ a Phong Tag, you can just do:
NormalStruct *pNorms = (NormalStruct * )ToPoly(op)->CreatePhongNormals();
...the CreatePhongNormals() routine will return a pointer to an array of Point Normals - **4** normals for every polygon in the mesh (just like the UVW Tag returns 4 uv coordinates per polygon). This is the same as the NormalStruct I list above, so you can use that structure to access the (a,b,c,d) normals.
If the mesh doesn't have a Phong Tag (ie. CreatePhongNormals() returns a Null), you can either skip it, or generate normals based on averaging the face normals (I'd suggest writing your own routine that does this, allocating, filling in and returning the same NormalStruct pointer/array).
Be sure to GeFree(pNorms) when done.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/06/2010 at 04:36, xxxxxxxx wrote:
thanks giblet for your input.. at the moment i am averaging the neighbouring polygon normals and it works like this on a standard sphere for example:
this is how i calculate it:
neighbor.GetPointPolys(i, &dadr, &dcnt); polyNormal=0; for (int j=0;j<dcnt;j++) { if (dadr[j]<maxcount) { polyNormal += polygonNormal(nCalc1,nCalc2,padr,pol,dadr[j]); } } polyNormal /= dcnt;
where polygonNormal(...) is returning the correct mormal for each polygon as it is working in my plugin.
it seems to me that there is an invisible cut going thru the mesh which results in wrong or no neighbour
any ideas?
cheers,
ellobtw: sorry for the hijacking here...
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/06/2010 at 05:01, xxxxxxxx wrote:
Hmmm.. not sure. Are you calling neighbor.Init() before trying to use it?
Here's some code I've been using (several class member variables are set up elsewhere, but it should be self-explanitory)...
Bool MeshMap::GetSrcVertexNormals(void) { LONG i, j, faceCnt, *pFaces = NULL; Vector vNorm, *pNorm; // initialize neighbor class... this is used to compute m_SrcvNorms if( !m_Neighbor.Init(m_numSrcVerts, m_SrcPolys, m_numSrcPolys, NULL) ) return false; StatusSetText("Computing Vertex Normals..."); pNorm = &m;_pSrcvNorms[0]; for(i=0; i<m_numSrcVerts; i++) { vNorm = Vector(); // (re)intitialize m_Neighbor.GetPointPolys(i, &pFaces;, &faceCnt;); if( faceCnt ) { for(j=0; j<faceCnt; j++) { Vector n = CalcFaceNormal(m_pxfSrcVerts, m_SrcPolys[pFaces[j]]); vNorm += !n; } vNorm /= faceCnt; // average the normal(s) *pNorm = !vNorm; // normalize and store } else *pNorm = Vector(0.0,1.0,0.0); pNorm++; } return true; }
EDIT: Note... this code only generates a normal-per-vertex, which is contrary to my suggestion in my previous reply (this particular implementation didn't need to concern itself with phong-edge-breaks).
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/06/2010 at 05:59, xxxxxxxx wrote:
thank you very much. i'll see if i can fix it with this input. i remember i didnt normalize it so maybe that coul cause it...
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/06/2010 at 18:25, xxxxxxxx wrote:
Hi Giblet,
Thank you for offering your struct for us to see. After I add your struct to my code and then use
NormalStruct \*pNorms = (NormalStruct \* )ToPoly(op)->CreatePhongNormals()
how do I use the NormalStruct pNorms?
could you give me an example of how I would then move a point along the normal that I found?
Thanks,
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/06/2010 at 22:51, xxxxxxxx wrote:
Hi Shawn,
The pNorms pointer will point to 'an array' of NormalStruct(s) - one for each polygon of the mesh.
A 'Normal' (call it vNorm) is a 'Unit Vector' (a vector who's length == 1.0) and the x/y/z values define a 'direction'.
So, given the above, if you multiply a float (Real rDist) distance value times a Normal (who's length is 1.0), you get a new Vector/Vertex that is rDist distance in vNorm direction.
I often use the following macro:
#define ray_project(vStart, vDir, rDist) ((vStart) + ((vDir) * (rDist))) //given the start point of a line, the direction and a distance, return end point
...where:
vStart - is any Vector/Point/Vertex that defines the start position
vDir - is any Normal Vector
vDist - is the floating point (Real) distance value that I want to travel/project....so example code might look something like so:
Vector *pPoints = op->GetPointW(); CPolygon *pPolys = op->GetPolygonW(); ... LONG pNdx = 0; // poly index CPolygon *pPoly = &pPolys;[pNdx]; ... Vector vStart = pPoints[pPoly->a]; Vector vDir = pNorms[pNdx].a; Real rDist = 5.0; ... Vector vEnd = ray_project(vStart, vDir, rDist);
...so, vEnd would be a Point that is 5.0 distance from the first Point in the first Polygon of the mesh, along (in the direction of) the Normal of that Point.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/06/2010 at 23:04, xxxxxxxx wrote:
...or something like that :).
Basically, anywhere you get a poly reference, you can also get the NormalStruct the same way - the difference between a CPolygon and a NormalStruct is that the elements (a,b,c,d) of the CPolygon are 'indices' into the points array and the elements of the NormalStruct are the actual Normal Vectors themselves, so:
NormalStruct *pNorms = (NormalStruct * )ToPoly(op)->CreatePhongNormals(); NormalStruct ns = pNorms[x]; // x == whatever polygon you are interested in Vector vNormA = ns.a; // Normal for Point a of Polygon Vector vNormB = ns.b; // Normal for Point b of Polygon Vector vNormC = ns.c; // Normal for Point c of Polygon Vector vNormD = ns.d; // Normal for Point d of Polygon
Cheers.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/06/2010 at 03:40, xxxxxxxx wrote:
BTW, I also remembered this topic (Normals / NormalStruct) comming up before, so I went back and found this thread, that has a lot of the same info in it (including a routine I used to generate a NormalStruct array if CreatePhongNormals() fails).
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/06/2010 at 05:04, xxxxxxxx wrote:
Awesome thanks a lot for you help Giblet! That helped a lot!
~Shawn