- Home /
Syncing up procedurally generated textures... where am I wrong?
So I am building a gradually decreasing slope using sine waves and a vertical offset. That's all well and good, but I am having a hell of a time getting the textures to match up when they are rendered in the real world. I am explaining this poorly so I have included a picture and some code.
terrain.transform.localPosition = spawnLocation;
terrain.transform.localScale = scale;
spawnLocation.x += sprite.bounds.extents.x * 2 * scale.x;
spawnLocation.y -= sprite.bounds.extents.y * (1 - lastHeight / textureSize.y) * scale.y;
A little info: spawnLocation is a vector owned by the object that spawns terrain and scale is the same but lets me fiddle with the size of the terrain in the inspector (it's currently set to Vector2.one). Finally, lastHeight is the last height calculated by my terrain generator in pixels and textureSize.y is the total texture height in pixels.
I'd love any insights, this problem is driving me insane.
Your answer
Follow this Question
Related Questions
Texture3D stays black no matter what? 1 Answer
Textures are Missing 1 Answer
What is the best way to create a simple colored plane object in NGUI? 1 Answer
Removing mipmap levels? 0 Answers
Texturing a cube.. noob? 1 Answer