LitSolid(AO) missing vertex element?

I didn’t know if there is an easy way to do it, for instance with a tool. But it looks like not.

When I get time I’ll work through it as per the link @Modanung provided.

I just wanted to get all those materials in the sample code working on hololens.

Getting to the root cause of the DiffAO material or shader issue is the more important issue because root cause of the error is not yet known, whereas the CustomMaterial related error just needs the GLSL to HLSL conversion.

I wiped out the code and started fresh. Whereupon the DiffAO related object at least paints, but still throws the error about the missing vertex.

Also, modified the TechniqueCustomShader.xml file from:

<technique vs="Sample43CustomShader" ps="Sample43CustomShader" vsdefines="NOUV" >
    <pass name="alpha" depthwrite="false" blend="alpha" />


<!--Sample23CustomShader.glsl for open GL systems, but on D3D it will go for the HLSL file -->
<technique vs="CustomLitSolid" ps="CustomLitSolid" vsdefines="NOUV" >
    <pass name="alpha" depthwrite="false" blend="alpha" />

Why? Because I’m just not a shader guru and don’t aspire to be one. And would just like the SharpReality c# samples to run on a hololens. And the CustomListSolid is a fairly interesting technique to view, but can’t put into words just what it is doing.

Just wanted to keep the error that’s occuring:

[4] [Fri Jan 11 19:40:33 2019] ERROR: Failed to create input layout for shader LitSolid(AO) due to missing vertex element(s) (HRESULT 80070057)
System.Exception: Failed to create blend state(HRESULT 80070057). You can omit this exception by subscribing to Urho.Application.UnhandledException event and set Handled property to True.
ApplicationOptions: args -w -nolimit -x 1268 -y 720 -p “CoreData;Data” -touch -hd -landscape -portrait
[4][Fri Jan 11 19:40:39 2019] ERROR: Failed to create blend state (HRESULT 80070057)

In the urho3d docs, there is this:

Inbuilt compilation defines

When rendering scene objects, t_he engine expects certain shader permutations to exist_ for different geometry types and lighting conditions. These correspond to the following compilation defines:

Vertex shader:

*** NUMVERTEXLIGHTS=1,2,3 or 4: number of vertex lights influencing the object**

Could this be what the error is referring to? There is a missing vertex light?

Got the urho logging going, so getting a bit more info, but not much. Here’s some of the log when loading the basic rendering techniques sample:

1:)  [Fri Jan 25 17:25:27 2019] DEBUG: Loading resource Shaders/HLSL/CopyFramebuffer.hlsl
1:)  [Fri Jan 25 17:25:28 2019] DEBUG: Compiled vertex shader CopyFramebuffer()
1:)  [Fri Jan 25 17:25:28 2019] DEBUG: Compiled pixel shader CopyFramebuffer()
1:)  [Fri Jan 25 17:25:28 2019] DEBUG: Compiled vertex shader Water()
1:)  [Fri Jan 25 17:25:28 2019] DEBUG: Compiled pixel shader Water()
1:)  [Fri Jan 25 17:25:28 2019] DEBUG: Loaded cached vertex shader CustomLitSolid(NOUV)
1:)  [Fri Jan 25 17:25:28 2019] DEBUG: Loaded cached pixel shader CustomLitSolid()
1:)  [Fri Jan 25 17:25:28 2019] DEBUG: Compiled vertex shader LitSolid(AO)
1:)  [Fri Jan 25 17:25:28 2019] DEBUG: Compiled pixel shader LitSolid(AO DIFFMAP)
4:)  [Fri Jan 25 17:25:28 2019] ERROR: Failed to create input layout for shader LitSolid(AO) due to missing vertex element(s) (HRESULT 80070057)
1:)  [Fri Jan 25 17:25:28 2019] DEBUG: Compiled pixel shader LitSolid(DIFFMAP DIRLIGHT PERPIXEL SPECULAR)
1:)  [Fri Jan 25 17:25:28 2019] DEBUG: Compiled pixel shader LitSolid(DIFFMAP)
1:)  [Fri Jan 25 17:25:30 2019] DEBUG: Compiled vertex shader Unlit(NOUV)
1:)  [Fri Jan 25 17:25:30 2019] DEBUG: Compiled pixel shader Unlit()
1:)  [Fri Jan 25 17:25:30 2019] DEBUG: Compiled pixel shader LitSolid(AMBIENT DIRLIGHT NORMALMAP PERPIXEL)
Failed to create blend state (HRESULT 80070057). You can omit this exception by subscribing to Urho.Application.UnhandledException event and set Handled property to True.
ApplicationOptions: args -w -nolimit -x 1268 -y 720 -p "CoreData;Data" -touch -hd -landscape -portrait :Error
4:)  [Fri Jan 25 17:25:30 2019] ERROR: Failed to create blend state (HRESULT 80070057)
1:)  [Fri Jan 25 17:25:31 2019] DEBUG: Removed unused screen buffer size 1268x720 format 10

