Hi,
Now I working on transparency and refraction in Opengl and GLSL. How to add fresnel calculation in GLSL code without using cubemapping.
I have used the method as per the below tutorial,
https://en.wikibooks.org/wiki/GLSL_Programming/Unity/Specular_Highlights_at_Silhouettes
GLSL
vec3 lightcalc(lightdata mlight)
{
vec3 lightDir; vec3 total;
float attenuation;
float specPhong,specBlinn,diff;
vec3 diffuse,specular;
vec3 norm = normalize(Normal);
vec3 view_pos = vec3(0.0,0.0,10.0);
lightDir = normalize(mlight.position.xyz - FragPos);
/************** DIFFUSE EFFECT *************/
diff = max(dot(norm, lightDir), 0.0);
diffuse = diff * diffuse_color * mlight.color.xyz;
/************** SPECULAR EFFECT *************/
vec3 viewDir = normalize(viewPos - FragPos);
vec3 reflectDir = reflect(-lightDir, norm);
vec3 halfwayDirection = normalize(lightDir + viewDir);
float w = pow(1.0 - max(0.0, dot(halfwayDirection, norm)), 5.0);
//float spec = pow(max(dot(viewDir, halfwayDirection), 0.0), 511.0);
specBlinn = pow(max(dot(norm, halfwayDirection), 0.0), shine);
specPhong = pow(max(dot(viewDir, reflectDir), 0.0), shine);
specular = mix(specular_color,vec3(1.0),w) * specBlinn * mlight.color.xyz;
total = ambient + diffuse + specular;
}
void main()
{
vec3 result;
result = lightcalc(light[0]);
FragColor = vec4(result,1.0);
}
But it does not give the result what i expect. Any one have any idea to render transparent object with fresnel? I want to render it as the below image.
Thanks