mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 06:09:42 +00:00
fresnel effect
This commit is contained in:
parent
f6342cfd60
commit
add4ebe445
3 changed files with 9 additions and 6 deletions
|
@ -11,6 +11,7 @@ compositor gbuffer
|
||||||
input none
|
input none
|
||||||
pass clear
|
pass clear
|
||||||
{
|
{
|
||||||
|
// make sure to set this to the viewport background color from outside
|
||||||
colour_value 0 0 0 1
|
colour_value 0 0 0 1
|
||||||
}
|
}
|
||||||
pass render_scene
|
pass render_scene
|
||||||
|
|
|
@ -64,7 +64,6 @@ void main_fp
|
||||||
float4 normal = tex2D(normalMap, uv1) + tex2D(normalMap, uv2) + tex2D(normalMap, uv3) + tex2D(normalMap, uv4);
|
float4 normal = tex2D(normalMap, uv1) + tex2D(normalMap, uv2) + tex2D(normalMap, uv3) + tex2D(normalMap, uv4);
|
||||||
normal = normal / 4.f;
|
normal = normal / 4.f;
|
||||||
normal = 2*normal - 1;
|
normal = 2*normal - 1;
|
||||||
//normal = normalize(normal);
|
|
||||||
|
|
||||||
float2 screenCoords_reflect = screenCoords + normal.yx * 0.05;
|
float2 screenCoords_reflect = screenCoords + normal.yx * 0.05;
|
||||||
float2 screenCoords_refract = screenCoords + normal.yx * 0.1 * depth1;
|
float2 screenCoords_refract = screenCoords + normal.yx * 0.1 * depth1;
|
||||||
|
@ -72,11 +71,14 @@ void main_fp
|
||||||
float4 reflection = tex2D(reflectionMap, screenCoords_reflect);
|
float4 reflection = tex2D(reflectionMap, screenCoords_reflect);
|
||||||
float4 refraction = tex2D(refractionMap, screenCoords_refract);
|
float4 refraction = tex2D(refractionMap, screenCoords_refract);
|
||||||
|
|
||||||
// fresnel
|
// tangent to object space
|
||||||
//float facing = 1.0 - max(abs(dot(iEyeVector.xyz, normal.xyz)), 0);
|
normal.xyz = normal.xzy;
|
||||||
//float reflectionFactor = saturate(0.3 + 0.7 * pow(facing, 2));
|
|
||||||
|
|
||||||
oColor.xyz = lerp(refraction.xyz, reflection.xyz, depth1);
|
// fresnel
|
||||||
|
float facing = 1.0 - max(abs(dot(normalize(iEyeVector.xyz), normal.xyz)), 0);
|
||||||
|
float reflectionFactor = saturate(0.3 + 0.7 * pow(facing, 2));
|
||||||
|
|
||||||
|
oColor.xyz = lerp(refraction.xyz, reflection.xyz, depth1 * reflectionFactor);
|
||||||
|
|
||||||
float fogValue = saturate((iDepth - fogParams.y) * fogParams.w);
|
float fogValue = saturate((iDepth - fogParams.y) * fogParams.w);
|
||||||
oColor.xyz = lerp(oColor.xyz, fogColour, fogValue);
|
oColor.xyz = lerp(oColor.xyz, fogColour, fogValue);
|
||||||
|
|
|
@ -48,7 +48,7 @@ material Water
|
||||||
|
|
||||||
vertex_program_ref Water_VP
|
vertex_program_ref Water_VP
|
||||||
{
|
{
|
||||||
//param_named_auto camPosObjSpace camera_position_object_space
|
param_named_auto camPosObjSpace camera_position_object_space
|
||||||
}
|
}
|
||||||
fragment_program_ref Water_FP
|
fragment_program_ref Water_FP
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue