git-svn-id: svn://db.shs.com.ru/libs@701 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2019-12-13 23:15:59 +00:00
parent cac73a63f1
commit 2136b4d30b
22 changed files with 653 additions and 671 deletions

View File

@@ -88,6 +88,7 @@ Map::Map() {
color_amount = 1.f; color_amount = 1.f;
color_offset = 0.f; color_offset = 0.f;
bitmap_scale = QPointF(1., 1.); bitmap_scale = QPointF(1., 1.);
use_bitmap = false;
_changed = true; _changed = true;
_layer = 0; _layer = 0;
} }
@@ -109,7 +110,7 @@ void Map::copyToQGLMap(QGLMap & m) const {
m.amount = color_amount; m.amount = color_amount;
m.offset = color_offset; m.offset = color_offset;
m.scale = QVector2D(bitmap_scale); m.scale = QVector2D(bitmap_scale);
if (hasBitmap()) { if (hasBitmap() && use_bitmap) {
m.array_index = tarMaps; m.array_index = tarMaps;
m.map_index = _layer; m.map_index = _layer;
} else { } else {
@@ -124,12 +125,12 @@ void Map::copyToQGLMap(QGLMap & m) const {
Material::Material(const QString _name)/*: map_reflection(512)*/ { Material::Material(const QString _name)/*: map_reflection(512)*/ {
setTypes(); setTypes();
name = _name; name = _name;
color_diffuse = color_specular = Qt::darkGray; color_diffuse = Qt::white;
color_emission = Qt::black; color_emission = Qt::black;
glass = false; glass = false;
transparency = reflectivity = 0.f; transparency = reflectivity = 0.f;
map_roughness.color_amount = 0.75f; map_roughness.color_amount = 0.75f;
map_specular.color_amount = 1.f; map_metalness.color_amount = 0.25f;
iof = 1.f; iof = 1.f;
dispersion = 0.05f; dispersion = 0.05f;
_changed = true; _changed = true;
@@ -150,7 +151,7 @@ bool Material::hasTransparency() const {
bool Material::isMapsChanged() const { bool Material::isMapsChanged() const {
return map_diffuse ._changed || return map_diffuse ._changed ||
map_normal ._changed || map_normal ._changed ||
map_specular ._changed || map_metalness._changed ||
map_roughness._changed || map_roughness._changed ||
map_emission ._changed || map_emission ._changed ||
map_relief ._changed; map_relief ._changed;
@@ -161,7 +162,7 @@ bool Material::isMapChanged(int type) const {
switch (type) { switch (type) {
case mtDiffuse : return map_diffuse ._changed; case mtDiffuse : return map_diffuse ._changed;
case mtNormal : return map_normal ._changed; case mtNormal : return map_normal ._changed;
case mtSpecular : return map_specular ._changed; case mtMetalness: return map_metalness._changed;
case mtRoughness: return map_roughness._changed; case mtRoughness: return map_roughness._changed;
case mtEmission : return map_emission ._changed; case mtEmission : return map_emission ._changed;
case mtRelief : return map_relief ._changed; case mtRelief : return map_relief ._changed;
@@ -173,7 +174,7 @@ bool Material::isMapChanged(int type) const {
void Material::load(TextureManager * tm) { void Material::load(TextureManager * tm) {
map_diffuse .load(tm); map_diffuse .load(tm);
map_normal .load(tm); map_normal .load(tm);
map_specular .load(tm); map_metalness.load(tm);
map_roughness.load(tm); map_roughness.load(tm);
map_emission .load(tm); map_emission .load(tm);
map_relief .load(tm); map_relief .load(tm);
@@ -183,7 +184,7 @@ void Material::load(TextureManager * tm) {
void Material::setMapsChanged() { void Material::setMapsChanged() {
map_diffuse ._changed = true; map_diffuse ._changed = true;
map_normal ._changed = true; map_normal ._changed = true;
map_specular ._changed = true; map_metalness._changed = true;
map_roughness._changed = true; map_roughness._changed = true;
map_emission ._changed = true; map_emission ._changed = true;
map_relief ._changed = true; map_relief ._changed = true;
@@ -191,10 +192,10 @@ void Material::setMapsChanged() {
void Material::setTypes() { void Material::setTypes() {
map_diffuse ._type = mtDiffuse; map_diffuse ._type = mtDiffuse ;
map_normal ._type = mtNormal; map_normal ._type = mtNormal ;
map_specular ._type = mtSpecular; map_metalness._type = mtMetalness;
map_roughness._type = mtRoughness; map_roughness._type = mtRoughness;
map_emission ._type = mtEmission; map_emission ._type = mtEmission ;
map_relief ._type = mtRelief; map_relief ._type = mtRelief ;
} }

View File

@@ -83,11 +83,12 @@ public:
void load(TextureManager * tm); void load(TextureManager * tm);
void copyToQGLMap(QGLEngineShaders::QGLMap & m) const; void copyToQGLMap(QGLEngineShaders::QGLMap & m) const;
QString bitmap_path; QString bitmap_path;
GLuint bitmap_id; GLuint bitmap_id;
QPointF bitmap_offset; QPointF bitmap_offset;
QPointF bitmap_scale; QPointF bitmap_scale;
float color_amount; float color_amount;
float color_offset; float color_offset;
bool use_bitmap;
bool _changed; bool _changed;
int _type, _layer; int _type, _layer;
@@ -105,7 +106,6 @@ public:
void setTypes(); void setTypes();
QString name; QString name;
QColor color_diffuse; QColor color_diffuse;
QColor color_specular;
QColor color_emission; QColor color_emission;
bool glass; bool glass;
float transparency; float transparency;
@@ -114,7 +114,7 @@ public:
float dispersion; float dispersion;
Map map_diffuse ; Map map_diffuse ;
Map map_normal ; Map map_normal ;
Map map_specular ; Map map_metalness;
Map map_roughness; Map map_roughness;
Map map_emission ; Map map_emission ;
Map map_relief ; Map map_relief ;
@@ -126,21 +126,23 @@ public:
inline QDataStream & operator <<(QDataStream & s, const Map & m) { inline QDataStream & operator <<(QDataStream & s, const Map & m) {
ChunkStream cs; ChunkStream cs;
cs.add(1, m.bitmap_path).add(2, m.color_amount).add(3, m.color_offset).add(6, m.bitmap_scale); cs.add(1, m.bitmap_path).add(2, m.color_amount).add(3, m.color_offset).add(6, m.bitmap_scale)
.add(7, m.use_bitmap);
s << cs.data(); return s; s << cs.data(); return s;
} }
inline QDataStream & operator >>(QDataStream & s, Map & m) { inline QDataStream & operator >>(QDataStream & s, Map & m) {
ChunkStream cs(s); ChunkStream cs(s);
cs.readAll(); cs.readAll();
cs.get(1, m.bitmap_path).get(2, m.color_amount).get(3, m.color_offset).get(6, m.bitmap_scale); cs.get(1, m.bitmap_path).get(2, m.color_amount).get(3, m.color_offset).get(6, m.bitmap_scale)
.get(7, m.use_bitmap);
return s; return s;
} }
inline QDataStream & operator <<(QDataStream & s, const Material * m) { inline QDataStream & operator <<(QDataStream & s, const Material * m) {
ChunkStream cs; ChunkStream cs;
cs.add(1, m->name).add(2, m->color_diffuse).add(3, m->color_specular).add(4, m->color_emission) cs.add(1, m->name).add(2, m->color_diffuse).add(4, m->color_emission)
.add(5, m->transparency).add(6, m->reflectivity).add(7, m->glass).add(8, m->map_diffuse).add(9, m->map_normal) .add(5, m->transparency).add(6, m->reflectivity).add(7, m->glass).add(8, m->map_diffuse).add(9, m->map_normal)
.add(10, m->map_relief).add(11, m->map_specular).add(12, m->map_roughness).add(13, m->map_emission); .add(10, m->map_relief).add(11, m->map_metalness).add(12, m->map_roughness).add(13, m->map_emission);
s << /*qCompress*/(cs.data()); return s; s << /*qCompress*/(cs.data()); return s;
} }
inline QDataStream & operator >>(QDataStream & s, Material *& m) { inline QDataStream & operator >>(QDataStream & s, Material *& m) {
@@ -153,7 +155,6 @@ inline QDataStream & operator >>(QDataStream & s, Material *& m) {
switch (cs.read()) { switch (cs.read()) {
case 1: cs.get(m->name); break; case 1: cs.get(m->name); break;
case 2: cs.get(m->color_diffuse); break; case 2: cs.get(m->color_diffuse); break;
case 3: cs.get(m->color_specular); break;
case 4: cs.get(m->color_emission); break; case 4: cs.get(m->color_emission); break;
case 5: cs.get(m->transparency); break; case 5: cs.get(m->transparency); break;
case 6: cs.get(m->reflectivity); break; case 6: cs.get(m->reflectivity); break;
@@ -161,7 +162,7 @@ inline QDataStream & operator >>(QDataStream & s, Material *& m) {
case 8: cs.get(m->map_diffuse); break; case 8: cs.get(m->map_diffuse); break;
case 9: cs.get(m->map_normal); break; case 9: cs.get(m->map_normal); break;
case 10: cs.get(m->map_relief); break; case 10: cs.get(m->map_relief); break;
case 11: cs.get(m->map_specular); break; case 11: cs.get(m->map_metalness); break;
case 12: cs.get(m->map_roughness); break; case 12: cs.get(m->map_roughness); break;
case 13: cs.get(m->map_emission); break; case 13: cs.get(m->map_emission); break;
} }

View File

@@ -70,7 +70,7 @@ const char qgl_structs[] =
"#define QGL_MAPS_COUNT 6\n" "#define QGL_MAPS_COUNT 6\n"
"#define QGL_MAP_DIFFUSE 0\n" "#define QGL_MAP_DIFFUSE 0\n"
"#define QGL_MAP_NORMAL 1\n" "#define QGL_MAP_NORMAL 1\n"
"#define QGL_MAP_SPECULAR 2\n" "#define QGL_MAP_METALNESS 2\n"
"#define QGL_MAP_ROUGHNESS 3\n" "#define QGL_MAP_ROUGHNESS 3\n"
"#define QGL_MAP_EMISSION 4\n" "#define QGL_MAP_EMISSION 4\n"
"#define QGL_MAP_RELIEF 5\n" "#define QGL_MAP_RELIEF 5\n"
@@ -85,7 +85,7 @@ const char qgl_structs[] =
"};\n" "};\n"
"struct QGLMaterial {\n" "struct QGLMaterial {\n"
" vec4 color_diffuse;\n" " vec4 color_diffuse;\n"
" vec4 color_specular;\n" //" vec4 color_specular;\n"
" vec4 color_emission;\n" " vec4 color_emission;\n"
" float transparency;\n" " float transparency;\n"
" float reflectivity;\n" " float reflectivity;\n"

View File

@@ -29,8 +29,7 @@ QGLEngineShaders::QGLMap::QGLMap() {
QGLEngineShaders::QGLMaterial::QGLMaterial() { QGLEngineShaders::QGLMaterial::QGLMaterial() {
color_diffuse = QVector4D(.5, .5, .5, 0.); color_diffuse = QVector4D(1., 1., 1., 0.);
color_specular = QVector4D(.5, .5, .5, 0.);
color_emission = QVector4D(0., 0., 0., 0.); color_emission = QVector4D(0., 0., 0., 0.);
transparency = 0.; transparency = 0.;
reflectivity = 0.; reflectivity = 0.;
@@ -38,6 +37,7 @@ QGLEngineShaders::QGLMaterial::QGLMaterial() {
dispersion = 0.; dispersion = 0.;
map[mtNormal].map_index = emrBlue; map[mtNormal].map_index = emrBlue;
map[mtRoughness].amount = 0.75; map[mtRoughness].amount = 0.75;
map[mtMetalness].amount = 0.25;
} }

View File

@@ -87,7 +87,7 @@ enum BindingPoints {
enum MapType { enum MapType {
mtDiffuse = 0, mtDiffuse = 0,
mtNormal = 1, mtNormal = 1,
mtSpecular = 2, mtMetalness = 2,
mtRoughness = 3, mtRoughness = 3,
mtEmission = 4, mtEmission = 4,
mtRelief = 5, mtRelief = 5,
@@ -114,7 +114,6 @@ struct QGLMap {
struct QGLMaterial { struct QGLMaterial {
QGLMaterial(); QGLMaterial();
QVector4D color_diffuse; QVector4D color_diffuse;
QVector4D color_specular;
QVector4D color_emission; QVector4D color_emission;
GLfloat transparency; GLfloat transparency;
GLfloat reflectivity; GLfloat reflectivity;

View File

@@ -112,16 +112,15 @@ Material * assimpMaterial(const aiMaterial * m) {
// qDebug()<< fromAiString(m->mProperties[i]->mKey);// << "=" << aiMatFloat(m, m->mProperties[i]->mKey.C_Str(), 0, 0); // qDebug()<< fromAiString(m->mProperties[i]->mKey);// << "=" << aiMatFloat(m, m->mProperties[i]->mKey.C_Str(), 0, 0);
//} //}
ret->color_diffuse = aiMatColor(m, AI_MATKEY_COLOR_DIFFUSE); ret->color_diffuse = aiMatColor(m, AI_MATKEY_COLOR_DIFFUSE);
ret->color_specular = aiMatColor(m, AI_MATKEY_COLOR_SPECULAR);
ret->color_emission = aiMatColor(m, AI_MATKEY_COLOR_EMISSIVE); ret->color_emission = aiMatColor(m, AI_MATKEY_COLOR_EMISSIVE);
float shine = aiMatFloat(m, AI_MATKEY_SHININESS, -1.f); float shine = aiMatFloat(m, AI_MATKEY_SHININESS, -1.f);
if (shine >= 0) { if (shine >= 0) {
ret->map_roughness.color_amount = 1.f - (shine / 100.f); ret->map_roughness.color_amount = 0.8f - (shine / 100.f * 0.6f);
//qDebug() << "shine" << shine; //qDebug() << "shine" << shine;
} }
ret->map_diffuse .bitmap_path = aiMatString(m, AI_MATKEY_TEXTURE_DIFFUSE(0)); ret->map_diffuse .bitmap_path = aiMatString(m, AI_MATKEY_TEXTURE_DIFFUSE(0));
ret->map_normal .bitmap_path = aiMatString(m, AI_MATKEY_TEXTURE_NORMALS(0)); ret->map_normal .bitmap_path = aiMatString(m, AI_MATKEY_TEXTURE_NORMALS(0));
ret->map_specular .bitmap_path = aiMatString(m, AI_MATKEY_TEXTURE_SPECULAR(0)); //ret->map_metalness.bitmap_path = aiMatString(m, AI_MATKEY_TEXTURE_SPECULAR(0));
ret->map_roughness.bitmap_path = aiMatString(m, AI_MATKEY_TEXTURE_SHININESS(0)); ret->map_roughness.bitmap_path = aiMatString(m, AI_MATKEY_TEXTURE_SHININESS(0));
ret->map_emission .bitmap_path = aiMatString(m, AI_MATKEY_TEXTURE_EMISSIVE(0)); ret->map_emission .bitmap_path = aiMatString(m, AI_MATKEY_TEXTURE_EMISSIVE(0));
ret->transparency = 1.f - aiMatFloat(m, AI_MATKEY_OPACITY, 1.f); ret->transparency = 1.f - aiMatFloat(m, AI_MATKEY_OPACITY, 1.f);

View File

@@ -379,7 +379,7 @@ void ObjectBase::setMaterial(Material * m, bool with_children) {
if (with_children) if (with_children)
foreach (ObjectBase * i, children_) i->setMaterial(m, true); foreach (ObjectBase * i, children_) i->setMaterial(m, true);
setObjectsChanged(); setObjectsChanged();
if (scene_) scene_->mat_changed = true; if (scene_) scene_->mat_changed = scene_->tree_changed = true;
} }

View File

@@ -442,8 +442,6 @@ bool Scene::prepare() {
if (!tree_changed && !mat_changed) return false; if (!tree_changed && !mat_changed) return false;
aol = root_->children(true); aol = root_->children(true);
if (tree_changed) { if (tree_changed) {
tree_changed = false;
lights_changed = true;
geometries_used[rpSolid ].clear(); geometries_used[rpSolid ].clear();
geometries_used[rpTransparent].clear(); geometries_used[rpTransparent].clear();
lights_used.clear(); lights_used.clear();
@@ -453,6 +451,8 @@ bool Scene::prepare() {
cleanUnused(); cleanUnused();
QMetaObject::invokeMethod(this, "treeChanged", Qt::QueuedConnection); QMetaObject::invokeMethod(this, "treeChanged", Qt::QueuedConnection);
} }
tree_changed = false;
lights_changed = true;
} }
mat_changed = false; mat_changed = false;
return true; return true;

View File

@@ -89,6 +89,7 @@ void Renderer::init(int width, int height) {
tone_proc.init(); tone_proc.init();
initQuad(quad); initQuad(quad);
initTextureArrays(); initTextureArrays();
initCoeffTextures();
need_init_shaders = true; need_init_shaders = true;
} }
@@ -155,6 +156,8 @@ void Renderer::initShaders() {
if (!bindShader(roles[p], &prog)) continue; if (!bindShader(roles[p], &prog)) continue;
for (int i = 0; i < 5; ++i) for (int i = 0; i < 5; ++i)
prog->setUniformValue(QString("tex_%1").arg(i).toLatin1().constData(), i); prog->setUniformValue(QString("tex_%1").arg(i).toLatin1().constData(), i);
//prog->setUniformValue("tex_coeffs[0]", (int)Renderer::dbrBuffersCount);
//prog->setUniformValue("tex_coeffs[1]", (int)Renderer::dbrBuffersCount+1);
} }
if (bindShader(srFinalPass, &prog)) { if (bindShader(srFinalPass, &prog)) {
prog->setUniformValue("tex_g1" , 0); prog->setUniformValue("tex_g1" , 0);
@@ -226,17 +229,26 @@ void Renderer::renderObjects(Scene & scene, RenderPass pass) {
} }
void Renderer::renderLight(int first_wr_buff) { void Renderer::renderLight(int first_wr_buff, bool clear_only) {
QOpenGLShaderProgram * prog = 0; QOpenGLShaderProgram * prog = 0;
Camera * cam = view->camera(); Camera * cam = view->camera();
for (int i = 0; i < 2; ++i) {
view->glActiveTexture(GL_TEXTURE0 + Renderer::dbrBuffersCount + i);
view->glBindTexture(GL_TEXTURE_2D, tex_coeff[i]);
}
fbo_ds.bindColorTextures(); fbo_ds.bindColorTextures();
fbo_out.bind(); fbo_out.bind();
//int ri = 1, wi = 0; //int ri = 1, wi = 0;
typedef QPair<Renderer::ShaderRole, Light::Type> PassPair; typedef QPair<Renderer::ShaderRole, Light::Type> PassPair;
QVector<PassPair> passes; QVector<PassPair> passes;
passes << PassPair(srLightOmniPass, Light::Omni) << PassPair(srLightSpotPass, Light::Cone); passes << PassPair(srLightOmniPass, Light::Omni) << PassPair(srLightSpotPass, Light::Cone);
QColor back = view->fogColor_;
back.setAlpha(0);
foreach (PassPair pass, passes) { foreach (PassPair pass, passes) {
if (bindShader(pass.first, &prog)) { if (bindShader(pass.first, &prog)) {
fbo_out.setWriteBuffer(first_wr_buff + pass.second);
glClearFramebuffer(back, false);
if (clear_only) continue;
setUniformCamera(prog, cam); setUniformCamera(prog, cam);
setUniformViewCorners(prog, cam); setUniformViewCorners(prog, cam);
prog->setUniformValue("lights_start", lights_start[pass.second]); prog->setUniformValue("lights_start", lights_start[pass.second]);
@@ -244,8 +256,6 @@ void Renderer::renderLight(int first_wr_buff) {
prog->setUniformValue("fog_color", view->fogColor_); prog->setUniformValue("fog_color", view->fogColor_);
prog->setUniformValue("fog_decay", qMax(view->fogDecay_, 0.001f)); prog->setUniformValue("fog_decay", qMax(view->fogDecay_, 0.001f));
prog->setUniformValue("fog_density", view->fogDensity_); prog->setUniformValue("fog_density", view->fogDensity_);
fbo_out.setWriteBuffer(first_wr_buff + pass.second);
glClearFramebuffer(Qt::black, false);
renderQuad(prog, quad, cam); renderQuad(prog, quad, cam);
} }
} }
@@ -307,7 +317,7 @@ void Renderer::renderScene() {
fbo_ds.release(); fbo_ds.release();
/// lighting passes /// lighting passes
renderLight(obrSolidOmni); renderLight(obrSolidOmni, scene.geometries_used[rpSolid].isEmpty());
/// transparent geometry pass /// transparent geometry pass
fbo_ds.bind(); fbo_ds.bind();
@@ -319,7 +329,7 @@ void Renderer::renderScene() {
fbo_ds.release(); fbo_ds.release();
/// lighting passes /// lighting passes
renderLight(obrTransparentOmni); renderLight(obrTransparentOmni, scene.geometries_used[rpTransparent].isEmpty());
/// blending layers /// blending layers
if (bindShader(srFinalPass, &prog)) { if (bindShader(srFinalPass, &prog)) {

View File

@@ -30,6 +30,7 @@
class Renderer: public RendererBase { class Renderer: public RendererBase {
friend class QGLView; friend class QGLView;
friend class MouseController; friend class MouseController;
friend class RendererBase;
friend class RendererMaterial; friend class RendererMaterial;
friend class RendererService; friend class RendererService;
friend class RendererSelection; friend class RendererSelection;
@@ -58,7 +59,9 @@ class Renderer: public RendererBase {
dbrNormalZ, dbrNormalZ,
dbrSpecularReflect, dbrSpecularReflect,
dbrEmissionRough, dbrEmissionRough,
//dbrSpeedBitangXY, dbrSpeedBitangXY,
dbrBuffersCount,
}; };
enum OutBufferRole { enum OutBufferRole {
obrTonemap, obrTonemap,
@@ -89,7 +92,7 @@ protected:
void fillObjectsBuffer(const ObjectBaseList & ol, RenderPass pass); void fillObjectsBuffer(const ObjectBaseList & ol, RenderPass pass);
void reloadObjects(); void reloadObjects();
void renderObjects(Scene & scene, RenderPass pass); void renderObjects(Scene & scene, RenderPass pass);
void renderLight(int first_wr_buff); void renderLight(int first_wr_buff, bool clear_only);
bool bindShader(ShaderRole role, QOpenGLShaderProgram ** ret = 0); bool bindShader(ShaderRole role, QOpenGLShaderProgram ** ret = 0);
bool bindShader(QOpenGLShaderProgram * sp); bool bindShader(QOpenGLShaderProgram * sp);

View File

@@ -19,6 +19,7 @@
#define GL_GLEXT_PROTOTYPES #define GL_GLEXT_PROTOTYPES
#include <QOpenGLExtraFunctions> #include <QOpenGLExtraFunctions>
#include "renderer_base.h" #include "renderer_base.h"
#include "renderer.h"
#include "qglview.h" #include "qglview.h"
#include "glmesh.h" #include "glmesh.h"
#include "gltexture_manager.h" #include "gltexture_manager.h"
@@ -38,6 +39,7 @@ RendererBase::RendererBase(QGLView * view_):
textures_manager = new TextureManager(view); textures_manager = new TextureManager(view);
maps_size = QSize(512, 512); maps_size = QSize(512, 512);
maps_hash = 0; maps_hash = 0;
tex_coeff[0] = tex_coeff[1] = 0;
} }
@@ -145,7 +147,7 @@ void RendererBase::reloadMaterials(Scene & scene) {
foreach (Material * m, scene.materials) { foreach (Material * m, scene.materials) {
if (m->map_diffuse .hasBitmap()) maps[0] << &(m->map_diffuse ); if (m->map_diffuse .hasBitmap()) maps[0] << &(m->map_diffuse );
if (m->map_normal .hasBitmap()) maps[1] << &(m->map_normal ); if (m->map_normal .hasBitmap()) maps[1] << &(m->map_normal );
if (m->map_specular .hasBitmap()) maps[0] << &(m->map_specular ); if (m->map_metalness.hasBitmap()) maps[0] << &(m->map_metalness);
if (m->map_roughness.hasBitmap()) maps[0] << &(m->map_roughness); if (m->map_roughness.hasBitmap()) maps[0] << &(m->map_roughness);
if (m->map_emission .hasBitmap()) maps[0] << &(m->map_emission ); if (m->map_emission .hasBitmap()) maps[0] << &(m->map_emission );
if (m->map_relief .hasBitmap()) maps[0] << &(m->map_relief ); if (m->map_relief .hasBitmap()) maps[0] << &(m->map_relief );
@@ -189,7 +191,6 @@ void RendererBase::reloadMaterials(Scene & scene) {
m->_index = cur_materials_.size(); m->_index = cur_materials_.size();
m->_changed = false; m->_changed = false;
glm.color_diffuse = QColor2QVector(m->color_diffuse ); glm.color_diffuse = QColor2QVector(m->color_diffuse );
glm.color_specular = QColor2QVector(m->color_specular);
glm.color_emission = QColor2QVector(m->color_emission); glm.color_emission = QColor2QVector(m->color_emission);
glm.transparency = m->transparency; glm.transparency = m->transparency;
glm.reflectivity = m->reflectivity; glm.reflectivity = m->reflectivity;
@@ -197,7 +198,7 @@ void RendererBase::reloadMaterials(Scene & scene) {
glm.dispersion = m->dispersion ; glm.dispersion = m->dispersion ;
m->map_diffuse .copyToQGLMap(glm.map[mtDiffuse ]); m->map_diffuse .copyToQGLMap(glm.map[mtDiffuse ]);
m->map_normal .copyToQGLMap(glm.map[mtNormal ]); m->map_normal .copyToQGLMap(glm.map[mtNormal ]);
m->map_specular .copyToQGLMap(glm.map[mtSpecular ]); m->map_metalness.copyToQGLMap(glm.map[mtMetalness ]);
m->map_roughness.copyToQGLMap(glm.map[mtRoughness]); m->map_roughness.copyToQGLMap(glm.map[mtRoughness]);
m->map_emission .copyToQGLMap(glm.map[mtEmission ]); m->map_emission .copyToQGLMap(glm.map[mtEmission ]);
m->map_relief .copyToQGLMap(glm.map[mtRelief ]); m->map_relief .copyToQGLMap(glm.map[mtRelief ]);
@@ -298,3 +299,50 @@ void RendererBase::renderQuad(QOpenGLShaderProgram * prog, Mesh * mesh, Camera *
setUniformCamera(prog, cam, false); setUniformCamera(prog, cam, false);
mesh->draw(view, 1); mesh->draw(view, 1);
} }
void RendererBase::initCoeffTextures() {
/*const int size = 512;
QVector<float> data_diff(size*size), data_spec(size*size);
double r, c, c2;
int ind = -1;
for (int x = 0; x < size; ++x) {
c = x / double(size - 1);
c = sqrt(c);
c = piMax(1.E-16, c);
c2 = c*c;
for (int y = 0; y < size; ++y) {
r = y / double(size - 1);
double r_d = r;
double r_s = r*r*r;
r_d = piMax(1.E-16, r_d);
r_s = piMax(1.E-16, r_s);
double ndlc = (1. - c2) / c2;
double diff = 2. / (1. + sqrt(1. + (1. - r_d) * ndlc));
double spec = c2 * (r_s + ndlc);
spec = r_s / (spec * spec) / M_PI;
++ind;
data_diff[ind] = piClamp(diff, 1.E-12, 1.E+36);
data_spec[ind] = piClamp(spec, 1.E-12, 1.E+36);
}
}
createCoeffTexture(tex_coeff[0], data_diff, size);
createCoeffTexture(tex_coeff[1], data_spec, size);*/
}
void RendererBase::createCoeffTexture(GLuint & id, const QVector<float> & data, int size) {
QOpenGLExtraFunctions * f = view;
deleteGLTexture(f, id);
f->glGenTextures(1, &id);
f->glBindTexture(GL_TEXTURE_2D, id);
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE );
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
f->glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, size, size, 0, GL_RED, GL_FLOAT, data.constData());
}

View File

@@ -45,6 +45,8 @@ protected:
void setMapsSize(QSize sz); void setMapsSize(QSize sz);
void initQuad(Mesh * mesh, QMatrix4x4 mat = QMatrix4x4()); void initQuad(Mesh * mesh, QMatrix4x4 mat = QMatrix4x4());
void renderQuad(QOpenGLShaderProgram * prog, Mesh * mesh, Camera * cam = 0, bool uniforms = true); void renderQuad(QOpenGLShaderProgram * prog, Mesh * mesh, Camera * cam = 0, bool uniforms = true);
void initCoeffTextures();
void createCoeffTexture(GLuint & id, const QVector<float> & data, int size);
QGLView * view; QGLView * view;
TextureManager * textures_manager; TextureManager * textures_manager;
@@ -57,6 +59,7 @@ protected:
Texture2DArray textures_empty, textures_maps; Texture2DArray textures_empty, textures_maps;
QSize maps_size; QSize maps_size;
uint maps_hash; uint maps_hash;
GLuint tex_coeff[2];
QMap<int, int> lights_start; QMap<int, int> lights_start;
QList<Light*> current_lights; QList<Light*> current_lights;

View File

@@ -66,7 +66,7 @@ void RendererMaterial::renderMaterial(Material * m) {
QOpenGLExtraFunctions * f = r->view; QOpenGLExtraFunctions * f = r->view;
fbo_mat_thumb.bind(); fbo_mat_thumb.bind();
glEnableDepth(); glEnableDepth();
glClearFramebuffer(); glClearFramebuffer(QColor(0,0,0,0));
if (r->bindShader(Renderer::srGeometryPass, &prog)) { if (r->bindShader(Renderer::srGeometryPass, &prog)) {
r->setUniformMaps(prog); r->setUniformMaps(prog);
r->setUniformCamera(prog, mat_camera, true, fbo_mat_thumb.size()); r->setUniformCamera(prog, mat_camera, true, fbo_mat_thumb.size());

View File

@@ -42,7 +42,8 @@ void main(void) {
dn *= dn_sl / (length(dn) + 1E-6); dn *= dn_sl / (length(dn) + 1E-6);
normal = normalize(geom_normal + dn); normal = normalize(geom_normal + dn);
vec4 specular = qgl_materialTexture(QGL_MAP_SPECULAR, tc, vec4(0)) * qgl_material[qgl_MaterialIndex].color_specular; float metalness = dot(qgl_materialTexture(QGL_MAP_METALNESS, tc, vec4(0)).rgb, luma);
metalness = clamp(metalness, 0, 1);
float roughness = dot(qgl_materialTexture(QGL_MAP_ROUGHNESS, tc, vec4(0)).rgb, luma); float roughness = dot(qgl_materialTexture(QGL_MAP_ROUGHNESS, tc, vec4(0)).rgb, luma);
roughness = clamp(roughness, 0.0001, 0.9999); roughness = clamp(roughness, 0.0001, 0.9999);
@@ -60,8 +61,8 @@ void main(void) {
qgl_FragData[0] = vec4(diffuse .rgba); qgl_FragData[0] = vec4(diffuse .rgba);
qgl_FragData[1] = vec4(normal .xyz, z); qgl_FragData[1] = vec4(normal .xyz, z);
qgl_FragData[2] = vec4(specular.rgb, reflectivity); qgl_FragData[2] = vec4(metalness, roughness, reflectivity, 0);
qgl_FragData[3] = vec4(emission.rgb, roughness/*bn.x*/); qgl_FragData[3] = vec4(emission.rgb, 0/*bn.x*/);
//qgl_FragData[4] = vec4(speed.xy, bn.yz); //qgl_FragData[4] = vec4(speed.xy, bn.yz);
//ivec2 itc = ivec2(gl_FragCoord.xy); //ivec2 itc = ivec2(gl_FragCoord.xy);

View File

@@ -5,6 +5,7 @@ out vec3 view_dir;
uniform vec4 view_corners[4]; uniform vec4 view_corners[4];
void main(void) { void main(void) {
qgl_FragTexture = qgl_Texture;
gl_Position = qgl_ftransform(); gl_Position = qgl_ftransform();
view_dir = view_corners[gl_VertexID].xyz; view_dir = view_corners[gl_VertexID].xyz;
} }
@@ -16,6 +17,7 @@ in vec3 view_dir;
uniform vec2 dt; uniform vec2 dt;
uniform float z_near; uniform float z_near;
uniform sampler2D tex_coeffs[2];
uniform sampler2D tex_0, tex_1, tex_2, tex_3, tex_4; uniform sampler2D tex_0, tex_1, tex_2, tex_3, tex_4;
uniform int lights_start, lights_count; uniform int lights_start, lights_count;
@@ -23,12 +25,12 @@ uniform vec4 fog_color = vec4(0.5, 0.5, 0.5, 1);
uniform float fog_decay = 10, fog_density = 0; uniform float fog_decay = 10, fog_density = 0;
const vec3 luma = vec3(0.299, 0.587, 0.114); const vec3 luma = vec3(0.299, 0.587, 0.114);
const float _pe = 2.4e-7, _min_rough = 1.e-8; const float _min_rough = 1.e-8;
vec4 pos, lpos, shp; vec4 pos, lpos, shp;
vec3 li, si, ldir, halfV, bn, bn2, lwdir; vec3 li, si, ldir, halfV, bn, bn2, lwdir;
//vec3 vds, vds2; //vec3 vds, vds2;
float shm_diff, shm_spec, dist, NdotL, NdotH, spot, ldist, diff, sdist, shadow; float rough_diff, rough_spec, dist, NdotL, NdotH, spot, ldist, diff, spec, sdist, shadow;
void calcLight(in int index, in vec3 n, in vec3 v) { void calcLight(in int index, in vec3 n, in vec3 v) {
lpos = qgl_light_position[index].position; lpos = qgl_light_position[index].position;
@@ -77,17 +79,20 @@ void calcLight(in int index, in vec3 n, in vec3 v) {
#endif #endif
vec3 dist_decay = vec3(1, ldist, ldist*ldist); vec3 dist_decay = vec3(1, ldist, ldist*ldist);
spot /= dot(qgl_light_parameter[index].decay_intensity.xyz, dist_decay); spot /= dot(qgl_light_parameter[index].decay_intensity.xyz, dist_decay);
float NdotLs = NdotL*NdotL; float NdotLs = NdotL*NdotL;
float NdotHs = NdotH*NdotH; float NdotHs = NdotH*NdotH;
float ndlc = (1. - NdotLs) / NdotLs; float ndlc = (1. - NdotLs) / NdotLs;
float der = NdotLs * (shm_diff + ndlc); diff = 2. / (1. + sqrt(1. + (1. - rough_diff) * ndlc));
diff = 2. / (1. + sqrt(1. + (1. - shm_diff) * ndlc)); //diff = texture(tex_coeffs[0], vec2(roughness, (NdotLs))).r;
li += spot * diff * qgl_light_parameter[index].color.rgb; li += spot * diff * qgl_light_parameter[index].color.rgb;
ndlc = (1. - NdotHs) / NdotHs; ndlc = (1. - NdotHs) / NdotHs;
der = NdotHs * (shm_spec + ndlc); float der = NdotHs * (rough_spec + ndlc);
si += spot * (shm_spec / (der*der) / 3.1416) * qgl_light_parameter[index].color.rgb; spec = rough_spec / (der*der) / 3.1416;
//spec = texture(tex_coeffs[1], vec2(roughness, (NdotHs))).r;
si += spot * spec * qgl_light_parameter[index].color.rgb;
} }
void main(void) { void main(void) {
@@ -95,8 +100,7 @@ void main(void) {
vec4 v1 = texelFetch(tex_1, tc, 0); vec4 v1 = texelFetch(tex_1, tc, 0);
float z = v1.w; float z = v1.w;
if (z == 1.) { if (z == 1.) {
qgl_FragColor = vec4(fog_color.rgb, 0); discard;
return;
} }
pos.w = 1; pos.w = 1;
pos.xyz = view_dir * z; pos.xyz = view_dir * z;
@@ -109,23 +113,25 @@ void main(void) {
vec3 diffuse = v0.rgb; vec3 diffuse = v0.rgb;
vec3 normal = v1.xyz; vec3 normal = v1.xyz;
vec3 specular = v2.rgb;
vec3 emission = v3.rgb; vec3 emission = v3.rgb;
float alpha = v0.a; float alpha = v0.a;
float reflectivity = v2.w; float metalness = v2.r;
float roughness = v3.w; float roughness = v2.g;
float reflectivity = v2.b;
//bn = normalize(vec3(v3.w, v4.zw)); //bn = normalize(vec3(v3.w, v4.zw));
//bn2 = normalize(cross(n, bn)); //bn2 = normalize(cross(n, bn));
roughness = max(roughness, _min_rough); rough_diff = max(roughness, _min_rough);
rough_spec = max(roughness*roughness*roughness, _min_rough);
float shlick = clamp(metalness + (1 - metalness) * pow(1 - dot(normal, v), 5), 0, 1);
shm_diff = roughness;
shm_spec = max(roughness*roughness*roughness, _min_rough);
//sh_pow = 1. / max(roughness, 0.00001);
li = vec3(0.);//qgl_AmbientLight.color.rgb * qgl_AmbientLight.intensity; li = vec3(0.);//qgl_AmbientLight.color.rgb * qgl_AmbientLight.intensity;
si = vec3(0.); si = vec3(0.);
for (int i = 0; i < lights_count; ++i) for (int i = 0; i < lights_count; ++i)
calcLight(lights_start + i, normal, v); calcLight(lights_start + i, normal, v);
vec3 res_col = max(vec3(0), li * diffuse + si * specular + emission); si *= shlick;
li *= (1 - shlick);
alpha = min(1, alpha * (1 + shlick));
vec3 res_col = max(vec3(0), li * diffuse + si * mix(vec3(1), diffuse, metalness) + emission);
float plen = length(pos.xyz); float plen = length(pos.xyz);
float fog = 1 - exp(-plen / fog_decay); float fog = 1 - exp(-plen / fog_decay);
@@ -133,5 +139,7 @@ void main(void) {
res_col = mix(res_col, fog_color.rgb, fog); res_col = mix(res_col, fog_color.rgb, fog);
qgl_FragColor = vec4(res_col, alpha); qgl_FragColor = vec4(res_col, alpha);
//qgl_FragColor.rgb = vec3(normal);
//qgl_FragColor.rgb = vec3(texture(tex_coeffs[0], qgl_FragTexture.xy).r);
//qgl_FragColor.rgb = vec3(ldir);
} }

View File

@@ -24,11 +24,18 @@
MaterialEditor::MaterialEditor(QWidget * parent): QWidget(parent) { MaterialEditor::MaterialEditor(QWidget * parent): QWidget(parent) {
ui = new Ui::MaterialEditor(); ui = new Ui::MaterialEditor();
ui->setupUi(this); ui->setupUi(this);
ui->mapDiffuse ->configure(tr("Diffuse"), true);
ui->mapNormal ->configure(tr("Normal"));
ui->mapMetalness->configure(tr("Metalness"));
ui->mapRoughness->configure(tr("Roughness"));
ui->mapEmission ->configure(tr("Emission"), true);
ui->mapRelief ->configure(tr("Relief"));
ui->checkGlass->hide(); ui->checkGlass->hide();
ui->frameReflection->hide(); ui->frameReflection->hide();
ui->label_13->hide(); ui->label_13->hide();
mat = 0; mat = 0;
active = true; active = true;
ignore_next = 0;
} }
@@ -46,27 +53,30 @@ void MaterialEditor::changeEvent(QEvent * e) {
void MaterialEditor::materialChanged() { void MaterialEditor::materialChanged() {
if (!active || !mat) return; if (!active || !mat) return;
ignore_next = 2;
mat->_changed = true; mat->_changed = true;
mat->color_diffuse = ui->colorDiffuse ->color(); mat->color_diffuse = ui->mapDiffuse ->color();
mat->color_specular = ui->colorSpecular->color(); mat->color_emission = ui->mapEmission->color();
mat->color_emission = ui->colorEmission->color();
mat->transparency = ui->spinTransparent->value(); mat->transparency = ui->spinTransparent->value();
mat->reflectivity = ui->spinReflect->value(); mat->reflectivity = ui->spinReflect->value();
mat->iof = ui->spinIOF->value(); mat->iof = ui->spinIOF->value();
mat->dispersion = ui->spinDispersion->value(); mat->dispersion = ui->spinDispersion->value();
mat->glass = ui->checkGlass->isChecked(); mat->glass = ui->checkGlass->isChecked();
emit changed(); //emit changed();
} }
void MaterialEditor::setMaterial(Material * m) { void MaterialEditor::setMaterial(Material * m) {
if (ignore_next > 0) {
//ignore_next = false;
return;
}
active = false; active = false;
mat = m; mat = m;
setEnabled(m); setEnabled(m);
if (!mat) return; if (!mat) return;
ui->colorDiffuse ->setColor(mat->color_diffuse ); ui->mapDiffuse ->setColor(mat->color_diffuse );
ui->colorSpecular->setColor(mat->color_specular); ui->mapEmission->setColor(mat->color_emission);
ui->colorEmission->setColor(mat->color_emission);
ui->spinTransparent->setValue(mat->transparency); ui->spinTransparent->setValue(mat->transparency);
ui->spinReflect->setValue(mat->reflectivity); ui->spinReflect->setValue(mat->reflectivity);
ui->spinIOF->setValue(mat->iof); ui->spinIOF->setValue(mat->iof);
@@ -74,7 +84,7 @@ void MaterialEditor::setMaterial(Material * m) {
ui->checkGlass->setChecked(mat->glass); ui->checkGlass->setChecked(mat->glass);
ui->mapDiffuse ->setMap(&(mat->map_diffuse )); ui->mapDiffuse ->setMap(&(mat->map_diffuse ));
ui->mapNormal ->setMap(&(mat->map_normal )); ui->mapNormal ->setMap(&(mat->map_normal ));
ui->mapSpecular ->setMap(&(mat->map_specular )); ui->mapMetalness->setMap(&(mat->map_metalness));
ui->mapRoughness->setMap(&(mat->map_roughness)); ui->mapRoughness->setMap(&(mat->map_roughness));
ui->mapEmission ->setMap(&(mat->map_emission )); ui->mapEmission ->setMap(&(mat->map_emission ));
ui->mapRelief ->setMap(&(mat->map_relief )); ui->mapRelief ->setMap(&(mat->map_relief ));

View File

@@ -28,6 +28,7 @@ namespace Ui {
class MaterialEditor: public QWidget class MaterialEditor: public QWidget
{ {
friend class MaterialsEditor;
Q_OBJECT Q_OBJECT
public: public:
explicit MaterialEditor(QWidget * parent = 0); explicit MaterialEditor(QWidget * parent = 0);
@@ -38,6 +39,7 @@ protected:
void changeEvent(QEvent * e); void changeEvent(QEvent * e);
bool active; bool active;
int ignore_next;
Ui::MaterialEditor * ui; Ui::MaterialEditor * ui;
Material * mat; Material * mat;

View File

@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>435</width> <width>435</width>
<height>817</height> <height>535</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
@@ -24,276 +24,87 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QGroupBox" name="groupDiffuse"> <widget class="MaterialMapEditor" name="mapDiffuse" native="true">
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">font:bold;</string> <string notr="true">font:normal;</string>
</property> </property>
<property name="title">
<string>Diffuse</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QWidget" name="widgetDiffuse" native="true">
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">font:normal;</string>
</property>
<property name="text">
<string>Color:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="ColorButton" name="colorDiffuse">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="styleSheet">
<string notr="true">font:normal;</string>
</property>
<property name="useAlphaChannel">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="MaterialMapEditor" name="mapDiffuse" native="true">
<property name="styleSheet">
<string notr="true">font:normal;</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupNormal"> <widget class="Line" name="line">
<property name="styleSheet"> <property name="orientation">
<string notr="true">font:bold;</string> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="title">
<string>Normal</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="MaterialMapEditor" name="mapNormal" native="true">
<property name="styleSheet">
<string notr="true">font:normal;</string>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupSpecular"> <widget class="MaterialMapEditor" name="mapNormal" native="true">
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">font:bold;</string> <string notr="true">font:normal;</string>
</property> </property>
<property name="title">
<string>Specular</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QWidget" name="widgetSpecular" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">font:normal;</string>
</property>
<property name="text">
<string>Color:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="ColorButton" name="colorSpecular">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="styleSheet">
<string notr="true">font:normal;</string>
</property>
<property name="useAlphaChannel">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="MaterialMapEditor" name="mapSpecular" native="true">
<property name="styleSheet">
<string notr="true">font:normal;</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupRoughness"> <widget class="Line" name="line_3">
<property name="styleSheet"> <property name="orientation">
<string notr="true">font:bold;</string> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="title">
<string>Roughness</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="MaterialMapEditor" name="mapRoughness" native="true">
<property name="styleSheet">
<string notr="true">font:normal;</string>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupEmission"> <widget class="MaterialMapEditor" name="mapMetalness" native="true">
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">font:bold;</string> <string notr="true">font:normal;</string>
</property> </property>
<property name="title">
<string>Emisson</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QWidget" name="widgetEmission" native="true">
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_12">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">font:normal;</string>
</property>
<property name="text">
<string>Color:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="ColorButton" name="colorEmission">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="styleSheet">
<string notr="true">font:normal;</string>
</property>
<property name="useAlphaChannel">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="MaterialMapEditor" name="mapEmission" native="true">
<property name="styleSheet">
<string notr="true">font:normal;</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupRelief"> <widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="MaterialMapEditor" name="mapRoughness" native="true">
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">font:bold;</string> <string notr="true">font:normal;</string>
</property> </property>
<property name="title"> </widget>
<string>Relief</string> </item>
<item>
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property> </property>
<property name="checkable"> </widget>
<bool>true</bool> </item>
<item>
<widget class="MaterialMapEditor" name="mapEmission" native="true">
<property name="styleSheet">
<string notr="true">font:normal;</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="MaterialMapEditor" name="mapRelief" native="true">
<property name="styleSheet">
<string notr="true">font:normal;</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="MaterialMapEditor" name="mapRelief" native="true">
<property name="styleSheet">
<string notr="true">font:normal;</string>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>
@@ -631,11 +442,6 @@
<extends>QWidget</extends> <extends>QWidget</extends>
<header>spinslider.h</header> <header>spinslider.h</header>
</customwidget> </customwidget>
<customwidget>
<class>ColorButton</class>
<extends>QPushButton</extends>
<header>colorbutton.h</header>
</customwidget>
<customwidget> <customwidget>
<class>MaterialMapEditor</class> <class>MaterialMapEditor</class>
<extends>QWidget</extends> <extends>QWidget</extends>
@@ -648,38 +454,6 @@
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections> <connections>
<connection>
<sender>colorDiffuse</sender>
<signal>colorChanged(QColor)</signal>
<receiver>MaterialEditor</receiver>
<slot>materialChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>326</x>
<y>49</y>
</hint>
<hint type="destinationlabel">
<x>282</x>
<y>17</y>
</hint>
</hints>
</connection>
<connection>
<sender>colorSpecular</sender>
<signal>colorChanged(QColor)</signal>
<receiver>MaterialEditor</receiver>
<slot>materialChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>376</x>
<y>202</y>
</hint>
<hint type="destinationlabel">
<x>284</x>
<y>45</y>
</hint>
</hints>
</connection>
<connection> <connection>
<sender>spinTransparent</sender> <sender>spinTransparent</sender>
<signal>valueChanged(double)</signal> <signal>valueChanged(double)</signal>
@@ -688,7 +462,7 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>433</x> <x>433</x>
<y>497</y> <y>468</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>283</x> <x>283</x>
@@ -704,7 +478,7 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>433</x> <x>433</x>
<y>526</y> <y>497</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>284</x> <x>284</x>
@@ -720,7 +494,7 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>433</x> <x>433</x>
<y>555</y> <y>526</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>284</x> <x>284</x>
@@ -736,7 +510,7 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>433</x> <x>433</x>
<y>468</y> <y>439</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>284</x> <x>284</x>
@@ -744,22 +518,6 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>colorEmission</sender>
<signal>colorChanged(QColor)</signal>
<receiver>MaterialEditor</receiver>
<slot>materialChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>421</x>
<y>351</y>
</hint>
<hint type="destinationlabel">
<x>326</x>
<y>63</y>
</hint>
</hints>
</connection>
<connection> <connection>
<sender>spinDispersion</sender> <sender>spinDispersion</sender>
<signal>valueChanged(double)</signal> <signal>valueChanged(double)</signal>
@@ -768,7 +526,7 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>433</x> <x>433</x>
<y>584</y> <y>555</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>326</x> <x>326</x>
@@ -793,14 +551,14 @@
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>mapSpecular</sender> <sender>mapMetalness</sender>
<signal>changed()</signal> <signal>changed()</signal>
<receiver>MaterialEditor</receiver> <receiver>MaterialEditor</receiver>
<slot>materialChanged()</slot> <slot>materialChanged()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>421</x> <x>421</x>
<y>218</y> <y>189</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>434</x> <x>434</x>
@@ -816,7 +574,7 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>421</x> <x>421</x>
<y>367</y> <y>338</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>434</x> <x>434</x>
@@ -848,7 +606,7 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>421</x> <x>421</x>
<y>427</y> <y>398</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>434</x> <x>434</x>
@@ -864,7 +622,7 @@
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>421</x> <x>421</x>
<y>278</y> <y>249</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>434</x> <x>434</x>
@@ -872,102 +630,6 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>groupDiffuse</sender>
<signal>toggled(bool)</signal>
<receiver>widgetDiffuse</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>40</x>
<y>10</y>
</hint>
<hint type="destinationlabel">
<x>47</x>
<y>56</y>
</hint>
</hints>
</connection>
<connection>
<sender>groupNormal</sender>
<signal>toggled(bool)</signal>
<receiver>mapNormal</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>54</x>
<y>103</y>
</hint>
<hint type="destinationlabel">
<x>55</x>
<y>123</y>
</hint>
</hints>
</connection>
<connection>
<sender>groupSpecular</sender>
<signal>toggled(bool)</signal>
<receiver>widgetSpecular</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>72</x>
<y>162</y>
</hint>
<hint type="destinationlabel">
<x>71</x>
<y>205</y>
</hint>
</hints>
</connection>
<connection>
<sender>groupRoughness</sender>
<signal>toggled(bool)</signal>
<receiver>mapRoughness</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>56</x>
<y>246</y>
</hint>
<hint type="destinationlabel">
<x>55</x>
<y>273</y>
</hint>
</hints>
</connection>
<connection>
<sender>groupEmission</sender>
<signal>toggled(bool)</signal>
<receiver>widgetEmission</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>67</x>
<y>314</y>
</hint>
<hint type="destinationlabel">
<x>71</x>
<y>353</y>
</hint>
</hints>
</connection>
<connection>
<sender>groupRelief</sender>
<signal>toggled(bool)</signal>
<receiver>mapRelief</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>42</x>
<y>397</y>
</hint>
<hint type="destinationlabel">
<x>44</x>
<y>422</y>
</hint>
</hints>
</connection>
</connections> </connections>
<slots> <slots>
<slot>materialChanged()</slot> <slot>materialChanged()</slot>

View File

@@ -25,6 +25,7 @@
MaterialMapEditor::MaterialMapEditor(QWidget * parent): QWidget(parent) { MaterialMapEditor::MaterialMapEditor(QWidget * parent): QWidget(parent) {
ui = new Ui::MaterialMapEditor(); ui = new Ui::MaterialMapEditor();
ui->setupUi(this); ui->setupUi(this);
ui->widgetMap->hide();
active = true; active = true;
} }
@@ -42,8 +43,9 @@ void MaterialMapEditor::changeEvent(QEvent * e) {
void MaterialMapEditor::resizeEvent(QResizeEvent * e) { void MaterialMapEditor::resizeEvent(QResizeEvent * e) {
ui->iconedLabel->setFixedWidth(ui->iconedLabel->height()); QSize sz = preferredIconSize(6, this);
ui->iconedLabel->setIconSize(ui->iconedLabel->size()); ui->iconedLabel->setFixedSize(sz);
ui->iconedLabel->setIconSize(sz);
} }
@@ -54,10 +56,18 @@ void MaterialMapEditor::updateIcon() {
void MaterialMapEditor::mapChanged() { void MaterialMapEditor::mapChanged() {
if (!active || !map) return; if (!active || !map) return;
map->color_amount = ui->sliderAmount->value(); active = false;
map->color_offset = ui->sliderOffset->value(); map->use_bitmap = ui->checkMap->isChecked();
if (ui->checkMap->isChecked()) {
map->color_amount = ui->sliderAmount->value();
map->color_offset = ui->sliderOffset->value();
} else {
map->color_amount = ui->sliderValue->value();
map->color_offset = 0.f;
}
map->bitmap_scale.setX(ui->spinScaleX->value()); map->bitmap_scale.setX(ui->spinScaleX->value());
map->bitmap_scale.setY(ui->spinScaleY->value()); map->bitmap_scale.setY(ui->spinScaleY->value());
active = true;
emit changed(); emit changed();
} }
@@ -67,6 +77,9 @@ void MaterialMapEditor::setMap(Map * m) {
map = m; map = m;
setEnabled(m); setEnabled(m);
if (!map) return; if (!map) return;
ui->stackedWidget->setCurrentIndex(map->use_bitmap ? 1 : 0);
ui->checkMap->setChecked(map->use_bitmap);
ui->sliderValue->setValue(map->color_amount);
ui->sliderAmount->setValue(map->color_amount); ui->sliderAmount->setValue(map->color_amount);
ui->sliderOffset->setValue(map->color_offset); ui->sliderOffset->setValue(map->color_offset);
ui->spinScaleX->setValue(map->bitmap_scale.x()); ui->spinScaleX->setValue(map->bitmap_scale.x());
@@ -76,6 +89,24 @@ void MaterialMapEditor::setMap(Map * m) {
active = true; active = true;
} }
void MaterialMapEditor::configure(QString title, bool has_color) {
ui->labelTitle->setText(title);
ui->colorButton->setVisible(has_color);
}
void MaterialMapEditor::setColor(QColor c) {
active = false;
ui->colorButton->setColor(c);
active = true;
}
QColor MaterialMapEditor::color() const {
return ui->colorButton->color();
}
/* /*
Map MaterialMapEditor::map() { Map MaterialMapEditor::map() {
Map m; Map m;
@@ -106,3 +137,14 @@ void MaterialMapEditor::on_buttonClear_clicked() {
updateIcon(); updateIcon();
mapChanged(); mapChanged();
} }
void MaterialMapEditor::on_checkMap_toggled(bool checked) {
if (checked) {
ui->sliderAmount->setValue(ui->sliderValue->value());
resizeEvent(0);
} else
ui->sliderValue->setValue(ui->sliderAmount->value());
ui->stackedWidget->setCurrentIndex(checked ? 1 : 0);
mapChanged();
}

View File

@@ -33,6 +33,9 @@ public:
explicit MaterialMapEditor(QWidget * parent = 0); explicit MaterialMapEditor(QWidget * parent = 0);
void setMap(Map * m); void setMap(Map * m);
void configure(QString title, bool has_color = false);
void setColor(QColor c);
QColor color() const;
protected: protected:
void changeEvent(QEvent * e); void changeEvent(QEvent * e);
@@ -47,6 +50,7 @@ private slots:
void mapChanged(); void mapChanged();
void on_buttonSelect_clicked(); void on_buttonSelect_clicked();
void on_buttonClear_clicked(); void on_buttonClear_clicked();
void on_checkMap_toggled(bool checked);
signals: signals:
void changed(); void changed();

View File

@@ -6,11 +6,11 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>587</width> <width>725</width>
<height>138</height> <height>218</height>
</rect> </rect>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
@@ -24,197 +24,313 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="IconedLabel" name="iconedLabel"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="direction"> <item>
<enum>IconedLabel::RightToLeft</enum> <widget class="QLabel" name="labelTitle">
</property> <property name="sizePolicy">
</widget> <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
</item> <horstretch>0</horstretch>
<item> <verstretch>0</verstretch>
<layout class="QFormLayout" name="formLayout"> </sizepolicy>
<item row="0" column="0" colspan="2"> </property>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <property name="styleSheet">
<property name="spacing"> <string notr="true">font: bold;</string>
<number>2</number>
</property> </property>
<item>
<widget class="QLineEdit" name="linePath"/>
</item>
<item>
<widget class="QToolButton" name="buttonClear">
<property name="icon">
<iconset resource="../qad/utils/qad_utils.qrc">
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonSelect">
<property name="icon">
<iconset resource="../qad/application/qad_application.qrc">
<normaloff>:/icons/document-open.png</normaloff>:/icons/document-open.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Amount:</string> <string>title:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item>
<widget class="SpinSlider" name="sliderAmount"> <widget class="ColorButton" name="colorButton">
<property name="minimum"> <property name="sizePolicy">
<double>-1.000000000000000</double> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
</property> <horstretch>0</horstretch>
<property name="maximum"> <verstretch>0</verstretch>
<double>1.000000000000000</double> </sizepolicy>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="singleStep">
<double>0.050000000000000</double>
</property>
<property name="pageStep">
<double>0.200000000000000</double>
</property>
<property name="spinMinimum">
<double>-99.000000000000000</double>
</property>
<property name="spinMaximum">
<double>99.000000000000000</double>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item>
<widget class="QLabel" name="label_2"> <widget class="QStackedWidget" name="stackedWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QWidget" name="page">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="SpinSlider" name="sliderValue">
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="singleStep">
<double>0.050000000000000</double>
</property>
<property name="pageStep">
<double>0.200000000000000</double>
</property>
<property name="spinMinimum">
<double>0.000000000000000</double>
</property>
<property name="spinMaximum">
<double>1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2"/>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkMap">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>Offset:</string> <string>Map</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1">
<widget class="SpinSlider" name="sliderOffset">
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="singleStep">
<double>0.050000000000000</double>
</property>
<property name="pageStep">
<double>0.200000000000000</double>
</property>
<property name="spinMinimum">
<double>-99.000000000000000</double>
</property>
<property name="spinMaximum">
<double>99.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Scale X:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="spinScaleX">
<property name="maximum">
<double>9999.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Scale Y:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="spinScaleY">
<property name="maximum">
<double>9999.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout> </layout>
</item> </item>
<item>
<widget class="QWidget" name="widgetMap" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="IconedLabel" name="iconedLabel">
<property name="direction">
<enum>IconedLabel::RightToLeft</enum>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>2</number>
</property>
<item>
<widget class="QLineEdit" name="linePath"/>
</item>
<item>
<widget class="QToolButton" name="buttonClear">
<property name="icon">
<iconset resource="../../qad/utils/qad_utils.qrc">
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="buttonSelect">
<property name="icon">
<iconset resource="../../qad/application/qad_application.qrc">
<normaloff>:/icons/document-open.png</normaloff>:/icons/document-open.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Amount:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="SpinSlider" name="sliderAmount">
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="singleStep">
<double>0.050000000000000</double>
</property>
<property name="pageStep">
<double>0.200000000000000</double>
</property>
<property name="spinMinimum">
<double>-99.000000000000000</double>
</property>
<property name="spinMaximum">
<double>99.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Offset:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="SpinSlider" name="sliderOffset">
<property name="minimum">
<double>-1.000000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="decimals">
<number>2</number>
</property>
<property name="singleStep">
<double>0.050000000000000</double>
</property>
<property name="pageStep">
<double>0.200000000000000</double>
</property>
<property name="spinMinimum">
<double>-99.000000000000000</double>
</property>
<property name="spinMaximum">
<double>99.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Scale X:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="spinScaleX">
<property name="maximum">
<double>9999.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Scale Y:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="spinScaleY">
<property name="maximum">
<double>9999.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
@@ -223,6 +339,11 @@
<extends>QWidget</extends> <extends>QWidget</extends>
<header>spinslider.h</header> <header>spinslider.h</header>
</customwidget> </customwidget>
<customwidget>
<class>ColorButton</class>
<extends>QPushButton</extends>
<header>colorbutton.h</header>
</customwidget>
<customwidget> <customwidget>
<class>IconedLabel</class> <class>IconedLabel</class>
<extends>QFrame</extends> <extends>QFrame</extends>
@@ -230,8 +351,8 @@
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../qad/utils/qad_utils.qrc"/> <include location="../../qad/utils/qad_utils.qrc"/>
<include location="../qad/application/qad_application.qrc"/> <include location="../../qad/application/qad_application.qrc"/>
</resources> </resources>
<connections> <connections>
<connection> <connection>
@@ -241,8 +362,8 @@
<slot>mapChanged()</slot> <slot>mapChanged()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>471</x> <x>598</x>
<y>22</y> <y>55</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>99</x> <x>99</x>
@@ -257,8 +378,8 @@
<slot>mapChanged()</slot> <slot>mapChanged()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>440</x> <x>655</x>
<y>38</y> <y>87</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>512</x> <x>512</x>
@@ -273,8 +394,8 @@
<slot>mapChanged()</slot> <slot>mapChanged()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>497</x> <x>655</x>
<y>66</y> <y>116</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>511</x> <x>511</x>
@@ -289,8 +410,8 @@
<slot>mapChanged()</slot> <slot>mapChanged()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>377</x> <x>491</x>
<y>104</y> <y>146</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>332</x> <x>332</x>
@@ -305,8 +426,8 @@
<slot>mapChanged()</slot> <slot>mapChanged()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>519</x> <x>647</x>
<y>110</y> <y>146</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>493</x> <x>493</x>
@@ -314,6 +435,70 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>checkMap</sender>
<signal>toggled(bool)</signal>
<receiver>sliderValue</receiver>
<slot>setHidden(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>693</x>
<y>15</y>
</hint>
<hint type="destinationlabel">
<x>626</x>
<y>14</y>
</hint>
</hints>
</connection>
<connection>
<sender>checkMap</sender>
<signal>toggled(bool)</signal>
<receiver>widgetMap</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>686</x>
<y>9</y>
</hint>
<hint type="destinationlabel">
<x>695</x>
<y>62</y>
</hint>
</hints>
</connection>
<connection>
<sender>sliderValue</sender>
<signal>valueChanged(double)</signal>
<receiver>MaterialMapEditor</receiver>
<slot>mapChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>99</x>
<y>15</y>
</hint>
<hint type="destinationlabel">
<x>130</x>
<y>28</y>
</hint>
</hints>
</connection>
<connection>
<sender>colorButton</sender>
<signal>colorChanged(QColor)</signal>
<receiver>MaterialMapEditor</receiver>
<slot>mapChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>60</x>
<y>11</y>
</hint>
<hint type="destinationlabel">
<x>75</x>
<y>27</y>
</hint>
</hints>
</connection>
</connections> </connections>
<slots> <slots>
<slot>mapChanged()</slot> <slot>mapChanged()</slot>

View File

@@ -114,6 +114,10 @@ void MaterialsEditor::selectionChanged() {
void MaterialsEditor::materialsChanged() { void MaterialsEditor::materialsChanged() {
if (ui->widgetMaterial->ignore_next > 0) {
ui->widgetMaterial->ignore_next--;
return;
}
Material * cm = currentMaterial(); Material * cm = currentMaterial();
ui->comboMaterial->clear(); ui->comboMaterial->clear();
if (!view) return; if (!view) return;