Urhosharp Material.FromImage not woking with some jpg files

I'm using Xamarin.Forms with Urhosharp in my project. I'm tring to set a matrial from an image on a sphere, everything is OK in my Android project but in iOS project, when I set material from some jpg files it doesn't work and all I get is a black screen.

Here is the jpg that works correctly:

And here is the other one that doesn't:

This is my code:

        var scene = new Scene();
    scene.CreateComponent<Octree>();


    // Node (Rotation and Position)
    var node = scene.CreateChild("room");
    node.Position = new Vector3(0, 0, 0);
    //node.Rotation = new Quaternion(10, 60, 10);
    node.SetScale(1f);

    // Model
    var modelObject = node.CreateComponent<StaticModel>();
    modelObject.Model = ResourceCache.GetModel("CustomModels/SmoothSphere.mdl");

    var zoneNode = scene.CreateChild("Zone");
    var zone = zoneNode.CreateComponent<Zone>();
    zone.SetBoundingBox(new BoundingBox(-300.0f, 300.0f));
    zone.AmbientColor = new Color(1f, 1f, 1f);

    //get image from byte[]

    //var url = "http://www.wsj.com/public/resources/media/0524yosemite_1300R.jpg";
    //var wc = new WebClient() { Encoding = Encoding.UTF8 };

    //var mb = new MemoryBuffer(wc.DownloadData(new Uri(url)));
    var mb = new MemoryBuffer(PanoramaBuffer.PanoramaByteArray);
    var image = new Image(Context) { Name = "MyImage" };
    image.Load(mb);

    //or from resource

    //var image = ResourceCache.GetImage("Textures/grave.jpg");
    var isFliped = image.FlipHorizontal();
    if (!isFliped)
    {
        throw new Exception("Unsuccessful flip");
    }
    var m = Material.FromImage("1.jpg");
    m.SetTechnique(0, CoreAssets.Techniques.DiffNormal, 0, 0);
    m.CullMode = CullMode.Cw;
    //m.SetUVTransform(Vector2.Zero, 0, 0);
    modelObject.SetMaterial(m);

    // Camera
    var cameraNode = scene.CreateChild("camera");
    _camera = cameraNode.CreateComponent<Camera>();
    _camera.Fov = 75.8f;
    _initialZoom = _camera.Zoom;

    // Viewport
    Renderer.SetViewport(0, new Viewport(scene, _camera, null));

I already tried to change compression level, ICCC profile and ...

Best Answer

Answers

Sign In or Register to comment.