Elffuss BraidHub

kikocis/VibeCodeViewer public

main · 1.4 KiBRawPermalink
1const OutputShader = {
2
3 name: 'OutputShader',
4
5 uniforms: {
6
7 'tDiffuse': { value: null },
8 'toneMappingExposure': { value: 1 }
9
10 },
11
12 vertexShader: /* glsl */`
13 precision highp float;
14
15 uniform mat4 modelViewMatrix;
16 uniform mat4 projectionMatrix;
17
18 attribute vec3 position;
19 attribute vec2 uv;
20
21 varying vec2 vUv;
22
23 void main() {
24
25 vUv = uv;
26 gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
27
28 }`,
29
30 fragmentShader: /* glsl */`
31
32 precision highp float;
33
34 uniform sampler2D tDiffuse;
35
36 #include <tonemapping_pars_fragment>
37 #include <colorspace_pars_fragment>
38
39 varying vec2 vUv;
40
41 void main() {
42
43 gl_FragColor = texture2D( tDiffuse, vUv );
44
45 // tone mapping
46
47 #ifdef LINEAR_TONE_MAPPING
48
49 gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
50
51 #elif defined( REINHARD_TONE_MAPPING )
52
53 gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
54
55 #elif defined( CINEON_TONE_MAPPING )
56
57 gl_FragColor.rgb = OptimizedCineonToneMapping( gl_FragColor.rgb );
58
59 #elif defined( ACES_FILMIC_TONE_MAPPING )
60
61 gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
62
63 #elif defined( AGX_TONE_MAPPING )
64
65 gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
66
67 #endif
68
69 // color space
70
71 #ifdef SRGB_TRANSFER
72
73 gl_FragColor = sRGBTransferOETF( gl_FragColor );
74
75 #endif
76
77 }`
78
79};
80
81export { OutputShader };