Page 1 of 1
High Level Shader Language(HLSL) getting parameter?
Posted: Sun Mar 13, 2005 1:46 am
by erbolat
Hi,
I use an HLSL document for my 3D application.
I can set a parameter but i cant get it back. When i call the paramater the value which i send before is returned.
Do you know how can i get parameters from HLSL document. If you want i can send the used code block .
Thanks...
Posted: Sun Mar 13, 2005 6:03 pm
by sinbad
What do you mean 'get' it? Shader parameters are one-way, you send them to the shader, you don't pull them back.
Posted: Sun Mar 13, 2005 8:34 pm
by erbolat
I am trying to get a float parameter.
For example;
I have a box. And i give it a color by randomly.
There is a paramater lets say
float x;
At first i set it 0 from my .cpp code( with SetParamater command);
if any of the pixels get a red color the parameter x becomes 1. And of the HLSL running i want to check if there is any red color and according to this i want do something else...
After the setting parameter and HLSL running i call back it with GetParameter command (I know it is an handle). But the value is always 0 which i assign before. I can see that my application has red colors, too.
How can i solve this porblem?
Posted: Tue Mar 15, 2005 8:33 am
by nfz
As Sinbad said, you can't read back parameters from the GPU that are modified at runtime in a shader. You will always get back what you sent since getParrameter just reads the value in the structure allocated by Ogre.
But maybe I am not understanding what exactly you are trying to do.
Posted: Tue Mar 15, 2005 3:15 pm
by dorvo
If I understand correctly how shaders work, if you pass a value into the shader and it gets modified in either the vertex shader or the fragment shader, it doesn't get stored anywhere... during the next time the frame is rendered, it still takes the data from the vertex buffer (or where ever you have it stored).
So, what nfz said should hold true. Everything that you pass into the shader, if it gets modified, that modified value is only temporary.
But, I could be completely off. This is just what I've deduced from reading books and articles.
Posted: Tue Mar 15, 2005 7:09 pm
by erbolat
Thanks ...
I usderstood your answers.
Is it possible to get store anywhere else my data which i want to know?
Posted: Tue Mar 15, 2005 9:20 pm
by dorvo
There must be some way to do that. But I wouldn't have the slightest clue.
I've heard of shaders being used for physics and collision detection, but I haven't a clue as to what's involved in that.
Posted: Wed Mar 16, 2005 12:48 am
by monster
I believe that some of the approaches that do this (e.g. collision detection on the GPU) work by getting the fragment shader top write to a special texture then reading that texture back into main memory and decoding the pixel values into return parameters.
What is it that you're trying to do? There's almost certainly a simpler approach.