@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
2 lines (1 loc) • 1.2 kB
JavaScript
export default "uniform bool useVertexColor;\nuniform vec3 globalColor;\nuniform sampler2D tDiffuse;\nvarying vec4 vUv;\nuniform float opacity;\nuniform float reflectionBlend;\nvarying vec3 vertexColor;\n\n#include <logdepthbuf_pars_fragment>\n\nfloat blendOverlay( float base, float blend ) {\n\n return( base < 0.5 ? ( 2.0 * base * blend ) : ( 1.0 - 2.0 * ( 1.0 - base ) * ( 1.0 - blend ) ) );\n\n}\n\nvec3 blendOverlay( vec3 base, vec3 blend ) {\n\n return vec3( blendOverlay( base.r, blend.r ), blendOverlay( base.g, blend.g ), blendOverlay( base.b, blend.b ) );\n\n}\n// TODO: add fresnel to blend with another material (maybe integrate this with material builders?)\n// TODO: use fresnel to modulate alpha, so that we can see through when viewed at perpendicular angle, but not parallel\nvoid main() {\n\n #include <logdepthbuf_fragment>\n\n vec3 definedColor = useVertexColor ? vertexColor * globalColor : globalColor;\n vec3 base = texture2DProj( tDiffuse, vUv ).rgb * definedColor;\n // gl_FragColor = vec4( blendOverlay( base.rgb, color ), opacity );\n vec3 finalColor = reflectionBlend * base + (1.-reflectionBlend) * definedColor;\n gl_FragColor = vec4( finalColor, opacity );\n\n}";