Color_Shader Question

About Truespace Archives

These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.

They are retained here for archive purposes only.

Color_Shader Question // Tech Forum

1  |  

Post by GraySho // Feb 7, 2009, 1:44pm

GraySho
Total Posts: 695
pic
I have a basic question, but it´s driving me nuts. I´m experimenting with HLSL and tried to define a shader color with a simple script, but all I get is grayscale colors. The simple code of the brick is the following:



void ColorScript(out RtFloat3 outColor)

{

outColor.r = 255;

outColor.g = 255;

outColor.b = 0;

}


Theoretically this should give me a yellow color?

I hook it up to the ShaderColor Brick within the Color_Shader but it does nothing but like "invert" the light direction (which might be a result of my shader experiments before).


What am I doing wrong??


http://www.spacerat.at/truespace/color_issue.jpg

Post by Jack Edwards // Feb 7, 2009, 3:53pm

Jack Edwards
Total Posts: 4062
pic
The values should be HDR float values so like this:

void ColorScript(out RtFloat4 outColor)
{
outColor.r = 1.0;
outColor.g = 1.0;
outColor.b = 0;
outColor.a = 1.0;
}
My guess is that with alpha at 0.0 you get black. ;) Haven't tested to make sure, but that's my quick guess.

Post by parva // Feb 8, 2009, 12:08am

parva
Total Posts: 822
pic
You have to convert the 255 rgb color table to a range between 0 and 1.

That means that 255 is 1 like Jack said.


If one Color value is 140 you get 140 / 255 = 0.54901


alpha 0 or 1 does only matter if you use an alpha channel

otherwise you can also use a float3 instead like you already had.

Post by GraySho // Feb 8, 2009, 2:27am

GraySho
Total Posts: 695
pic
OK, now I feel a bit stupid :D but changing the values to ranges within 0 and 1.0 does nothing, I still get the same result, as if some old test scripts would remain active. Maybe I have to start a new scene and try from scratch.

Post by Johny // Feb 8, 2009, 2:59am

Johny
Total Posts: 672
pic
You need to disconect wire link, then reconect it again for refresh/see the new result on LE view.

Post by parva // Feb 8, 2009, 3:17am

parva
Total Posts: 822
pic
refreshing is a bit odd indeed.

There are several ways, disconnecting-connecting is one but time consuming.


Another way is, if you have some brick with an input attached (a float integer where you can enter a description or a bitmap node where you can change settings), just change one attribute of these so that an update is forced through the pipeline.


For myself I use 2 LE windows, one for HLSL and the second for LE.

If I do changes in the HLSL script just hit "syntax check and commit" and hit enter in an attached brick at the LE.

So you don't need to leave the HLSL script and can update in realtime.

Post by Johny // Feb 8, 2009, 3:51am

Johny
Total Posts: 672
pic
....
For myself I use 2 LE windows, one for HLSL and the second for LE.
If I do changes in the HLSL script just hit "syntax check and commit" and hit enter in an attached brick at the LE.
So you don't need to leave the HLSL script and can update in realtime.
Thanks for this clever idea Parva. :)
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn