UNPKG

@threlte/extras

Version:

Utilities, abstractions and plugins for your Threlte apps

36 lines (27 loc) 936 B
import { revision } from '../../lib/revision'; export const fragmentShader = ` #include <fog_pars_fragment> #include <logdepthbuf_pars_fragment> uniform float useDash; uniform float dashArray; uniform float dashOffset; uniform float dashRatio; uniform sampler2D alphaMap; uniform float useAlphaMap; varying vec2 vUV; varying vec4 vColor; varying float vCounters; vec4 CustomLinearTosRGB( in vec4 value ) { return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); } void main() { #include <logdepthbuf_fragment> #include <${revision < 154 ? 'encodings_fragment' : 'colorspace_fragment'}> vec4 c = vColor; if( useAlphaMap == 1. ) c.a *= texture2D( alphaMap, vUV ).r; if( useDash == 1. ){ c.a *= ceil(mod(vCounters + dashOffset, dashArray) - (dashArray * dashRatio)); } gl_FragColor = CustomLinearTosRGB(c); } `;