RandomProceduralCubeScriptOk.. so i've seen post on here and I had to fix it... if you're going to want more things on you're style try modifying the altitude... I even tryed using 3.142 pi* and it gave a really trippy height effect.....
But I got what I want it seems about right ..... mmm I would like it to flatten at the top alittle more but thats ok ......... also if you want lower ground just look at where the green and the brown < are and change those to larger values... also think randomizer for colors to create something pretty unique
Here's the image - Deviant Art
http://fav.me/dairubyHere's the script...
Ps. This script opens public properties attached to the terrain volume .... I will make it data importable .... inless it's already done

... I'm sure You guys are going to be adding ao and lighting ....
If not good adventure just not sure how i'm going to due a few things.... like water ...... ?
I would have to get into the sdk....
But right now i'm heading towards the brushes.... that will be complicated 0.0....
Not sure what i'm going to use to sweep threw with... *randomize brushes*
Blah blah , but here you go m8's I kinda dread leaving this like this ... though .... you do need to look into what is there... I still have the slightest clue there is alot of goodies though.....
Code:
using UnityEngine;
using System.Collections;
using Cubiquity;
public class ProceduralColoredCubes : MonoBehaviour {
public int width = 128;
public int height = 32;
public int depth = 128;
// Use this for initialization
void Start () {
// FIXME - Where should we delete this?
/// [DoxygenSnippet-CreateEmptyTerrainVolumeData]
//Create an empty TerrainVolumeData with dimensions width * height * depth
ColoredCubesVolumeData data = VolumeData.CreateEmptyVolumeData<ColoredCubesVolumeData>(new Region(0, 0, 0, width-1, height-1, depth-1));
/// [DoxygenSnippet-CreateEmptyTerrainVolumeData]
ColoredCubesVolume volume = GetComponent<ColoredCubesVolume>();
ColoredCubesVolumeRenderer volumeRenderer = GetComponent<ColoredCubesVolumeRenderer>();
volume.data = data;
// Defines colors for each cubic square.
QuantizedColor green = new QuantizedColor(18, 115, 38, 255);
QuantizedColor brown = new QuantizedColor(115, 87, 18, 255);
QuantizedColor gray = new QuantizedColor(127, 127, 127, 255);
QuantizedColor white = new QuantizedColor(255, 255, 255, 255);
float rockScale = 0.01F;
// Iterate over every voxel of our volume
for (int z = 0; z < depth; z++)
{
for (int y = height - 1; y > 0; y--)
{
for (int x = 0; x < width; x++)
{
float sampleX = (float)x * rockScale;
float sampleY = (float)y * rockScale;
float sampleZ = (float)z * rockScale;
float simplexNoiseValue = SimplexNoise.Noise.Generate(sampleX, sampleY, sampleZ);
float altitude = (float)(y + 0.5f) / (float)height;
// Map the altitude to the range -1.0 to +1.0..
altitude = (altitude * simplexNoiseValue) - 0.002F;
simplexNoiseValue -= altitude;
//simplexNoiseValue *= 0.5f;
simplexNoiseValue = Mathf.Clamp(simplexNoiseValue, -0.005f, 0.05f);
simplexNoiseValue *= 15;
int simplexCubicValue = Mathf.RoundToInt (simplexNoiseValue);
if(y < 12)
{
// Add to bedrock material channel.
data.SetVoxel(x , y , z , green);
}
if(y < 10)
{
// Add to bedrock material channel.
data.SetVoxel(x , y , z , brown);
}
data.SetVoxel(x* simplexCubicValue , y * simplexCubicValue , z* simplexCubicValue , gray);
}
}
}//End the loop of voxeling
}
}
I'm going to be frank it's just complicated....
The simplex formula has different return functions...
either by xyz
or individual ....
Since SetVoxel is only got args x,y,z and not float....
I'm just confused.
Is there a way you could cook up a quick script?
If I find a method i will edit... but i've been scratching at this one..... since I need a rounded float .....
it's alittle more complicated.... using set voxel with quant color.... not levels of the "biome"
I know its no easy process i've done it before but I used a whole different approach .....
Btw I appreciate any feedback I know using unity's built in tripoligy was complicated enough...
But now i cannot use it again after figureing out how much quicker this renders.
EDIT :
woooh kay atleast I got them moving but nope.... it looks like a cube dance party going on ...
Image of what happened deviant art
http://fav.me/dair93jHere's the code
Code:
using UnityEngine;
using System.Collections;
using Cubiquity;
public class ProceduralColoredCubes : MonoBehaviour {
public int width = 128;
public int height = 32;
public int depth = 128;
// Use this for initialization
void Start () {
// FIXME - Where should we delete this?
/// [DoxygenSnippet-CreateEmptyTerrainVolumeData]
//Create an empty TerrainVolumeData with dimensions width * height * depth
ColoredCubesVolumeData data = VolumeData.CreateEmptyVolumeData<ColoredCubesVolumeData>(new Region(0, 0, 0, width-1, height-1, depth-1));
/// [DoxygenSnippet-CreateEmptyTerrainVolumeData]
ColoredCubesVolume volume = GetComponent<ColoredCubesVolume>();
ColoredCubesVolumeRenderer volumeRenderer = GetComponent<ColoredCubesVolumeRenderer>();
volume.data = data;
// Defines colors for each cubic square.
QuantizedColor green = new QuantizedColor(18, 115, 38, 255);
QuantizedColor brown = new QuantizedColor(115, 87, 18, 255);
QuantizedColor gray = new QuantizedColor(127, 127, 127, 255);
QuantizedColor white = new QuantizedColor(255, 255, 255, 255);
float rockScale = 0.5F;
// Iterate over every voxel of our volume
for (int z = 0; z < depth; z++)
{
for (int y = height - 1; y > 0; y--)
{
for (int x = 0; x < width; x++)
{
float sampleX = (float)x * rockScale;
float sampleY = (float)y * rockScale;
float sampleZ = (float)z * rockScale;
float simplexNoiseValue = SimplexNoise.Noise.Generate(sampleX, sampleY, sampleZ);
float altitude = (float)(y + 1) / (float)height;
// Map the altitude to the range -1.0 to +1.0...
altitude = (altitude * 0.5f) - 0.5f;
simplexNoiseValue -= altitude;
simplexNoiseValue *= 255;
int simplexCubicValue = Mathf.RoundToInt (simplexNoiseValue);
data.SetVoxel(x + simplexCubicValue, y+ simplexCubicValue, z+ simplexCubicValue, green);
}
}
}//End the loop of voxeling
}
}
EDIT :
So the wierd thing is It starts to not fly around but instead it seems to implode a random noise
The box gets created but inside of the box you can see the simplex and it kinda works.
Code:
using UnityEngine;
using System.Collections;
using Cubiquity;
public class ProceduralColoredCubes : MonoBehaviour {
public int width = 128;
public int height = 32;
public int depth = 128;
// Use this for initialization
void Start () {
// FIXME - Where should we delete this?
/// [DoxygenSnippet-CreateEmptyTerrainVolumeData]
//Create an empty TerrainVolumeData with dimensions width * height * depth
ColoredCubesVolumeData data = VolumeData.CreateEmptyVolumeData<ColoredCubesVolumeData>(new Region(0, 0, 0, width-1, height-1, depth-1));
/// [DoxygenSnippet-CreateEmptyTerrainVolumeData]
ColoredCubesVolume volume = GetComponent<ColoredCubesVolume>();
ColoredCubesVolumeRenderer volumeRenderer = GetComponent<ColoredCubesVolumeRenderer>();
volume.data = data;
// Defines colors for each cubic square.
QuantizedColor green = new QuantizedColor(18, 115, 38, 255);
QuantizedColor brown = new QuantizedColor(115, 87, 18, 255);
QuantizedColor gray = new QuantizedColor(127, 127, 127, 255);
QuantizedColor white = new QuantizedColor(255, 255, 255, 255);
float rockScale = 0.005F;
// Iterate over every voxel of our volume
for (int z = 0; z < depth; z++)
{
for (int y = height - 1; y > 0; y--)
{
for (int x = 0; x < width; x++)
{
float sampleX = (float)x * rockScale;
float sampleY = (float)y * rockScale;
float sampleZ = (float)z * rockScale;
float simplexNoiseValue = SimplexNoise.Noise.Generate(sampleX, sampleY, sampleZ);
float altitude = (float)(y - 0.05f) / (float)height;
// Map the altitude to the range -1.0 to +1.0...
altitude = (altitude * 0.05f) + 0.05f;
simplexNoiseValue -= altitude;
simplexNoiseValue *= 1.0f;
simplexNoiseValue = Mathf.Clamp(simplexNoiseValue, -0.05f, 0.05f);
simplexNoiseValue *= 123;
int simplexCubicValue = Mathf.RoundToInt (simplexNoiseValue);
data.SetVoxel(x + simplexCubicValue, y+ simplexCubicValue, z+ simplexCubicValue, green);
}
}
}//End the loop of voxeling
}
}
EDIT :
Sorry about all the edits getting it almost figured out the last code was alittle different ...
but I like the outcome of this.....
Theres a snap
http://fav.me/daireldCode:
using UnityEngine;
using System.Collections;
using Cubiquity;
public class ProceduralColoredCubes : MonoBehaviour {
public int width = 128;
public int height = 32;
public int depth = 128;
// Use this for initialization
void Start () {
// FIXME - Where should we delete this?
/// [DoxygenSnippet-CreateEmptyTerrainVolumeData]
//Create an empty TerrainVolumeData with dimensions width * height * depth
ColoredCubesVolumeData data = VolumeData.CreateEmptyVolumeData<ColoredCubesVolumeData>(new Region(0, 0, 0, width-1, height-1, depth-1));
/// [DoxygenSnippet-CreateEmptyTerrainVolumeData]
ColoredCubesVolume volume = GetComponent<ColoredCubesVolume>();
ColoredCubesVolumeRenderer volumeRenderer = GetComponent<ColoredCubesVolumeRenderer>();
volume.data = data;
// Defines colors for each cubic square.
QuantizedColor green = new QuantizedColor(18, 115, 38, 255);
QuantizedColor brown = new QuantizedColor(115, 87, 18, 255);
QuantizedColor gray = new QuantizedColor(127, 127, 127, 255);
QuantizedColor white = new QuantizedColor(255, 255, 255, 255);
float rockScale = 0.02F;
// Iterate over every voxel of our volume
for (int z = 0; z < depth; z++)
{
for (int y = height - 1; y > 0; y--)
{
for (int x = 0; x < width; x++)
{
float sampleX = (float)x * rockScale;
float sampleY = (float)y * rockScale;
float sampleZ = (float)z * rockScale;
float simplexNoiseValue = SimplexNoise.Noise.Generate(sampleX, sampleY, sampleZ);
float altitude = (float)(y - 0.05f) / (float)height;
// Map the altitude to the range -1.0 to +1.0...
altitude = (altitude * 0.05f) - 0.05f;
simplexNoiseValue -= altitude;
simplexNoiseValue *= 0.05f;
simplexNoiseValue = Mathf.Clamp(simplexNoiseValue, -0.05f, 0.05f);
simplexNoiseValue *= 15;
int simplexCubicValue = Mathf.RoundToInt (simplexNoiseValue);
if(y < 8)
{
// Add to bedrock material channel.
data.SetVoxel(x , y , z , green);
}
data.SetVoxel(x , y * simplexCubicValue, z , gray);
}
}
}//End the loop of voxeling
}
}