This repository was archived by the owner on Aug 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPQSMod_VertexSimplexNoiseColor.cs
More file actions
76 lines (65 loc) · 1.96 KB
/
PQSMod_VertexSimplexNoiseColor.cs
File metadata and controls
76 lines (65 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* libpqsmods - A standalone implementation of KSP's PQSMods
* Copyright (c) Thomas P. 2016
* Licensed under the terms of the MIT license
*/
using System;
using ProceduralQuadSphere.KSP;
using ProceduralQuadSphere.Unity;
namespace ProceduralQuadSphere
{
/// <summary>
/// A PQSMod that lerps a simplex color into the pqs color
/// </summary>
/// <seealso cref="PQSMod" />
public class PQSMod_VertexSimplexNoiseColor : PQSMod
{
/// <summary>
/// The seed for the simplex
/// </summary>
public Int32 seed;
/// <summary>
/// How much of the color should end up on the surface
/// </summary>
public Single blend;
/// <summary>
/// The starting color
/// </summary>
public Color colorStart;
/// <summary>
/// The color at the end
/// </summary>
public Color colorEnd;
/// <summary>
/// The octaves for the simplex
/// </summary>
public Double octaves;
/// <summary>
/// The persistence for the simplex
/// </summary>
public Double persistence;
/// <summary>
/// The frequency for the simplex
/// </summary>
public Double frequency;
/// <summary>
/// The final simplex
/// </summary>
private Simplex simplex;
/// <summary>
/// Initializes the base mod
/// </summary>
public override void OnSetup()
{
simplex = new Simplex(seed, octaves, persistence, frequency);
}
/// <summary>
/// Called when the parent sphere builds it's color
/// </summary>
public override void OnVertexBuild(VertexBuildData data)
{
Single n = (Single)((this.simplex.noise(data.directionFromCenter) + 1) / 2);
data.vertColor = Color.Lerp(data.vertColor, Color.Lerp(colorStart, colorEnd, n), blend);
}
}
}