浏览代码

Fix parameter order of BFE

/feature-ReflectionProbeFit
Evgenii Golubev 7 年前
当前提交
d1b5d0f0
共有 9 个文件被更改,包括 42 次插入22 次删除
  1. 2
      ScriptableRenderPipeline/Core/ShaderLibrary/API/D3D11.hlsl
  2. 2
      ScriptableRenderPipeline/Core/ShaderLibrary/API/Metal.hlsl
  3. 5
      ScriptableRenderPipeline/Core/ShaderLibrary/API/PSSL.hlsl
  4. 2
      ScriptableRenderPipeline/Core/ShaderLibrary/API/Vulkan.hlsl
  5. 2
      ScriptableRenderPipeline/Core/ShaderLibrary/API/XBoxOne.hlsl
  6. 20
      ScriptableRenderPipeline/Core/ShaderLibrary/Common.hlsl
  7. 25
      ScriptableRenderPipeline/Core/ShaderLibrary/Packing.hlsl
  8. 4
      ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
  9. 2
      ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/VaryingMesh.hlsl

2
ScriptableRenderPipeline/Core/ShaderLibrary/API/D3D11.hlsl


#define UNITY_NEAR_CLIP_VALUE (1.0)
// This value will not go through any matrix projection convertion
#define UNITY_RAW_FAR_CLIP_VALUE (0.0)
#define FRONT_FACE_SEMATIC SV_IsFrontFace
#define FRONT_FACE_SEMANTIC SV_IsFrontFace
#define FRONT_FACE_TYPE bool
#define IS_FRONT_VFACE(VAL, FRONT, BACK) ((VAL) ? (FRONT) : (BACK))

2
ScriptableRenderPipeline/Core/ShaderLibrary/API/Metal.hlsl


#define UNITY_NEAR_CLIP_VALUE (1.0)
// This value will not go through any matrix projection convertion
#define UNITY_RAW_FAR_CLIP_VALUE (0.0)
#define FRONT_FACE_SEMATIC SV_IsFrontFace
#define FRONT_FACE_SEMANTIC SV_IsFrontFace
#define FRONT_FACE_TYPE bool
#define IS_FRONT_VFACE(VAL, FRONT, BACK) ((VAL) ? (FRONT) : (BACK))

5
ScriptableRenderPipeline/Core/ShaderLibrary/API/PSSL.hlsl


// This file assume SHADER_API_D3D11 is defined
#define INTRINSIC_BITFIELD_EXTRACT
#define BitFieldExtract __v_bfe_u32
#define INTRINSIC_BITFIELD_EXTRACT_SIGN_EXTEND
#define BitFieldExtractSignExtend __v_bfe_i32
#define INTRINSIC_WAVEREADFIRSTLANE
#define WaveReadFirstLane ReadFirstLane
#define INTRINSIC_MAD24

#define UNITY_NEAR_CLIP_VALUE (1.0)
// This value will not go through any matrix projection convertion
#define UNITY_RAW_FAR_CLIP_VALUE (0.0)
#define FRONT_FACE_SEMATIC SV_IsFrontFace
#define FRONT_FACE_SEMANTIC SV_IsFrontFace
#define FRONT_FACE_TYPE bool
#define IS_FRONT_VFACE(VAL, FRONT, BACK) ((VAL) ? (FRONT) : (BACK))

2
ScriptableRenderPipeline/Core/ShaderLibrary/API/Vulkan.hlsl


#define UNITY_NEAR_CLIP_VALUE (1.0)
// This value will not go through any matrix projection convertion
#define UNITY_RAW_FAR_CLIP_VALUE (0.0)
#define FRONT_FACE_SEMATIC SV_IsFrontFace
#define FRONT_FACE_SEMANTIC SV_IsFrontFace
#define FRONT_FACE_TYPE bool
#define IS_FRONT_VFACE(VAL, FRONT, BACK) ((VAL) ? (FRONT) : (BACK))

2
ScriptableRenderPipeline/Core/ShaderLibrary/API/XBoxOne.hlsl


#define UNITY_NEAR_CLIP_VALUE (1.0)
// This value will not go through any matrix projection convertion
#define UNITY_RAW_FAR_CLIP_VALUE (0.0)
#define FRONT_FACE_SEMATIC SV_IsFrontFace
#define FRONT_FACE_SEMANTIC SV_IsFrontFace
#define FRONT_FACE_TYPE bool
#define IS_FRONT_VFACE(VAL, FRONT, BACK) ((VAL) ? (FRONT) : (BACK))

20
ScriptableRenderPipeline/Core/ShaderLibrary/Common.hlsl


