Skip to content

Commit

Permalink
fix: syntax errors in shaders (#405)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett authored Jan 29, 2025
1 parent 6bed3f4 commit 12f00a3
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 48 deletions.
70 changes: 35 additions & 35 deletions src/shaders/ACESFilmicToneMappingShader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,68 +23,68 @@ export const ACESFilmicToneMappingShader: IACESFilmicToneMappingShader = {
},

vertexShader: /* glsl */ `
varying vec2 vUv;,
varying vec2 vUv;
void main() {,
void main() {
vUv = uv;,
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );,
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
},
}
`,
fragmentShader: /* glsl */ `
#define saturate(a) clamp( a, 0.0, 1.0 ),
#define saturate(a) clamp( a, 0.0, 1.0 )
uniform sampler2D tDiffuse;,
uniform sampler2D tDiffuse;
uniform float exposure;,
uniform float exposure;
varying vec2 vUv;,
varying vec2 vUv;
vec3 RRTAndODTFit( vec3 v ) {,
vec3 RRTAndODTFit( vec3 v ) {
vec3 a = v * ( v + 0.0245786 ) - 0.000090537;,
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;,
return a / b;,
vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
return a / b;
},
}
vec3 ACESFilmicToneMapping( vec3 color ) {,
vec3 ACESFilmicToneMapping( vec3 color ) {
// sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT
const mat3 ACESInputMat = mat3(,
vec3( 0.59719, 0.07600, 0.02840 ),, // transposed from source
vec3( 0.35458, 0.90834, 0.13383 ),,
vec3( 0.04823, 0.01566, 0.83777 ),
);,
const mat3 ACESInputMat = mat3(
vec3( 0.59719, 0.07600, 0.02840 ), // transposed from source
vec3( 0.35458, 0.90834, 0.13383 ),
vec3( 0.04823, 0.01566, 0.83777 )
);
// ODT_SAT => XYZ => D60_2_D65 => sRGB
const mat3 ACESOutputMat = mat3(,
vec3( 1.60475, -0.10208, -0.00327 ),, // transposed from source
vec3( -0.53108, 1.10813, -0.07276 ),,
vec3( -0.07367, -0.00605, 1.07602 ),
);,
const mat3 ACESOutputMat = mat3(
vec3( 1.60475, -0.10208, -0.00327 ), // transposed from source
vec3( -0.53108, 1.10813, -0.07276 ),
vec3( -0.07367, -0.00605, 1.07602 )
);
color = ACESInputMat * color;,
color = ACESInputMat * color;
// Apply RRT and ODT
color = RRTAndODTFit( color );,
color = RRTAndODTFit( color );
color = ACESOutputMat * color;,
color = ACESOutputMat * color;
// Clamp to [0, 1]
return saturate( color );,
return saturate( color );
},
}
void main() {,
void main() {
vec4 tex = texture2D( tDiffuse, vUv );,
vec4 tex = texture2D( tDiffuse, vUv );
tex.rgb *= exposure / 0.6;, // pre-exposed, outside of the tone mapping function
tex.rgb *= exposure / 0.6; // pre-exposed, outside of the tone mapping function
gl_FragColor = vec4( ACESFilmicToneMapping( tex.rgb ), tex.a );,
gl_FragColor = vec4( ACESFilmicToneMapping( tex.rgb ), tex.a );
},
}
`,
}
8 changes: 4 additions & 4 deletions src/shaders/FXAAShader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const FXAAShader = {
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
"// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AS IS AND ANY",
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AS IS AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
Expand Down Expand Up @@ -129,7 +129,7 @@ export const FXAAShader = {
/*--------------------------------------------------------------------------*/
#ifndef FXAA_EARLY_EXIT
//
" // Controls algorithms early exit path.",
// Controls algorithms early exit path.
// On PS3 turning this ON adds 2 cycles to the shader.
// On 360 turning this OFF adds 10ths of a millisecond to the shader.
// Turning this off on console will result in a more blurry image.
Expand All @@ -146,9 +146,9 @@ export const FXAAShader = {
// Only valid for PC OpenGL currently.
// Probably will not work when FXAA_GREEN_AS_LUMA = 1.
//
" // 1 = Use discard on pixels which dont need AA.",
// 1 = Use discard on pixels which dont need AA.
// For APIs which enable concurrent TEX+ROP from same surface.
" // 0 = Return unchanged color on pixels which dont need AA.",
// 0 = Return unchanged color on pixels which dont need AA.
//
#define FXAA_DISCARD 0
#endif
Expand Down
8 changes: 4 additions & 4 deletions src/shaders/GodRaysShader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const GodRaysGenerateShader = {
// Unrolling didnt do much on my hardware (ATI Mobility Radeon 3450),
// so ive just left the loop
"for ( float i = 0.0; i < TAPS_PER_PASS; i += 1.0 ) {",
for ( float i = 0.0; i < TAPS_PER_PASS; i += 1.0 ) {
// Accumulate samples, making sure we dont walk past the light source.
Expand All @@ -133,10 +133,10 @@ export const GodRaysGenerateShader = {
// sun is to the left, right or bottom of screen as these cases are
// not specifically handled.
" col += ( i <= iters && uv.y < 1.0 ? texture2D( tInput, uv ).r : 0.0 );",
" uv += stepv;",
col += ( i <= iters && uv.y < 1.0 ? texture2D( tInput, uv ).r : 0.0 );
uv += stepv;
"}",
}
*/
// Unrolling loop manually makes it work in ANGLE
Expand Down
2 changes: 1 addition & 1 deletion src/shaders/ParallaxShader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const ParallaxShader = {
float initialHeight = texture2D( bumpMap, vUv ).r;
// No Offset Limitting: messy, floating output at grazing angles.
//"vec2 texCoordOffset = parallaxScale * V.xy / V.z * initialHeight;",
//vec2 texCoordOffset = parallaxScale * V.xy / V.z * initialHeight;
// Offset Limiting
vec2 texCoordOffset = parallaxScale * V.xy * initialHeight;
Expand Down
8 changes: 4 additions & 4 deletions src/shaders/VignetteShader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ export const VignetteShader = {
// alternative version from glfx.js
// this one makes more "dusty" look (as opposed to "burned")
" vec4 color = texture2D( tDiffuse, vUv );",
" float dist = distance( vUv, vec2( 0.5 ) );",
" color.rgb *= smoothstep( 0.8, offset * 0.799, dist *( darkness + offset ) );",
" gl_FragColor = color;",
vec4 color = texture2D( tDiffuse, vUv );
float dist = distance( vUv, vec2( 0.5 ) );
color.rgb *= smoothstep( 0.8, offset * 0.799, dist *( darkness + offset ) );
gl_FragColor = color;
*/
}
Expand Down

0 comments on commit 12f00a3

Please sign in to comment.