mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
improve ShaderMaterial
This commit is contained in:
parent
9e062155f6
commit
3844b109f2
@ -5,12 +5,13 @@ import { propsValues, defaultFragmentShader, defaultVertexShader } from '../tool
|
||||
export default {
|
||||
inject: ['three', 'mesh'],
|
||||
props: {
|
||||
uniforms: { type: Object, default: () => {} },
|
||||
uniforms: { type: Object, default: () => { return {}; } },
|
||||
vertexShader: { type: String, default: defaultVertexShader },
|
||||
fragmentShader: { type: String, default: defaultFragmentShader },
|
||||
},
|
||||
created() {
|
||||
this.createMaterial();
|
||||
console.log(this.uniforms);
|
||||
['vertexShader', 'fragmentShader'].forEach(p => {
|
||||
watch(() => this[p], () => {
|
||||
// recreate material if we change either shader
|
||||
|
@ -77,15 +77,13 @@ function getMatcapFormatString(format) {
|
||||
// shader defaults
|
||||
export const defaultVertexShader = `
|
||||
varying vec2 vUv;
|
||||
|
||||
void main(){
|
||||
vUv = uv;
|
||||
gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);
|
||||
vUv = uv;
|
||||
gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);
|
||||
}`;
|
||||
|
||||
export const defaultFragmentShader = `
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vec4(vUv.x, vUv.y, 0., 1.0);
|
||||
}`;
|
||||
}`;
|
||||
|
Loading…
Reference in New Issue
Block a user