SpiderPig Posted August 16, 2023 Share Posted August 16, 2023 I want to save my heightmaps as R16 textures an use them for displacement and other things in shaders. Are these textures sampled any different to normal RGBA textures? Does the sample still return a vec4 with values in the range of 0 to 1? Quote Link to comment Share on other sites More sharing options...
Josh Posted August 16, 2023 Share Posted August 16, 2023 This constant corresponds to VK_FORMAT_R16_SFLOAT, so the values are just a 16-bit floating point number with any value. I think the limits of half-floats is somewhere around +/- 65000.0. I use this format for terrain heightmaps. It's nice because you don't have to worry about scaling an integer value between a min and max. 1 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...
SpiderPig Posted August 16, 2023 Author Share Posted August 16, 2023 Can I still sample a half float texture like this? vec4 color = texture(texture2DSampler[textureID], texcoords.xy); Or is there a different function for this? I don't know what the value of the vec4 would actually be... Quote Link to comment Share on other sites More sharing options...
Solution Josh Posted August 16, 2023 Solution Share Posted August 16, 2023 Every value except the red channel will be 0, so you might as well do this: float h = texture(texture2DSampler[textureID], texcoords.xy).r; 1 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...
SpiderPig Posted August 16, 2023 Author Share Posted August 16, 2023 Oh cool, thanks. And that'll still between 0 and 1 yeah? Quote Link to comment Share on other sites More sharing options...
SpiderPig Posted August 16, 2023 Author Share Posted August 16, 2023 Also I couldn't save a pixmap with R16 format as DDS. I saw you had it working here though, is this no longer supported? Quote Link to comment Share on other sites More sharing options...
Josh Posted August 17, 2023 Share Posted August 17, 2023 17 hours ago, SpiderPig said: Oh cool, thanks. And that'll still between 0 and 1 yeah? No, why would it be? It's just a floating point number. 17 hours ago, SpiderPig said: Also I couldn't save a pixmap with R16 format as DDS. I saw you had it working here though, is this no longer supported? It should work. If not this is a bug. I am pretty sure DDS supports this format. 1 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...
SpiderPig Posted August 17, 2023 Author Share Posted August 17, 2023 Posted a bug report for the saving issue. https://www.ultraengine.com/community/topic/62096-cant-save-r16-pixmap-as-dds/ Quote 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.