浏览代码

HDRenderPipeline: Create branch

/Branch_Batching2
sebastienlagarde 8 年前
当前提交
091558f9
共有 2 个文件被更改,包括 42 次插入12 次删除
  1. 35
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitData.hlsl
  2. 19
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl

35
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitData.hlsl


// Calculate displacement for per vertex displacement mapping
float ComputePerVertexDisplacement(LayerTexCoord layerTexCoord, float4 vertexColor, float lod)
{
return SampleHeightmapLod(layerTexCoord, lod);
return SampleHeightmapLod(layerTexCoord, lod, _HeightCenter, _HeightAmplitude);
}
void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)

float3 viewDirTS = TransformWorldToTangent(V, input.tangentToWorld);
int numSteps = (int)lerp(_PPDMaxSamples, _PPDMinSamples, viewDirTS.z);
// To be correct, we need to perform PPP on each unique UVSet
// And if we are triplanar we are suppose to do it 3 time (one for each direction)
// It is catastrophic for performance so PPP is only allowed on the UVSet use for the Main layer.
// However it still take into account all heightmap to produce the height use for the displacement
ParallaxOcclusionMappingLayer1(layerTexCoord, numSteps, viewDirTS);
ParallaxOcclusionMappingLayer2(layerTexCoord, numSteps, viewDirTS);
ParallaxOcclusionMappingLayer3(layerTexCoord, numSteps, viewDirTS);
#endif
}

return blendMasks;
}
/*
// Calculate displacement for per vertex displacement mapping
float ComputePerPixelHeightDisplacement(LayerTexCoord layerTexCoord, float4 vertexColor, float lod, float4 weights)
{
float height0 = SampleHeightmapLodOffset0(layerTexCoord, lod, _HeightCenter0, _HeightAmplitude0, _HeightCenterOffset0, _HeightFactor0);
float height1 = SampleHeightmapLodOffset1(layerTexCoord, lod, _HeightCenter1, _HeightAmplitude1, _HeightCenterOffset1, _HeightFactor1);
float height2 = SampleHeightmapLodOffset2(layerTexCoord, lod, _HeightCenter2, _HeightAmplitude2, _HeightCenterOffset2, _HeightFactor2);
float height3 = SampleHeightmapLodOffset3(layerTexCoord, lod, _HeightCenter3, _HeightAmplitude3, _HeightCenterOffset3, _HeightFactor3);
float heightResult = BlendLayeredScalar(height0, height1, height2, height3, weights);
#if defined(_MAIN_LAYER_INFLUENCE_MODE)
// Think that inheritbasedheight will be 0 if height0 is fully visible in weights. So there is no double contribution of height0
float inheritBaseHeight = BlendLayeredScalar(0.0, _InheritBaseHeight1, _InheritBaseHeight2, _InheritBaseHeight3, weights);
return heightResult + height0 * inheritBaseHeight;
#endif
}
*/
// Calculate displacement for per vertex displacement mapping
float ComputePerVertexDisplacement(LayerTexCoord layerTexCoord, float4 vertexColor, float lod)
{

ComputeMaskWeights(blendMasks, weights);
float height0 = SampleHeightmapLod0(layerTexCoord, lod, _HeightCenterOffset0, _HeightFactor0);
float height1 = SampleHeightmapLod1(layerTexCoord, lod, _HeightCenterOffset1, _HeightFactor1);
float height2 = SampleHeightmapLod2(layerTexCoord, lod, _HeightCenterOffset2, _HeightFactor2);
float height3 = SampleHeightmapLod3(layerTexCoord, lod, _HeightCenterOffset3, _HeightFactor3);
float height0 = SampleHeightmapLod0(layerTexCoord, lod, _HeightCenter0, _HeightAmplitude0, _HeightCenterOffset0, _HeightFactor0);
float height1 = SampleHeightmapLod1(layerTexCoord, lod, _HeightCenter1, _HeightAmplitude1, _HeightCenterOffset1, _HeightFactor1);
float height2 = SampleHeightmapLod2(layerTexCoord, lod, _HeightCenter2, _HeightAmplitude2, _HeightCenterOffset2, _HeightFactor2);
float height3 = SampleHeightmapLod3(layerTexCoord, lod, _HeightCenter3, _HeightAmplitude3, _HeightCenterOffset3, _HeightFactor3);
float heightResult = BlendLayeredScalar(height0, height1, height2, height3, weights);
#if defined(_MAIN_LAYER_INFLUENCE_MODE)

19
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/LitDataInternal.hlsl


ADD_IDX(layerTexCoord.details).uvXY = TRANSFORM_TEX(uvXY, ADD_IDX(_DetailMap));
}
float ADD_IDX(SampleHeightmap)(LayerTexCoord layerTexCoord, float centerOffset = 0.0, float multiplier = 1.0)
// TODO: Ideally we should concat these value in the inspector - But still in development and use change frequently
float ADD_IDX(SampleHeightmap)(LayerTexCoord layerTexCoord, float centerOffset, float heightMultiplier, float layerCenterOffset = 0.0, float layerHeightMultiplier = 1.0)
{
#ifdef _HEIGHTMAP
return (SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), ADD_IDX(layerTexCoord.base)).r - centerOffset - layerCenterOffset) * heightMultiplier * layerHeightMultiplier;
#else
return 0.0;
#endif
}
float ADD_IDX(SampleHeightmapLod)(LayerTexCoord layerTexCoord, float lod, float centerOffset, float heightMultiplier, float layerCenterOffset = 0.0, float layerHeightMultiplier = 1.0)
return (SAMPLE_LAYER_TEXTURE2D(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), ADD_IDX(layerTexCoord.base)).r - ADD_IDX(_HeightCenter) - centerOffset) * ADD_IDX(_HeightAmplitude) * multiplier;
return (SAMPLE_LAYER_TEXTURE2D_LOD(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), ADD_IDX(layerTexCoord.base), lod).r - centerOffset - layerCenterOffset) * heightMultiplier * layerHeightMultiplier;
float ADD_IDX(SampleHeightmapLod)(LayerTexCoord layerTexCoord, float lod, float centerOffset = 0.0, float multiplier = 1.0)
// Use with Per pixel Displacement - No triplanar allowed here as this should be perform 3 times for each UVSet
float ADD_IDX(SampleHeightmapLodOffset)(LayerTexCoord layerTexCoord, float lod, float2 texOffset, float centerOffset, float heightMultiplier, float layerCenterOffset = 0.0, float layerHeightMultiplier = 1.0)
return (SAMPLE_LAYER_TEXTURE2D_LOD(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), ADD_IDX(layerTexCoord.base), lod).r - ADD_IDX(_HeightCenter) - centerOffset) * ADD_IDX(_HeightAmplitude) * multiplier;
return (SAMPLE_TEXTURE2D_LOD(ADD_IDX(_HeightMap), ADD_ZERO_IDX(sampler_HeightMap), ADD_IDX(layerTexCoord.base).uv + texOffset, lod).r - centerOffset - layerCenterOffset) * heightMultiplier * layerHeightMultiplier;
#else
return 0.0;
#endif

正在加载...
取消
保存