{"id":16125770,"url":"https://github.com/dy/nogl-shader-output","last_synced_at":"2025-09-12T23:31:00.074Z","repository":{"id":65424814,"uuid":"55087840","full_name":"dy/nogl-shader-output","owner":"dy","description":"Process fragment shader in js","archived":false,"fork":false,"pushed_at":"2016-04-08T04:42:50.000Z","size":35,"stargazers_count":9,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-02T00:03:54.227Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dy.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-30T18:39:27.000Z","updated_at":"2022-10-17T21:41:37.000Z","dependencies_parsed_at":"2023-01-23T10:55:23.499Z","dependency_job_id":null,"html_url":"https://github.com/dy/nogl-shader-output","commit_stats":null,"previous_names":["dfcreative/nogl-shader-output"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fnogl-shader-output","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fnogl-shader-output/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fnogl-shader-output/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dy%2Fnogl-shader-output/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dy","download_url":"https://codeload.github.com/dy/nogl-shader-output/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232797470,"owners_count":18577981,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-09T21:31:47.020Z","updated_at":"2025-01-06T22:54:45.748Z","avatar_url":"https://github.com/dy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Process rectangular shaders without webgl and obtain the result. Can be used for shaders unit testing, audio processing etc. A nogl analog of [gl-shader-output](https://github.com/jam3/gl-shader-output) for node.\n\n\n[![npm install nogl-shader-output](https://nodei.co/npm/nogl-shader-output.png?mini=true)](https://npmjs.org/package/nogl-shader-output/)\n\n\n```js\nvar ShaderOutput = require('nogl-shader-output')\n\n//get a draw function for our test\nvar draw = ShaderOutput(`\n    precision mediump float;\n    uniform float green;\n    void main() {\n        gl_FragColor = vec4(0.0, green, 0.0, 1.0);\n    }\n`, {\n    width: 1,\n    height: 1\n});\n\n//returns the frag color as [R, G, B, A]\nvar color = draw()\n\n//we could also set uniforms before rendering\nvar color2 = draw({ green: 0.5 })\n\n//due to precision loss, you may want to use a fuzzy equality check\nvar epsilon = 1e-5;\nvar almostEqual = require('array-almost-equal')\nalmostEqual(color2, [0.0, 0.5, 0.0, 1.0], epsilon)\n```\n\n## API\n\n#### `draw = ShaderOutput(shader, options?)`\n\nTakes a gl-shader instance or fragment shader source and an options, returns a `draw` function. Possible options:\n\n- `width` the width of a drawing buffer, by default - 1\n- `height` the height of a drawing buffer, by default - 1\n\nThe draw function has the following signature:\n\n```js\nvar fragColor = draw(uniforms?)\n```\n\nWhere `uniforms` is an optional map of uniform names to values (such as `[x, y]` array for vec2), applied before rendering.\n\nThe return value is the gl_FragColor RGBA of the canvas, in floats, such as `[0.5, 1.0, 0.25, 1.0]`.\n\n**Hint:** you can define varyings by passing gl-shader instance with custom vertex shader. To create gl-shader in node, you can use [nogl](https://github.com/dfcreative/nogl):\n\n```js\nvar gl = require('nogl')();\nvar shader = require('gl-shader')(gl, vertexSrc, fragmentSrc);\nvar draw = require('nogl-shader-output')(shader);\n```\n\n\n## Related\n\n* [gl-shader-output](http://npmjs.org/package/gl-shader-output) — a webgl version of fragment shader processor.\n* [audio-shader](https://github.com/audio-lab/audio-shader) — an example case of application of nogl-shader-output for processing audio.\n* [nogl](https://npmjs.org/package/nogl) — WebGL shim for node.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdy%2Fnogl-shader-output","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdy%2Fnogl-shader-output","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdy%2Fnogl-shader-output/lists"}