@fnet/glsl-processor
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

@fnet/glsl-processor

The project related to the source code provided is @fnet/glsl-processor. This project functions as a GLSL (OpenGL Shading Language) program code handler, designed to parse, manipulate, and generate GLSL source code. It leverages a package called ShaderFrog GLSL Parser.

Functionality

Primarily, this GLSL processor operates in three core stages: Parsing, Resolving Includes, and Code Generation.

  • Parsing: In this stage, the processor tackles the received GLSL source code, converting it into an Abstract Syntax Tree (AST), which is a neat representation of the program's structure.

  • Resolving Includes: Once the AST is obtained, the processor attempts to resolve any #include directives contained within the initial source code. These instructions indicate that the content of another file should be inserted at that particular point in the source code. @fnet/glsl-processor is capable of handling these instructions and properly integrates the content from other files.

  • Code Generation: After all #include directives are resolved, the processor generates the modified GLSL source code back from the manipulated AST and finally returns the transpiled source code.

Thus, the main purpose of @fnet/glsl-processor is to allow for handling and editing GLSL source code programmatically, taking care of resolving dependencies, and offering the necessary infrastructure to make further transformations or analyses on the GLSL code. This makes it a valuable tool for developing graphical applications where GLSL shader manipulation may be required.

Usage

From an end-user perspective, using @fnet/glsl-processor involves providing the necessary GLSL file and a specific fileLoader function while calling the index function. The fileLoader works as a custom file loading mechanic, and should be a function that takes a filename and returns the content of that file. This function is used to load any files referenced by #include directives. Upon execution, @fnet/glsl-processor returns the transpiled GLSL code.

Readme

Keywords

none

Package Sidebar

Install

npm i @fnet/glsl-processor

Weekly Downloads

0

Version

0.1.3

License

MIT

Unpacked Size

547 kB

Total Files

8

Last publish

Collaborators

  • serdark
  • serdar986
  • gboyraz