Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 10:32
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
6 registered members (AndrewAMD, alibaba, fairtrader, ozgur, TipmyPip, Quad), 604 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
cubic mapping #130683
05/19/07 11:45
05/19/07 11:45
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline OP
Serious User
Scorpion  Offline OP
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
hello folks
here i am with my lil shader i wrote
its new for me to work with structs and i guess i ran there into a small problem...
"undeclared identfier 'cubeCrd'"
what did i do wrong?

Code:
float4x4 matWorldViewProj;
float4x4 matWorld;

float3 vecViewDir;

texture mtlSkin1;
samplerCUBE cubeMap = sampler_state
{
Texture=<mtlSkin1>;
};

struct VSHin
{
float4 pos :POSITION;
float3 normal :NORMAL;
};

struct VSHout
{
float4 pos :POSITION;
float3 cubeCrd :TEXCOORD0;
};

VSHout cubicVS( VSHin IN,
VSHout OUT)
{
OUT.pos = mul(IN.pos,matWorldViewProj);
float3 V = normalize(-vecViewDir);
float3 N = normalize(mul(IN.normal, matWorld));
OUT.cubeCrd = 2*N*(dot(N,V))-V;//here i could use reflect
return OUT;
}

float4 cubicPS(VSHout IN):COLOR
{
return texCUBE(cubeMap,cubeCrd);
}

technique cubemapping
{
pass p0
{
vertexShader = compile vs_1_1 cubicVS();
pixelShader = compile ps_1_1 cubicPS();
}
}








edit:without the structs it works perfect...no one knows where the problem is?
Code:
float4x4 matWorldViewProj;
float4x4 matWorld;

float3 vecViewDir;

texture mtlSkin1;
samplerCUBE cubeMap = sampler_state
{
Texture=<mtlSkin1>;
};

void cubicVS( in float4 pos :POSITION,
in float3 normal :NORMAL,
out float4 oPos :POSITION,
out float3 cubeCrd :TEXCOORD0)
{
oPos = mul(pos,matWorldViewProj);
float3 V = normalize(-vecViewDir);
float3 N = normalize(mul(normal, matWorld));
cubeCrd = 2*N*(dot(N,V))-V;//here i could use reflect
}

float4 cubicPS(in float3 cubeCrd:TEXCOORD0):COLOR
{
return texCUBE(cubeMap,cubeCrd);
}

technique cubemapping
{
pass p0
{
vertexShader = compile vs_1_1 cubicVS();
pixelShader = compile ps_1_1 cubicPS();
}
}



Last edited by Scorpion; 05/19/07 14:28.
Re: cubic mapping [Re: Scorpion] #130684
05/28/07 15:38
05/28/07 15:38
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Try this...

Code:

VSHout cubicVS(VSHin IN)
{
VSHout OUT = (VSHout)0;
...
}




xXxGuitar511
- Programmer
Re: cubic mapping [Re: xXxGuitar511] #130685
05/29/07 01:29
05/29/07 01:29
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline
Expert
Matt_Aufderheide  Offline
Expert
M

Joined: Oct 2003
Posts: 4,131
Quote:

float4 cubicPS(VSHout IN):COLOR
{
return texCUBE(cubeMap,cubeCrd);
}




when using structs like this you must use the struct name you have defined, in this case, "IN"

so basically you use IN.cubeCrd


Sphere Engine--the premier A6 graphics plugin.
Re: cubic mapping [Re: Matt_Aufderheide] #130686
05/29/07 06:11
05/29/07 06:11
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
...or return the struct...

Code:

VSHout cubicVS(VSHin IN)
{
VSHout OUT = (VSHout)0;
...
OUT.texCoord = IN.texCoord;
...
return OUT;
}



Remember that Shaders are CASE-SENSITIVE

Last edited by xXxGuitar511; 05/29/07 06:12.

xXxGuitar511
- Programmer

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | 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