浏览代码

Added float and half variants to instrisicts

/main
Felipe Lira 7 年前
当前提交
60efd574
共有 12 个文件被更改,包括 130 次插入11 次删除
  1. 12
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/D3D11.hlsl
  2. 12
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/GLCore.hlsl
  3. 19
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/GLES2.hlsl
  4. 12
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/GLES3.hlsl
  5. 12
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/Metal.hlsl
  6. 12
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/PSSL.hlsl
  7. 12
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/Switch.hlsl
  8. 12
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/Vulkan.hlsl
  9. 12
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/XBoxOne.hlsl
  10. 10
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Core.hlsl
  11. 6
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/DepthCopy.hlsl
  12. 10
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightScreenSpaceShadows.shader

12
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/D3D11.hlsl


#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
#define TEXTURE2D_FLOAT(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_FLOAT(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_FLOAT(textureName) TEXTURECUBE(textureName)
#define TEXTURECUBE_ARRAY_FLOAT(textureName) TEXTURECUBE_ARRAY(textureName)
#define TEXTURE3D_FLOAT(textureName) TEXTURE3D(textureName)
#define TEXTURE2D_HALF(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_HALF(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_HALF(textureName) TEXTURECUBE(textureName)
#define TEXTURECUBE_ARRAY_HALF(textureName) TEXTURECUBE_ARRAY(textureName)
#define TEXTURE3D_HALF(textureName) TEXTURE3D(textureName)
#define TEXTURE2D_SHADOW(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_SHADOW(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_SHADOW(textureName) TEXTURECUBE(textureName)

12
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/GLCore.hlsl


#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
#define TEXTURE2D_FLOAT(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_FLOAT(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_FLOAT(textureName) TEXTURECUBE(textureName)
#define TEXTURECUBE_ARRAY_FLOAT(textureName) TEXTURECUBE_ARRAY(textureName)
#define TEXTURE3D_FLOAT(textureName) TEXTURE3D(textureName)
#define TEXTURE2D_HALF(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_HALF(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_HALF(textureName) TEXTURECUBE(textureName)
#define TEXTURECUBE_ARRAY_HALF(textureName) TEXTURECUBE_ARRAY(textureName)
#define TEXTURE3D_HALF(textureName) TEXTURE3D(textureName)
#define TEXTURE2D_SHADOW(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_SHADOW(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_SHADOW(textureName) TEXTURECUBE(textureName)

19
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/GLES2.hlsl


#define CBUFFER_START(name)
#define CBUFFER_END
// flow control attributes
#define UNITY_BRANCH
#define UNITY_FLATTEN
#define UNITY_UNROLL
#define UNITY_UNROLLX(_x)
#define UNITY_LOOP
#define uint int
#define rcp(x) 1.0 / x

#define TEXTURECUBE(textureName) samplerCUBE textureName
#define TEXTURECUBE_ARRAY(textureName) samplerCUBE textureName // No supoport to textureCubeArray and can't emulate with texture2DArray
#define TEXTURE3D(textureName) sampler3D textureName
#define TEXTURE2D_FLOAT(textureName) sampler2D_float textureName
#define TEXTURE2D_ARRAY_FLOAT(textureName) TEXTURECUBE_FLOAT(textureName) // No support to texture2DArray
#define TEXTURECUBE_FLOAT(textureName) samplerCUBE_float textureName
#define TEXTURECUBE_ARRAY_FLOAT(textureName) TEXTURECUBE_FLOAT(textureName) // No support to textureCubeArray
#define TEXTURE3D_FLOAT(textureName) sampler3D_float textureName
#define TEXTURE2D_HALF(textureName) sampler2D_half textureName
#define TEXTURE2D_ARRAY_HALF(textureName) TEXTURECUBE_HALF(textureName) // No support to texture2DArray
#define TEXTURECUBE_HALF(textureName) samplerCUBE_half textureName
#define TEXTURECUBE_ARRAY_HALF(textureName) TEXTURECUBE_HALF(textureName) // No support to textureCubeArray
#define TEXTURE3D_HALF(textureName) sampler3D_half textureName
#define TEXTURE2D_SHADOW(textureName) SHADOW2D_TEXTURE_AND_SAMPLER textureName
#define TEXTURE2D_ARRAY_SHADOW(textureName) TEXTURECUBE_SHADOW(textureName) // No support to texture array

12
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/GLES3.hlsl


