浏览代码

Merge pull request #815 from Unity-Technologies/minor-comment/code-on-decal

minor comment/code on decal
/main
GitHub 7 年前
当前提交
d90fdb95
共有 2 个文件被更改,包括 13 次插入14 次删除
  1. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/DecalProjectorComponent.cs
  2. 24
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderPass/ShaderPassDBuffer.hlsl

3
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/DecalProjectorComponent.cs


[ExecuteInEditMode]
public class DecalProjectorComponent : MonoBehaviour
{
private static readonly int m_WorldToDecal = Shader.PropertyToID("_WorldToDecal");
private static readonly int m_DecalToWorldR = Shader.PropertyToID("_DecalToWorldR");
public Material m_Material = null;
private Material m_OldMaterial = null;
public const int kInvalidIndex = -1;

24
ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderPass/ShaderPassDBuffer.hlsl


VaryingsMeshType Transform(AttributesMesh input)
{
VaryingsMeshType output;
UNITY_SETUP_INSTANCE_ID(input)
UNITY_TRANSFER_INSTANCE_ID(input, output);

output.positionWS = decalRotation[0];
output.normalWS = decalRotation[1];
output.tangentWS = float4(decalRotation[2], 0);
output.tangentWS = float4(decalRotation[2], 0.0);
return output;
}

}
void Frag( PackedVaryingsToPS packedInput,
OUTPUT_DBUFFER(outDBuffer)
OUTPUT_DBUFFER(outDBuffer)
{
{
float d = LOAD_TEXTURE2D(_MainDepthTexture, posInput.positionSS).x;
UpdatePositionInput(d, UNITY_MATRIX_I_VP, UNITY_MATRIX_VP, posInput);
float depth = LOAD_TEXTURE2D(_MainDepthTexture, posInput.positionSS).x;
UpdatePositionInput(depth, UNITY_MATRIX_I_VP, UNITY_MATRIX_VP, posInput);
// Transform from world space to decal space (DS) to clip the decal.
// For this we must use absolute position.
// There is no lose of precision here as it doesn't involve the camera matrix
float3 positionDS = mul(UNITY_MATRIX_I_M, float4(positionWS, 1.0f)).xyz;
positionDS = positionDS * float3(1.0f, -1.0f, 1.0f) + float3(0.5f, 0.0f, 0.5f);
clip(positionDS < 0 ? -1 : 1);
clip(positionDS > 1 ? -1 : 1);
float3 positionDS = mul(UNITY_MATRIX_I_M, float4(positionWS, 1.0)).xyz;
positionDS = positionDS * float3(1.0, -1.0, 1.0) + float3(0.5, 0.0f, 0.5);
clip(positionDS); // clip negative value
clip(1.0 - positionDS); // Clip value above one
DecalSurfaceData surfaceData;
float3x3 decalToWorld;

正在加载...
取消
保存