forked from Orillusion/orillusion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImageMaterial.ts
71 lines (61 loc) · 1.89 KB
/
ImageMaterial.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { Engine3D, MaterialBase, ShaderLib, Vector4, Color, Texture } from "@orillusion/core";
import ImageMaterialShader from "./ImageMaterialShader.wgsl?raw";
/**
* ImageMaterial
* Do not compute light, only read pixel color from a Image source
* @group Material
*/
export class ImageMaterial extends MaterialBase {
/**
* Create a new ImageMaterial
*/
constructor() {
super();
ShaderLib.register("ImageMaterialShader", ImageMaterialShader);
let shader = this.setShader(`ImageMaterialShader`, `ImageMaterialShader`);
shader.setShaderEntry(`VertMain`, `FragMain`)
shader.setUniformVector4(`transformUV1`, new Vector4(0, 0, 1, 1));
shader.setUniformVector4(`transformUV2`, new Vector4(0, 0, 1, 1));
shader.setUniformColor(`baseColor`, new Color());
shader.setUniformVector4(`rectClip`, new Vector4(0, 0, 0, 0));
shader.setUniformFloat(`alphaCutoff`, 0.5);
let shaderState = shader.shaderState;
shaderState.acceptShadow = false;
shaderState.receiveEnv = false;
shaderState.acceptGI = false;
shaderState.useLight = false;
shaderState.castShadow = false;
shaderState.useZ = false;
// default value
this.baseMap = Engine3D.res.whiteTexture;
}
/**
* Set the clip rect area
*/
public set rectClip(value: Vector4) {
this.renderShader.uniforms[`rectClip`].vector4 = value;
}
/**
* Get the clip rect area
*/
public get rectClip(): Vector4 {
return this.renderShader.uniforms[`rectClip`].vector4;
}
/**
* Set no env Map
*/
public set envMap(texture: Texture) {
//no need env texture
}
/**
* Set no shadow Map
*/
public set shadowMap(texture: Texture) {
//not need shadowMap texture
}
/**
* Start debug GUI
*/
debug() {
}
}