Jump to content

Texture problem


darhal

Recommended Posts

the walls textures sometimes appear like this : http://imgur.com/tcw9nYi

  
    local myshader = dxCreateShader("material/effect.fx") 
    local mytexture = dxCreateTexture(texPath, "dxt3") 
    dxSetShaderValue( myshader,"gTexture", mytexture) 
    engineApplyShaderToWorldTexture( myshader, getObjectTextureName(objectInEdit), createdObject ) 
  

this my code nothing special :/ the problem is in dxSetShaderValue the 3 argument is bad argument P.S: this work sometimes and break othertimes

Link to comment
So it sometimes fails to create the Texture?

Maybe you create too many of those at once.

Exactly !, It fail to create Textures but what u mean by "creating too many of those once ?"

I don't know how the rest of your code looks like.

Also post the error log if possible.

Link to comment

The block that contain those functions is realy huge this is a part of it

for k, v in pairs(zoneTable.objectsPositions) do 
                if area  then  
                    createdObjectAfterSave = createObject(v.model, v.x, v.y, v.z, v.rx, v.ry, v.rz) 
                    setElementCollisionsEnabled (createdObjectAfterSave, true) 
                    table.insert(currentZoneObjects, createdObjectAfterSave) 
                    --createdObjectAfterSave = currentZoneObjects[k] 
                    setObjectScale(createdObjectAfterSave, 1)--v.scale) 
                    setElementData(createdObjectAfterSave, "objectArea", area) 
                    if v.texture and getObjectTextureName(createdObjectAfterSave) then 
                        local myshader = dxCreateShader("material/effect.fx") 
                        local mytexture = dxCreateTexture(v.texture, "dxt3") 
                        dxSetShaderValue( myshader,"gTexture", mytexture) 
                        engineApplyShaderToWorldTexture( myshader, getObjectTextureName(createdObjectAfterSave), createdObjectAfterSave) 
                        texture[createdObjectAfterSave] = v.texture 
                    end 
                    if area then  

Link to comment
  • Moderators

Maybe your textures are too heavy?

Try to save with "dxt5", dxt3 is an older version of dxt5.

Still now chances? > Save large png's without alpha changes/levels, with png-8.

And I strongly recommend to load a lot of textures with "onClientRender" in combination with getTickCount(). Because somehow the next frame has to wait before the function has been fully executed. This is an old bug from the gta san core.

Example:

local index = 1 
local nextTextureLoadTime = 0 
function loadingTexture () 
    local timeNow = getTickCount() 
    if timeNow > nextTextureLoadTime then 
        nextTextureLoadTime = timeNow+30 
         
        local objects = zoneTable.objectsPositions 
        local v = objects[index]  
         
        if v then 
            -- put your code here -- 
             
            ------------------------ 
            index = index+1 
        else 
            removeEventHandler("onClientRender",root,loadingTexture) 
        end 
    end 
end 
  
addEventHandler("onClientRender",root,loadingTexture) 

So some slow pc's can now gets up with the replacement process and won't crash so fast.

Link to comment
Maybe your textures are too heavy?

Try to save with "dxt5", dxt3 is an older version of dxt5.

Still now chances? > Save large png's without alpha changes/levels, with png-8.

And I strongly recommend to load a lot of textures with "onClientRender" in combination with getTickCount(). Because somehow the next frame has to wait before the function has been fully executed. This is an old bug from the gta san core.

Example:

local index = 1 
local nextTextureLoadTime = 0 
function loadingTexture () 
    local timeNow = getTickCount() 
    if timeNow > nextTextureLoadTime then 
        nextTextureLoadTime = timeNow+30 
         
        local objects = zoneTable.objectsPositions 
        local v = objects[index]  
         
        if v then 
            -- put your code here -- 
             
            ------------------------ 
            index = index+1 
        else 
            removeEventHandler("onClientRender",root,loadingTexture) 
        end 
    end 
end 
  
addEventHandler("onClientRender",root,loadingTexture) 

So some slow pc's can now gets up with the replacement process and won't crash so fast.

Well thanks I edited my code and it works fine and the game freeze is massive lag now but I didint understand this part

Still now chances? > Save large png's without alpha changes/levels, with png-8.

I use phooshop to edit textures is this function in photoshop ?

Link to comment
  • Moderators

Png-8 can be selected when you use the save for web methode.

Png-8 is smaller, but is terible with alpha blending.

Your game did also freeze using the onClientRender methode?

Well you solved it, but I am still kinda interested.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...