#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
#define TEXTURE2D_FLOAT(textureName) Texture2D<float4> textureName
#define TEXTURE2D_ARRAY_FLOAT(textureName) Texture2DArray<float4> textureName
#define TEXTURECUBE_FLOAT(textureName) TextureCube<float4> textureName
#define TEXTURECUBE_ARRAY_FLOAT(textureName) TextureCubeArray<float4> textureName
#define TEXTURE3D_FLOAT(textureName) Texture3D<float4> textureName
#define TEXTURE2D_HALF(textureName) Texture2D<half4> textureName
#define TEXTURE2D_ARRAY_HALF(textureName) Texture2DArray<half4> textureName
#define TEXTURECUBE_HALF(textureName) TextureCube<half4> textureName
#define TEXTURECUBE_ARRAY_HALF(textureName) TextureCubeArray<half4> textureName
#define TEXTURE3D_HALF(textureName) Texture3D<half4> textureName
#define TEXTURE2D_SHADOW(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_SHADOW(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_SHADOW(textureName) TEXTURECUBE(textureName)

12
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/Metal.hlsl


#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
#define TEXTURE2D_FLOAT(textureName) Texture2D<float4> textureName
#define TEXTURE2D_ARRAY_FLOAT(textureName) Texture2DArray<float4> textureName
#define TEXTURECUBE_FLOAT(textureName) TextureCube<float4> textureName
#define TEXTURECUBE_ARRAY_FLOAT(textureName) TextureCubeArray<float4> textureName
#define TEXTURE3D_FLOAT(textureName) Texture3D<float4> textureName
#define TEXTURE2D_HALF(textureName) Texture2D<half4> textureName
#define TEXTURE2D_ARRAY_HALF(textureName) Texture2DArray<half4> textureName
#define TEXTURECUBE_HALF(textureName) TextureCube<half4> textureName
#define TEXTURECUBE_ARRAY_HALF(textureName) TextureCubeArray<half4> textureName
#define TEXTURE3D_HALF(textureName) Texture3D<half4> textureName
#define TEXTURE2D_SHADOW(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_SHADOW(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_SHADOW(textureName) TEXTURECUBE(textureName)

12
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/PSSL.hlsl


#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
#define TEXTURE2D_FLOAT(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_FLOAT(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_FLOAT(textureName) TEXTURECUBE(textureName)
#define TEXTURECUBE_ARRAY_FLOAT(textureName) TEXTURECUBE_ARRAY(textureName)
#define TEXTURE3D_FLOAT(textureName) TEXTURE3D(textureName)
#define TEXTURE2D_HALF(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_HALF(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_HALF(textureName) TEXTURECUBE(textureName)
#define TEXTURECUBE_ARRAY_HALF(textureName) TEXTURECUBE_ARRAY(textureName)
#define TEXTURE3D_HALF(textureName) TEXTURE3D(textureName)
#define TEXTURE2D_SHADOW(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_SHADOW(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_SHADOW(textureName) TEXTURECUBE(textureName)

12
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/Switch.hlsl


#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
#define TEXTURE2D_FLOAT(textureName) Texture2D<float4> textureName
#define TEXTURE2D_ARRAY_FLOAT(textureName) Texture2DArray<float4> textureName
#define TEXTURECUBE_FLOAT(textureName) TextureCube<float4> textureName
#define TEXTURECUBE_ARRAY_FLOAT(textureName) TextureCubeArray<float4> textureName
#define TEXTURE3D_FLOAT(textureName) Texture3D<float4> textureName
#define TEXTURE2D_HALF(textureName) Texture2D<half4> textureName
#define TEXTURE2D_ARRAY_HALF(textureName) Texture2DArray<half4> textureName
#define TEXTURECUBE_HALF(textureName) TextureCube<half4> textureName
#define TEXTURECUBE_ARRAY_HALF(textureName) TextureCubeArray<half4> textureName
#define TEXTURE3D_HALF(textureName) Texture3D<half4> textureName
#define TEXTURE2D_SHADOW(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_SHADOW(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_SHADOW(textureName) TEXTURECUBE(textureName)

12
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/Vulkan.hlsl


#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
#define TEXTURE2D_FLOAT(textureName) Texture2D<float4> textureName
#define TEXTURE2D_ARRAY_FLOAT(textureName) Texture2DArray<float4> textureName
#define TEXTURECUBE_FLOAT(textureName) TextureCube<float4> textureName
#define TEXTURECUBE_ARRAY_FLOAT(textureName) TextureCubeArray<float4> textureName
#define TEXTURE3D_FLOAT(textureName) Texture3D<float4> textureName
#define TEXTURE2D_HALF(textureName) Texture2D<half4> textureName
#define TEXTURE2D_ARRAY_HALF(textureName) Texture2DArray<half4> textureName
#define TEXTURECUBE_HALF(textureName) TextureCube<half4> textureName
#define TEXTURECUBE_ARRAY_HALF(textureName) TextureCubeArray<half4> textureName
#define TEXTURE3D_HALF(textureName) Texture3D<half4> textureName
#define TEXTURE2D_SHADOW(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_SHADOW(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_SHADOW(textureName) TEXTURECUBE(textureName)

