image thumbnail

Automatic Terrain Generation

by

 

A set a tools for generating artificial terrain and other rough phenomena mapped over a 2D surface.

sun_tones(t)
function sun_tone = sun_tones(t)

% sun_tone = sun_tones(t)
% 
% Generates an appropriate color for sunlight for a given time of day. The
% input time, t, ranges from 0 (midnight) to 1 (midnight), with 0.5
% representing noon, 0.25 representing dawn, and 0.75 representing dusk.
%
% See terrain_generation_introduction.m for an example.
%
% Tucker McClure
% Copyright 2012, The MathWorks, Inc.

    % Times of day
    sun_tones_times = [0 5.5 5.75 6.5 7 12 17 17.5 18 18.5 18.75 19 24]/24;

    % Colors at times of day
    sun_tones = [ 32  31  48; ...
                  32  31  58; ...
                 225 137  98; ...
                 245 220 170; ...
                 210 220 245; ...
                 225 235 255; ...
                 205 220 245; ...
                 225 218 172; ...
                 247 184 111; ...
                 202 123  83; ...
                  72  35  35; ...
                  32  31  58; ...
                  32  31  48]/255;

    % Color at requested time of day.
    sun_tone = interp1(sun_tones_times, sun_tones, t);

end

Contact us