1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 04:12:02 +08:00

improve ShaderMaterial

This commit is contained in:
Kevin Levron 2021-03-12 23:14:49 +01:00
parent 9e062155f6
commit 3844b109f2
2 changed files with 5 additions and 6 deletions

View File

@ -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

View File

@ -77,7 +77,6 @@ function getMatcapFormatString(format) {
// shader defaults
export const defaultVertexShader = `
varying vec2 vUv;
void main(){
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);
@ -85,7 +84,6 @@ void main(){
export const defaultFragmentShader = `
varying vec2 vUv;
void main() {
gl_FragColor = vec4(vUv.x, vUv.y, 0., 1.0);
}`;