voici les lignes de mon pixel shader :
/********* pixel shader ********/
// modified refraction function that returns boolean for total internal reflection
float3
refract2( float3 I, float3 N, float eta, out bool fail )
{
float IdotN = dot(I, N);
float k = 1 - eta*eta*(1 - IdotN*IdotN);
// return k < 0 ? (0,0,0) : eta*I - (eta*IdotN + sqrt(k))*N;
fail = k < 0;
return eta*I - (eta*IdotN + sqrt(k))*N;
}
// approximate Fresnel function
float fresnel(float NdotV, float bias, float power)
{
return bias + (1.0-bias)*pow(1.0 - max(NdotV, 0), power);
}
// function to generate a texture encoding the Fresnel function
float4 generateFresnelTex(float NdotV : POSITION) : COLOR
{
return fresnel(NdotV, 0.2, 4.0);
}
float4 mainPS(vertexOutput IN,
uniform samplerCUBE EnvironmentMap,
uniform half reflectStrength,
uniform half refractStrength,
uniform half3 etas
) : COLOR
{
half3 N = normalize(IN.WorldNormal);
float3 V = normalize(IN.WorldView);
// reflection
half3 R = reflect(-V, N);
half4 reflColor = texCUBE(EnvironmentMap, R);
// half fresnel = fresnel(dot(N, V), 0.2, 4.0);
half fresnel = tex2D(fresnelSampler, dot(N, V));
// wavelength colors
const half4 colors[3] = {
{ 1, 0, 0, 0 },
{ 0, 1, 0, 0 },
{ 0, 0, 1, 0 },
};
// transmission
half4 transColor = 0;
bool fail = false;
for(int i=0; i<3; i++) {
half3 T = refract2(-V, N, etas[i], fail);
transColor += texCUBE(EnvironmentMap, T) * colors[i];
}
return lerp(transColor*refractStrength, reflColor*reflectStrength, fresnel);
}
/*************/
Quand j'aplique le shader sur une teapot generer par le programe qui crée le shader sa marche , mais pas dans mon programme! Pour ton probleme je voit se que tu veut dire le pb c'est que je sui pas assez avancer pour te repondre malheuresement !