mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 12:29:18 +02:00
texture load fixes, shader changes
This commit is contained in:
@@ -768,6 +768,9 @@ opengl_texture::create() {
|
|||||||
if (f_it != precompressed_formats.end())
|
if (f_it != precompressed_formats.end())
|
||||||
components = data_format;
|
components = data_format;
|
||||||
|
|
||||||
|
if (!components_hint)
|
||||||
|
components_hint = GL_SRGB_ALPHA;
|
||||||
|
|
||||||
GLint internal_format = mapping[components][components_hint];
|
GLint internal_format = mapping[components][components_hint];
|
||||||
|
|
||||||
auto blocksize_it = precompressed_formats.find(internal_format);
|
auto blocksize_it = precompressed_formats.find(internal_format);
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ struct opengl_texture {
|
|||||||
std::string traits; // requested texture attributes: wrapping modes etc
|
std::string traits; // requested texture attributes: wrapping modes etc
|
||||||
std::string name; // name of the texture source file
|
std::string name; // name of the texture source file
|
||||||
std::size_t size{ 0 }; // size of the texture data, in kb
|
std::size_t size{ 0 }; // size of the texture data, in kb
|
||||||
GLint components_hint; // components that material wants
|
GLint components_hint = 0; // components that material wants
|
||||||
|
|
||||||
GLenum target = GL_TEXTURE_2D;
|
GLenum target = GL_TEXTURE_2D;
|
||||||
static std::array<GLuint, gl::MAX_TEXTURES + 2> units;
|
static std::array<GLuint, gl::MAX_TEXTURES + 2> units;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace gl
|
|||||||
|
|
||||||
enum class components_e
|
enum class components_e
|
||||||
{
|
{
|
||||||
R = GL_R,
|
R = GL_RED,
|
||||||
RG = GL_RG,
|
RG = GL_RG,
|
||||||
RGB = GL_RGB,
|
RGB = GL_RGB,
|
||||||
RGBA = GL_RGBA,
|
RGBA = GL_RGBA,
|
||||||
|
|||||||
40
material.cpp
40
material.cpp
@@ -87,6 +87,9 @@ void opengl_material::finalize(bool Loadnow)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!shader)
|
||||||
|
return;
|
||||||
|
|
||||||
for (auto it : parse_info->param_mapping)
|
for (auto it : parse_info->param_mapping)
|
||||||
{
|
{
|
||||||
std::string key = it.first;
|
std::string key = it.first;
|
||||||
@@ -191,16 +194,6 @@ opengl_material::deserialize_mapping( cParser &Input, int const Priority, bool c
|
|||||||
parse_info->tex_mapping.erase(it);
|
parse_info->tex_mapping.erase(it);
|
||||||
parse_info->tex_mapping.emplace(std::make_pair(key, parse_info_s::tex_def({ value, Priority })));
|
parse_info->tex_mapping.emplace(std::make_pair(key, parse_info_s::tex_def({ value, Priority })));
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
size_t num = std::stoi(key) - 1;
|
|
||||||
if (num < textures.size() &&
|
|
||||||
(textures[num] == null_handle || Priority > m_texture_priority[num]))
|
|
||||||
{
|
|
||||||
std::replace(value.begin(), value.end(), '\\', '/');
|
|
||||||
textures[num] = GfxRenderer.Fetch_Texture( value, Loadnow );
|
|
||||||
m_texture_priority[num] = Priority;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
else if (key.compare(0, 5, "param") == 0) {
|
else if (key.compare(0, 5, "param") == 0) {
|
||||||
key.erase(0, 5);
|
key.erase(0, 5);
|
||||||
@@ -220,21 +213,6 @@ opengl_material::deserialize_mapping( cParser &Input, int const Priority, bool c
|
|||||||
parse_info->param_mapping.erase(it);
|
parse_info->param_mapping.erase(it);
|
||||||
parse_info->param_mapping.emplace(std::make_pair(key, parse_info_s::param_def({ data, Priority })));
|
parse_info->param_mapping.emplace(std::make_pair(key, parse_info_s::param_def({ data, Priority })));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
size_t num = std::stoi(key) - 1;
|
|
||||||
if (num < params.size() &&
|
|
||||||
(Priority > m_param_priority[num]))
|
|
||||||
{
|
|
||||||
std::istringstream stream(value);
|
|
||||||
|
|
||||||
stream >> params[num].r;
|
|
||||||
stream >> params[num].g;
|
|
||||||
stream >> params[num].b;
|
|
||||||
stream >> params[num].a;
|
|
||||||
|
|
||||||
m_param_priority[num] = Priority;
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
else if (key == "shader:" &&
|
else if (key == "shader:" &&
|
||||||
(!shader || Priority > m_shader_priority))
|
(!shader || Priority > m_shader_priority))
|
||||||
@@ -342,7 +320,14 @@ material_manager::create( std::string const &Filename, bool const Loadnow ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// material would attach default shader anyway, but it would spit to error log
|
// material would attach default shader anyway, but it would spit to error log
|
||||||
material.shader = GfxRenderer.Fetch_Shader("default_1");
|
try
|
||||||
|
{
|
||||||
|
material.shader = GfxRenderer.Fetch_Shader("default_1");
|
||||||
|
}
|
||||||
|
catch (gl::shader_exception const &e)
|
||||||
|
{
|
||||||
|
ErrorLog("invalid shader: " + std::string(e.what()));
|
||||||
|
}
|
||||||
|
|
||||||
// use texture path and name to tell the newly created materials apart
|
// use texture path and name to tell the newly created materials apart
|
||||||
filename = GfxRenderer.Texture( material.textures[0] ).name;
|
filename = GfxRenderer.Texture( material.textures[0] ).name;
|
||||||
@@ -352,6 +337,9 @@ material_manager::create( std::string const &Filename, bool const Loadnow ) {
|
|||||||
|
|
||||||
material.finalize(Loadnow);
|
material.finalize(Loadnow);
|
||||||
|
|
||||||
|
if (!material.shader)
|
||||||
|
return null_handle;
|
||||||
|
|
||||||
material_handle handle = m_materials.size();
|
material_handle handle = m_materials.size();
|
||||||
m_materialmappings.emplace(material.name, handle);
|
m_materialmappings.emplace(material.name, handle);
|
||||||
m_materials.emplace_back( std::move(material) );
|
m_materials.emplace_back( std::move(material) );
|
||||||
|
|||||||
@@ -44,6 +44,6 @@ void main()
|
|||||||
vec2 texcoord = f_coords;
|
vec2 texcoord = f_coords;
|
||||||
vec3 hdr_color = texture(tex1, texcoord).xyz;
|
vec3 hdr_color = texture(tex1, texcoord).xyz;
|
||||||
|
|
||||||
vec3 mapped= ACESFilm(hdr_color);
|
vec3 mapped = ACESFilm(hdr_color);
|
||||||
gl_FragColor = vec4(mapped, 1.0);
|
gl_FragColor = vec4(mapped, 1.0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user