texture load fixes, shader changes

This commit is contained in:
milek7
2018-07-19 19:10:50 +02:00
parent a729c5fa1d
commit 4d198840dc
5 changed files with 20 additions and 29 deletions

View File

@@ -768,6 +768,9 @@ opengl_texture::create() {
if (f_it != precompressed_formats.end())
components = data_format;
if (!components_hint)
components_hint = GL_SRGB_ALPHA;
GLint internal_format = mapping[components][components_hint];
auto blocksize_it = precompressed_formats.find(internal_format);

View File

@@ -54,7 +54,7 @@ struct opengl_texture {
std::string traits; // requested texture attributes: wrapping modes etc
std::string name; // name of the texture source file
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;
static std::array<GLuint, gl::MAX_TEXTURES + 2> units;

View File

@@ -22,7 +22,7 @@ namespace gl
enum class components_e
{
R = GL_R,
R = GL_RED,
RG = GL_RG,
RGB = GL_RGB,
RGBA = GL_RGBA,

View File

@@ -87,6 +87,9 @@ void opengl_material::finalize(bool Loadnow)
}
}
if (!shader)
return;
for (auto it : parse_info->param_mapping)
{
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.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) {
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.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:" &&
(!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.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
filename = GfxRenderer.Texture( material.textures[0] ).name;
@@ -352,6 +337,9 @@ material_manager::create( std::string const &Filename, bool const Loadnow ) {
material.finalize(Loadnow);
if (!material.shader)
return null_handle;
material_handle handle = m_materials.size();
m_materialmappings.emplace(material.name, handle);
m_materials.emplace_back( std::move(material) );

View File

@@ -44,6 +44,6 @@ void main()
vec2 texcoord = f_coords;
vec3 hdr_color = texture(tex1, texcoord).xyz;
vec3 mapped= ACESFilm(hdr_color);
vec3 mapped = ACESFilm(hdr_color);
gl_FragColor = vec4(mapped, 1.0);
}