浏览代码

initial commit

/main
Paul Melamed 7 年前
当前提交
0c97c0da
共有 6 个文件被更改,包括 31 次插入15 次删除
  1. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/DecalSystem.cs
  2. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs
  3. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs
  4. 24
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDUtils.cs
  5. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/DBufferManager.cs
  6. 9
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/Blit.shader

6
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Decal/DecalSystem.cs


public class DecalSystem
{
public const int kInvalidIndex = -1;
public const int kDecalAtlasSize = 128;
public const int kDecalAtlasWidth = 128;
public const int kDecalAtlasHeight = 128;
const int kDecalAtlasSlices = 256; // 128x128x256 argb32 = 16MB......
public class DecalHandle
{

if (m_DecalAtlas == null)
{
m_DecalAtlas = new TextureCache2D("DecalAtlas");
m_DecalAtlas.AllocTextureArray(2048, kDecalAtlasSize, kDecalAtlasSize, TextureFormat.ARGB32, true);
m_DecalAtlas.AllocTextureArray(kDecalAtlasSlices, kDecalAtlasWidth, kDecalAtlasHeight, TextureFormat.ARGB32, true);
}
return m_DecalAtlas;
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


else
{
HDUtils.SetRenderTarget(cmd, hdCamera, m_CameraColorBuffer, m_CameraDepthStencilBuffer);
if (m_FrameSettings.enableDBuffer) // enable d-buffer flag value is being interpreted more like enable decals in general now that we have clustered
if ((m_FrameSettings.enableDBuffer) && (DecalSystem.m_DecalsVisibleThisFrame > 0)) // enable d-buffer flag value is being interpreted more like enable decals in general now that we have clustered
{
DecalSystem.instance.SetAtlas(cmd); // for clustered decals
}

3
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs


public static readonly int _DebugFullScreenTexture = Shader.PropertyToID("_DebugFullScreenTexture");
public static readonly int _BlitTexture = Shader.PropertyToID("_BlitTexture");
public static readonly int _BlitScaleBias = Shader.PropertyToID("_BlitScaleBias");
public static readonly int _BlitScaleBiasSrc = Shader.PropertyToID("_BlitScaleBiasSrc");
public static readonly int _BlitScaleBiasDst = Shader.PropertyToID("_BlitScaleBiasDst");
public static readonly int _BlitMipLevel = Shader.PropertyToID("_BlitMipLevel");
public static readonly int _WorldScales = Shader.PropertyToID("_WorldScales");

24
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDUtils.cs


}
}
public static void BlitTexture(CommandBuffer cmd, RTHandle source, RTHandle destination, Vector4 scaleBias, float mipLevel, bool bilinear)
public static void BlitTexture(CommandBuffer cmd, RTHandle source, RTHandle destination, Vector4 scaleBiasSrc, Vector4 scaleBiasDst, float srcMipLevel, int dstMipLevel, bool bilinear)
s_PropertyBlock.SetVector(HDShaderIDs._BlitScaleBias, scaleBias);
s_PropertyBlock.SetVector(HDShaderIDs._BlitScaleBiasSrc, scaleBiasSrc);
s_PropertyBlock.SetVector(HDShaderIDs._BlitScaleBiasDst, scaleBiasDst);
s_PropertyBlock.SetFloat(HDShaderIDs._BlitMipLevel, srcMipLevel);
cmd.SetRenderTarget(destination, dstMipLevel);
cmd.DrawProcedural(Matrix4x4.identity, GetBlitMaterial(), bilinear ? 1 : 0, MeshTopology.Triangles, 3, 1, s_PropertyBlock);
}
public static void BlitTexture(CommandBuffer cmd, RTHandle source, RTHandle destination, Vector4 scaleBiasSrc, Vector4 scaleBiasDst, float mipLevel, bool bilinear)
{
s_PropertyBlock.SetTexture(HDShaderIDs._BlitTexture, source);
s_PropertyBlock.SetVector(HDShaderIDs._BlitScaleBiasSrc, scaleBiasSrc);
s_PropertyBlock.SetVector(HDShaderIDs._BlitScaleBiasDst, scaleBiasDst);
s_PropertyBlock.SetFloat(HDShaderIDs._BlitMipLevel, mipLevel);
cmd.DrawProcedural(Matrix4x4.identity, GetBlitMaterial(), bilinear ? 1 : 0, MeshTopology.Triangles, 3, 1, s_PropertyBlock);
}

