浏览代码

removed Vec2/Vec3/Vec4/Mat44, regenerated .hlsl includes

/main
vlad-andreev 8 年前
当前提交
ea3c49e2
共有 9 个文件被更改,包括 70 次插入126 次删除
  1. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs
  2. 21
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LightDefinition.cs
  3. 18
      Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LightDefinition.cs.hlsl
  4. 4
      Assets/ScriptableRenderLoop/common/ShaderBase.h
  5. 26
      Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
  6. 37
      Assets/ScriptableRenderLoop/fptl/LightDefinitions.cs
  7. 34
      Assets/ScriptableRenderLoop/fptl/LightDefinitions.cs.hlsl
  8. 42
      Assets/ScriptableRenderLoop/common/ShaderBase.cs
  9. 12
      Assets/ScriptableRenderLoop/common/ShaderBase.cs.meta

2
Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs


float lightColorG = light.light.intensity * Mathf.GammaToLinearSpace(light.light.color.g);
float lightColorB = light.light.intensity * Mathf.GammaToLinearSpace(light.light.color.b);
l.color = new Vec3(lightColorR, lightColorG, lightColorB);
l.color.Set(lightColorR, lightColorG, lightColorB);
// Light direction is opposite to the forward direction
l.forward = -light.light.transform.forward;

21
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LightDefinition.cs


using UnityEngine;
namespace UnityEngine.ScriptableRenderLoop
{
// These structures share between C# and hlsl need to be align on float4, so we pad them.

public Vec3 positionWS;
public Vector3 positionWS;
public Vec3 color;
public Vector3 color;
public Vec3 forward;
public Vector3 forward;
public Vec3 up;
public Vector3 up;
public Vec3 right;
public Vector3 right;
public Vec2 unused2;
public Vector2 unused2;
public Vec3 positionWS;
public Vector3 positionWS;
public Vec3 positionWS;
public Vector3 positionWS;
public Vec3 positionWS;
public Vector3 positionWS;
};
} // namespace UnityEngine.ScriptableRenderLoop

18
Assets/ScriptableRenderLoop/HDRenderLoop/Shaders/LightDefinition.cs.hlsl


// PackingRules = Exact
struct PunctualLightData
{
float3 positionWS; // x: x y: y z: z
float3 positionWS;
float3 color; // x: x y: y z: z
float3 color;
float3 forward; // x: x y: y z: z
float3 forward;
float3 up; // x: x y: y z: z
float3 up;
float3 right; // x: x y: y z: z
float3 right;
float2 unused2; // x: x y: y
float2 unused2;
};
// Generated from UnityEngine.ScriptableRenderLoop.AreaLightData

float3 positionWS; // x: x y: y z: z
float3 positionWS;
};
// Generated from UnityEngine.ScriptableRenderLoop.EnvLightData

float3 positionWS; // x: x y: y z: z
float3 positionWS;
};
// Generated from UnityEngine.ScriptableRenderLoop.PlanarLightData

float3 positionWS; // x: x y: y z: z
float3 positionWS;
};
//

4
Assets/ScriptableRenderLoop/common/ShaderBase.h


#define public
#define Vec2 float2
#define Vec3 float3
#define Vec4 float4
#define Mat44 float4x4
#define unistruct cbuffer
#define hbool bool

26
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs


l.vLaxisY = vy;
l.vLaxisZ = vz;
l.vCol = new Vec3(light.finalColor.r, light.finalColor.g, light.finalColor.b);
l.vCol.Set(light.finalColor.r, light.finalColor.g, light.finalColor.b);
l.fLightIntensity = light.light.intensity;
lights.Add(l);

