problem in assign shader in ofusion

at2142

05-11-2008 09:49:44

hi,
sorry,i'm not write English very vel
i have one shader,this shader write with cg programing,
in time use shader in ofusion i have error in PS code,
please look at code me.
'''''''
void ETDynLighting_fp
(
float2 uv : TEXCOORD0,
float4 position : TEXCOORD1,
float3 normal : TEXCOORD2,
float4 lightPos : TEXCOORD3,
float3 eyePos : TEXCOORD4,
float3 tangent : TEXCOORD5,

uniform sampler2D covMap1,
uniform sampler2D covMap2,
uniform sampler2D splat1,
uniform sampler2D splat2,
uniform sampler2D splat3,
uniform sampler2D splat4,
uniform sampler2D splat5,
uniform sampler2D splat6,

uniform float splatScaleX,
uniform float splatScaleZ,

uniform float4 lightDiffuse,
uniform float4 lightSpecular,
uniform float exponent,
uniform float4 ambient,

out float4 oColor : COLOR
)
{
float3 cov1 = tex2D(covMap1, uv).rgb;
float3 cov2 = tex2D(covMap2, uv).rgb;
uv.x *= splatScaleX;
uv.y *= splatScaleZ;
float3 normModifier = tex2D(splat1, uv) * cov1.x
+ tex2D(splat2, uv) * cov1.y
+ tex2D(splat3, uv) * cov1.z
+ tex2D(splat4, uv) * cov2.x
+ tex2D(splat5, uv) * cov2.y
+ tex2D(splat6, uv) * cov2.z;

normModifier = normModifier.xzy;

float3 binormal = cross(tangent, normal);
// Form a rotation matrix out of the vectors
float3x3 rotation = float3x3(tangent, binormal, normal);
normModifier = mul(rotation, normModifier);

normModifier = normalize(normModifier);

float3 EyeDir = normalize(eyePos - position.xyz);
float3 LightDir = lightPos.xyz - (position * lightPos.w);
float dist = length(LightDir);
// Normalize this way since we already found the magnitude
LightDir = LightDir / dist;
float3 HalfAngle = normalize(LightDir + EyeDir);

normal = normalize(normal);
normal = normal + normModifier;
normal = normalize(normal);
float NdotL = max(dot(LightDir, normal), 0.0);
float NdotH = max(dot(HalfAngle, normal), 0.0);
//float NdotL = max(dot(LightDir, normModifier), 0.0);
//float NdotH = max(dot(HalfAngle, normModifier), 0.0);
float4 Lit = lit(NdotL, NdotH, exponent);

oColor = lightDiffuse * Lit.y + lightSpecular * Lit.z + ambient;
// Taking the ambient component out here and doing an ambient pass first,
// then doing additive lighting passes looks like shit for some reason.
// Look into this later... this method only looks good with only 1 light.
//oColor = lightDiffuse * Lit.y + lightSpecular * Lit.z;



// Attenuation stuff. Probably put this in the vp if I ever go back to it
//float fLuminence = 1 / (atten.y + atten.z * dist + atten.w * dist * dist);
//oColor = ambient + (fLuminence * (lightDiffuse * Lit.y + lightSpecular * Lit.z));
//oColor = ambient + (fLuminence * (lightDiffuse * NdotL + lightSpecular * NdotH));

}
tanks.

Lioric

13-11-2008 16:21:30

The shader seems to be mostly correct, what is the error when you load this shader? any specific error message or could you provide more details about your issue?

What exactly is not working, loading it or displaying it?

Why do you use the TEXCOORDn buffers to pass position and tangents and not the POSITION and TANGENT buffers?