浏览代码

update shader with latest change

/stochastic_alpha_test
Sebastien Lagarde 7 年前
当前提交
bd36a2f9
共有 4 个文件被更改,包括 12 次插入22 次删除
  1. 2
      ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Eye.hlsl
  2. 8
      ScriptableRenderPipeline/HDRenderPipeline/Material/Fabric/FabricDataInternal.hlsl
  3. 21
      ScriptableRenderPipeline/HDRenderPipeline/Material/Hair/Hair.hlsl
  4. 3
      ScriptableRenderPipeline/HDRenderPipeline/Material/Hair/Hair.shader

2
ScriptableRenderPipeline/HDRenderPipeline/Material/Eye/Eye.hlsl


void FillMaterialIdStandardData(float3 baseColor, float specular, float metallic, float roughness, float3 normalWS, float3 tangentWS, float anisotropy, inout BSDFData bsdfData)
{
bsdfData.diffuseColor = baseColor*0.5;
bsdfData.fresnel0 =1;
bsdfData.fresnel0 = baseColor;
// TODO: encode specular

8
ScriptableRenderPipeline/HDRenderPipeline/Material/Fabric/FabricDataInternal.hlsl


// Apply tiling options
ADD_IDX(layerTexCoord.base).uv = TRANSFORM_TEX(uvBase, ADD_IDX(_BaseColorMap));
ADD_IDX(layerTexCoord.details).uv = TRANSFORM_TEX(uvDetails, ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.fuzz).uv = TRANSFORM_TEX(0.2*uvDetails, ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.fuzz).uv = TRANSFORM_TEX(0.1*uvDetails, ADD_IDX(_DetailMap));
ADD_IDX(layerTexCoord.base).uvXZ = TRANSFORM_TEX(uvXZ, ADD_IDX(_BaseColorMap));
ADD_IDX(layerTexCoord.base).uvXY = TRANSFORM_TEX(uvXY, ADD_IDX(_BaseColorMap));

// Return opacity
float ADD_IDX(GetSurfaceData)(FragInputs input, LayerTexCoord layerTexCoord, out SurfaceData surfaceData, out float3 normalTS)
{
float alpha = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_BaseColorMap), ADD_ZERO_IDX(sampler_BaseColorMap), ADD_IDX(layerTexCoord.base)).a * ADD_IDX(_BaseColor).a;
float alpha = SAMPLE_UVMAPPING_TEXTURE2D(ADD_IDX(_BaseColorMap), ADD_ZERO_IDX(sampler_BaseColorMap), ADD_IDX(layerTexCoord.details)).a * ADD_IDX(_BaseColor).a;
// Perform alha test very early to save performance (a killed pixel will not sample textures)

float a1 = 1 - a0;
float ditherSample = BayerDither4x4(input.unPositionSS.xy);
float ditherPattern = (abs(a0 - alpha) < ditherSample) ? a1 : a0;
alpha = alpha > ditherPattern ? 1.0 : alpha;
//alpha = alpha > ditherPattern ? 1.0 : alpha;
//----------------------------------
clip(alpha - _AlphaCutoff); // Let artists make prepass cutout thinner

#else
surfaceData.ambientOcclusion = 1.0;
#endif
// This part of the code is not used in case of layered shader but we keep the same macro system for simplicity
#if !defined(LAYERED_LIT_SHADER)

21
ScriptableRenderPipeline/HDRenderPipeline/Material/Hair/Hair.hlsl


bsdfData.perceptualRoughness = lerp(0.4,1.5,surfaceData.perceptualSmoothness);//PerceptualSmoothnessToPerceptualRoughness(surfaceData.perceptualSmoothness);
bsdfData.roughness = PerceptualRoughnessToRoughness(bsdfData.perceptualRoughness);
bsdfData.fresnel0 = 1;
bsdfData.fresnel0 = 0.04;
bsdfData.tangentWS = surfaceData.tangentWS;
bsdfData.bitangentWS = cross(surfaceData.normalWS, surfaceData.tangentWS);

// For anisotropy we must not saturate these values
float TdotH = dot(bsdfData.tangentWS, H);
float TdotL = dot(bsdfData.tangentWS, L);
float BdotH = dot(B2, H);
float BdotL = dot(B2, L);
float BdotV = dot(B2, V);
bsdfData.roughnessT = ClampRoughnessForAnalyticalLights(bsdfData.roughnessT);
bsdfData.roughnessB = ClampRoughnessForAnalyticalLights(bsdfData.roughnessB);
// TODO: Do comparison between this correct version and the one from isotropic and see if there is any visual difference
// TODO: Do comparison between this correct version and the one from isotropic and see if there is any visual difference
Vis = V_SmithJointGGXAniso( preLightData.TdotV, preLightData.BdotV, NdotV, TdotL, BdotL, NdotL,
bsdfData.roughnessT, bsdfData.roughnessB);
D = D_GGXAniso(TdotH, BdotH, NdotH, bsdfData.roughnessT, bsdfData.roughnessB);
float3 hairSpec2 = _SecondarySpecular*(Vis * D)*lerp(bsdfData.diffuseColor,_SpecularTint,0.5);
float3 hairSpec2 = _SecondarySpecular*KajiyaKaySpecular(H, V, bsdfData.normalWS, B2, _SecondarySpecularShift, bsdfData.roughness)*lerp(bsdfData.diffuseColor,_SpecularTint,0.5);
float scatterFresnel = 3*dot(V,-transL)*dot(V,-transL)*dot(V,-transL)*(1.0 - NdotV)*(1.0 - NdotL)+ 0.5*(1-NdotV)*(1-NdotV)*(1-NdotV);
float scatterFresnel = 3*dot(V,-transL)*dot(V,-transL)*dot(V,-transL)*dot(V,-transL)*dot(V,-transL)*dot(V,-transL)*dot(V,-transL)*dot(V,-transL)*dot(V,-transL)*(1.0 - NdotV)*(1.0 - NdotL)+ 0.5*(1-NdotV)*(1-NdotV)*(1-NdotV)*(1-NdotV)*(1-NdotV)*(1-NdotV)*(1-NdotV)*(1-NdotV)*(1-NdotV);
float3 transColor = saturate(transAmount * float3(0.992, 0.808, 0.518)*bsdfData.specularOcclusion);
float3 transColor = 2*saturate(transAmount * float3(1, 0.6, 0.26)*bsdfData.specularOcclusion*bsdfData.specularOcclusion);
float diffuseTerm = Lambert();
diffuseLighting = bsdfData.diffuseColor * diffuseTerm+transColor;
}

3
ScriptableRenderPipeline/HDRenderPipeline/Material/Hair/Hair.shader


}
}
CustomEditor "Experimental.Rendering.HDPipeline.HairGUI"
CustomEditor "Experimental.Rendering.HDPipeline.CharacterGUI"
//CustomEditor "Experimental.Rendering.HDPipeline.HairGUI"
}
正在加载...
取消
保存