Vector3 lightPos = lightToWorld.GetColumn(3);
boundData[i].vBoxAxisX = new Vec3(1, 0, 0);
boundData[i].vBoxAxisY = new Vec3(0, 1, 0);
boundData[i].vBoxAxisZ = new Vec3(0, 0, 1);
boundData[i].vScaleXY = new Vec2(1.0f, 1.0f);
boundData[i].vBoxAxisX.Set(1, 0, 0);
boundData[i].vBoxAxisY.Set(0, 1, 0);
boundData[i].vBoxAxisZ.Set(0, 0, 1);
boundData[i].vScaleXY.Set(1.0f, 1.0f);
lightData[i].vCol = new Vec3(cl.finalColor.r, cl.finalColor.g, cl.finalColor.b);
lightData[i].vCol.Set(cl.finalColor.r, cl.finalColor.g, cl.finalColor.b);
lightData[i].iSliceIndex = 0;
lightData[i].uLightModel = (uint)LightDefinitions.DIRECT_LIGHT;
lightData[i].uShadowLightIndex = shadowLightIndex;

float fAltDist = Mathf.Sqrt(fAltDy * fAltDy + (bIsCircularSpot ? 1.0f : 2.0f) * fAltDx * fAltDx);
boundData[i].fRadius = fAltDist > (0.5f * range) ? fAltDist : (0.5f * range); // will always pick fAltDist
boundData[i].vScaleXY = bSqueeze ? new Vec2(0.01f, 0.01f) : new Vec2(1.0f, 1.0f);
boundData[i].vScaleXY = bSqueeze ? new Vector2(0.01f, 0.01f) : new Vector2(1.0f, 1.0f);
// fill up ldata
lightData[i].uLightType = (uint)LightDefinitions.SPOT_LIGHT;

}
boundData[i].vCen = worldToView.MultiplyPoint(lightPos);
boundData[i].vBoxAxisX = new Vec3(range, 0, 0);
boundData[i].vBoxAxisY = new Vec3(0, range, 0);
boundData[i].vBoxAxisZ = new Vec3(0, 0, -range); // transform to camera space (becomes a left hand coordinate frame in Unity since Determinant(worldToView)<0)
boundData[i].vScaleXY = new Vec2(1.0f, 1.0f);
boundData[i].vBoxAxisX.Set(range, 0, 0);
boundData[i].vBoxAxisY.Set(0, range, 0);
boundData[i].vBoxAxisZ.Set(0, 0, -range); // transform to camera space (becomes a left hand coordinate frame in Unity since Determinant(worldToView)<0)
boundData[i].vScaleXY.Set(1.0f, 1.0f);
boundData[i].fRadius = range;
// represents a left hand coordinate system in world space since det(worldToView)<0

Vector3 delta = combinedExtent - e;
lightData[i].vBoxInnerDist = e;
lightData[i].vBoxInvRange = new Vec3(1.0f / delta.x, 1.0f / delta.y, 1.0f / delta.z);
lightData[i].vBoxInvRange.Set(1.0f / delta.x, 1.0f / delta.y, 1.0f / delta.z);
boundData[i].vScaleXY = new Vec2(1.0f, 1.0f);
boundData[i].vScaleXY.Set(1.0f, 1.0f);
boundData[i].fRadius = combinedExtent.magnitude;
// fill up ldata

37
Assets/ScriptableRenderLoop/fptl/LightDefinitions.cs


//#define LEFT_HAND_COORDINATES
using UnityEngine;
[UnityEngine.ScriptableRenderLoop.GenerateHLSL]
public struct SFiniteLightData
{

public uint uLightType;
public uint uLightModel; // DIRECT_LIGHT=0, REFLECTION_LIGHT=1
public Vec3 vLpos;
public Vector3 vLpos;
public Vec3 vLaxisX;
public Vector3 vLaxisX;
public Vec3 vLaxisY;
public Vector3 vLaxisY;
public Vec3 vLaxisZ; // spot +Z axis
public Vector3 vLaxisZ; // spot +Z axis
public Vec3 vCol;
public Vector3 vCol;
public Vec3 vBoxInnerDist;
public Vector3 vBoxInnerDist;
public Vec3 vBoxInvRange;
public Vector3 vBoxInvRange;
public Vec3 vLocalCubeCapturePoint;
public Vector3 vLocalCubeCapturePoint;
public float fProbeBlendDistance;
};

