Horde3D
http://horde3d.org/forums/

Only vec4 support on shader uniforms?
http://horde3d.org/forums/viewtopic.php?f=2&t=951
Page 1 of 1

Author:  r3d [ 22.09.2009, 01:55 ]
Post subject:  Only vec4 support on shader uniforms?

Is there a way to pass - for example - float uniforms to the shaders?. I have only found a way to pass vec4 values.

Thanks in advance

Author:  marciano [ 22.09.2009, 20:33 ]
Post subject:  Re: Only vec4 support on shader uniforms?

You can only pass vec4 (=float4) vectors. The hardware does not have single float registers and drivers will probably not compact single float values, so you would waste register space with single floats.

Author:  r3d [ 25.09.2009, 19:14 ]
Post subject:  Re: Only vec4 support on shader uniforms?

And what about passing an array of vec4 like
uniform vec4 samples[16];

Do you suggest it would be better to upload the values to a texture and use a sampler2D (IIRC there is no 1D texture support in Horde3D) ?

Thanks

Author:  marciano [ 27.09.2009, 11:57 ]
Post subject:  Re: Only vec4 support on shader uniforms?

If you have just a few values you could use separate uniforms like sample0, sample1, sample2 etc. but with a huger array this is not very convenient and will not work well if you need to access the array by index. A texture may really be the better idea here. Horde does not have explicit 1D texture support but yo can easiy emulate that with a 2D texture that has just a few pixels of height.

The other thing to keep in mind is that, depending on the hardware, there is only a limited number of vec4 uniforms available (256 for SM3 hardware) and if you use hw skinning a major part of these is already taken.

Author:  r3d [ 27.09.2009, 22:51 ]
Post subject:  Re: Only vec4 support on shader uniforms?

You will have the same problem trying to pass a mat4, splitting the matrix in 4 vec4 and then having to join them in the shader. Well, I know it makes the API bigger and that you aim to simplicity :)

Thanks for you time

Author:  marciano [ 27.09.2009, 23:30 ]
Post subject:  Re: Only vec4 support on shader uniforms?

The purpose of the material uniforms is to expose shader parameters which can be tweaked by artists to customize a shader. Matrices are not a use case for that. More complex constants should usually be managed inside the engine code (for example by an extension) and not using the material system. What do you need these more complex uniforms for?

Author:  DarkAngel [ 28.09.2009, 01:08 ]
Post subject:  Re: Only vec4 support on shader uniforms?

marciano wrote:
The purpose of the material uniforms is to expose shader parameters which can be tweaked by artists to customize a shader. Matrices are not a use case for that. More complex constants should usually be managed inside the engine code (for example by an extension) and not using the material system. What do you need these more complex uniforms for?
Actually, I use user-supplied matrices in my artist-tweakable post-processing shaders.
A matrix can be used to perform colour shifts (e.g. hue, brightness, etc...) on an RGB-vector. It would be nice to be able to upload this as a mat4.

The data that is put in this matrix will be generated by a tool, so it doesn't really matter to my users if 4 vec4's are used instead of a mat4... but it would simplify my code :wink:

Author:  swiftcoder [ 28.09.2009, 02:19 ]
Post subject:  Re: Only vec4 support on shader uniforms?

DarkAngel wrote:
Quote:
What do you need these more complex uniforms for?
Actually, I use user-supplied matrices in my artist-tweakable post-processing shaders. A matrix can be used to perform colour shifts (e.g. hue, brightness, etc...) on an RGB-vector. It would be nice to be able to upload this as a mat4.
I use them as blend weights for RGBA-vectors in various texturing situations. As with DarkAngel, matrix uniforms would simplify the code a bit.

Author:  marciano [ 29.09.2009, 20:10 ]
Post subject:  Re: Only vec4 support on shader uniforms?

DarkAngel and swiftcoder, thanks for your feedback. Hmm yeah, for basic color grading a matrix can makes sense (although I would rather use a 3d texture as LUT - btw 3d texture support is not yet there but should be easy to add).

Ok, we will reconsider support for different uniform types. Actually it is easy but the important thing is that it plays nicely with uniform/constant buffers. All design decisions from now on will be taken with D3D10 in mind.

Author:  r3d [ 29.09.2009, 20:33 ]
Post subject:  Re: Only vec4 support on shader uniforms?

That's great :)

About Directx 10. Have you consider to pass 10 and go directly with 11, that supports different feature level set (10 and 9, for example).

Best regards

Author:  marciano [ 01.10.2009, 20:25 ]
Post subject:  Re: Only vec4 support on shader uniforms?

r3d wrote:
About Directx 10. Have you consider to pass 10 and go directly with 11, that supports different feature level set (10 and 9, for example).

Yeah, that would be the main motivation. But since d3d11 is so similar to 10 regarding the API, I just talk of 10. ;)

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