DaveLee Posted June 28, 2011 Share Posted June 28, 2011 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: 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 Quote Link to comment Share on other sites More sharing options...
Mumbles Posted June 30, 2011 Share Posted June 30, 2011 I don't know, but doesn't your first buffer need BUFFER_DEPTH as well as BUFFER_COLOR? Quote LE Version: 2.50 (Eventually) Link to comment Share on other sites More sharing options...
Josh Posted June 30, 2011 Share Posted June 30, 2011 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. Quote 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 More sharing options...
Guest Red Ocktober Posted June 30, 2011 Share Posted June 30, 2011 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 Quote Link to comment Share on other sites More sharing options...
macklebee Posted June 30, 2011 Share Posted June 30, 2011 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. Quote 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 More sharing options...
Guest Red Ocktober Posted June 30, 2011 Share Posted June 30, 2011 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 Quote Link to comment Share on other sites More sharing options...
DaveLee Posted June 30, 2011 Author Share Posted June 30, 2011 TGA works great. Thanks guys! Quote Link to comment Share on other sites More sharing options...
macklebee Posted June 30, 2011 Share Posted June 30, 2011 Well there is definitely an issue there but i am not sure what to make of it. If I just save a framework rendered buffer to PNG there is no issue... it looks correct. Quote 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 More sharing options...
Richard Simpson Posted June 30, 2011 Share Posted June 30, 2011 That's a cool script... Quote Intel core 2 quad 6600 | Nvidia Geforce GTX460 1GB | 2GB DDR2 Ram | Windows 7. Google Sketchup | Photoshop | Blender | UU3D | Leadwerks Engine 2.4 Link to comment Share on other sites More sharing options...
Recommended Posts
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.