|
|
把waterworld改到OpenGL下,顶点渲染可以了,但着色一直不行,这是fragment的代码:
struct PS_INPUT {
float2 tcBump0 : TEXCOORD0; //texture coordinates
float2 tcBump1 : TEXCOORD1; //texture coordinates
float3 vEye : TEXCOORD2; //eye vector
float3x3 mToWorld: TEXCOORD3;
};
struct PS_OUTPUT {
float4 vColor : COLOR0;
};
PS_OUTPUT main(PS_INPUT input,
float4 watercolor,
float4 waterhighcolor,
uniform sampler BumpTex0,
uniform sampler BumpTex1,
uniform sampler CubeTex)
{
// zero out members of output
PS_OUTPUT output;
// sample appropriate textures
float3 vNormal0 = tex2D(BumpTex0, input.tcBump0).xyz;
float3 vNormal1 = tex2D(BumpTex1, input.tcBump1).xyz;
float3 vNormal = (vNormal0 + vNormal1 )/2;
vNormal = mul(vNormal, input.mToWorld);
float eDotN = dot(input.vEye, vNormal);
float3 vEyeReflected = 2* eDotN * vNormal - input.vEye; float4 reflection = texCUBE(CubeTex, vEyeReflected);
float Fresnel = (1 - eDotN)*reflection.g;
float4 diffuse = watercolor * 0.5 * eDotN;
float4 color = saturate(lerp(diffuse,reflection * 1.2 * eDotN,Fresnel) + reflection * 0.3);
float4 specular = waterhighcolor * pow(reflection.g,8) * eDotN ; output.vColor = saturate(color + specular);
return output;
}
1.是不是只要把BumpTex0,BumpTex1,CubeTex传进去就可以了,其它参数不用管?
2.我随便生成了个纹理传进去,然后cgGLEnableProfile(fProfile);cgGLBindProgram(fProgram);之后画面就是黑的了,这是怎么回事?
3.还有BumpTex0,BumpTex1,CubeTex这几个纹理是怎么生成的? |
|