• 泳池水面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;

  • 相关阅读:
    类,对象和方法
    jmeter对接口测试入参进行MD5加密
    Jmeter配置代理进行录制
    MYSQL——having 和 where的区别
    MySQL
    Python——面试编程题
    mysql——面试题
    Vue——解决跨域请求问题
    Vue——axios网络的基本请求
    ES6 数组map(映射)、reduce(汇总)、filter(过滤器)、forEach(循环迭代)
  • 原文地址:https://www.cnblogs.com/minggoddess/p/7521204.html
Copyright © 2020-2023  润新知