Page 1 of 1

An issue with texture loading

Posted: Fri Feb 20, 2009 7:25 pm
by Blue Hampster
Hey there, I have just been taking up some more programming and having trouble already. I am developing a program that does a nice smooth 3D display of my images, but every image I load comes up really weird, as if it has been shrunk then stretched. I was wondering if anyone knew what was wrong with my code. What I have written already is this:

Code: Select all

Imports IrrlichtNETCP
Imports IrrlichtNETCP.Inheritable

Module Main
    Dim device As IrrlichtDevice

    Sub Main()
        Dim dt As DriverType = DriverType.Direct3D8
        Dim aa As Boolean = True
        Dim width As Integer = My.Computer.Screen.Bounds.Width
        Dim height As Integer = My.Computer.Screen.Bounds.Height
        Dim colourdepth As Integer = 32
        Dim img As String = "C:/mypicture.png"

        device = New IrrlichtDevice(dt, New Dimension2D(width, height), colourdepth, True, True, True, aa)

        Dim smgr As SceneManager = device.SceneManager
        Dim driver As VideoDriver = device.VideoDriver

        Dim rectangle As IrrlichtNETCP.BillboardSceneNode = smgr.AddBillboardSceneNode(smgr.RootSceneNode, New Dimension2Df(width, height), 1)
        rectangle.Position = New Vector3D(0, 0, 550)

        rectangle.SetMaterialType(MaterialType.TransparentAddColor)
        rectangle.SetMaterialTexture(0, driver.GetTexture(img))
        rectangle.SetMaterialFlag(MaterialFlag.Lighting, False)
        rectangle.SetMaterialFlag(MaterialFlag.ZBuffer, False)

        Dim camera As CameraSceneNode = smgr.AddCameraSceneNode(smgr.RootSceneNode)
        camera.Position = New Vector3D(0, 0, 0)
        camera.Rotation = New Vector3D(0, 0, 0)

        While device.Run
            device.VideoDriver.BeginScene(True, False, New Color(0, 0, 0, 0))
            device.SceneManager.DrawAll()
            device.GUIEnvironment.DrawAll()

            device.VideoDriver.EndScene()

            Threading.Thread.Sleep(50)
        End While
    End Sub
End Module
If anyone could help, that would be great :)

Posted: Fri Feb 20, 2009 7:36 pm
by Acki
NPOT texture(s) ?!?!? :lol:

Posted: Fri Feb 20, 2009 7:38 pm
by Blue Hampster
lets pretend i dont know what they are, lol
could ya tell me which bits of the code i need to change to make it work?

Posted: Fri Feb 20, 2009 8:15 pm
by bitplane
Resize your textures so they are a power of two in each dimension, for example 64x128 or 256x512

Posted: Fri Feb 20, 2009 8:24 pm
by zillion42

Posted: Fri Feb 20, 2009 8:54 pm
by Blue Hampster
It was already in a power of two, it was an image 1920 by 1080. Are you saying i need to double it then reload it, or do i need to change it so that the values are to the power of two (i.e. 2048x2048)?

Posted: Fri Feb 20, 2009 9:06 pm
by zillion42
unfortunately 1920 isn't, nor is 1080

http://en.wikipedia.org/wiki/Power_of_two

edit:
2048x1024 is the closest to your original format

Posted: Fri Feb 20, 2009 10:30 pm
by Acki
Blue Hampster wrote:It was already in a power of two, it was an image 1920 by 1080.
you have "Multiple Of Two" and not "Power Of Two" there !!! ;)

Posted: Sat Feb 21, 2009 2:02 pm
by Blue Hampster
Kk, that does help, but could you suggest any coding that could be added so that the image would appear normally?

Posted: Sat Feb 21, 2009 2:05 pm
by Blue Hampster
Hold ya horses. Just put in a piece of code that resizes the image to 4096x4096. This seems to work much better than before, unfortunatly its still a bit blurred. Is there anyway of clearing up the image any more?

Posted: Sat Feb 21, 2009 2:56 pm
by zillion42
are you upscaling the images ? sounds not so good, best would be to keep a 1:1 relation... whatever...
maybe

Code: Select all

driver->setTextureCreationFlag(video::E_TEXTURE_CREATION_FLAG::ETCF_CREATE_MIP_MAPS,false);
but if the image quality is really getting any better without mipmaps depends on how far away you are from it...

video::ETCF_CREATE_MIP_MAPS would be enough, but depending on your ide, this way you can take a look at the other E_TEXTURE_CREATION_FLAG's aswell and play around a little...

http://irrlicht.sourceforge.net/docu/na ... c5bf11876f

Posted: Sun Feb 22, 2009 6:52 pm
by Blue Hampster
the billboard is the same size as the picture, and then its a fixed distance from the camera with mipmaps off. Ill have a play, if anyone has any ideas what too do, then do tell, and if i get a working version, ill shout all about it