UstymUkhman / vite-plugin-glsl

:spider_web: Import, inline (and compress) GLSL shader files :electric_plug:
https://www.npmjs.com/package/vite-plugin-glsl
MIT License
319 stars 21 forks source link

How to handle #include conflicts (function already has a body)? #57

Closed misaelvillaverde closed 3 months ago

misaelvillaverde commented 3 months ago

Hello, awesome library. I got this on my vertex.glsl

#include ../partials/perlin3d;
#include ../partials/perlin4d;

void main() {
    . . .
}

The issue is that perlin3d and perlin4d share some functions, how would you handle the conflict?

Should I separate the functions into another file and include it each time I call perlin3d or perlin4d?

Error: CleanShot 2024-08-08 at 20 47 17@2x

UstymUkhman commented 3 months ago

Hi @misaelvillaverde, thanks! And thanks for your star. Yes, you are correct. As explained here, this plugin does not create any scope for variables or functions defined within one chuck. So basically, you should rename at least one of those functions to avoid naming conflicts.