[SM5] Error X4532 with POM Material

I have a POM Material in unreal, my material is like this
7afe39a2b58aaea0429192936115b65b026be4d6.jpeg
But i get a error and say this: [SM5] error X4532: cannot map expression to cs_5_0 instruction set, my gpu supports shader model 5 and i am using unreal 4.8.1.

Try using the updated code from the POM material thread towards the end. Page 5 should have it. I’m not sure what is going on but there was an early version of this code that had a questionable texture lookup method. Maybe that is causing some problems?

Also if that does not work, what is your video card?

If you want to try just swapping the texture sample lines find these 2 lines:

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 ) );

and replace them with:

CurrSampledHeight = dot(InChannelMask, Tex.SampleGrad(TexSampler,InTexCoord+CurrOffset,InDX,InDY));

Then you must also rename the heightmap input “NormalHeightMap” to “Tex”.

If that doesn’t work try removing the “calcSilhouette” node.

Until 4.8.1 POM works fine, but on 4.8.1 the following error occur:
“Error [SM5] error X4532: cannot map expression to cs_5_0 instruction set.”
Strange- in viewport of material editor the material is visualizated correctly, but can’t be saved.
4.8.1 for me is the worst release. The quality is drop so deep by some reason (Unity and CryEngine have original POM in their releases from years, but UE4 haven’t. It is absurd??? And how there are so many useless sample projects but absent some basic/critical materials- the priorities are so wrong …)

Which version, the version shown in the image at the top of this thread or the updated version from here:
https://forums.unrealengine.com/showthread.php?49169-POM-material&p=303149&viewfull=1#post303149

I haven’t seen any problems with the latter version in latest UE4.

The original version “the version shown in the image at the top” not work on UE 4.8.1. Before two days the same project work absolutely fine on 4.7

I see.

There isn’t really an engine bug here.

The version of that node you are using is using a sketchy method to sample the texture. It is possible that it was purposefully prevented from being accessed like that now that better support for sampling textures within custom nodes has been added.

Have you tried replacing the line with the line in my post above? I suspect that will fix it.

When replaced two old lines with one new and rename the heightmap input “NormalHeightMap” to "Tex in “CalcParallax” custom material expression the following error was occured:
“Error [SM5] error X3004: undeclared identifier ‘TexSampler’”

Ok, let me sync up to the latest build and I will see if I can’t try this out and reproduce it.

Although an error like that usually indicates more of a missing semicolon or parentheses mismatch…

The original code works only if not replaced the two old lines or rename any input of “CalcParallax” custom expression, but when delete “calcSilhouette” node

Well I am actually on ~4.9 and I do not have access to an exact 4.8.1 build yet but this works fine for me here.

