Restructuring shader generation in ofMaterial #7802
Replies: 1 comment
-
@neilmendoza thank you for your thoughts on this! It has been an interesting task tying in the complexity that comes with shadows and PBR rendering with the goal of creating something that is flexible to use, fast (enough ;) and runs on all of the supported platforms and GL versions. There is definitely room for improvement as it feels a bit hard to read and follow as the generated shaders are scattered throughout the OF project.
Ah yes, with the current setup, a shader per texture type, this might be tricky but the ability should be supported.
There needs to be some documentation on this, down to the OF shader level, ie. the uniforms that are set by OF. The shadow frag shader needs certain vars to write proper depth to the output fbo. There are a lot of functions available for the material shaders that need to be documented ( outside of just the examples ) to properly understand the structure of the shader.
This should be fixed now, thank you for mentioning it at an earlier time :)
That is strange and confusing and should be remedied!
Hmm, I think you need to call You should be able to set uniforms while the shader is bound, but not create new ones ( maybe not textures though :0 Some gpus did not like if a texture was not set) The materialPBRExample should demonstrate this:
Yes, I love this idea and have been thinking about something similar for a while but am unsure about the best approach. Decoupling renderer specific code ( ie glsl shader code, GL fbo code, etc. ) from classes to hold data only would help with future renderers as well. It seems like it would be easier to include shaders/shadow/shadowFunctions.glsl or something similar in your glsl shader, but then those shaders would have to be exposed somehow. They are in various places throughout the project and mostly dynamically generated or configured, so it's hard to decipher and understand. A few ways that shaders are currently being constructed or dynamically created:
Wondering if a large shader for ofMaterial that activates pieces of code via defines would make the code more readable or just too overwhelming. The pieces of code could be separated into files and included based on what is needed. So the code would be in the separated files and not spread throughout ofMaterial.
Would love a way to have a shader as you would normally use it, but include bits of shader code regarding PBR, etc. The shader files for PBR are broken up to be included in such a manner. It also includes functions to create and configure materials, etc. However, the only way to access it easily is via ofMaterial. And then you must set a shader main on |
Beta Was this translation helpful? Give feedback.
-
I’m super psyched that PBR materials with shadows are part of OF now. Thanks for all the hard work that went into this @NickHardeman! After having played around, I have a few ideas that could make it more usable and offer something unique that’s not available in any other coding framework or game engine.
The thing that’s always drawn me back to OF is its hackability and that it doesn’t add unnecessary complexity on top of the underlying APIs and libraries it uses. I felt like with the shadow/PBR (and to some extent the renderer abstraction) code, there was a slight shift towards hiding complexity at the expense of flexibility (in day to day use rather than writing a new renderer). When doing anything out of the ordinary with custom shaders and shadows, you need a lot of knowledge about what OF is doing under the hood to avoid gotchas. For instance…
It’s been a couple of months since I was deep in openFrameworks land so the details are a little hazy but it felt like there was an extra level of indirection that we could get rid of with a little restructuring. Maybe that could be a combination of any of the following…
Beta Was this translation helpful? Give feedback.
All reactions