Trying to understand the root cause of this error:

E_INVALIDARG : One or more arguments are not valid ( 0x80070057 )

From LitSolid.hlsl:

#ifdef AO
// If using AO, the vertex light ambient is black, calculate occluded ambient here
finalColor += Sample2D(EmissiveMap, iTexCoord2).rgb * cAmbientColor.rgb * diffColor.rgb;

AO uses second UV map and probably that’s what You’re missing.

1 Like

Ok. But not sure what to do to fix that.

Experimented (did little changes all over the code, in the material file, the hlsl shader file, etc) trying to get some change in the error message. Nothing I did changed that error message.

Also noted that DiffAO.xml won’t show anything, but DiffAOAlpha.xml gives the exact same error but does show some of the material.

Also verified the UWP Feature Sample behaves identically as my converted Hololens sample, and it does. Both generate the exact same message for UWP.

To verify that this feature sample creates the error, did a simple change and then ran it.

The change was to allow the sample to be included, the author’s of the UWP sample purposely excluded the Basic Techniques sample for UWP. In the file MainPage.XAML.cs, added the comment characters to allow Basic Techniques to be included. :

		public MainPage()
			Urho.Application.UnhandledException += (s, e) => e.Handled = true;
			GameTypes = typeof(Sample).GetTypeInfo().Assembly.GetTypes()
				.Where(t => t.GetTypeInfo().IsSubclassOf(typeof(Application)) 
					&& t != typeof(Sample) //&& t != typeof(BasicTechniques) 
					&& t != typeof(PBRMaterials) && t != typeof(DynamicGeometry))
				.Select((t, i) => new TypeInfo(t, $"{i + 1}. {t.Name}", ""))
			DataContext = this;

Are You using model with second UV map? If not, don’t use technique that require second UV with model that don’t have it.

Well, I just don’t know if it has the second UV map. I’m not experienced with materials, or models or blender. I’m coming at this from a code first approach, and this is one of the few things I’ve not gotten past. Shadows is a second.

But here is what I do know:

The feature samples provided with SharpReality, can run this without the error, when run on WPF or WinForms platforms. It fails with UWP.

Because two platforms run this same model, and don’t have the error, it would seem it’s not a missing UV map in the model. Again, newbie assumption here I’m making.

The only difference, besides possible platform differences, and that I can find with my beginner eyes, is the UWP platform sample includes it’s own Data file.

So I took all those files, and added to them all the files in Data/Assets folders I could find, those files used by the WPF and WinForms samples. My Data folder is now about .5 GB in size, bursting with every file found. And I don’t get any messages about missing files (except one custom hlsl shader, that is unrelated to this).

Now, my assumption all along is that some file is missing, because it works fine on WPF and winforms.

If I could find some way to relate that error message to something tangible, something to do other than hope, then maybe I’ll make progress. Have reviewed all I know to review, but in the end, it will surely be something totally simple. That’s just how it goes.

Edit: Here’s another difference. The WPF and Winforms samples must be running OpenGL, because they also show the CustomMaterial, and it’s shader is only provided in the GLSL version.

So apparently the DiffAO works only on OpenGL, and there must be some difference in the HLSL file or there is something else missing.

This is not true. I’ve downloaded model used in the sample and on neather Directx nor OpenGL this material doesn’t work properly, it’s because of what I’ve said earlier - model don’t have second UV set, OpenGL just doesn’t log any error. Just to be clear I’m using ‘normal’ C++ Urho, but this shouldn’t make a difference.
As for Your “code first approach”, this not a way to go with this error. Here is the list of vertex elements and before that there is important, in this case, sentence: " Each of the following elements may or may not be present". Error under discussion means that shader require element that is not present. If You want to fix it only from code, here is what You should do to make this sample work as it supposed to: calculate uv coordinates for every vertex of each geometry (this model have 3 of them) and place them in right place in vertex buffers. It can be done, but good luck with that (ok, in this particular case it may not be that hard, since You’d propably want to use same coordinates as UV1).
Now, here are realistic and much simpler solutions: don’t use this technique, since it’s not suitable for this model, modify shader to use only one UV or use 3d modelling software to add missing vertex elements. You can also remove all "defines=“AO” from “DiffAO” technique xml, but then it will be the same as “Diff.xml” technique.
To make it even more clear: nornal map can be another example - using normal map require tangent vertex element, if it’s not present You’ll get the same error on DirectX and on OpenGL material will be displayed without normal map.
And for the reference, here is how this material look on model with second UV:

