泳池水面fresnel 的近似替代

vs

float4 ep = TBMultiply(ModelViewMatrix, FinalPosition);
DistFromEye.x = TBSaturate( 10.0 + ep.z / 10.0 );
DistFromEye.y = -ep.z;
ScaledElapsedTime.x = ElapsedTime * 0.1;
ScaledElapsedTime.y = ElapsedTime * 0.1;
float3x3 myTangentBasis = float3x3(FinalTangent, FinalBinormal, FinalNormal);
Incident = TBMultiply(TBCast(float3x3, ModelViewMatrixInverse), ep.xyz);// scaled position proj back to model space
Incident = TBMultiplyInvs(myTangentBasis, Incident);// to tangent space 

ps

float3 incidentVec = -normalize(Incident);
float3 cube = TextureLookupCube(CubeMap, CubeMap_ULL, reflect(incidentVec, bumpedNormal)).xyz * ReflectionStrength;
half R0 = 0.0203;
half edotn = abs(dot(-incidentVec, bumpedNormal));
half fresnel = R0 + (1.0-R0) * pow(1.0-edotn, 5.0);//compute in tangent space

 FPOutput.rgb = TBLerp(col, cube, fresnel);

////////////////

complex solution:

half currentDepth = DepthTextureLookup( RenderDepthBufferAsColour, RenderDepthBufferAsColour_ULL, screenTexCoord ).x;
currentDepth = FarPlane * NearPlane / ( currentDepth * ( NearPlane - FarPlane ) + FarPlane );
/* float2 DistFromEye; DistFromEye.x = saturate( 10.0 + ep.z / 10.0 );
DistFromEye.y = -ep.z;*/ float invClarityLength = 1.0 / ClarityLength;
float depth = TBSaturate((currentDepth - DistFromEye.y) * invClarityLength);
float kClarity = 1.0 - depth; DistFromEye.x = TBSaturate(DistFromEye.x);
float2 offsetCoord = renderBufferCopyCoords + bumpedNormal.xy * DistFromEye.x * 0.1f * depth;

原文地址:https://www.cnblogs.com/minggoddess/p/7521204.html