UnityShader源码2017---学习笔记与自我拓展045

源自Internal-BlitCopy,Internal-BlitCopyDepth,Internal-CombineDepthNormals

讲一下unity的潜规则

Shader "Hidden/Internal-CombineDepthNormals" {}

只有以Hidden/开头的shader,都会在shader列表中隐藏起来。

 

BlitCopy从名字上看应该是Blit()函数调用时使用的吧,不负责任的猜测。

这个shader没有知识点

看一下BlitCopyDepth里的几个函数

SAMPLE_RAW_DEPTH_TEXTURE(_MainTex, i.texcoord)

然后查HLSLSupport里的

#define SAMPLE_RAW_DEPTH_TEXTURE(tex, uv) UNITY_SAMPLE_TEX2DARRAY(tex, float3(uv.xy, (float)unity_StereoEyeIndex))

然后就到了

#define UNITY_SAMPLE_TEX2DARRAY(tex,coord) tex.Sample (sampler##tex,coord)

。。。好像都到头了。。。废话了一堆,没有什么可以记录的

看一下CombineDepthNormals

这个其实就是把depthNormal弄到一张图里

return (d < (1.0-1.0/65025.0)) ? EncodeDepthNormal (d, n.xyz) : float4(0.5,0.5,1.0,1.0);

比较难以理解的就是1.0-1.0/65025.0这个几乎接近1的值。我也不理解,可能是知识断层

inline float4 EncodeDepthNormal( float depth, float3 normal )
{
    float4 enc;
    enc.xy = EncodeViewNormalStereo (normal);
    enc.zw = EncodeFloatRG (depth);
    return enc;
}

。。。感觉好水。。。难道是不想写blog了么。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值