Gamestudio Links
Zorro Links
Newest Posts
Camera always moves upwards?
by NeoDumont. 02/17/26 15:40
Hedge on FXCM, 4 or 5?
by Martin_HH. 02/16/26 16:09
Zorro version 3.0 prerelease!
by jcl. 02/12/26 14:05
MarginCost discrepancy?
by jcl. 02/12/26 14:02
CMC MT4 CFD vs FX Active - what's better?
by mayarik. 02/11/26 11:00
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (qin), 8,797 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 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