MCPcopy Create free account
hub / github.com/galacean/engine / initCustomShader

Function initCustomShader

examples/src/buffer-mesh-instance.ts:142–174  ·  view source on GitHub ↗

* Create custom instance shader.

()

Source from the content-addressed store, hash-verified

140 * Create custom instance shader.
141 */
142function initCustomShader(): Shader {
143 const shader = Shader.create(
144 "CustomShader",
145 `uniform mat4 renderer_MVPMat;
146 attribute vec4 POSITION;
147 attribute vec3 INSTANCE_OFFSET;
148 attribute vec3 INSTANCE_COLOR;
149
150 uniform mat4 renderer_MVMat;
151
152 varying vec3 v_position;
153 varying vec3 v_color;
154
155 void main() {
156 vec4 position = POSITION;
157 position.xyz += INSTANCE_OFFSET;
158 gl_Position = renderer_MVPMat * position;
159
160 v_color = INSTANCE_COLOR;
161 }`,
162
163 `
164 varying vec3 v_color;
165 uniform vec4 u_color;
166
167 void main() {
168 vec4 color = vec4(v_color,1.0);
169 gl_FragColor = color;
170 }
171 `
172 );
173 return shader;
174}

Callers 1

Calls 1

createMethod · 0.45

Tested by

no test coverage detected