{"id":20373291,"url":"https://github.com/tntmeijs/glsl-shader-includes","last_synced_at":"2025-09-08T10:32:47.564Z","repository":{"id":140229736,"uuid":"129247292","full_name":"tntmeijs/GLSL-Shader-Includes","owner":"tntmeijs","description":"A utility class which adds a way to include external files in a shader file.","archived":false,"fork":false,"pushed_at":"2024-07-01T18:37:37.000Z","size":8,"stargazers_count":60,"open_issues_count":1,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-27T02:06:49.498Z","etag":null,"topics":["glsl","graphics-programming","opengl","shaders","source-code"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tntmeijs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-12T12:24:57.000Z","updated_at":"2024-11-20T17:33:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"16a102c6-02cf-4bf0-b9bf-3aef680ed39d","html_url":"https://github.com/tntmeijs/GLSL-Shader-Includes","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tntmeijs%2FGLSL-Shader-Includes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tntmeijs%2FGLSL-Shader-Includes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tntmeijs%2FGLSL-Shader-Includes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tntmeijs%2FGLSL-Shader-Includes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tntmeijs","download_url":"https://codeload.github.com/tntmeijs/GLSL-Shader-Includes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232302276,"owners_count":18502114,"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":["glsl","graphics-programming","opengl","shaders","source-code"],"created_at":"2024-11-15T01:17:34.926Z","updated_at":"2025-01-03T06:47:55.093Z","avatar_url":"https://github.com/tntmeijs.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GLSL Shader Includes\nA utility class which allows the end user to make use of the include statement in a shader file.\nThis is a C++ class but any programmer that has basic knowledge of his / her programming language of choice, should be able to quickly convert the code to another language within a couple minutes. It is that simple.\n\n### Introduction\nThe sole purpose of this class is to load a file and extract the text that is in it. In theory, this class could be used for a variety of text-processing purposes, but it was initially designed to be used to load shader source code for GLSL, as it does not have a built-in function that lets you include another source files easily.\n\n### Using this class\nSince the entire class is a static class, you only have to add this to to your project:\n\n```cpp\n#include \"Shadinclude.hpp\"\n```\n```cpp\nstd::string shaderSource = Shadinclude::load(\"./path/to/shader.extension\", \"customKeyword\");\n```\n\nThis will (recursively) extract the source code from the first shader file.\n\nNow, you might be wondering, what is the point of using your code for something so trivial as to loading a file and calling the \"std::getline()\" function on it?\n\nWell, besides loading the shader source code from a single file, the loader also supports custom keywords that allow you to include external files inside your shader source code! Since all of this loading is still fairly trivial but cumbersome to write over and over again, it has been uploaded to this repository for you to use.\n\n### Example\n*Vertex shader [./resources/shaders/basic.vs]*\n```glsl\n#version 330 core\nlayout (location = 0) in vec3 position;\n\n// Include other files\n#include include/functions.incl\n#include include/uniforms.incl\n\nvoid main()\n{\n    position += doFancyCalculationA() * offsetA;\n    position += doFancyCalculationB() * offsetB;\n    position += doFancyCalculationC() * offsetC;\n\n    gl_Position = vec4(position, 1.0);\n}\n```\n\n*Utility functions [./resources/shaders/include/functions.incl]*\n```glsl\nvec3 doFancyCalculationA()\n{\n    return vec3(1.0, 0.0, 1.0);\n}\n\nvec3 doFancyCalculationB()\n{\n    return vec3(0.0, 1.0, 0.0);\n}\n\nvec3 doFancyCalculationC()\n{\n    return vec3(0.0, 0.0, 1.0);\n}\n```\n\n*Uniforms [./resources/shaders/include/uniforms.incl]*\n```glsl\nuniform vec3 offsetA;\nuniform vec3 offsetB;\nuniform vec3 offsetC;\n```\n\n*Result*\n```glsl\n#version 330 core\nlayout (location = 0) in vec3 position;\n\nvec3 doFancyCalculationA()\n{\n    return vec3(1.0, 0.0, 1.0);\n}\n\nvec3 doFancyCalculationB()\n{\n    return vec3(0.0, 1.0, 0.0);\n}\n\nvec3 doFancyCalculationC()\n{\n    return vec3(0.0, 0.0, 1.0);\n}\n\nuniform vec3 offsetA;\nuniform vec3 offsetB;\nuniform vec3 offsetC;\n\nvoid main()\n{\n    position += doFancyCalculationA() * offsetA;\n    position += doFancyCalculationB() * offsetB;\n    position += doFancyCalculationC() * offsetC;\n\n    gl_Position = vec4(position, 1.0);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftntmeijs%2Fglsl-shader-includes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftntmeijs%2Fglsl-shader-includes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftntmeijs%2Fglsl-shader-includes/lists"}