Okay here is the material graph, theres a lot that can be improved, but is a pretty good starting point
Custom code blocks are as follows:
CalcParallax
float CurrRayHeight = 1.0;
float2 CurrOffset = float2( 0, 0 );
float2 LastOffset = float2( 0, 0 );
float LastSampledHeight = 1;
float CurrSampledHeight = 1;
int CurrSample = 0;
while ( CurrSample < (int) InNumSamples )
{
float4 Temp = Material.Texture2D_0.SampleGrad( Material.Texture2D_0Sampler, InTexCoord + CurrOffset, InDX, InDY );
CurrSampledHeight = ( ( Temp.r * InChannelMask.r ) + ( Temp.g * InChannelMask.g ) + ( Temp.b * InChannelMask.b ) );
if ( CurrSampledHeight > CurrRayHeight )
{
float Delta1 = CurrSampledHeight - CurrRayHeight;
float Delta2 = ( CurrRayHeight + InStepSize ) - LastSampledHeight;
float Ratio = Delta1/( Delta1 + Delta2 );
CurrOffset = ( Ratio ) * LastOffset + ( 1.0 - Ratio ) * CurrOffset;
CurrSample = InNumSamples + 1;
}
else
{
CurrSample++;
CurrRayHeight -= InStepSize;
LastOffset = CurrOffset;
CurrOffset += InStepSize * InMaxOffset;
LastSampledHeight = CurrSampledHeight;
}
}
return CurrOffset;
Output Type: CMOT Float 2
Inputs are:
InNumSamples
InStepSize
InTexCoord
InDX
InDY
NormalHeightMap (Not actually used, just there to ensure texture doesn’t get optimized out)
InMaxOffset
InChannelMask
CalcSilhouette
if( InUseSilhouette > 0.0f )
{
clip( InFinalCoords );
clip( 1.0f - InFinalCoords );
}
return InFinalCoords;
Output Type: CMOT Float 2
Inputs are:
InFinalCoords
InUseSilhouette
**NOTE: **Make sure that the height map is the first texture you drop into the material graph as the above custom code block accesses that texture directly via Material.Texture2D_0 and Material.Texture2D_0Sampler If you don’t drop it in first, it will be referencing the wrong texture. To fix that you will need to change those two values to whichever one is assigned to the heightmap.
, can you share how exactly achieve the displacement (tessellation) result on your picture POM2.jpg (for T_CobbleStone_Pebble_D and T_CobbleStone_Smooth_D). I tried so many variants with your height maps and exactly copy of your shader and material network (CalcParallax; CalcSilhouette; etc) but nothing work on even close to your result? I have 64 bit/PCD3DSM5 (DirectX11)? Thanks man