Distortion on 3d object

What I’m trying to do is implementing a 360 degree image viewer in Xamarin.Forms.
I’m using UrhoSharp and here are the steps of what I’ve done to view a 360 degree image:

  • Creating a 3d sphere model
  • Loading a 360 degree (Panorama) image
  • Set image as the Material of the Sphere

All the above steps are OK and I can see the flatten image from different view points but the problem is some kind of waves or distortions are in the image and the line which supposed to be straight are wavy. I don’t know what setting could solve the problem, please help.

Here is the wavy outcome:
And here is my code:

private void CreateScene()
        // Scene
        var scene = new Scene();

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

        // Model
        var modelObject = node.CreateComponent<StaticModel>();
        modelObject.Model = ResourceCache.GetModel("Models/Sphere.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" };

        //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(image);
        m.SetTechnique(0, CoreAssets.Techniques.DiffNormal, 0, 0);
        m.CullMode = CullMode.Cw;
        //m.SetUVTransform(Vector2.Zero, 0, 0);

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

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

Hello @shahram.shobeiri and welcome. Sorry for being blunt (or rather anti-sharp), but I’m afraid these are not the UrhoSharp/Xamarin forums, this question is off-topic here.
You’re welcome, or even encouraged, to rewrite your project using Urho3D - as opposed to UrhoSharp - and ask this community for any support along the way.

Those are triangles linearly interpolating their UVs. You can either increase number of polygons in your sphere or generate accurate UVs in pixel shader.


Thanks @Bananaft, I’m completely new in Urho3D and 3D concepts, How can I increase number of polygons in my sphere?

You’re using UrhoSharp, it is not the same as Urho3D.

1 Like

Yeah, sphere is just a model in models folder. You have to model and export a new one. B.t.w. you can observe the same UV artifact in blender.

Finally my problem solved. Even though @Modanung said the topic is irrelevant to Urho3D but your response was really helpful for me.
I understood that I should increase the polygons of my sphere by creating a new model in a tool like Blender and export it to MDL format by a add-in and use the new model in my code.
Thank you very much @Bananaft and @Modanung.
Here is the outcome:

1 Like

I can’t help it. :slight_smile:

I’m glad you solved your problem and I hope the times ahead will be bearable, looking at your location.

1 Like