Jump to content

No Get/SetPixels in Lua, problems importing 16bit greyscale image


Recommended Posts

Posted

1) The Lua API doesn't provide methods for getting or setting the pixels of a texture. Is this due to technical reasons, or could those methods be exposee?

 

2) I have no success in importing a 16bit greyscale image (tried various formats). Is this not supported?

 

Posted

OK, I see?

 

@dude: What do you mean by .raw? Like raw image data? That doesn't work as well.

 

@Josh: I see in the terrain.shader you get the terrain height from the second row of the entity matrix. So I guess this is where the 16bit raw data from imported heightmaps go, spread over two channels or so?

Posted

The height map is a texture that gets read for each point's height. This is in the vertex shader.

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

Posted

Ah, you're referring to the clipmader.shader, right? This is reading from the red channel - so is this an 8bit or 16bit texture? And if the latter, what do I have to do to import and use one myself?

 

EDIT: Sorry, talking rubbish, of course the heightmap sampling's taking place in terrain.shader. Either wasn't looking or thinking straight... wacko.png

Posted

My problem is not that I can't create a .raw file and import that for the Leadwerks terrain, but rather that I would like to do heightmap displacement myself. So I need to get that texture to the shader, and 8bit resolution isn't enough. I guess I could encode this in two channels, but maybe there's an easier way.

Posted

OK, searched a bit further, and this seems to be common among game engines: While OpenGL supports 64bit textures, most engines just allow up to 8 bits per channel.

 

I am calculating the normal map for a heightmap-displaced terrain in the fragment shader using central differencing, and for this 8bit just isn't enough (it produces ugly steps in the terrain). However, World Machine allows to export heightmaps in a "Povray TGA" format, where the 16 bits are spread over the red and green channels. So I went ahead and used that. As a comparison,

 

this is using an 8bit heightmap

 

post-6662-0-21690200-1390337136_thumb.png

 

and here I am using the 16bit/2 channel format

 

post-6662-0-00575500-1390337203_thumb.png

 

Pretty amazing what a normal map (even a calculated one) can add, the base mesh for this terrain is just 65x65 vertices, no tessellation or anything.

 

Since I'm calculating the normals in the fragment shader - is there a way I could render this to a texture and sample the texture later on? Using the current Lua API?

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.

×
×
  • Create New...