浏览代码

shader upgrade to 5.5

/main
vlad-andreev 8 年前
当前提交
60d4b7c4
共有 4 个文件被更改,包括 28 次插入18 次删除
  1. 16
      Assets/ScriptableRenderLoop/fptl/Internal-DeferredReflections.shader
  2. 10
      Assets/ScriptableRenderLoop/fptl/Internal-DeferredShading.shader
  3. 2
      Assets/ScriptableRenderLoop/fptl/LightDefinitions.cs
  4. 18
      Assets/TestScenes/ForwardRenderLoop/Materials/gray.mat

16
Assets/ScriptableRenderLoop/fptl/Internal-DeferredReflections.shader


return float4(c,1.0);
}
struct UnityStandardData
struct StandardData
{
float3 specularColor;
float3 diffuseColor;

};
UnityStandardData UnityStandardDataFromGbuffer(float4 gbuffer0, float4 gbuffer1, float4 gbuffer2)
StandardData UnityStandardDataFromGbuffer(float4 gbuffer0, float4 gbuffer1, float4 gbuffer2)
UnityStandardData data;
StandardData data;
data.normalWorld = normalize(2*gbuffer2.xyz-1);
data.smoothness = gbuffer1.a;

float4 gbuffer1 = _CameraGBufferTexture1.Load( uint3(pixCoord.xy, 0) );
float4 gbuffer2 = _CameraGBufferTexture2.Load( uint3(pixCoord.xy, 0) );
UnityStandardData data = UnityStandardDataFromGbuffer(gbuffer0, gbuffer1, gbuffer2);
StandardData data = UnityStandardDataFromGbuffer(gbuffer0, gbuffer1, gbuffer2);
float oneMinusReflectivity = 1.0 - SpecularStrength(data.specularColor.rgb);
float3 worldNormalRefl = reflect(-vWSpaceVDir, data.normalWorld);

UnityLight light;
light.color = 0;
light.dir = 0;
light.ndotl = 0;
//light.ndotl = 0;
float3 ints = 0;

worldNormal0 = worldNormalRefl;
Unity_GlossyEnvironmentData g;
g.roughness = 1 - data.smoothness;
g.perceptualRoughness = SmoothnessToPerceptualRoughness(data.smoothness);
g.reflUVW = worldNormal0;
half3 env0 = Unity_GlossyEnvironment(UNITY_PASS_TEXCUBEARRAY(_reflCubeTextures), lgtDat.iSliceIndex, float4(lgtDat.fLightIntensity, lgtDat.fDecodeExp, 0.0, 0.0), g);

{
#if UNITY_GLOSS_MATCHES_MARMOSET_TOOLBAG2 && (SHADER_TARGET >= 30)
// TODO: remove pow, store cubemap mips differently
half roughness = pow(glossIn.roughness, 3.0/4.0);
half roughness = pow(glossIn.perceptualRoughness, 3.0/4.0);
half roughness = glossIn.roughness; // MM: switched to this
half roughness = glossIn.perceptualRoughness; // MM: switched to this
#endif
//roughness = sqrt(sqrt(2/(64.0+2))); // spec power to the square root of real roughness

10
Assets/ScriptableRenderLoop/fptl/Internal-DeferredShading.shader


//return float4(pow(c,1/2.2),1.0);
}
struct UnityStandardData
struct StandardData
{
float3 specularColor;
float3 diffuseColor;

UnityStandardData UnityStandardDataFromGbuffer(float4 gbuffer0, float4 gbuffer1, float4 gbuffer2)
StandardData UnityStandardDataFromGbuffer(float4 gbuffer0, float4 gbuffer1, float4 gbuffer2)
UnityStandardData data;
StandardData data;
data.normalWorld = normalize(2*gbuffer2.xyz-1);
data.smoothness = gbuffer1.a;

float4 gbuffer1 = _CameraGBufferTexture1.Load( uint3(pixCoord.xy, 0) );
float4 gbuffer2 = _CameraGBufferTexture2.Load( uint3(pixCoord.xy, 0) );
UnityStandardData data = UnityStandardDataFromGbuffer(gbuffer0, gbuffer1, gbuffer2);
StandardData data = UnityStandardDataFromGbuffer(gbuffer0, gbuffer1, gbuffer2);
float oneMinusReflectivity = 1.0 - SpecularStrength(data.specularColor.rgb);

UnityLight light;
light.color.xyz = lgtDat.vCol.xyz*atten;
light.dir.xyz = mul((float3x3) g_mViewToWorld, vL).xyz; //unity_CameraToWorld
light.ndotl = LambertTerm(data.normalWorld, light.dir.xyz);
ints += UNITY_BRDF_PBS (data.diffuseColor, data.specularColor, oneMinusReflectivity, data.smoothness, data.normalWorld, vWSpaceVDir, light, ind);

UnityLight light;
light.color.xyz = lgtDat.vCol.xyz*atten;
light.dir.xyz = vLw;
light.ndotl = LambertTerm(data.normalWorld, vLw);
ints += UNITY_BRDF_PBS (data.diffuseColor, data.specularColor, oneMinusReflectivity, data.smoothness, data.normalWorld, vWSpaceVDir, light, ind);

2
Assets/ScriptableRenderLoop/fptl/LightDefinitions.cs


float FetchDepth(Texture2D depthTexture, uint2 pixCoord)
{
return /*1-*/depthTexture.Load( uint3(pixCoord.xy, 0) ).x;
return 1-depthTexture.Load( uint3(pixCoord.xy, 0) ).x;
}
#endif

18
Assets/TestScenes/ForwardRenderLoop/Materials/gray.mat


m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: gray
m_Shader: {fileID: 4800000, guid: 908b379d4818cd64184b95a21123d909, type: 3}
m_ShaderKeywords: S_RECEIVE_SHADOWS S_SPECULAR_METALLIC
m_LightmapFlags: 5
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: S_RECEIVE_SHADOWS S_SPECULAR_METALLIC _EMISSION
m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap:
OriginalShader: Standard (Specular setup)

name: _DstBlend
second: 0
- first:
name: _GlossMapScale
second: 1
- first:
- first:
name: _GlossyReflections
second: 1
- first:
name: _Metallic
second: 0

- first:
name: _Parallax
second: 0.02
- first:
name: _SmoothnessTextureChannel
second: 0
- first:
name: _SpecularHighlights
second: 1
- first:
name: _SpecularMode
second: 2

正在加载...
取消
保存