Thanks! Now D3D11 works fine. However, iOS is not working
1. RSC_UAV is also never set for iOS. Since my iPad can even do compute shader based voxelization, it should support UAV, right?
2. Shader compile error:
Code: Select all
Metal SL Compiler Error in 0SpecularIblIntegrator_cs:
Compilation failed:
program_source:331:31: error: no matching member function for call to 'read'
float4 lastResultVal = OGRE_imageLoad2D( lastResult, loadCoords.xy );
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
program_source:108:50: note: expanded from macro 'OGRE_imageLoad2D'
#define OGRE_imageLoad2D( inImage, iuv ) inImage.read( ushort2( iuv ) )
~~~~~~~~^~~~
/System/Library/PrivateFrameworks/GPUCompiler.framework/Libraries/lib/clang/902.9/include/metal/metal_texture:3071:24: note: candidate function not viable: requires at least 2 arguments, but 1 was provided
METAL_FUNC vec<T, 4> read(ushort2 coord, ushort array, ushort lod = 0) const thread
^
/System/Library/PrivateFrameworks/GPUCompiler.framework/Libraries/lib/clang/902.9/include/metal/metal_texture:3090:24: note: candidate function not viable: requires at least 2 arguments, but 1 was provided
METAL_FUNC vec<T, 4> read(uint2 coord, uint array, uint lod = 0) const thread
^
/System/Library/PrivateFrameworks/GPUCompiler.framework/Libraries/lib/clang/902.9/include/metal/metal_texture:3110:24: note: candidate function not viable: requires at least 2 arguments, but 1 was provided
METAL_FUNC vec<T, 4> read(ushort2 coord, ushort array, ushort lod = 0) const device
^
/System/Library/PrivateFrameworks/GPUCompiler.framework/Libraries/lib/clang/902.9/include/metal/metal_texture:3129:24: note: candidate function not viable: requires at least 2 arguments, but 1 was provided
METAL_FUNC vec<T, 4> read(uint2 coord, uint array, uint lod = 0) const device
^
/System/Library/PrivateFrameworks/GPUCompiler.framework/Libraries/lib/clang/902.9/include/metal/metal_texture:3150:24: note: candidate function not viable: requires at least 2 arguments, but 1 was provided
METAL_FUNC vec<T, 4> read(ushort2 coord, ushort array, ushort lod = 0) const constant
^
/System/Library/PrivateFrameworks/GPUCompiler.framework/Libraries/lib/clang/902.9/include/metal/metal_texture:3169:24: note: candidate function not viable: requires at least 2 arguments, but 1 was provided
METAL_FUNC vec<T, 4> read(uint2 coord, uint array, uint lod = 0) const constant
^
program_source:360:14: error: use of undeclared identifier 'mod'
normal.x = mod( uv0.x, 0.5 ) * 4.0 - 1.0;
^
program_source:365:23: error: no matching function for call to 'runIntegrator'
float4 outputValue = runIntegrator( normal, gl_GlobalInvocationID.xyz PARAMS_ARG );
^~~~~~~~~~~~~
program_source:321:16: note: candidate function not viable: no known conversion from 'texture2d<float, access::read_write>' to 'texture2d_array<float, access::read_write>' for 6th argument
INLINE float4 runIntegrator( float3 normal, ushort3 loadCoords PARAMS_ARG_DECL )
^
Error retriving entry point 'main_metal' in shader 0SpecularIblIntegrator_cs
Like we discussed, I've added a variable perceptualRoughness to PixelData struct because I'm using both roughness AND perceptualRoughness (see below). I haven't tested as carefully as xrgo, but I also did some experiments and believe this change is needed to match other engines.
Here is the diff that we're currently satisfied with:
Code: Select all
--- a/Hlms/Pbs/Any/Main/200.BRDFs_piece_ps.any
+++ b/Hlms/Pbs/Any/Main/200.BRDFs_piece_ps.any
@@ -217,7 +217,7 @@ float3 BRDF_IR( float3 lightDir, float3 lightDiffuse, PixelData pixelData )
@property( ltc_texture_available )
#define brdfLUT ltcMatrix
float2 envBRDF = OGRE_SampleArray2D( brdfLUT, ltcSampler,
- float2( pixelData.NdotV, 1.0 - pixelData.roughness ), 2 ).xy;
+ float2( pixelData.NdotV, 1.0 - pixelData.perceptualRoughness ), 2 ).xy;
@else
float2 envBRDF = float2( 1.0f, 0.0f );
@end
diff --git a/Hlms/Pbs/Any/Main/800.PixelShader_piece_ps.any b/Hlms/Pbs/Any/Main/800.PixelShader_piece_ps.any
index 166fa79..aa57e7d 100644
--- a/Hlms/Pbs/Any/Main/800.PixelShader_piece_ps.any
+++ b/Hlms/Pbs/Any/Main/800.PixelShader_piece_ps.any
@@ -1,4 +1,4 @@
-@piece( envSpecularRoughness ) pixelData.roughness * passBuf.envMapNumMipmaps @end
+@piece( envSpecularRoughness ) pixelData.perceptualRoughness * passBuf.envMapNumMipmaps @end
@piece( DefaultHeaderPS )
@property( !fresnel_scalar )
@@ -34,6 +34,7 @@
@end
float4 diffuse;
float3 specular;
+ float perceptualRoughness;
float roughness;
float_fresnel F0;
@@ -300,15 +301,15 @@
@piece( SampleRoughnessMap )
/// ROUGHNESS MAP
- pixelData.roughness = material.kS.w;
+ pixelData.perceptualRoughness = material.kS.w;
@property( roughness_map )
- pixelData.roughness = SampleRoughness( textureMaps@value( roughness_map_idx ),
+ pixelData.perceptualRoughness = SampleRoughness( textureMaps@value( roughness_map_idx ),
samplerState@value( roughness_map_sampler ),
UV_ROUGHNESS( inPs.uv@value(uv_roughness).xy ),
texIndex_roughnessIdx ).x;
@end
// convert from perceptual linear roughness to internal roughness
- pixelData.roughness = max( 0.001f, pixelData.roughness * pixelData.roughness );
+ pixelData.roughness = max( 0.001f, pixelData.perceptualRoughness * pixelData.perceptualRoughness );
@end