Quick Links: Gideros Home | Download Gideros | Developer Guide
RenderTarget Export Issue
  • antixantix +1 -1
    Member
    I am trying to export some images. I have a Spine model that I am animating and then at set intervals I draw this model to a RenderTarget which I then save as a png file. Whilst this does work, there are two issues I am experiencing with it...

    1. The image seen in the Gideros Player is darker than the actual source art.
    2. The exported RenderTarget has transparent areas where you can see through the model.

    These are shown in the following image...
    imageYou can see that in the Gideros Player, none of the background shows through the model, but in the exported RenderTarget it does. You can also see the original art is much brighter than the one in the other two images.

    So can anyone explain why these things are happening?
    what_the.png
    672 x 213 - 79K
    Check out my DevBlog, my GitHub, and my games Falling Animals | Breaky Wall | Exetor
  • Yan +1 -1
    Member
    1) What is sprite extension ?
    2) Show us the render code
  • antixantix +1 -1
    Member
    @Yan, sprite extension?
    This is the main.lua code I have...
    application:setBackgroundColor(0xff0000)
    application:setFps(60)
     
    local spine = require "spine-gideros.spine"
     
    local json = spine.SkeletonJson.new()
    json.scale = 1
    local assetFolder = "data2"
     
    local skeletonData = json:readSkeletonDataFile(assetFolder .. "/survivor.json")
     
    local skeleton = spine.Skeleton.new(skeletonData)
     
    function skeleton:createImage (attachment)
    local image = Bitmap.new(Texture.new(assetFolder .. "/" .. attachment.name .. ".png"))
    image:setAnchorPoint(0.5, 0.5)
    return image
    end
     
    local canvasSize = 256
     
    skeleton.x = canvasSize * 0.5
    skeleton.y = canvasSize * 0.5
    skeleton.flipX = false
    skeleton.flipY = false
    skeleton.debug = false -- Omit or set to false to not draw debug lines on top of the images.
    skeleton:setToSetupPose()
     
    skeleton:setPosition(skeleton.x, skeleton.y)
    skeleton:setRotation(0)
     
    local stateData = spine.AnimationStateData.new(skeletonData)
    local animationName = "move_rifle"
     
     
    local state = spine.AnimationState.new(stateData)
    state:addAnimationByName(0, animationName, true, 0)
     
    stage:addChild(skeleton)
     
    local canvas = RenderTarget.new(canvasSize, canvasSize)
     
    local lastTime = 0
    local animationTime = 0
     
    local capturing = true
    local captureDelay = 1
    local captureCount = 15
    local frameNumber = 0
     
    stage:addEventListener("enterFrame", function (event)
     
    local dt = event.deltaTime
     
    -- Compute time in seconds since last frame.
    local currentTime = event.time -- / 1000
    local delta = currentTime - lastTime
     
    lastTime = currentTime
     
    state:update(delta * 0.5) -- Accumulate time and pose skeleton using animation.
    state:apply(skeleton)
    skeleton:updateWorldTransform()
     
    if capturing then
    local delay = captureDelay - 1
    if delay == 0 then
    delay = 4
     
    local fileName = "|D|survivor-" .. animationName .. "_" .. frameNumber.. ".png"
    -- capture
    canvas:clear(0, 0)
    canvas:draw(skeleton)
    canvas:save(fileName, 0, 0, 256, 256)
     
    print(fileName .. " saved")
    frameNumber = frameNumber + 1
     
    local count = captureCount
    count = count - 1
    if count == 0 then
    capturing = false
    end
    captureCount = count
    end
    captureDelay = delay
    end
    end)
    Check out my DevBlog, my GitHub, and my games Falling Animals | Breaky Wall | Exetor
  • pie +1 -1
    Member
    @antix I can't be sure without seeing the single images of pieces, but the lines between the pieces of your actor seems to be coming from antialias filter: I had a similar issue some time ago. I think it may be related to pixel translucency/alpha value. I never investigated that.. :)
    Have you tried exporting the images without antialias and enable antialias in gideros on texturePack and/or on the rendertarget? it worked for me

  • antixantix +1 -1
    Member
    @pie, okay so maybe set filter = true on the RenderTarget? I didn't think of that. I tried that but the result is the same.

    This really is strange because it is ONLY when I am drawing to and saving the RenderTarget that I'm having any issues at all.

    I think I might just flag this and buy Spine.
    Check out my DevBlog, my GitHub, and my games Falling Animals | Breaky Wall | Exetor
  • pie +1 -1
    Member
    It comes from rendertarget for me too, but only if I use antialiased source images. My guess (i don't have knowledge about this) is that rendertarget messes up on translucent pixels (which are usually added by antialias filter).
    If I use crispy edge source images (no translucent pixel at all - each pixel is 100% transparent or 100% coloured) all is well.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Login with Facebook Sign In with OpenID

In this Discussion

Top Posters