Project 29: Shaded Product Mockup
3D Engineer
Step 1 of 2
Project
Review: Custom Shaders
Apply a UV-based custom shader to a product mockup box.
🎯 Your Task
Please add the exact code shown in the light gray box below to your editor.Do not delete your previous code, just insert these new lines in the correct place!
const vertexShader = `
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`;
const fragmentShader = `
varying vec2 vUv;
void main() {
gl_FragColor = vec4(vUv.x, 0.3, 1.0 - vUv.y, 1.0);
}
`;
export default function Scene() {
return (
<Canvas>
<mesh>
<boxGeometry args={[1.2, 1.2, 1.2]} />
<shaderMaterial vertexShader={vertexShader} fragmentShader={fragmentShader} />
</mesh>
</Canvas>
);
}