12
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/API/XBoxOne.hlsl


#define TEXTURECUBE_ARRAY(textureName) TextureCubeArray textureName
#define TEXTURE3D(textureName) Texture3D textureName
#define TEXTURE2D_FLOAT(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_FLOAT(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_FLOAT(textureName) TEXTURECUBE(textureName)
#define TEXTURECUBE_ARRAY_FLOAT(textureName) TEXTURECUBE_ARRAY(textureName)
#define TEXTURE3D_FLOAT(textureName) TEXTURE3D(textureName)
#define TEXTURE2D_HALF(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_HALF(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_HALF(textureName) TEXTURECUBE(textureName)
#define TEXTURECUBE_ARRAY_HALF(textureName) TEXTURECUBE_ARRAY(textureName)
#define TEXTURE3D_HALF(textureName) TEXTURE3D(textureName)
#define TEXTURE2D_SHADOW(textureName) TEXTURE2D(textureName)
#define TEXTURE2D_ARRAY_SHADOW(textureName) TEXTURE2D_ARRAY(textureName)
#define TEXTURECUBE_SHADOW(textureName) TEXTURECUBE(textureName)

10
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Core.hlsl


// Stereo-related bits
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
#define SCREENSPACE_TEXTURE TEXTURE2D_ARRAY
#define SCREENSPACE_TEXTURE TEXTURE2D_ARRAY
#define SCREENSPACE_TEXTURE_FLOAT TEXTURE2D_ARRAY_FLOAT
#define SCREENSPACE_TEXTURE_HALF TEXTURE2D_ARRAY_HALF
#define SCREENSPACE_TEXTURE TEXTURE2D
#endif // defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
#define SCREENSPACE_TEXTURE TEXTURE2D
#define SCREENSPACE_TEXTURE_FLOAT TEXTURE2D_FLOAT
#define SCREENSPACE_TEXTURE_HALF TEXTURE2D_HALF
#endif
#if defined(UNITY_SINGLE_PASS_STEREO)
float2 TransformStereoScreenSpaceTex(float2 uv, float w)

6
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/DepthCopy.hlsl


#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
#define DEPTH_TEXTURE_MS(name, samples) Texture2DMSArray<float, samples> name
#define DEPTH_TEXTURE(name) TEXTURE2D_ARRAY(name)
#define DEPTH_TEXTURE(name) TEXTURE2D_ARRAY_FLOAT(name)
#define DEPTH_TEXTURE(name) TEXTURE2D(name)
#define DEPTH_TEXTURE(name) TEXTURE2D_FLOAT(name)
#define LOAD(uv, sampleIndex) LOAD_TEXTURE2D_MSAA(_CameraDepthAttachment, uv, sampleIndex)
#define SAMPLE(uv) SAMPLE_DEPTH_TEXTURE(_CameraDepthAttachment, sampler_CameraDepthAttachment, uv)
#endif

int2 coord = int2(uv * _CameraDepthAttachment_TexelSize.zw);
float outDepth = DEPTH_DEFAULT_VALUE;
[unroll]
UNITY_UNROLL
for (int i = 0; i < MSAA_SAMPLES; ++i)
outDepth = DEPTH_OP(LOAD(coord, i), outDepth);
return outDepth;

10
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightScreenSpaceShadows.shader


#include "LWRP/ShaderLibrary/Shadows.hlsl"
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
TEXTURE2D_ARRAY(_CameraDepthTexture);
TEXTURE2D_ARRAY_FLOAT(_CameraDepth);
TEXTURE2D(_CameraDepthTexture);
TEXTURE2D_FLOAT(_CameraDepth);
SAMPLER(sampler_CameraDepthTexture);
SAMPLER(sampler_CameraDepth);
struct VertexInput
{

UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
float deviceDepth = SAMPLE_TEXTURE2D_ARRAY(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoord.xy, unity_StereoEyeIndex).r;
float deviceDepth = SAMPLE_TEXTURE2D_ARRAY(_CameraDepth, sampler_CameraDepth, i.texcoord.xy, unity_StereoEyeIndex).r;
float deviceDepth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoord.xy);
float deviceDepth = SAMPLE_DEPTH_TEXTURE(_CameraDepth, sampler_CameraDepth, i.texcoord.xy);
#endif
#if UNITY_REVERSED_Z

正在加载...
取消
保存