So I am generating a Terrain Heightmap with a rtt.
The idea is besides the zones texture size of 1024x1024, I am trying to have it generate a gutter around the applicable area so when I go to calculate normals I can sample a point that is off the zone.
Now I am kinda lost on where to go from here,
When sampling the texture I am doing it be detail units so pseudo code:
var overflowUnit = textureSize/meshSubDivs;
textureSize.xy += overflowUnit*2;
then when I iterate over it:
var pID=0;
for(var y=1; y<detail.y+2; y++){
for(var x=1; x<detail.x+2; x++, pID+=3){
xUV = x/(detail.x+2);
yUV = y/(detail.y+2);
xp = (Math.floor(size.x*xUV)-this.args.overflow.x)+1;
yp = (Math.floor(size.y*yUV)-this.args.overflow.y)+1;
id = (xp*4)+(yp*size.x*4);
var v = (this.getMapDataAtID(map, id)).r;
v = this.transposeRange(v/255, this.args.heights.x, this.args.heights.y);
vDat.positions[pID+1] = v;
}
}
Now, how would I use this loop to manually define the normals? Pretty sure all the data is there.
http://www.babylonjs-playground.com/#N123V9#23
*edit*
http://www.babylonjs-playground.com/#N123V9#25
seems my numbers are off by a bit.