I am creating a simple Plan geometry, so that I can control the Vertex definitions. I only want Position and TEXCOORD1, no normals (unlike the built in plane.mdl). So it’s 5 floats per vertex (Vec3 for Position, plus Vec2 for UV coordinate). I am using an Index Buffer, with 6 indices.
All works wonderfully on Windows, for HLSL.
But when I switch to Android with GLSL, it fails miserably. My Vertex/Pixel Shaders for GLSL seem fine because they are butt simple and work just fine when applied to the Plane.Mdl. However when I use my own manually generated Plane Geometry, it is NOT VISIBLE on Android. No Errors, No Warnings in the log. The Plane is simply just NOT THERE. I’ve pared the GLSL vertex shader down to merely rendering RED, instead of even reading a DIFFUSE map… still shows NOTHING.
I then simplified my Geometry to be Position-Only (no TEXCOORD), and still is shows NOTHING. Other shaders work fine on Android, and so does the Plane if I use the Plane.MDL, but just not my manual geometry.
Here is the shader:
#include “Uniforms.glsl”
#include “Samplers.glsl”
#include “Transform.glsl”
void VS()
{
mat4 modelMatrix = iModelMatrix;
vec3 worldPos = GetWorldPos(modelMatrix);
gl_Position = GetClipPos(worldPos);
}
void PS()
{
gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0);
}
===
and here is the code that sets up the Plane Geometry setup:
private const int NUMVERTICES = 4;
private const int NUMINDICES = 6;
static private short[] _tileIndexData = new short[6] { 0, 2, 1, 0, 3, 2 }; // { 0, 1, 2, 0, 2, 3 };
…
s_TileVertexData = new float[] { -0.5f, 0, -0.5f, 0.5f, 0, -0.5f, 0.5f, 0, 0.5f, -0.5f, 0, 0.5f };
_tileIndexBuffer = new IndexBuffer(UrhoApp.Context);
_tileIndexBuffer.SetSize(NUMINDICES, false, false);
_tileIndexBuffer.SetData(_tileIndexData);
_tileBounds = new BoundingBox(-0.5f, 0.5f);
VertexBuffer vb = new VertexBuffer(UrhoApp.Context);
vb.SetSize(NUMVERTICES, ElementMask.Position);
vb.SetData(s_TileVertexData);
Geometry g = new Geometry();
g.SetVertexBuffer(0, vb);
g.IndexBuffer = _tileIndexBuffer;
g.SetDrawRange(PrimitiveType.TriangleList, 0, NUMINDICES, false);
var model = new Model();
model.NumGeometries = 1;
model.SetGeometry(0, 0, g);
model.BoundingBox = _tileBounds;
_plane.Model = model;
_material = _tileMaterial.Clone();
_material.CullMode = CullMode.None;
_plane.SetMaterial(_material);
===
Again – all this works fine on Windows, but is NOT VISIBLE on Android and log shows no warnings or errors.