// Unsigned integer bit field extraction.
// Note that the intrinsic itself generates a vector instruction.
// Wrap this function with WaveReadFirstLane() to get scalar output.
uint BitFieldExtract(uint data, uint numBits, uint offset)
uint BitFieldExtract(uint data, uint offset, uint numBits)
uint mask = UINT_MAX >> (32u - numBits);
uint mask = (1u << numBits) - 1u;
#ifndef INTRINSIC_BITFIELD_EXTRACT_SIGN_EXTEND
// Integer bit field extraction with sign extension.
// Note that the intrinsic itself generates a vector instruction.
// Wrap this function with WaveReadFirstLane() to get scalar output.
int BitFieldExtractSignExtend(int data, uint offset, uint numBits)
{
int shifted = data >> offset; // Sign-extending (arithmetic) shift
int signBit = shifted & (1u << (numBits - 1u));
uint mask = (1u << numBits) - 1u;
return -signBit | (shifted & mask); // Use 2-complement for negation to replicate the sign bit
}
#endif // INTRINSIC_BITFIELD_EXTRACT_SIGN_EXTEND
return BitFieldExtract(data, 1u, offset) != 0;
return BitFieldExtract(data, offset, 1u) != 0;
}
void SetBit(inout uint data, uint offset)

25
ScriptableRenderPipeline/Core/ShaderLibrary/Packing.hlsl


// Packs an integer stored using at most 'numBits' into a [0..1] float.
float PackInt(uint i, uint numBits)
{
uint maxInt = UINT_MAX >> (32u - numBits);
uint maxInt = (1u << numBits) - 1u;
return saturate(i * rcp(maxInt));
}

uint maxInt = UINT_MAX >> (32u - numBits);
uint maxInt = (1u << numBits) - 1u;
return (uint)(f * maxInt + 0.5); // Round instead of truncating
}

// Packs 8 lowermost bits of a [0..65535] integer into a [0..1] float.
float PackShortLo(uint i)
{
uint lo = BitFieldExtract(i, 8u, 0u);
uint lo = BitFieldExtract(i, 0u, 8u);
return PackInt(lo, 8);
}

//-----------------------------------------------------------------------------
// src must be between 0.0 and 1.0
uint PackFloatToUInt(float src, uint numBits, uint offset)
uint PackFloatToUInt(float src, uint offset, uint numBits)
float UnpackUIntToFloat(uint src, uint numBits, uint offset)
float UnpackUIntToFloat(uint src, uint offset, uint numBits)
uint maxInt = UINT_MAX >> (32u - numBits);
return float(BitFieldExtract(src, numBits, offset)) * rcp(maxInt);
uint maxInt = (1u << numBits) - 1u;
return float(BitFieldExtract(src, offset, numBits)) * rcp(maxInt);
return (PackFloatToUInt(rgba.x, 10, 0) | PackFloatToUInt(rgba.y, 10, 10) | PackFloatToUInt(rgba.z, 10, 20) | PackFloatToUInt(rgba.w, 2, 30));
return (PackFloatToUInt(rgba.x, 0, 10) |
PackFloatToUInt(rgba.y, 10, 10) |
PackFloatToUInt(rgba.z, 20, 10) |
PackFloatToUInt(rgba.w, 30, 2));
ouput.x = UnpackUIntToFloat(rgba, 10, 0);
ouput.x = UnpackUIntToFloat(rgba, 0, 10);
ouput.z = UnpackUIntToFloat(rgba, 10, 20);
ouput.w = UnpackUIntToFloat(rgba, 2, 30);
ouput.z = UnpackUIntToFloat(rgba, 20, 10);
ouput.w = UnpackUIntToFloat(rgba, 30, 2);
return ouput;
}

4
ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl


{
bsdfData.diffuseColor = surfaceData.baseColor;
bsdfData.fresnel0 = SKIN_SPECULAR_VALUE; // TODO: take from the SSS profile
uint transmissionMode = BitFieldExtract(asuint(_TransmissionFlags), 2u, 2u * surfaceData.subsurfaceProfile);
uint transmissionMode = BitFieldExtract(asuint(_TransmissionFlags), 2u * surfaceData.subsurfaceProfile, 2u);
FillMaterialIdSssData(surfaceData.subsurfaceProfile,
surfaceData.subsurfaceRadius,

DecodeFromSSSBuffer(inGBuffer0, positionSS, sssData);
subsurfaceProfile = sssData.subsurfaceProfile;
transmissionMode = BitFieldExtract(asuint(_TransmissionFlags), 2u, 2u * subsurfaceProfile);
transmissionMode = BitFieldExtract(asuint(_TransmissionFlags), 2u * subsurfaceProfile, 2u);
radius = sssData.subsurfaceRadius;
thickness = inGBuffer2.g;

2
ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/VaryingMesh.hlsl


#endif
#if defined(VARYINGS_NEED_CULLFACE) && SHADER_STAGE_FRAGMENT
FRONT_FACE_TYPE cullFace : FRONT_FACE_SEMATIC;
FRONT_FACE_TYPE cullFace : FRONT_FACE_SEMANTIC;
#endif
};

正在加载...
取消
保存