Here is the entire custom node text to paste in case there was an error:


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 )
{
CurrSampledHeight = dot(InChannelMask, Tex.SampleGrad(TexSampler,InTexCoord+CurrOffset,InDX,InDY));
	
	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;

I just verified that this version works fine with 4.8.1. In fact I had no problem with even the original but I could see cases where it would fail to compile using that old texture sample line (it depends on the order that your textures nodes are initialized by the material editor).

I don’t think there is working solution for original POM in 4.8.1 except if delete the node “calcSilhouette”. I tried all solutions including the order of adding the texture nodes as first is height map but the following error is continue occurring: “Error [SM5] error X3004: undeclared identifier ‘TexSampler’”.

If it’s just the silhouette node causing this, it is most likely the clip operation is not working anymore. I wasn’t actually testing that part of it just the parallax.

That should probably be rewritten a different way since it doesn’t really make since to rely on clipped UVs as an opacity mask. It should probably just check if offset is less than 0 or greater than 1 and return an opacity mask rather than clipped UVs.

Actually UE4 does have POM now, it has been checked into engine for a few weeks now and will be in the next public release. It doesn’t have the silhouette mapping though since I don’t think it makes sense to support since it’s such hard to use feature. The version in that material you posted only works for simple square 0-1 uv shapes it won’t work on any random floor shape you use. There is no easy way for it to work on arbitrary UV boundaries.

About new version of POM on page 5, i can’t create and test it because there is not clear tutorial how to do that- only chaotic screenshots and texts. Tutorial of first version of POM of Ehamloptiran (on page 1, post #10) is pattern for good and clear steps tutorial!

Hard to use for us or hard to implement for you?
As much as I love the new UE4 POM feature, I shamefully admit my disappointment as to your approach on the icing on the cake, the silhouette mapping/clipping.
It’s a essential ingredient for added realism, most noticeably on corners with bricks, stones and just about anything you want to make ‘pop out’ with extra detail at oblique angles.
This is why (S)POM as featured in CE3 made such a dramatic impact, because it was a fully working solution for just about every way you could possibly need it.
With the current state of UE4 POM, you are still forcing us to revert back to tessellation/displacement if we want to achieve a similar look, making for multi material/shader needs
per scene cause there is no ‘one fits all’ available. You could make this happen Ryan but you don’t see the benefit. That’s unfortunate. I see lots of benefits!
Maybe watch this clip again and tell me, you really can’t see this looks way better with Silhouette clipping as opposed to just discarding it?
I really hope you’ll reconsider :slight_smile:

On a side note: Is PADM more of the same in terms of technique required?
It produces stunning results and afaik, it does not require a tesselated mesh.

It is easily supported by me but it would be a pain for people to actually use. You would need to make a unique material instance for pretty much every surface in the world and define the UV borders. Unless every surface in the world using it is a simple 0-1 flat square of the same size. Angles would require more math.

It is easy to turn it on for a small cube demo like that but then it only works for that cube shape.

If this is something you care about, you can easily add it yourself. It could even be a separate node it doesn’t matter where it comes from. I will even show you how, but I hope you will realize after trying to use it that this is more of a ‘demo mode’ feature and not something that usable in development. Unless there is some magical trick going on to make it work using arbitrary UV borders but so far I don’t think that is the case.

Even in the video you posted you can see the corners are not really correct you just see two separate surfaces clipping at different points so they don’t show the corners head on, instead they show the more flattering angle for the majority of the video. I feel that gives a a false impression that its more robust.

I am also suggesting that in most cases, pixel depth offset gives you the same results in a much more flexible way. The only case that doesn’t handle is exterior corners, which again the crytek method does not get right either. But it handles the surface hitting another surface like trim nicely.

I will look into PADM to see if its something different going on. Looks like its actually pushing pixels beyond the original silhouette so I am not sure exactly what is going on there.

From my experience in CryEngine the silhouette clipping worked automatically. No user input required whatsoever. The moment they released PADM however, it all became rather ‘obsolete’ cause that one was a real blast to play with.
Only a heightmap required and even if you dropped in a fairly low poly tree (with those typical bends in the trunk you wish the modeler would have given just a couple more edgeloops) it did a miraculous job of lifting the whole thing up a quality notch or two. It’s also exactly those outside corners you mention (and I’m sure you’ll agree these are among the most eye catching details in the simple architectural context of level building block-outs) that make the difference between a shading ‘gimmick’ and something coming across very realistic. Right now we have displacement to remedy this but it’s the most expensive method by far and also requires the mesh to be optimized for tessellation. Something which may or may not be desirable for all circumstances. I’ll work with the current POM on offer in the meantime cause, just to be clear, it’s an awesome improvement already. Looking forward to any possible iterations and/or improvements of course :0)
Thanks for your efforts Ryan!

Ok, maybe there is a kind of alternate clipping with the PADM that uses curvature to figure out when the ray would have left the surface’s Z plane due to curvature. I could see that working for curved objects but I still don’t think it will work for absolutely hard edged corners. Maybe it’s the type of thing that you need to build a soft chamfer into your corners for it to work nicely?

Every time I think I found a resource that explains how the automatic silhouette stuff works it turns out to be something else.

I thought this paper would go into it:
http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/Tatarchuk-ParallaxOcclusionMapping-FINAL_Print.pdf

but then at the end of the paper this is their solution to corners:

60a453a91f30030dd1b16be2f9933b591e3c8932.jpeg

I’d appreciate if you find any resources that talk about that part specifically. There is an nvidia/speedtree tree material that may be useful here but it may rely on the 'fin’s they create. not sure yet.

So far this is the best stuff I have found, and its pretty much repeating what I assumed to be the case:

http://sirkan.iit.bme.hu/~szirmay/egdisfinal3.pdf

So it does seem like using curvature is probably the way to go. That most likely means that only smooth chamfered corners will work automatically and there may be some limit to how well it works based on how round the corner is. But I am still not 100% sure since I haven’t had time to read everything.