static void Tutorial4() { Console.WriteLine("Begin Tutorial 4"); RiggedMultifractal mountainTerrain = new RiggedMultifractal(); Billow baseFlatTerrain = new Billow(); baseFlatTerrain.Frequency = 2.0; ScaleBias flatTerrain = new ScaleBias(); flatTerrain[0] = baseFlatTerrain; flatTerrain.Scale = 0.125; flatTerrain.Bias = -0.75; Perlin terrainType = new Perlin(); terrainType.Frequency = 0.5; terrainType.Persistence = 0.25; Select finalTerrain = new Select(); finalTerrain[0] = flatTerrain; finalTerrain[1] = mountainTerrain; finalTerrain.Controller = terrainType; finalTerrain.SetBounds(0.0, 1000.0); finalTerrain.FallOff = 0.125; NoiseMap heightMap = new NoiseMap(); NoiseMapBuilderPlane heightMapBuilder = new NoiseMapBuilderPlane();; heightMapBuilder.SetSourceModule(finalTerrain); heightMapBuilder.SetDestNoiseMap(heightMap); heightMapBuilder.SetDestSize(256, 256); heightMapBuilder.SetBounds(6.0, 10.0, 1.0, 5.0); heightMapBuilder.Build(); RendererImage renderer = new RendererImage(); NoiseImage image = new NoiseImage(); renderer.SetSourceNoiseMap(heightMap); renderer.SetDestImage(image); renderer.ClearGradient(); renderer.AddGradientPoint(-1.00, new Color(32, 160, 0, 255)); // grass renderer.AddGradientPoint(-0.25, new Color(224, 224, 0, 255)); // dirt renderer.AddGradientPoint(0.25, new Color(128, 128, 128, 255)); // rock renderer.AddGradientPoint(1.00, new Color(255, 255, 255, 255)); // snow renderer.EnableLight(); renderer.SetLightContrast(3.0); renderer.SetLightBrightness(2.0); renderer.Render(); WriterBMP writer = new WriterBMP(); writer.SetSourceImage(image); writer.SetDestFilename("tutorial4.bmp"); writer.WriteDestFile(); Console.WriteLine("End Tutorial 4"); }
// Use this for initialization void Start() { IModule mountainTerrain = new RidgedMulti(); IModule baseFlatTerrain = new Billow(); ((Billow)baseFlatTerrain).Frequency = 2.0; IModule flatTerrain = new ScaleBias(baseFlatTerrain, 0.125, -0.75); IModule terrainType = new Perlin(); ((Perlin)terrainType).Frequency = 0.5; ((Perlin)terrainType).Persistence = 0.25; IModule finalTerrain = new Select(flatTerrain, mountainTerrain, terrainType); ((Select)finalTerrain).SetBounds(0.0, 1000.0); ((Select)finalTerrain).SetEdgeFallOff(0.125); NoiseMapBuilderPlane heightMapBuilder = new NoiseMapBuilderPlane(256, 256); heightMapBuilder.SetBounds(6.0, 10.0, 1.0, 5.0); heightMapBuilder.Build(finalTerrain); RendererImage render = new RendererImage(); render.SourceNoiseMap = heightMapBuilder.Map; render.ClearGradient(); render.AddGradientPoint(-1.0000, new Color32(32, 160, 0, 255)); render.AddGradientPoint(-0.2500, new Color32(224, 224, 0, 255)); render.AddGradientPoint(0.2500, new Color32(128, 128, 128, 255)); render.AddGradientPoint(1.0000, new Color32(255, 255, 255, 255)); render.IsLightEnabled = true; render.LightContrast = 3.0; render.LightBrightness = 2.0; render.Render(); tex = render.GetTexture(); }
// Use this for initialization void Start() { IModule module = new Perlin(); NoiseMapBuilderSphere heightMap = new NoiseMapBuilderSphere(512, 256); heightMap.SetBounds(-90.0, 90.0, -180.0, 180.0); heightMap.Build(module); RendererImage render = new RendererImage(); render.SourceNoiseMap = heightMap.Map; render.ClearGradient(); render.AddGradientPoint(-1.0000, new Color32(0, 0, 128, 255)); // deeps render.AddGradientPoint(-0.2500, new Color32(0, 0, 255, 255)); // shallow render.AddGradientPoint(0.0000, new Color32(0, 128, 255, 255)); // shore render.AddGradientPoint(0.0625, new Color32(240, 240, 64, 255)); // sand render.AddGradientPoint(0.1250, new Color32(32, 160, 0, 255)); // grass render.AddGradientPoint(0.3750, new Color32(224, 224, 0, 255)); // dirt render.AddGradientPoint(0.7500, new Color32(128, 128, 128, 255)); // rock render.AddGradientPoint(1.0000, new Color32(255, 255, 255, 255)); // snow render.IsLightEnabled = true; render.LightContrast = 3.0; render.LightBrightness = 2.0; render.Render(); tex = render.GetTexture(); }
/// <summary> /// Renders a single frame using the renderer's data. /// </summary> public RendererImage Render( ) { RendererImage Image = new RendererImage(this.Settings.Resolution); this.PerformRender(ref Image); return(Image); }
static void Tutorial3() { Console.WriteLine("Begin Tutorial 3"); Perlin myModule = new Perlin(); NoiseMap heightMap = new NoiseMap(); NoiseMapBuilderPlane heightMapBuilder = new NoiseMapBuilderPlane(); heightMapBuilder.SetSourceModule(myModule); heightMapBuilder.SetDestNoiseMap(heightMap); heightMapBuilder.SetDestSize(256, 256); heightMapBuilder.SetBounds(6.0, 10.0, 1.0, 5.0); RendererImage renderer = new RendererImage(); NoiseImage image = new NoiseImage(); renderer.SetSourceNoiseMap(heightMap); renderer.SetDestImage(image); WriterBMP writer = new WriterBMP(); writer.SetSourceImage(image); renderer.ClearGradient(); renderer.AddGradientPoint(-1.0000, new Color(0, 0, 128, 255)); // deeps renderer.AddGradientPoint(-0.2500, new Color(0, 0, 255, 255)); // shallow renderer.AddGradientPoint(0.0000, new Color(0, 128, 255, 255)); // shore renderer.AddGradientPoint(0.0625, new Color(240, 240, 64, 255)); // sand renderer.AddGradientPoint(0.1250, new Color(32, 160, 0, 255)); // grass renderer.AddGradientPoint(0.3750, new Color(224, 224, 0, 255)); // dirt renderer.AddGradientPoint(0.7500, new Color(128, 128, 128, 255)); // rock renderer.AddGradientPoint(1.0000, new Color(255, 255, 255, 255)); // snow renderer.EnableLight(); renderer.SetLightContrast(3.0); // Triple the contrast renderer.SetLightBrightness(2.0); // Double the brightness for (int octave = 1; octave <= 6; octave++) { for (int frecuency = 1; frecuency <= 8; frecuency = frecuency * 2) { for (int persistence = 1; persistence <= 3; persistence++) { myModule.OctaveCount = octave; myModule.Frequency = frecuency; myModule.Persistence = persistence / 4.0f; heightMapBuilder.Build(); renderer.Render(); writer.SetDestFilename("tutorial3-" + octave + "-" + frecuency + "-" + persistence + ".bmp"); writer.WriteDestFile(); } } } Console.WriteLine("End Tutorial 3"); }
static void Init() { //Init render render = new RendererImage(); //Init noise modules = new List <IModule>(); //Init window window = (Edt_TextureCreator)EditorWindow.GetWindow(typeof(Edt_TextureCreator)); window.position = windowPosition; window.minSize = windowMinSize; //window.maxSize = windowMaxSize; window.titleContent.text = windowTitle; window.Show(); }
// Use this for initialization void Start() { IModule primaryGranite = new Billow(); ((Billow)primaryGranite).Seed = 0; ((Billow)primaryGranite).Frequency = 8.0; ((Billow)primaryGranite).Persistence = 0.625; ((Billow)primaryGranite).Lacunarity = 2.18359375; ((Billow)primaryGranite).OctaveCount = 6; ((Billow)primaryGranite).NoiseQuality = NoiseQuality.Standard; IModule baseGrains = new Voronoi(); ((Voronoi)baseGrains).Seed = 1; ((Voronoi)baseGrains).Frequency = 16.0; ((Voronoi)baseGrains).EnableDistance = true; IModule scaledGrains = new ScaleBias(baseGrains); ((ScaleBias)scaledGrains).Scale = -0.5; ((ScaleBias)scaledGrains).Bias = 0.0; IModule combinedGranite = new Add(primaryGranite, scaledGrains); IModule finalGranite = new Turbulence(combinedGranite); ((Turbulence)finalGranite).Seed = 2; ((Turbulence)finalGranite).Frequency = 4.0; ((Turbulence)finalGranite).Power = 1.0 / 8.0; ((Turbulence)finalGranite).Roughness = 6; NoiseMapBuilderPlane plane = new NoiseMapBuilderPlane(256, 256); plane.SetBounds(-1.0, 1.0, -1.0, 1.0); plane.Build(finalGranite); RendererImage render = new RendererImage(); render.SourceNoiseMap = plane.Map; render.ClearGradient(); render.AddGradientPoint(-1.0000, new Color32(0, 0, 0, 255)); render.AddGradientPoint(-0.9375, new Color32(0, 0, 0, 255)); render.AddGradientPoint(-0.8750, new Color32(216, 216, 242, 255)); render.AddGradientPoint(0.0000, new Color32(191, 191, 191, 255)); render.AddGradientPoint(0.5000, new Color32(210, 116, 125, 255)); render.AddGradientPoint(0.7500, new Color32(210, 113, 98, 255)); render.AddGradientPoint(1.0000, new Color32(255, 176, 192, 255)); render.IsLightEnabled = true; render.LightAzimuth = 135.0; render.LightElev = 60.0; render.LightContrast = 2.0; render.LightColor = new Color32(255, 255, 255, 0); render.Render(); tex = render.GetTexture(); }
protected override void PerformRender(ref RendererImage Image) { for (int X = 0; X < this.Settings.Resolution.X; X++) { for (int Y = 0; Y < this.Settings.Resolution.Y; Y++) { Ray R = this.Camera.GetRayFromPixel(X, Y); CollisionData Hit = this.Scene.Objects.Select(O => O.CollidesWith(R)) .Where(O => O.Hit) .OrderBy(O => O.Distance) .FirstOrDefault( ); Image.SetPixel(X, Y, Hit.Hit ? new Color(255, 0, 0) : new Color(0, 255, 0)); } } }
private static void Main(string [] args) { RenderScene Scene = new RenderScene( ); Sphere S = new Sphere { Position = new Vector3(0, 0, -40), Radius = 1 }; Scene.AddRendererObject(S); RenderSettings Settings = new RaytracerSettings( ); Renderer R = new Raytracer( ); R.SetData(Scene, Settings); RendererImage Render = R.Render( ); Bitmap Bmp = Render.ConvertToBitmap( ); Bmp.Save("D:\\Temp\\tempimg.png"); Process.Start("D:\\Temp\\tempimg.png"); Console.ReadLine( ); }
static void Tutorial2() { Console.WriteLine("Begin Tutorial 2"); Perlin myModule = new Perlin(); NoiseMap heightMap = new NoiseMap(); NoiseMapBuilderPlane heightMapBuilder = new NoiseMapBuilderPlane(); heightMapBuilder.SetSourceModule(myModule); heightMapBuilder.SetDestNoiseMap(heightMap); heightMapBuilder.SetDestSize(256, 256); heightMapBuilder.SetBounds(2.0, 6.0, 1.0, 5.0); heightMapBuilder.Build(); RendererImage renderer = new RendererImage(); NoiseImage image = new NoiseImage(); renderer.SetSourceNoiseMap(heightMap); renderer.SetDestImage(image); renderer.Render(); WriterBMP writer = new WriterBMP(); writer.SetSourceImage(image); writer.SetDestFilename("tutorial2-1.bmp"); writer.WriteDestFile(); renderer.ClearGradient(); renderer.AddGradientPoint(-1.0000, new Color(0, 0, 128, 255)); // deeps renderer.AddGradientPoint(-0.2500, new Color(0, 0, 255, 255)); // shallow renderer.AddGradientPoint(0.0000, new Color(0, 128, 255, 255)); // shore renderer.AddGradientPoint(0.0625, new Color(240, 240, 64, 255)); // sand renderer.AddGradientPoint(0.1250, new Color(32, 160, 0, 255)); // grass renderer.AddGradientPoint(0.3750, new Color(224, 224, 0, 255)); // dirt renderer.AddGradientPoint(0.7500, new Color(128, 128, 128, 255)); // rock renderer.AddGradientPoint(1.0000, new Color(255, 255, 255, 255)); // snow renderer.Render(); writer.SetDestFilename("tutorial2-2.bmp"); writer.WriteDestFile(); renderer.EnableLight(); renderer.Render(); writer.SetDestFilename("tutorial2-3.bmp"); writer.WriteDestFile(); renderer.SetLightContrast(3.0); // Triple the contrast renderer.Render(); writer.SetDestFilename("tutorial2-4.bmp"); writer.WriteDestFile(); renderer.SetLightBrightness(2.0); // Double the brightness renderer.Render(); writer.SetDestFilename("tutorial2-5.bmp"); writer.WriteDestFile(); heightMapBuilder.SetDestSize(256 * 2, 256); heightMapBuilder.SetBounds(2.0, 10.0, 1.0, 5.0); heightMapBuilder.Build(); renderer.Render(); writer.SetDestFilename("tutorial2-6.bmp"); writer.WriteDestFile(); Console.WriteLine("End Tutorial 2"); }
/// <summary> /// Performs the actual rendering. /// </summary> protected abstract void PerformRender(ref RendererImage Result);