{"_id":"glsl-fog","_rev":"8-163623edc865c4ba59745bcd1d92e8ad","name":"glsl-fog","description":"Basic fog functions for GLSL: linear, exp and exp2","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.0":{"name":"glsl-fog","description":"Basic fog functions for GLSL: linear, exp and exp2","version":"0.0.0","main":"exp2.glsl","browser":"exp2.glsl","dependencies":{},"devDependencies":{},"scripts":{},"author":{"name":"Hugh Kennedy","email":"hughskennedy@gmail.com","url":"http://github.com/hughsk"},"license":"MIT","repository":{"type":"git","url":"git://github.com/hughsk/glsl-fog"},"bugs":{"url":"https://github.com/hughsk/glsl-fog/issues"},"keywords":["glsl","fog","function","distance","draw","fade","exp2"],"readme":"# glsl-fog [![experimental](http://hughsk.github.io/stability-badges/dist/experimental.svg)](http://github.com/hughsk/stability-badges) #\n\nBasic fog functions for GLSL, generic but intended for use with\n[glslify](http://github.com/chrisdickinson/glslify).\n\n## Usage ##\n\n[![glsl-fog](https://nodei.co/npm/glsl-fog.png?mini=true)](https://nodei.co/npm/glsl-fog)\n\nHere's a hypothetical example of linear fog calculated in a vertex shader:\n\n``` glsl\n#define FOG_START 100\n#define FOG_END 500\n\nvarying float fogAmount;\nuniform vec3 position;\n\n#pragma glslify: fog_linear = require(glsl-fog/linear)\n\nvoid main() {\n  gl_Position = projection * view * model * vec4(positon, 1.0);\n  float fogDistance = length(gl_Position.xyz);\n  fogAmount = fog_linear(fogDistance, FOG_START, FOG_END);\n}\n```\n\nAnd another (separate) example using exp/exp2 per-pixel fog:\n\n``` glsl\n#define FOG_DENSITY 0.05\n\nvarying vec4 vertexColor;\n\n// Take your pick: these should be usable interchangeably.\n#pragma glslify: fog_exp2 = require(glsl-fog/exp2)\n#pragma glslify: fog_exp = require(glsl-fog/exp)\n\nvoid main() {\n  float fogDistance = gl_FragCoord.z / gl_FragCoord.w;\n  float fogAmount = fog_exp2(fogDistance, FOG_DENSITY);\n  const float fogColor = vec4(1.0); // white\n\n  gl_FragColor = mix(vertexColor, fogColor, fogAmount);\n}\n```\n\n## License ##\n\nMIT. See [LICENSE.md](http://github.com/hughsk/glsl-fog/blob/master/LICENSE.md) for details.\n","readmeFilename":"README.md","_id":"glsl-fog@0.0.0","dist":{"shasum":"14146e7afc478ec448ad21888afeb71befa4ba0c","tarball":"https://registry.npmjs.org/glsl-fog/-/glsl-fog-0.0.0.tgz","integrity":"sha512-o9noZwrEkwByjSpFvKbtZwU3jGodHl6eR0xDrnqWOPwaVbAfwHyxw1rLL+mZSgTyriHW3ehsyrHPk1pFrH6EOg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGmXlr4c+BZjlLMG73+qenvelcInxGFnFQrGM5XMAjADAiBu3RuGUDmkz/4+/WgYFvQ6rzrV7bcEAjpGMtv2JIre0g=="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"hughsk","email":"hughskennedy@gmail.com"},"maintainers":[{"name":"hughsk","email":"hughskennedy@gmail.com"}]},"0.0.1":{"name":"glsl-fog","description":"Basic fog functions for GLSL: linear, exp and exp2","version":"0.0.1","main":"exp2.glsl","browser":"exp2.glsl","dependencies":{},"devDependencies":{},"scripts":{},"author":{"name":"Hugh Kennedy","email":"hughskennedy@gmail.com","url":"http://github.com/hughsk"},"license":"MIT","repository":{"type":"git","url":"git://github.com/hughsk/glsl-fog"},"bugs":{"url":"https://github.com/hughsk/glsl-fog/issues"},"keywords":["glsl","fog","function","distance","draw","fade","exp2"],"readme":"# glsl-fog [![experimental](http://hughsk.github.io/stability-badges/dist/experimental.svg)](http://github.com/hughsk/stability-badges) #\n\nBasic fog functions for GLSL, generic but intended for use with\n[glslify](http://github.com/chrisdickinson/glslify).\n\n## Usage ##\n\n[![glsl-fog](https://nodei.co/npm/glsl-fog.png?mini=true)](https://nodei.co/npm/glsl-fog)\n\nHere's a hypothetical example of linear fog calculated in a vertex shader:\n\n``` glsl\n#define FOG_START 100\n#define FOG_END 500\n\nuniform mat4 projection;\nuniform mat4 view;\nuniform mat4 model;\n\nattribute vec3 position;\nvarying float fogAmount;\n\n#pragma glslify: fog_linear = require(glsl-fog/linear)\n\nvoid main() {\n  gl_Position = projection * view * model * vec4(positon, 1.0);\n  float fogDistance = length(gl_Position.xyz);\n  fogAmount = fog_linear(fogDistance, FOG_START, FOG_END);\n}\n```\n\nAnd another (separate) example using exp/exp2 per-pixel fog:\n\n``` glsl\n#define FOG_DENSITY 0.05\n\nvarying vec4 vertexColor;\n\n// Take your pick: these should be usable interchangeably.\n#pragma glslify: fog_exp2 = require(glsl-fog/exp2)\n#pragma glslify: fog_exp = require(glsl-fog/exp)\n\nvoid main() {\n  float fogDistance = gl_FragCoord.z / gl_FragCoord.w;\n  float fogAmount = fog_exp2(fogDistance, FOG_DENSITY);\n  const float fogColor = vec4(1.0); // white\n\n  gl_FragColor = mix(vertexColor, fogColor, fogAmount);\n}\n```\n\n## License ##\n\nMIT. See [LICENSE.md](http://github.com/hughsk/glsl-fog/blob/master/LICENSE.md) for details.\n","readmeFilename":"README.md","_id":"glsl-fog@0.0.1","dist":{"shasum":"e104daba4343c74ea94038a41b3dd971d57372ee","tarball":"https://registry.npmjs.org/glsl-fog/-/glsl-fog-0.0.1.tgz","integrity":"sha512-iWsoojWRORUxvj5YiutFKchrWbSAumU/uMHB+6ub6f85OJ5KzNtebVhUJMMBhZ/d3P0mEWvGkLI69IALtxDURg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDUCAJeieMJPtlLtX48yqKS6nadX7yLd+hFyaaipIRuBgIgM5J2qCos/LuMmIeG3g5zPZoYKYWO2bwrVHO++gghBcE="}]},"_from":".","_npmVersion":"1.3.11","_npmUser":{"name":"hughsk","email":"hughskennedy@gmail.com"},"maintainers":[{"name":"hughsk","email":"hughskennedy@gmail.com"}]}},"readme":"# glsl-fog [![experimental](http://hughsk.github.io/stability-badges/dist/experimental.svg)](http://github.com/hughsk/stability-badges) #\n\nBasic fog functions for GLSL, generic but intended for use with\n[glslify](http://github.com/chrisdickinson/glslify).\n\n## Usage ##\n\n[![glsl-fog](https://nodei.co/npm/glsl-fog.png?mini=true)](https://nodei.co/npm/glsl-fog)\n\nHere's a hypothetical example of linear fog calculated in a vertex shader:\n\n``` glsl\n#define FOG_START 100\n#define FOG_END 500\n\nvarying float fogAmount;\nuniform vec3 position;\n\n#pragma glslify: fog_linear = require(glsl-fog/linear)\n\nvoid main() {\n  gl_Position = projection * view * model * vec4(positon, 1.0);\n  float fogDistance = length(gl_Position.xyz);\n  fogAmount = fog_linear(fogDistance, FOG_START, FOG_END);\n}\n```\n\nAnd another (separate) example using exp/exp2 per-pixel fog:\n\n``` glsl\n#define FOG_DENSITY 0.05\n\nvarying vec4 vertexColor;\n\n// Take your pick: these should be usable interchangeably.\n#pragma glslify: fog_exp2 = require(glsl-fog/exp2)\n#pragma glslify: fog_exp = require(glsl-fog/exp)\n\nvoid main() {\n  float fogDistance = gl_FragCoord.z / gl_FragCoord.w;\n  float fogAmount = fog_exp2(fogDistance, FOG_DENSITY);\n  const float fogColor = vec4(1.0); // white\n\n  gl_FragColor = mix(vertexColor, fogColor, fogAmount);\n}\n```\n\n## License ##\n\nMIT. See [LICENSE.md](http://github.com/hughsk/glsl-fog/blob/master/LICENSE.md) for details.\n","maintainers":[{"name":"hughsk","email":"hughskennedy@gmail.com"}],"time":{"modified":"2022-06-18T13:00:44.935Z","created":"2013-10-11T01:20:43.425Z","0.0.0":"2013-10-11T01:20:48.361Z","0.0.1":"2013-10-11T01:23:43.559Z"},"author":{"name":"Hugh Kennedy","email":"hughskennedy@gmail.com","url":"http://github.com/hughsk"},"repository":{"type":"git","url":"git://github.com/hughsk/glsl-fog"},"users":{"mystaticself":true}}