FIRE-15667: Added option to create 24bit depth maps to the snapshot floater; patch contributed by Sempervirens Oddfellow
parent
01546c430e
commit
4701a2b215
|
|
@ -43,6 +43,8 @@ LL_ALIGN_16( const F32 F_OOU8MAX_4A[4] ) = { OOU8MAX, OOU8MAX, OOU8MAX, OOU8MAX
|
|||
const U8 FIRSTVALIDCHAR = 54;
|
||||
const U8 MAXSTRINGVAL = U8MAX - FIRSTVALIDCHAR; //we don't allow newline or null
|
||||
|
||||
// <FS:Ansariel> FIRE-15667: 24bit depth maps
|
||||
const U32 U24MAX = 16777215;
|
||||
|
||||
inline U16 F32_to_U16_ROUND(F32 val, F32 lower, F32 upper)
|
||||
{
|
||||
|
|
@ -107,6 +109,18 @@ inline U8 F32_to_U8(F32 val, F32 lower, F32 upper)
|
|||
return (U8)(llfloor(val*U8MAX));
|
||||
}
|
||||
|
||||
// <FS:Ansariel> FIRE-15667: 24bit depth maps
|
||||
inline U32 F32_to_U32(F32 val, F32 lower, F32 upper)
|
||||
{
|
||||
val = llclamp(val, lower, upper);
|
||||
// make sure that the value is positive and normalized to <0, 1>
|
||||
val -= lower;
|
||||
val /= (upper - lower);
|
||||
|
||||
return (U32)(llround(val*U24MAX));
|
||||
}
|
||||
// </FS:Ansariel>
|
||||
|
||||
inline F32 U8_to_F32(U8 ival, F32 lower, F32 upper)
|
||||
{
|
||||
F32 val = ival*OOU8MAX;
|
||||
|
|
|
|||
|
|
@ -250,6 +250,10 @@ LLViewerWindow::ESnapshotType LLFloaterSnapshot::Impl::getLayerType(LLFloaterSna
|
|||
type = LLViewerWindow::SNAPSHOT_TYPE_COLOR;
|
||||
else if (id == "depth")
|
||||
type = LLViewerWindow::SNAPSHOT_TYPE_DEPTH;
|
||||
// <FS:Ansariel> FIRE-15667: 24bit depth maps
|
||||
else if (id == "depth24")
|
||||
type = LLViewerWindow::SNAPSHOT_TYPE_DEPTH24;
|
||||
// </FS:Ansariel>
|
||||
return type;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5050,6 +5050,38 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei
|
|||
raw->getData() + output_buffer_offset
|
||||
);
|
||||
}
|
||||
// <FS:Ansariel> FIRE-15667: 24bit depth maps
|
||||
else if (type == SNAPSHOT_TYPE_DEPTH24)
|
||||
{
|
||||
LLPointer<LLImageRaw> depth_line_buffer = new LLImageRaw(read_width, 1, sizeof(GL_FLOAT)); // need to store floating point values
|
||||
glReadPixels(
|
||||
subimage_x_offset, out_y + subimage_y_offset,
|
||||
read_width, 1,
|
||||
GL_DEPTH_COMPONENT, GL_FLOAT,
|
||||
depth_line_buffer->getData()// current output pixel is beginning of buffer...
|
||||
);
|
||||
|
||||
for (S32 i = 0; i < (S32)read_width; i++)
|
||||
{
|
||||
F32 depth_float = *(F32*)(depth_line_buffer->getData() + (i * sizeof(F32)));
|
||||
|
||||
F32 linear_depth_float = 1.f / (depth_conversion_factor_1 - (depth_float * depth_conversion_factor_2));
|
||||
U32 RGB24 = F32_to_U32(linear_depth_float, LLViewerCamera::getInstance()->getNear(), LLViewerCamera::getInstance()->getFar());
|
||||
//A max value of 16777215 for RGB24 evaluates to black when it shold be white. The clamp assures that the divisions do not somehow become >=256.
|
||||
U8 depth_byteR = (U8)(llclamp(llfloor(RGB24 / 65536.f), 0, 255));
|
||||
U8 depth_byteG = (U8)(llclamp(llfloor((RGB24 - depth_byteR * 65536) / 256.f), 0, 255));
|
||||
U8 depth_byteB = (U8)(llclamp((RGB24 - depth_byteR * 65536 - depth_byteG * 256), 0u, 255u));
|
||||
// write converted scanline out to result image
|
||||
*(raw->getData() + output_buffer_offset + (i * raw->getComponents())) = depth_byteR;
|
||||
*(raw->getData() + output_buffer_offset + (i * raw->getComponents()) + 1) = depth_byteG;
|
||||
*(raw->getData() + output_buffer_offset + (i * raw->getComponents()) + 2) = depth_byteB;
|
||||
for (S32 j = 3; j < raw->getComponents(); j++)
|
||||
{
|
||||
*(raw->getData() + output_buffer_offset + (i * raw->getComponents()) + j) = depth_byteR;
|
||||
}
|
||||
}
|
||||
}
|
||||
// </FS:Ansariel>
|
||||
else // SNAPSHOT_TYPE_DEPTH
|
||||
{
|
||||
LLPointer<LLImageRaw> depth_line_buffer = new LLImageRaw(read_width, 1, sizeof(GL_FLOAT)); // need to store floating point values
|
||||
|
|
|
|||
|
|
@ -346,7 +346,9 @@ public:
|
|||
typedef enum
|
||||
{
|
||||
SNAPSHOT_TYPE_COLOR,
|
||||
SNAPSHOT_TYPE_DEPTH
|
||||
SNAPSHOT_TYPE_DEPTH,
|
||||
SNAPSHOT_TYPE_DEPTH24 // <FS:Ansariel> FIRE-15667: 24bit depth maps
|
||||
|
||||
} ESnapshotType;
|
||||
BOOL saveSnapshot(const std::string& filename, S32 image_width, S32 image_height, BOOL show_ui = TRUE, BOOL do_rebuild = FALSE, ESnapshotType type = SNAPSHOT_TYPE_COLOR);
|
||||
BOOL rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_height, BOOL keep_window_aspect = TRUE, BOOL is_texture = FALSE,
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
<combo_box label="Bildebenen" name="layer_types">
|
||||
<combo_box.item label="Farben" name="Colors"/>
|
||||
<combo_box.item label="Tiefe" name="Depth"/>
|
||||
<combo_box.item label="Tiefe (24 Bit)" name="Depth24"/>
|
||||
</combo_box>
|
||||
<check_box label="Benutzeroberfläche" name="ui_check"/>
|
||||
<check_box label="L$-Kontostand" name="currency_check"/>
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ Additional code generously contributed to Firestorm by:
|
|||
top_pad="4"
|
||||
width="420"
|
||||
wrap="true">
|
||||
Albatroz Hird, Alexie Birman, Andromeda Rage, Armin Weatherwax, Casper Warden, Chalice Yao, Cron Stardust, Damian Zhaoying, Dan Threebeards, Dawa Gurbux, Drake Arconis, Felyza Wishbringer, f0rbidden, Fractured Crystal, Geenz Spad, Hitomi Tiponi, Inusaito Sayori, Katharine Berry, Kittin Ninetails, Kool Koolhoven, Lance Corrimal, Latif Khalifa, Magne Metaverse LLC, Magus Freston, Manami Hokkigai, MartinRJ Fayray, McCabe Maxstead, Melancholy Lemon, Miguael Liamano, Mimika Oh, Mister Acacia, Mysty Saunders, Nagi Michinaga, Name Short, nhede Core, NiranV Dean, Nogardrevlis Lectar, Paladin Forzane, paperwork, Peyton Menges, programmtest, Qwerty Venom, Revolution Smythe, Sahkolihaa Contepomi, sal Kaligawa, Samm Florian, Satomi Ahn, Sei Lisa, Shin Wasp, Shyotl Kuhr, Sione Lomu, Skills Hak, StarlightShining, Sunset Faulkes, Thickbrick Sleaford, Vaalith Jinn, Whirly Fizzle, Zwagoth Klaar and others.
|
||||
Albatroz Hird, Alexie Birman, Andromeda Rage, Armin Weatherwax, Casper Warden, Chalice Yao, Cron Stardust, Damian Zhaoying, Dan Threebeards, Dawa Gurbux, Drake Arconis, Felyza Wishbringer, f0rbidden, Fractured Crystal, Geenz Spad, Hitomi Tiponi, Inusaito Sayori, Katharine Berry, Kittin Ninetails, Kool Koolhoven, Lance Corrimal, Latif Khalifa, Magne Metaverse LLC, Magus Freston, Manami Hokkigai, MartinRJ Fayray, McCabe Maxstead, Melancholy Lemon, Miguael Liamano, Mimika Oh, Mister Acacia, Mysty Saunders, Nagi Michinaga, Name Short, nhede Core, NiranV Dean, Nogardrevlis Lectar, Paladin Forzane, paperwork, Peyton Menges, programmtest, Qwerty Venom, Revolution Smythe, Sahkolihaa Contepomi, sal Kaligawa, Samm Florian, Satomi Ahn, Sei Lisa, Sempervirens Oddfellow, Shin Wasp, Shyotl Kuhr, Sione Lomu, Skills Hak, StarlightShining, Sunset Faulkes, Thickbrick Sleaford, Vaalith Jinn, Whirly Fizzle, Zwagoth Klaar and others.
|
||||
</text>
|
||||
<text
|
||||
follows="top|left"
|
||||
|
|
|
|||
|
|
@ -173,6 +173,10 @@
|
|||
label="Depth"
|
||||
name="Depth"
|
||||
value="depth" />
|
||||
<combo_box.item
|
||||
label="Depth (24 bit)"
|
||||
name="Depth24"
|
||||
value="depth24" />
|
||||
</combo_box>
|
||||
<check_box
|
||||
label="Interface"
|
||||
|
|
|
|||
Loading…
Reference in New Issue