From Jason Daly, "Somehow, one of the shaders in the bsp plugin started behaving incorrectly between the original submission and now. I suspect it has to do with a typo in the setup of the shader that was fixed at some point, or it happened during the recent warnings purge. In any case, I had to invert the usage of a parameter in the shader to make it behave properly again.
The vtf plugin wasn't working in Windows due to OS differences in the byte-packing of the header structure (on Windows, the big block read was causing a buffer overrun). I fixed this by reading the structure from the file field by field. It's now happy on both Linux and Windows."
This commit is contained in:
@@ -685,9 +685,9 @@ ref_ptr<StateSet> VBSPReader::createBlendShader(Texture * tex1, Texture * tex2)
|
||||
" vec4 tex1Color;\n"
|
||||
" vec4 tex2Color;\n"
|
||||
"\n"
|
||||
" tex1Color = texture2D(tex1, gl_TexCoord[0].st) * fBlendParam;\n"
|
||||
" tex2Color = texture2D(tex2, gl_TexCoord[0].st) *\n"
|
||||
" tex1Color = texture2D(tex1, gl_TexCoord[0].st) *\n"
|
||||
" (1.0 - fBlendParam);\n"
|
||||
" tex2Color = texture2D(tex2, gl_TexCoord[0].st) * fBlendParam;\n"
|
||||
"\n"
|
||||
" gl_FragColor = gl_Color * (tex1Color + tex2Color);\n"
|
||||
"}\n"
|
||||
|
||||
@@ -375,17 +375,41 @@ osg::Image* ReadVTFFile(std::istream& _istream)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Read next two fields of the header (which includes the header size)
|
||||
_istream.read((char *)&vtf_header.file_version[0], 12);
|
||||
|
||||
// Now, read the rest of the header
|
||||
_istream.read((char *)&vtf_header.image_width, vtf_header.header_size - 16);
|
||||
_istream.read((char *)&vtf_header.file_version[0], 8);
|
||||
_istream.read((char *)&vtf_header.header_size, 4);
|
||||
_istream.read((char *)&vtf_header.image_width, 2);
|
||||
_istream.read((char *)&vtf_header.image_height, 2);
|
||||
_istream.read((char *)&vtf_header.image_flags, 4);
|
||||
_istream.read((char *)&vtf_header.num_frames, 2);
|
||||
_istream.read((char *)&vtf_header.start_frame, 2);
|
||||
_istream.ignore(4);
|
||||
_istream.read((char *)&vtf_header.reflectivity_value, 12);
|
||||
_istream.ignore(4);
|
||||
_istream.read((char *)&vtf_header.bump_scale, 4);
|
||||
_istream.read((char *)&vtf_header.image_format, 4);
|
||||
_istream.read((char *)&vtf_header.num_mip_levels, 1);
|
||||
_istream.read((char *)&vtf_header.low_res_image_format, 4);
|
||||
_istream.read((char *)&vtf_header.low_res_image_width, 1);
|
||||
_istream.read((char *)&vtf_header.low_res_image_height, 1);
|
||||
|
||||
// No depth in textures earlier than version 7.2
|
||||
if ((vtf_header.file_version[0] < 7) ||
|
||||
((vtf_header.file_version[0] == 7) &&
|
||||
(vtf_header.file_version[1] < 2)))
|
||||
{
|
||||
// No depth in header, set it to 1
|
||||
vtf_header.image_depth = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Read the image depth
|
||||
_istream.read((char *)&vtf_header.image_depth, 2);
|
||||
}
|
||||
|
||||
// Skip past the rest of the header's space
|
||||
std::streampos filePos = _istream.tellg();
|
||||
_istream.ignore(vtf_header.header_size - filePos);
|
||||
|
||||
// Environment maps not supported
|
||||
if (vtf_header.image_flags & VTF_FLAGS_ENVMAP)
|
||||
@@ -634,9 +658,9 @@ osg::Image* ReadVTFFile(std::istream& _istream)
|
||||
_istream.read((char*)&imageData[mipOffset], mipSize);
|
||||
}
|
||||
|
||||
// We've read all of the mipmaps except the largest (the original,
|
||||
// We've read all of the mipmaps except the largest (the original
|
||||
// image), so do that now
|
||||
mipSize = mipmaps[1];
|
||||
mipSize = mipmaps[0];
|
||||
_istream.read((char*)imageData, mipSize);
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user