Horde3D

Next-Generation Graphics Engine
It is currently 30.11.2024, 05:53

All times are UTC + 1 hour




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: 22.09.2009, 01:55 
Offline

Joined: 09.09.2009, 00:13
Posts: 12
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

_________________
r3D^rgba


Top
 Profile  
Reply with quote  
PostPosted: 22.09.2009, 20:33 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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.


Top
 Profile  
Reply with quote  
PostPosted: 25.09.2009, 19:14 
Offline

Joined: 09.09.2009, 00:13
Posts: 12
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

_________________
r3D^rgba


Top
 Profile  
Reply with quote  
PostPosted: 27.09.2009, 11:57 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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.


Top
 Profile  
Reply with quote  
PostPosted: 27.09.2009, 22:51 
Offline

Joined: 09.09.2009, 00:13
Posts: 12
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

_________________
r3D^rgba


Top
 Profile  
Reply with quote  
PostPosted: 27.09.2009, 23:30 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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?


Top
 Profile  
Reply with quote  
PostPosted: 28.09.2009, 01:08 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
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:


Top
 Profile  
Reply with quote  
PostPosted: 28.09.2009, 02:19 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
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.

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
PostPosted: 29.09.2009, 20:10 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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.


Top
 Profile  
Reply with quote  
PostPosted: 29.09.2009, 20:33 
Offline

Joined: 09.09.2009, 00:13
Posts: 12
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

_________________
r3D^rgba


Top
 Profile  
Reply with quote  
PostPosted: 01.10.2009, 20:25 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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. ;)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 20 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group