LitSolid(AO) missing vertex element?


#22

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.


#23

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.


#24

That is what I’ve done at this point.


#25

Modify geometry to have two UV maps sounds like what you really want.

The vertex data in your model requires more than one UV per vertex - so go back to your modelling app, and add a second UV map, save the asset, and reimport it. You should not be hacking the AO shader to suit the model, you should be hacking the model to suit the shader.


#26

Yes, @lezak has been making that same point.

To which I responded:

In conclusion, was able to make a very simple change to an existing shader, and provided a custom shader for the particular problem, so I could continue to use the materials supplied with the original sample, and get close to a fully working sample.

Going through the process in the code allowed me to grasp the linkages between the .xml material file, the techniques, textures and shaders. Blender use hasn’t yet transferred that knowledge to me (what I have gleaned from blender is I don’t know it well enough to use it effectively yet, and it’s just not yet the right time to begin to fully consume it with my mind, but have been slowly trodding that path, just not with determination, only curiosity)

Apparently, those much more experienced in graphics/3D world tech don’t agree. That’s fine, we all don’t have to agree.

My next steps for this are to write a custom shader by converting the glsl custom shader to an hlsl shader. Then figure out why the NoTextureMultiply sample isn’t working.


While @lezak points out the obvious differences between his AO display and mine, it would seem the edit I did and described above, produces identical results to his when ASSUMING the lighting, the ambient lighting, and material’s settings and zone settings are defined identically.

Because in the custom shader I did, it uses the first UV map as the second. In the custom model he did, he created a second UV map by copying the first.

It would be great if all the samples just worked on all the platforms. But learning blender won’t give me enough (or any) details on how to get the samples running on hololens without code changes. Digging into the code and actually getting the samples running on hololens does. But this code-first implementation is more about the hololens binding implementation than it is about urho3d (shadows not working on hololens). But ultimately, without useful bindings, what good is urho3d?


#27

Rather sonner then later You’ll reach the point where You’ll have to use 3d modelling software, I would even say, that because we’ll still discussing in this topic, You’ve already reached that point.
The thing about ambient occlusion texture is that it shouldn’t be using overlapping UVs and that’s why it’s good to have it on the second UV, but if there is no overlapping (for example this case) there is no harm in using the same UV.

Just to be clear - it’s not this line causing error, it’s wrong model, but this solution should work just fine. I would also suggest using different AO texture , to make it look better (I’ve used default sphere and shader modified same way as You did):

Wrong forum for this part. Maybe You should create issue on github/forum dedicated to urhosharp?


#28

Not sure which texture you were referring to? I usually get them from here.


#29

Got the customshader sample running, in case anyone is interested.

The HLSL shader code is:

#include "Uniforms.hlsl"
#include "Samplers.hlsl"
#include "Transform.hlsl"
#include "ScreenPos.hlsl"

void VS(float4 iPos : POSITION,
	float3 iNormal : NORMAL,
	float4 iTangent : TANGENT,
	float2 iTexCoord : TEXCOORD0,
	out float2 oTexCoord : TEXCOORD0,
	out float3 oNormal : TEXCOORD1,
	out float4 oWorldPos : TEXCOORD2,
	out float4 oTangent : TEXCOORD3,
	out float4 oEyeVec : TEXCOORD4,
	out float4 oScreenPos : TEXCOORD5,
	out float4 oPos : OUTPOSITION)
{
	float3 worldPos = GetWorldPos(iModelMatrix);
	oPos = GetClipPos(worldPos);
	oNormal = GetWorldNormal(iModelMatrix);
	oWorldPos = float4(worldPos, GetDepth(oPos));
	float3 tangent = GetWorldTangent(iModelMatrix);
	float3 bitangent = cross(tangent, oNormal) * iTangent.w;
	oTexCoord = float4(GetTexCoord(iTexCoord), bitangent.xy);
	oEyeVec = float4(cCameraPos - worldPos, GetDepth(oPos));
}

void PS(
	float4 iTexCoord : TEXCOORD0,
	float3 iNormal : TEXCOORD1,
	float4 iWorldPos : TEXCOORD2,
	float4 iTangent : TEXCOORD3,
	float4 iEyeVec : TEXCOORD4,
	float4 iScreenPos : TEXCOORD5,
	out float4 oColor : OUTCOLOR0)
{
	float f = dot(normalize(iEyeVec.xyz), normalize(iNormal));
	oColor = float4(1,1,1,1-f);
}

First shader I’ve ever written. But it was mostly cut and paste.

There is something interesting in the rewrite.

The technique defines NOUV, which acts in the other shaders to make iTexCoord a float2. But when I left it this way, the shader didn’t work. So I stipped out the float2 definition, and left it as a float4, and then in the VS part, also calculated as a float4 as shown. Otherwise, it would have been just (GetTexCoord(iTexCoord)).


#30

The last issue in that sample is the NoTextureMultiply doesn’t work.

This is the error generated:
ERROR: Failed to create blend state (HRESULT 80070057)

The hresult decodes as: E_INVALIDARG One or more arguments are not valid

Not sure what this could be. The only way this particular sample varies from the NoTextureAdd sample is in the technique file:

NoTextureAdd.xml

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

And NoTextureMultiply:

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

Not sure how to approach this to solve it. Tried re-writing the shader, as per the CustomShader rewrite described above (by setting the iTexCoord to a float4).

So the blend state alpha pass of multiply doesn’t work, but add works.

Can anyone offer a clue how to solve or find more info?

edit: also, if a new material for DiffMultiply is added, using the technique DiffMlutiply.xml, the same error is emitted.


#31

That shader doesn’t quite work correctly. Viewed through a stereoscopic display (such as hololens), each of the lenses gets a slightly different output depending on orientation. Moving left to right across the object highlights the issue.

Still researching, andfound this resource which has a lot of info, butexplains uv maps and materials from urho3d’s viewpoint. The sections on UV and on Materials explain it well.