-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
preprocessor definitions inside a shadermaterial #2412
Comments
I was already thinking about something like that, just it would be probably simpler, just passing in values for defines somehow, not any explicit interaction with uniforms. Anyways unused uniforms should be detectable from GL API (we already use this quite a lot). |
…Material. For the moment tried to keep it as dumb as possible: one string for define label, another string for define value. I'm not yet fully sure of all the details but that's something I wanted to do for a long time, to be able to have user-configurable way for baked-in parameters (for use cases like the convolution filter). See mrdoob#2412
I would love to have an update where it is possible to have preprocessor variables without a value.
|
@gero3 I think it's better as it's now. It's more explicit and easier to understand/learn as it currently is. |
@gero3 So if I understood well your use case, what you would actually need is not to generate any function generateDefines ( defines ) {
var value, chunk, chunks = [];
for ( var d in defines ) {
value = defines[ d ];
if ( value === false ) continue;
chunk = "#define " + d + " " + value;
chunks.push( chunk );
}
return chunks.join( "\n" );
}; |
indeed as it makes more sense for boolean values |
Yup, this should also work for So we would get this:
This would lead to nicer shader code than getting |
Ah, I see. Makes sense. |
See discussion mrdoob#2412
…ions to ShaderMaterial. For the moment tried to keep it as dumb as possible: one string for define label, another string for define value. I'm not yet fully sure of all the details but that's something I wanted to do for a long time, to be able to have user-configurable way for baked-in parameters (for use cases like the convolution filter). See mrdoob#2412
Introduction
This is a suggestion on how we could make use of preprocessor definitions inside a shadermaterial.
Why
I needed a shadermaterial that had more then 16 texture uniforms defined but depending on the configuration of my application only used 16 or less texture uniforms. So I needed the rebuild my shader sourcecode programmatically or I could make a definition system which used preprocessor definitions.
How
We add a new property to the object to define the preprocessor definitions called 'defines'. We also add another property to the uniforms called 'defined' which indicate by which preprocessor definitions they are defined.
Example
Consequence
The text was updated successfully, but these errors were encountered: