Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,561 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Incorrect use of vecSkill? #187641
03/09/08 00:43
03/09/08 00:43
Joined: Mar 2007
Posts: 677
0x00000USA
M
MrCode Offline OP
User
MrCode  Offline OP
User
M

Joined: Mar 2007
Posts: 677
0x00000USA
Either I'm doing it completely wrong, or the manual is wrong about how to use vecSkill1-4 in shader code.

according to the manual:

Quote:


float4 vecskill1; // shader code: define the vector
...
float fValue = vecSkill1.x; // fValue now contains 1.5





and here's one of my shader codes, done exactly the same way:

Code:

float4 vecSkill1;

float contrast= vecSkill1.x; //a tweakable

//YOU DON'T WANNA SCREW WITH THIS STUFF! ;)
float4 vecViewPort;
texture TargetMap;
sampler TargetSampler= sampler_state {texture= <TargetMap>;};

//the shader function
float4 Shader_PPS(float2 tex :TEXCOORD0):COLOR0
{
float4 color= float4(0.5,0.5,0.5,1.0);
color= tex2D(TargetSampler,tex.xy);
if(color.r < (contrast / 100)) //if the red value of each pixel is less than 65 / 100= 0.65...
color.r= 0.0; //nullify it.
if(color.g < (contrast / 100)) //same here with green
color.g= 0.0; //ditto
if(color.b < (contrast / 100)) //"
color.b= 0.0; //"
return color; //give the result; render it to the screen.
}

technique postprocess
{
pass p0
{
Lighting= False;
PixelShader= compile ps_2_0 Shader_PPS(); //compile the shader function using Shader Model 2.0.
}
}



When I try to run my program, however, I get an "Error in effect" message (about 3 times) saying that my float definitions (the ones with vecSkill1.x) have to be literals.

Am I doing this completely wrong?


Code:
void main()
{
    cout << "I am MrCode,";
    cout << "hear me roar!";
    system("PAUSE");
}
Re: Incorrect use of vecSkill? [Re: MrCode] #187642
03/09/08 07:55
03/09/08 07:55
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
Just like in C, you can't make assignments from variables (as opposed to literals) outside of a function. If you want to use vecSkill1.x as contrast, either use it directly in your function or rename it with a define.

The variable declarations outside of a function are processed at compile time, and the compiler doesn't know the value of vecSkill1.x at compile time yet.


Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1