public Vec3 vBoxAxisX;
public Vec3 vBoxAxisY;
public Vec3 vBoxAxisZ;
public Vec3 vCen; // a center in camera space inside the bounding volume of the light source.
public Vec2 vScaleXY;
public Vector3 vBoxAxisX;
public Vector3 vBoxAxisY;
public Vector3 vBoxAxisZ;
public Vector3 vCen; // a center in camera space inside the bounding volume of the light source.
public Vector2 vScaleXY;
public float fRadius;
};

public Vec3 vCol;
public Vector3 vCol;
public Vec3 vLaxisX;
public Vector3 vLaxisX;
public Vec3 vLaxisY;
public Vector3 vLaxisY;
public Vec3 vLaxisZ;
public Vector3 vLaxisZ;
public float fPad1;
};

34
Assets/ScriptableRenderLoop/fptl/LightDefinitions.cs.hlsl


int flags;
uint uLightType;
uint uLightModel;
float3 vLpos; // x: x y: y z: z
float3 vLpos;
float3 vLaxisX; // x: x y: y z: z
float3 vLaxisX;
float3 vLaxisY; // x: x y: y z: z
float3 vLaxisY;
float3 vLaxisZ; // x: x y: y z: z
float3 vLaxisZ;
float3 vCol; // x: x y: y z: z
float3 vCol;
float3 vBoxInnerDist; // x: x y: y z: z
float3 vBoxInnerDist;
float3 vBoxInvRange; // x: x y: y z: z
float3 vBoxInvRange;
float3 vLocalCubeCapturePoint; // x: x y: y z: z
float3 vLocalCubeCapturePoint;
float fProbeBlendDistance;
};

{
float3 vBoxAxisX; // x: x y: y z: z
float3 vBoxAxisY; // x: x y: y z: z
float3 vBoxAxisZ; // x: x y: y z: z
float3 vCen; // x: x y: y z: z
float2 vScaleXY; // x: x y: y
float3 vBoxAxisX;
float3 vBoxAxisY;
float3 vBoxAxisZ;
float3 vCen;
float2 vScaleXY;
float fRadius;
};

{
float3 vCol; // x: x y: y z: z
float3 vCol;
float3 vLaxisX; // x: x y: y z: z
float3 vLaxisX;
float3 vLaxisY; // x: x y: y z: z
float3 vLaxisY;
float3 vLaxisZ; // x: x y: y z: z
float3 vLaxisZ;
float fPad1;
};

42
Assets/ScriptableRenderLoop/common/ShaderBase.cs


#if !__HLSL
using UnityEngine;
public struct Vec2
{
public static implicit operator Vec2(Vector2 v) { return new Vec2(v.x, v.y); }
public Vec2(Vec2 v) { x = v.x; y = v.y; }
public Vec2(float fX, float fY) { x = fX; y = fY; }
public float x, y;
};
public struct Vec3
{
public static implicit operator Vec3(Vector3 v) { return new Vec3(v.x, v.y, v.z); }
public static implicit operator Vec3(Vector4 v) { return new Vec3(v.x, v.y, v.z); }
public Vec3(Vec3 v) { x = v.x; y = v.y; z = v.z; }
public Vec3(float fX, float fY, float fZ) { x = fX; y = fY; z = fZ; }
public float x, y, z;
};
public struct Vec4
{
public static implicit operator Vec4(Vector4 v) { return new Vec4(v.x, v.y, v.z, v.w); }
public static implicit operator Vec4(Vector3 v) { return new Vec4(v.x, v.y, v.z, 1.0f); }
public Vec4(Vec4 v) { x = v.x; y = v.y; z = v.z; w = v.w; }
public Vec4(float fX, float fY, float fZ, float fW) { x = fX; y = fY; z = fZ; w = fW; }
public float x, y, z, w;
};
public struct Mat44
{
public Mat44( Matrix4x4 m ) { c0 = new Vec4(m.GetColumn(0)); c1 = new Vec4(m.GetColumn(1)); c2 = new Vec4(m.GetColumn(2)); c3 = new Vec4(m.GetColumn(3)); }
public Vec4 c0, c1, c2, c3;
};
#endif

12
Assets/ScriptableRenderLoop/common/ShaderBase.cs.meta


fileFormatVersion: 2
guid: c1ebf357fa7277c4697f21c295e8c4c2
timeCreated: 1467917164
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存