-
Notifications
You must be signed in to change notification settings - Fork 46
/
image-based-lighting.ts
51 lines (43 loc) · 1.37 KB
/
image-based-lighting.ts
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
import { Texture } from "@pixi/core"
import { MIPMAP_MODES } from "@pixi/constants"
import { Cubemap } from "../cubemap/cubemap"
import png from "./assets/lut-ggx.png"
/**
* Collection of components used for image-based lighting (IBL), a
* rendering technique which involves capturing an omnidirectional representation
* of real-world light information as an image.
*/
export class ImageBasedLighting {
private _diffuse: Cubemap
private _specular: Cubemap
/** The default BRDF integration map lookup texture. */
static defaultLookupBrdf = Texture.from(png, {
mipmap: MIPMAP_MODES.OFF
})
/** Cube texture used for the diffuse component. */
get diffuse() {
return this._diffuse
}
/** Cube mipmap texture used for the specular component. */
get specular() {
return this._specular
}
/** BRDF integration map lookup texture. */
lookupBrdf?: Texture
/**
* Creates a new image-based lighting object.
* @param diffuse Cubemap used for the diffuse component.
* @param specular Cubemap used for the specular component.
*/
constructor(diffuse: Cubemap, specular: Cubemap) {
this._diffuse = diffuse
this._specular = specular
}
/**
* Value indicating if this object is valid to be used for rendering.
*/
get valid() {
return this._diffuse.valid &&
this._specular.valid && (!this.lookupBrdf || this.lookupBrdf.valid)
}
}