Hey guys, I need a hand with something.
I've seen shaders where someone was able to override a previously defined function, such as ProcessMaterial, in the case of parallax mapping shaders.
I'm trying to figure out if I can override the ProcessMaterialLight function with my own version. It's essentially a straight carbon copy of the original but with an additional line or two.
But when I try this it tells me the function is already defined. How is this not an issue with the other shaders I've seen that do similar?
Specific Shader Question
Moderators: GZDoom Developers, Raze Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
-
-
- Posts: 3109
- Joined: Sat May 28, 2016 1:01 pm
Re: Specific Shader Question
GZDoom concatenates several lumps into one when generating a shader. It basically creates it out of the following lumps:
1) main.fp
2) one lump containing ProcessMaterialLight for the active material light model ("BRDF"): material_normal.fp, material_specular.fp or material_pbr.fp
3) one lump containing ProcessMaterial for describing the material: func_normal.fp, func_warp.fp, active hardware shader
4) func_defaultlight.fp (not sure why this one exists - looks like some glue that is always included)
So to answer your question, the system allows you to override the material lump but not the light BRDF function. This is a deliberate split as I did not want the internals of the light list become public functionality. It uses a uniform or storage buffer today, but it might use something else tomorrow and if this could be accessed by a mod the engine would be locked into its current choice. The packing of each light would also get stuck in time if user shaders were allowed to edit it.
Note that if you want to override it in a specific way as part of a new PR, then it is known as the 'lightfunc' lump in gl_shader.cpp.
1) main.fp
2) one lump containing ProcessMaterialLight for the active material light model ("BRDF"): material_normal.fp, material_specular.fp or material_pbr.fp
3) one lump containing ProcessMaterial for describing the material: func_normal.fp, func_warp.fp, active hardware shader
4) func_defaultlight.fp (not sure why this one exists - looks like some glue that is always included)
So to answer your question, the system allows you to override the material lump but not the light BRDF function. This is a deliberate split as I did not want the internals of the light list become public functionality. It uses a uniform or storage buffer today, but it might use something else tomorrow and if this could be accessed by a mod the engine would be locked into its current choice. The packing of each light would also get stuck in time if user shaders were allowed to edit it.
Note that if you want to override it in a specific way as part of a new PR, then it is known as the 'lightfunc' lump in gl_shader.cpp.
-
- Posts: 271
- Joined: Mon Jul 13, 2009 3:33 pm
Re: Specific Shader Question
Ok. Thank you for your help.