That is how the material looks in the feature samples when run on the WPF and WinForms platforms. Those two platforms run all the materials in the Basic Techniques seemingly perfectly. I didn’t know what DiffAO looked like until viewing on those. But, my eyes may not see enough detail, perhaps they are not right.

The UWP sample fails and there is nothing visible at all.

I thought all three WPF, UWP and WInForms would be D3D11. But I don’t understand where they get the HLSL shader for the CustomMaterial, so propose the WPF and WInForms samples run on GLSL not HLSL, and that is why they work.

Here’s the UWP, then WPF samples. The WPF sample also runs the CustomMaterial without error and only the GLSL shader is provided for it.


and now WPF

Also on the UWP sample it looks like NoTextureMultiply isn’t working right either.

Is that model available online? I’ll try to run it and see how it goes. Or another model I can use with 2nd UV map.

But also think you’re running OpenGL and that is why it is working. There isn’t a working instance of DiffAO on HLSL shaders that I’ve found.

The current model used is the Urho.Shapes.Sphere and this is the material:

    <technique name="Techniques/DiffAO.xml" />
	<texture unit="diffuse" name="Sample43/Earth.jpg" />
	<texture unit="emissive" name="Sample43/Earth_SpecularMap.png" />
    <parameter name="MatSpecColor" value="0.3 0.3 0.3 1" />

Read the link provided, and checked the vertex buffers of a model that is working:

Not sure how visible it is, there is a single buffer.

The element mask is Position | Normal | Color | TexCoord1 | Tangent.

Here’s the same for a not working model, same model, but on UWP platform, and not working:

Have verified the WPF and Winforms samples are running the GLSL shaders.

So the primary difference between the working samples, and the NOT working sample is the working samples use LitSolid.GLSL and the NOT working sample uses the LitSolid.HLSL shader.

I propose the LitSolid.HLSL shader does not work with AO. That it is faulty.

Similar but slightly different thread, not for AO.

Exploring why the LitSolid.hlsl shader doesn’t work with AO would be valuable, if you have time. As per my thesis …

I don’t want to repeat, but once again: this material doesn’t work properly with this model no matter what graphics API You are using. Screenshot of Your “working” version just confirms that, because the material is not displayed correctly. Here’ s the tip if You don’t see any difference between screenshot I posted and what You think is correct: look closer at the part of sphere that is occluded from the light, there is a quite noticeable diffrence in looks of continents and oceans.
As for the model, I cannot upload it to the forum directly, but it’s just a sphere with the same uv map in two slots made in blender.

Ok, is there any model anywhere … anywhere obtainable, with two uv maps?

I’m not ready to learn blender yet.

I’ve found that if I disable the vertex shading portion and just do the pixel shading of LitSolid.hlsl, then it will paint an output in UWP that looks very similar to the OpenGL version. So I am thinking that the glsl silently ignores VS, and just does PS for AO, at least for the model I’m using.


Is that easy? I looked through the file, and am not sure where the first UV map is being accessed, not to mention the second.

So following the code as shown here … what I’d need to do is define another TexCoord on each vertex?

Is that what will fix the model?

Found an example of rewriting PS() in the litsolid shader. This sample explains it enough to be able to provide a custom shader for the AO implementation.

This is enough to figure out a workaround.

Still, at the point of use of the material in the code (mat = Material.FromImage(imageWithOneUVmap);), I suspect there is a simple way to correct this missing UV layer problem.

This is the line causing that error message to appear.

If TEXCOORD1 is changed to TEXCOORD0, it will successfully paint the object, but the result is apparently is not proper AO.


Still haven’t got around to fixing CustomShader or NoTextureMultiply. The CustomShader in the sample is missing the HLSL shader, and not sure what is wrong with NoTextureMultiply.