0.1.3 • Published 7 months ago

@fnet/glsl-processor v0.1.3

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

@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.

0.1.3

7 months ago

0.1.2

7 months ago

0.1.1

7 months ago