feat: custom shaders

This commit is contained in:
TrèsAbhi committed 2024-01-09 22:31:34 -06:00
1 parent a7d8f08522
commit 4a6b5e3aa9
9 files changed
+176 -46

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
import { GreaterEqualDepth } from 'three';
const INFLATE = '0.0';
export function ArmorHighlightMaterial() {
return (
<shaderMaterial
depthFunc={GreaterEqualDepth}
args={[
{
transparent: true,
vertexShader: `
varying vec3 vNormal;
varying vec3 vViewPosition; // Camera position in view space
void main() {
vNormal = normalMatrix * normal; // Transform normal to view space
vViewPosition = (modelViewMatrix * vec4(position, 1.0)).xyz; // Camera position in view space
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`,
fragmentShader: `
// Fragment Shader
varying vec3 vNormal;
varying vec3 vViewPosition;
void main() {
// Use vNormal for your fragment shader calculations
vec3 normal = normalize(vNormal);
float uhhh = dot(normal, vViewPosition) * 0.5 + 1.0;
// ... rest of your fragment shader code ...
gl_FragColor = vec4(1.0, 0.0, 0.0, uhhh);
}
`,
},
]}
/>
);
}