-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSHEncoding.cs
More file actions
executable file
·54 lines (45 loc) · 1.16 KB
/
SHEncoding.cs
File metadata and controls
executable file
·54 lines (45 loc) · 1.16 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
// Marmoset Skyshop
// Copyright 2013 Marmoset LLC
// http://marmoset.co
using UnityEngine;
using System;
using System.IO;
namespace mset {
[System.Serializable]
public class SHEncoding {
public float[] c = new float[27]; //spherical harmonics weights
public Vector4[] cBuffer = new Vector4[9]; //shader buffer for weights
public SHEncoding() {
clearToBlack();
}
public void clearToBlack() {
for(int i=0; i<27; ++i) { c[i] = 0.0f; }
for(int i=0; i<9; ++i) { cBuffer[i] = Vector4.zero; }
}
public void copyFrom(SHEncoding src) {
for(int i=0; i<27; ++i) {
this.c[i] = src.c[i];
}
copyToBuffer();
}
public void copyToBuffer() {
for(int i=0; i<9; ++i) {
float eqc = sEquationConstants[i];
cBuffer[i].x = c[i*3+0]*eqc;
cBuffer[i].y = c[i*3+1]*eqc;
cBuffer[i].z = c[i*3+2]*eqc;
}
}
public static float[] sEquationConstants = {
0.28209479f, // l= 0 m= 0
0.4886025f, // l= 1 m=-1
0.4886025f, // l= 1 m= 0
0.4886025f, // l= 1 m= 1
1.09254843f, // l= 2 m=-2
1.09254843f, // l= 2 m=-1
0.315391565f, // l= 2 m= 0
1.09254843f, // l= 2 m= 1
0.546274215f, // l= 2 m= 2
};
};
}