Is it possible to do displacement mapping on iOS ?

Hi,

I’ve been experimenting with making a displacement mapped ocean. I’ve got a nice working material running on a desktop and now want to run it on iOS. Problem is that it appears “Texture Sampling” to fetch my height map data won’t work in the current GLES 2 pipeline. I understand why this is since it is using SM2/SM3 (tried Metal too), and SM4 is needed to support vertex texture sampling.

The question I have, is it appears iOS DOES support texture sampling from a vertex shader (Listing 10-10):
[Best Practices for Shaders][1]

is it possible to override the “shader model level” to run iOS as SM4? Or is there a work around to get TextureSampler to work in the vertex shader path?

Thanks in advance!

You wouldn’t want to set IOS to always be SM4 feature level, as that will enable a slew of other things. However, you can override the SM4 selection for your one feature. We have made changes recently for MetalMRT (deferred on Metal), with replacing FeatureLevel checks with something like:

inline bool RHISupportsComputeShaders(const EShaderPlatform Platform)
{
	return IsFeatureLevelSupported(Platform, ERHIFeatureLevel::SM5) || (Platform == SP_METAL_MRT);
}

Then you can add whatever logic in that function for IOS, or extension checking, or whatever.

Does that work well enough for your particular issue?

Josh

Possibly, Ill dig into it this weekend (alas not my day job). Would TextureSampling in a vertex shader be considered a “Compute Shader”?

I know under the hood the material graph is compiled to HLSL then HLSLCC is used to compile to GLSL. Looking at FHLSLMaterialTranslator::TextureSample I see it explicitly check for SM4 (like below). If I override this making it “not an error” will that work? Does HLSLCC have any concept of SM feature level? IE if the material graph generating HLSL that used TextureSample in a vertex shader, would HLSL happily try to generate the Metal shader? (or GLES for that matter?) Or will it explode too? (Obviously going to try this when I get a chance)


    if (ShaderFrequency != SF_Pixel
    && ErrorUnlessFeatureLevelSupported(ERHIFeatureLevel::SM4) == INDEX_NONE)
    {
    	return INDEX_NONE;
    }