Horde3D
http://horde3d.org/forums/

Shader selection based on available OpenGL extensions
http://horde3d.org/forums/viewtopic.php?f=8&t=521
Page 1 of 1

Author:  phoenix64 [ 04.10.2008, 18:44 ]
Post subject:  Shader selection based on available OpenGL extensions

With my work on Shadow Mapping for point lights, I just saw that it might be good to be able to write more than just one shader for a material, with one shader being a fallback for every hardware, and others being chosen based on the available extensions. I atm didn't see any si9mple way to do this in Horde3D, if there is one, correct me.
(When thinking about this, I though about the depth cubemaps provided with EXT_gpu_shader4, though they are no good example for this as they also depend on changes on the C++ side of the things, when used, they might make things quite a bit easier though)

I thought about a setup like this in the shader file:
Code:
[...]
<Context id="OVERLAY">
<Variant priority = "0">
<VertexShader>
[...]
</VertexShader>
<FragmentShader>
[...]
</FragmentShader>
</Variant>
<Variant priority = "1" extension="EXT_gpu_shader4">
[...]
</Variant>
</Context>
[...]

This would just execute the variant of the shader with the highest priority which is available with the given extensions.

If this is a bad idea, just say so, but I though this might be handy.

Author:  marciano [ 04.10.2008, 21:26 ]
Post subject:  Re: Shader selection based on available OpenGL extensions

The current solution for slightly different hardware caps is using #ifdefs in the shader (ubershader approach). There is an API function setShaderPreambles with which you can define a common header for all shaders. You can put #defines there depending on the hardware configuration. Is that sufficient for your needs?

Author:  phoenix64 [ 04.10.2008, 21:27 ]
Post subject:  Re: Shader selection based on available OpenGL extensions

Yeah, probably it is :)

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/