Jump to content

LUA screenshot script results in white terrain


DaveLee
 Share

Recommended Posts

Hey folks,

 

I'm trying to render a screenshot via a LUA script that I saved from last year, but my terrain ends up white like this:

 

EMNxE.jpg

 

Can anyone tell what I'm doing wrong? Here's the script:

 

local width=1920
local height=1200

require("scripts/constants/engine_const")

local buffer=CreateBuffer(width,height,BUFFER_COLOR)
if buffer==nil then
Notify("Failed to create buffer!",1)
return
end

local buffer2=CreateBuffer(width,height,BUFFER_COLOR)
if buffer2==nil then
Notify("Failed to create buffer!",1)
buffer=nil
return
end

SetBuffer(buffer)

fw:Render()

SetBuffer(buffer2)
DrawImage(GetColorBuffer(buffer),0,0,buffer:Width(),buffer:Height())

SetBuffer(BackBuffer())

SaveBuffer(buffer2,"test.png")
buffer=nil
buffer2=nil

Link to comment
Share on other sites

Does the scene appear fine, otherwise? ATI hasn't fixed their driver bug they created recently that makes terrain not appear

 

He doesn't need a depth buffer for that, since the depth is processed by the time the results are copied to that buffer.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Guest Red Ocktober

your converted (to BlitzMAX) code seems to work prefectly here...

 

Function TakePicture()

Local width=1024 
Local height=768 


Local buffer:TBuffer=CreateBuffer(width,height,BUFFER_COLOR) 
If buffer=Null Then 
       Notify("Failed to create buffer!",1) 
       Return 
EndIf 

Local buffer2:TBuffer=CreateBuffer(width,height,BUFFER_COLOR) 
If buffer2=Null Then 
       Notify("Failed to create buffer!",1) 
       buffer=Null 
       Return 
EndIf 

SetBuffer(buffer) 

Game.fw.Render() 

SetBuffer(buffer2) 
DrawImage(GetColorBuffer(buffer),0,0,buffer.Width(),buffer.Height()) 

SetBuffer(BackBuffer()) 

SaveBuffer(buffer2,"test.png") 
buffer=Null 
buffer2=Null 

EndFunction

 

 

gonna try it in the lua editor next...

 

 

here's the code i used in the lua script editor... just used start.kua and replaced the mainloop with your stuff...

 

require("Scripts/constants/keycodes") 

--Register abstract path 
RegisterAbstractPath("") 

--Set graphics mode 
if Graphics(1024,768)==0 then 
Notify("Failed to set graphics mode.",1) 
return 
end 

world=CreateWorld() 
if world==nil then 
Notify("Failed to initialize engine.",1)   return 
end 

gbuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight(),1+2+4+8) 

camera=CreateCamera() 
camera:SetPosition(Vec3(0,0,-2)) 

light=CreateSpotLight(10) 
light:SetRotation(Vec3(45,55,0)) 
light:SetPosition(Vec3(5,5,-5)) 

--Uncomment these two lines to produce a crash:
--light:Free()
--light:SetPosition(Vec3(5,5,-5)) 

material=LoadMaterial("abstract::cobblestones.mat") 

mesh=CreateCube() 
mesh:Paint(material) 

ground=CreateCube() 
ground:SetScale(Vec3(10.0,1.0,10.0)) 
ground:SetPosition(Vec3(0.0,-2.0,0.0)) 
ground:Paint(material) 

light=CreateDirectionalLight() 
light:SetRotation(Vec3(45,45,45)) 

local width=1920  
local height=1200  

require("scripts/constants/engine_const")  

local buffer=CreateBuffer(width,height,BUFFER_COLOR)  
if buffer==nil then  
       Notify("Failed to create buffer!",1)  
       return  
end  

local buffer2=CreateBuffer(width,height,BUFFER_COLOR)  
if buffer2==nil then  
       Notify("Failed to create buffer!",1)  
       buffer=nil  
       return  
end  

SetBuffer(buffer)  

world:Render()  

SetBuffer(buffer2)  
DrawImage(GetColorBuffer(buffer),0,0,buffer:Width(),buffer:Height())  

SetBuffer(BackBuffer())  

SaveBuffer(buffer2,"test2.png")  
buffer=nil  
buffer2=nil

 

the cobblestone texture on the cubes was washed out almost white like your terrain...

 

using a geforce9500 gpu...

 

the two pics are attached below... top one from BlitzMAX

 

--Mike

post-65-0-50473100-1309452711_thumb.png

post-65-0-16275600-1309452815_thumb.png

Link to comment
Share on other sites

I think it has something to do with the PNG format... I am getting weird results with it. If I look at the resulting png screenshot in MSPaint, it looks fine. If I look at it with Windows Photo Gallery, the terrain and sky are white. If I open it with Gimp (where the entire scene is covered by a transparency checkerboard) and save it to another format (JPG), the terrain and sky are whited out.

 

If I use TGA for the file format to save the buffer to, it appears to work ok.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Guest Red Ocktober

confirmed...

 

Mack's conclusion about the problem having something to do with the .png format seems to be correct... output to .jpg is also problematic... but tga and bmp seem to work ok...

 

--Mike

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...