High Level Shader Language(HLSL) getting parameter?

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
Post Reply
erbolat
Gnoblar
Posts: 3
Joined: Sun Mar 13, 2005 1:43 am

High Level Shader Language(HLSL) getting parameter?

Post 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...
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67
Contact:

Post 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.
erbolat
Gnoblar
Posts: 3
Joined: Sun Mar 13, 2005 1:43 am

Post 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?
nfz
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 1263
Joined: Wed Sep 24, 2003 4:00 pm
Location: Halifax, Nova Scotia, Canada

Post 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.
dorvo
Halfling
Posts: 68
Joined: Tue Nov 02, 2004 8:01 pm

Post 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.
erbolat
Gnoblar
Posts: 3
Joined: Sun Mar 13, 2005 1:43 am

Post by erbolat »

Thanks ...
I usderstood your answers.

Is it possible to get store anywhere else my data which i want to know?
dorvo
Halfling
Posts: 68
Joined: Tue Nov 02, 2004 8:01 pm

Post 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.
User avatar
monster
OGRE Community Helper
OGRE Community Helper
Posts: 1098
Joined: Mon Sep 22, 2003 2:40 am
Location: Melbourne, Australia
Contact:

Post 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.
Post Reply