mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 11:17:05 +02:00
feat: custom shaders
This commit is contained in:
1 parent
a7d8f08522
commit
4a6b5e3aa9
9 files changed
+176
-46
No files matched your search
@@ -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);
|
||||
}
|
||||
`,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user