浏览代码

adding support for rotatable refl probes

adding support for rotatable refl probes
/main
mmikk 8 年前
当前提交
e37eac8f
共有 2 个文件被更改,包括 17 次插入6 次删除
  1. 22
      Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
  2. 1
      Assets/ScriptableRenderLoop/fptl/Internal-DeferredReflections.shader

22
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs


Vector3 boxOffset = rl.center;
float blendDistance = rl.blendDistance;
float imp = rl.importance;
Matrix4x4 mat = rl.transform.localToWorldMatrix;
Vector3 reflPos = mat.GetColumn(3);
Vector3 C = bnds.center; // P + boxOffset;
Vector3 posForShaderParam = bnds.center - boxOffset; // gives same as rl.GetComponent<Transform>().position;
//Vector3 C = bnds.center; // P + boxOffset;
Vector3 C = mat.MultiplyPoint(boxOffset); // same as commented out line above when rot is identity
//Vector3 posForShaderParam = bnds.center - boxOffset; // gives same as rl.GetComponent<Transform>().position;
Vector3 posForShaderParam = reflPos; // same as commented out line above when rot is identity
Vector3 vx = new Vector3(1, 0, 0); // always axis aligned in world space for now
Vector3 vy = new Vector3(0, 1, 0);
Vector3 vz = new Vector3(0, 0, 1);
//Vector3 vx = new Vector3(1, 0, 0); // always axis aligned in world space for now
//Vector3 vy = new Vector3(0, 1, 0);
//Vector3 vz = new Vector3(0, 0, 1);
Vector3 vx = mat.GetColumn(0);
Vector3 vy = mat.GetColumn(1);
Vector3 vz = mat.GetColumn(2);
// transform to camera space (becomes a left hand coordinate frame in Unity since Determinant(worldToView)<0)
vx = worldToView.MultiplyVector(vx);

1
Assets/ScriptableRenderLoop/fptl/Internal-DeferredReflections.shader


float4 vBoxOuterDistance = float4( lgtDat.vBoxInnerDist + float3(blendDistance, blendDistance, blendDistance), 0.0 );
#if 0
// if rotation is NOT supported
worldNormal0 = BoxProjectedCubemapDirection(worldNormalRefl, posInProbeSpace, float4(-lgtDat.vProbeBoxOffset, 1.0), -vBoxOuterDistance, vBoxOuterDistance);
#else
float3 probeSpaceRefl = float3( dot(vspaceRefl, lgtDat.vLaxisX), dot(vspaceRefl, lgtDat.vLaxisY), dot(vspaceRefl, lgtDat.vLaxisZ) );

正在加载...
取消
保存