|
nothing happend
#281480
07/27/09 13:56
07/27/09 13:56
|
Joined: Jul 2009
Posts: 10
ProjectB
OP
Newbie
|
OP
Newbie
Joined: Jul 2009
Posts: 10
|
I try different things with glas shaders. My glas shader is:
float4 vecAmbient;
float4 vecDiffuse;
float4 vecSpecular;
float4 vecEmissive;
// transformations
float4x4 matWorld;
float4x4 matWorldViewProj;
float3 vecViewPos;
float4 vecFog;
float4 vecTime;
texture entSkin1;
texture entSkin2;
texture mtlSkin1;
samplerCUBE EnvironmentSampler = sampler_state
{
Texture = <mtlSkin1>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
sampler ColorSampler =sampler_state
{
Texture=<entSkin1>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
sampler NormalSampler =sampler_state
{
Texture=<entSkin2>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
};
// vertex shader output structure
struct VS_OUTPUT
{
float4 Pos : POSITION;
float2 Tex : TEXCOORD0;
float3 Eye : TEXCOORD1;
float3 Norm: TEXCOORD2;
float3 m1: TEXCOORD3;
float3 m2: TEXCOORD4;
float3 m3: TEXCOORD5;
float Fog: FOG;
};
VS_OUTPUT VS(
float4 inPos : POSITION,
float3 inNormal : NORMAL,
float2 inTex : TEXCOORD0,
float3 inTangent : TEXCOORD2)
{
VS_OUTPUT Out = (VS_OUTPUT)0;
float4 Pos = mul(inPos,matWorld);
float3 Normal = normalize(mul(inNormal, (float3x3)matWorld));
Out.Pos = mul(inPos, matWorldViewProj);
Out.Fog = 1 - (distance(Pos, vecViewPos) - vecFog.x) * vecFog.z;
Out.Tex = inTex;
Out.Eye=Pos - vecViewPos;
Out.Norm=Normal;
float3x3 matTangent;
matTangent[0] = mul(inTangent,matWorld);
matTangent[1] = mul(cross(inTangent,inNormal),matWorld); // binormal
matTangent[2] = mul(inNormal,matWorld);
Out.m1=matTangent[0];
Out.m2=matTangent[1];
Out.m3=matTangent[2];
return Out;
}
float4 PS ( VS_OUTPUT In) : COLOR
{
float4 OutColor;
float4 color = tex2D(ColorSampler, In.Tex);
float4 normal = tex2D(NormalSampler, In.Tex)*2-1;
float3x3 toWorld;
toWorld[0]=In.m1;
toWorld[1]=In.m2;
toWorld[2]=In.m3;
float3 norm=mul(normal.xyz,toWorld);
float3 vec = reflect(normalize(In.Eye), norm);
float4 Environment = texCUBE(EnvironmentSampler,vec);
float3 vec2 = refract(normalize(In.Eye), norm, 0.95);
float3 vec3 = refract(normalize(In.Eye), norm, 0.9525);
float3 vec4 = refract(normalize(In.Eye), norm, 0.955);
float4 EnvRefract = float4(texCUBE(EnvironmentSampler,vec2).r,texCUBE(EnvironmentSampler,vec3).g,texCUBE(EnvironmentSampler,vec4).b,1);
float fresnel = 1-(dot(norm,-normalize(In.Eye)));
fresnel=pow(fresnel,1.5);
OutColor.rgb=lerp(color.rgb,EnvRefract,color.a)+Environment.rgb*1*fresnel;
OutColor.a=(1-color.a)+pow(fresnel,0.25);
return OutColor;
}
float4 PS_back( VS_OUTPUT In) : COLOR
{
float4 OutColor;
float4 color = tex2D(ColorSampler, In.Tex);
float3 norm=In.Norm;
float3 vec = reflect(normalize(In.Eye), norm);
float4 Environment = texCUBE(EnvironmentSampler,vec);
float fresnel = 1-abs(dot(norm,-normalize(In.Eye)));
fresnel=0.4+pow(fresnel,1.5);
OutColor.rgb=vecAmbient.rgb*Environment.rgb*1*fresnel;
OutColor.a=(1-color.a);
return OutColor;
}
technique glas
{
pass P0
{
CullMode=cw;
Zenable=true;
ZWriteEnable=true;
VertexShader = compile vs_2_0 VS();
PixelShader = compile ps_2_0 PS_back();
}
pass P1
{
CullMode=ccw;
Zenable=true;
ZWriteEnable=true;
VertexShader = compile vs_2_0 VS();
PixelShader = compile ps_2_0 PS();
}
}
Now i try two methods to use this shader on an object in WED. method 1:
material glas
{
effect = "glas.fx";
}
action shader1 //wird im WED dem Modell zugewiesen
{
my.material = glas;
}
And then I use this material on an simpel block in WED. method 2:
bmap bmp_cubemap=<eigenx.bmp>;
material mat_earth
{
effect="earth_glas.fx";
skin1=bmp_cubemap;
flags=TRANSLUCENT;
ambient_red=200;
ambient_green=180;
ambient_blue=150;
}
action earth
{
my.material=mat_earth;
bmap_to_cubemap(bmp_cubemap);
}
And then I use this material on an simpel block in WED. In both situiation nothing happend with the block, when i compile the scene. What i doing wrong. Can you help me? Thanks.
|
|
|
Re: nothing happend
[Re: Rei_Ayanami]
#281495
07/27/09 14:25
07/27/09 14:25
|
Joined: Jul 2009
Posts: 10
ProjectB
OP
Newbie
|
OP
Newbie
Joined: Jul 2009
Posts: 10
|
|
|
|
Re: nothing happend
[Re: Quad]
#281509
07/27/09 15:06
07/27/09 15:06
|
Joined: Oct 2005
Posts: 4,771 Bay City, MI
lostclimate
Expert
|
Expert
Joined: Oct 2005
Posts: 4,771
Bay City, MI
|
what does version number have to do with it, unless your one of these "detectives" who likes to ask everyone with pro trying to find if they have warez or not. people do own pro. and version number past a7, and comm+ should all run shaders just fine.
|
|
|
|