当前位置: 首页>>代码示例>>C#>>正文


C# ShadingState.traceRefractionPhoton方法代码示例

本文整理汇总了C#中ShadingState.traceRefractionPhoton方法的典型用法代码示例。如果您正苦于以下问题:C# ShadingState.traceRefractionPhoton方法的具体用法?C# ShadingState.traceRefractionPhoton怎么用?C# ShadingState.traceRefractionPhoton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ShadingState的用法示例。


在下文中一共展示了ShadingState.traceRefractionPhoton方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ScatterPhoton

 public void ScatterPhoton(ShadingState state, Color power)
 {
     Color refr = Color.mul(1 - f0, color);
     Color refl = Color.mul(f0, color);
     float avgR = refl.getAverage();
     float avgT = refr.getAverage();
     double rnd = state.getRandom(0, 0, 1);
     if (rnd < avgR)
     {
         state.faceforward();
         // don't reflect internally
         if (state.isBehind())
             return;
         // photon is reflected
         float cos = state.getCosND();
         power.mul(refl).mul(1.0f / avgR);
         float dn = 2 * cos;
         Vector3 dir = new Vector3();
         dir.x = (dn * state.getNormal().x) + state.getRay().getDirection().x;
         dir.y = (dn * state.getNormal().y) + state.getRay().getDirection().y;
         dir.z = (dn * state.getNormal().z) + state.getRay().getDirection().z;
         state.traceReflectionPhoton(new Ray(state.getPoint(), dir), power);
     }
     else if (rnd < avgR + avgT)
     {
         state.faceforward();
         // photon is refracted
         float cos = state.getCosND();
         float neta = state.isBehind() ? eta : 1.0f / eta;
         power.mul(refr).mul(1.0f / avgT);
         float wK = -neta;
         float arg = 1 - (neta * neta * (1 - (cos * cos)));
         Vector3 dir = new Vector3();
         if (state.isBehind() && absorptionDistance > 0)
         {
             // this ray is inside the object and leaving it
             // compute attenuation that occured along the ray
             power.mul(Color.mul(-state.getRay().getMax() / absorptionDistance, absorptionColor.copy().opposite()).exp());
         }
         if (arg < 0)
         {
             // TIR
             float dn = 2 * cos;
             dir.x = (dn * state.getNormal().x) + state.getRay().getDirection().x;
             dir.y = (dn * state.getNormal().y) + state.getRay().getDirection().y;
             dir.z = (dn * state.getNormal().z) + state.getRay().getDirection().z;
             state.traceReflectionPhoton(new Ray(state.getPoint(), dir), power);
         }
         else
         {
             float nK = (neta * cos) - (float)Math.Sqrt(arg);
             dir.x = (-wK * state.getRay().dx) + (nK * state.getNormal().x);
             dir.y = (-wK * state.getRay().dy) + (nK * state.getNormal().y);
             dir.z = (-wK * state.getRay().dz) + (nK * state.getNormal().z);
             state.traceRefractionPhoton(new Ray(state.getPoint(), dir), power);
         }
     }
 }
开发者ID:,项目名称:,代码行数:58,代码来源:


注:本文中的ShadingState.traceRefractionPhoton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。