{
// Will set the correct camera viewport as well.
SetRenderTarget(cmd, camera, destination);
BlitTexture(cmd, source, destination, camera.scaleBias, mipLevel, bilinear);
BlitTexture(cmd, source, destination, camera.scaleBias, new Vector4(1.0f, 1.0f, 0.0f, 0.0f), mipLevel, bilinear);
}
// This case, both source and destination are camera-scaled but we want to override the scale/bias parameter.

SetRenderTarget(cmd, camera, destination);
BlitTexture(cmd, source, destination, scaleBias, mipLevel, bilinear);
BlitTexture(cmd, source, destination, scaleBias, new Vector4(1.0f, 1.0f, 0.0f, 0.0f),mipLevel, bilinear);
}
public static void BlitCameraTexture(CommandBuffer cmd, HDCamera camera, RTHandle source, RTHandle destination, Rect destViewport, float mipLevel = 0.0f, bool bilinear = false)

BlitTexture(cmd, source, destination, camera.scaleBias, mipLevel, bilinear);
BlitTexture(cmd, source, destination, camera.scaleBias, new Vector4(1.0f, 1.0f, 0.0f, 0.0f), mipLevel, bilinear);
}
// This particular case is for blitting a camera-scaled texture into a non scaling texture. So we setup the full viewport (implicit in cmd.Blit) but have to scale the input UVs.

SetRenderTarget(cmd, camera, destination);
cmd.SetGlobalTexture(HDShaderIDs._BlitTexture, source);
cmd.SetGlobalVector(HDShaderIDs._BlitScaleBias, new Vector4(1.0f, 1.0f, 0.0f, 0.0f));
cmd.SetGlobalVector(HDShaderIDs._BlitScaleBiasSrc, new Vector4(1.0f, 1.0f, 0.0f, 0.0f));
cmd.SetGlobalVector(HDShaderIDs._BlitScaleBiasDst, new Vector4(1.0f, 1.0f, 0.0f, 0.0f));
cmd.SetGlobalFloat(HDShaderIDs._BlitMipLevel, 0.0f);
// Wanted to make things clean and not use SetGlobalXXX APIs but can't use MaterialPropertyBlock with RenderTargetIdentifier so YEY
//s_PropertyBlock.SetTexture(HDShaderIDs._BlitTexture, source);

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Decal/DBufferManager.cs


if (frameSettings.enableDBuffer)
{
cmd.SetGlobalInt(HDShaderIDs._EnableDBuffer, vsibleDecalCount > 0 ? 1 : 0);
cmd.SetGlobalVector(HDShaderIDs._DecalAtlasResolution, new Vector2(DecalSystem.kDecalAtlasSize, DecalSystem.kDecalAtlasSize));
cmd.SetGlobalVector(HDShaderIDs._DecalAtlasResolution, new Vector2(DecalSystem.kDecalAtlasWidth, DecalSystem.kDecalAtlasHeight));
BindBufferAsTextures(cmd);
}
else

9
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/Blit.shader


TEXTURE2D(_BlitTexture);
SamplerState sampler_PointClamp;
SamplerState sampler_LinearClamp;
uniform float4 _BlitScaleBias;
uniform float4 _BlitScaleBiasSrc;
uniform float4 _BlitScaleBiasDst;
uniform float _BlitMipLevel;
struct Attributes

Varyings Vert(Attributes input)
{
Varyings output;
output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID);
output.texcoord = GetFullScreenTriangleTexCoord(input.vertexID) * _BlitScaleBias.xy + _BlitScaleBias.zw;
output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID) * float4(_BlitScaleBiasDst.xy, 1, 1) + float4(_BlitScaleBiasDst.zw, 0, 0);
output.texcoord = GetFullScreenTriangleTexCoord(input.vertexID) * float4(_BlitScaleBiasSrc.xy, 1, 1) + float4(_BlitScaleBiasSrc.zw, 0, 0);
return output;
}

#pragma vertex Vert
#pragma fragment FragBilinear
ENDHLSL
}
}
}
Fallback Off
正在加载...
取消
保存