git-svn-id: svn://db.shs.com.ru/libs@701 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -88,6 +88,7 @@ Map::Map() {
|
||||
color_amount = 1.f;
|
||||
color_offset = 0.f;
|
||||
bitmap_scale = QPointF(1., 1.);
|
||||
use_bitmap = false;
|
||||
_changed = true;
|
||||
_layer = 0;
|
||||
}
|
||||
@@ -109,7 +110,7 @@ void Map::copyToQGLMap(QGLMap & m) const {
|
||||
m.amount = color_amount;
|
||||
m.offset = color_offset;
|
||||
m.scale = QVector2D(bitmap_scale);
|
||||
if (hasBitmap()) {
|
||||
if (hasBitmap() && use_bitmap) {
|
||||
m.array_index = tarMaps;
|
||||
m.map_index = _layer;
|
||||
} else {
|
||||
@@ -124,12 +125,12 @@ void Map::copyToQGLMap(QGLMap & m) const {
|
||||
Material::Material(const QString _name)/*: map_reflection(512)*/ {
|
||||
setTypes();
|
||||
name = _name;
|
||||
color_diffuse = color_specular = Qt::darkGray;
|
||||
color_diffuse = Qt::white;
|
||||
color_emission = Qt::black;
|
||||
glass = false;
|
||||
transparency = reflectivity = 0.f;
|
||||
map_roughness.color_amount = 0.75f;
|
||||
map_specular.color_amount = 1.f;
|
||||
map_metalness.color_amount = 0.25f;
|
||||
iof = 1.f;
|
||||
dispersion = 0.05f;
|
||||
_changed = true;
|
||||
@@ -150,7 +151,7 @@ bool Material::hasTransparency() const {
|
||||
bool Material::isMapsChanged() const {
|
||||
return map_diffuse ._changed ||
|
||||
map_normal ._changed ||
|
||||
map_specular ._changed ||
|
||||
map_metalness._changed ||
|
||||
map_roughness._changed ||
|
||||
map_emission ._changed ||
|
||||
map_relief ._changed;
|
||||
@@ -161,7 +162,7 @@ bool Material::isMapChanged(int type) const {
|
||||
switch (type) {
|
||||
case mtDiffuse : return map_diffuse ._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 mtEmission : return map_emission ._changed;
|
||||
case mtRelief : return map_relief ._changed;
|
||||
@@ -173,7 +174,7 @@ bool Material::isMapChanged(int type) const {
|
||||
void Material::load(TextureManager * tm) {
|
||||
map_diffuse .load(tm);
|
||||
map_normal .load(tm);
|
||||
map_specular .load(tm);
|
||||
map_metalness.load(tm);
|
||||
map_roughness.load(tm);
|
||||
map_emission .load(tm);
|
||||
map_relief .load(tm);
|
||||
@@ -183,7 +184,7 @@ void Material::load(TextureManager * tm) {
|
||||
void Material::setMapsChanged() {
|
||||
map_diffuse ._changed = true;
|
||||
map_normal ._changed = true;
|
||||
map_specular ._changed = true;
|
||||
map_metalness._changed = true;
|
||||
map_roughness._changed = true;
|
||||
map_emission ._changed = true;
|
||||
map_relief ._changed = true;
|
||||
@@ -191,10 +192,10 @@ void Material::setMapsChanged() {
|
||||
|
||||
|
||||
void Material::setTypes() {
|
||||
map_diffuse ._type = mtDiffuse;
|
||||
map_normal ._type = mtNormal;
|
||||
map_specular ._type = mtSpecular;
|
||||
map_diffuse ._type = mtDiffuse ;
|
||||
map_normal ._type = mtNormal ;
|
||||
map_metalness._type = mtMetalness;
|
||||
map_roughness._type = mtRoughness;
|
||||
map_emission ._type = mtEmission;
|
||||
map_relief ._type = mtRelief;
|
||||
map_emission ._type = mtEmission ;
|
||||
map_relief ._type = mtRelief ;
|
||||
}
|
||||
|
||||
@@ -83,11 +83,12 @@ public:
|
||||
void load(TextureManager * tm);
|
||||
void copyToQGLMap(QGLEngineShaders::QGLMap & m) const;
|
||||
QString bitmap_path;
|
||||
GLuint bitmap_id;
|
||||
GLuint bitmap_id;
|
||||
QPointF bitmap_offset;
|
||||
QPointF bitmap_scale;
|
||||
float color_amount;
|
||||
float color_offset;
|
||||
bool use_bitmap;
|
||||
|
||||
bool _changed;
|
||||
int _type, _layer;
|
||||
@@ -105,7 +106,6 @@ public:
|
||||
void setTypes();
|
||||
QString name;
|
||||
QColor color_diffuse;
|
||||
QColor color_specular;
|
||||
QColor color_emission;
|
||||
bool glass;
|
||||
float transparency;
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
float dispersion;
|
||||
Map map_diffuse ;
|
||||
Map map_normal ;
|
||||
Map map_specular ;
|
||||
Map map_metalness;
|
||||
Map map_roughness;
|
||||
Map map_emission ;
|
||||
Map map_relief ;
|
||||
@@ -126,21 +126,23 @@ public:
|
||||
|
||||
inline QDataStream & operator <<(QDataStream & s, const Map & m) {
|
||||
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;
|
||||
}
|
||||
inline QDataStream & operator >>(QDataStream & s, Map & m) {
|
||||
ChunkStream cs(s);
|
||||
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;
|
||||
}
|
||||
|
||||
inline QDataStream & operator <<(QDataStream & s, const Material * m) {
|
||||
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(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;
|
||||
}
|
||||
inline QDataStream & operator >>(QDataStream & s, Material *& m) {
|
||||
@@ -153,7 +155,6 @@ inline QDataStream & operator >>(QDataStream & s, Material *& m) {
|
||||
switch (cs.read()) {
|
||||
case 1: cs.get(m->name); 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 5: cs.get(m->transparency); 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 9: cs.get(m->map_normal); 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 13: cs.get(m->map_emission); break;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ const char qgl_structs[] =
|
||||
"#define QGL_MAPS_COUNT 6\n"
|
||||
"#define QGL_MAP_DIFFUSE 0\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_EMISSION 4\n"
|
||||
"#define QGL_MAP_RELIEF 5\n"
|
||||
@@ -85,7 +85,7 @@ const char qgl_structs[] =
|
||||
"};\n"
|
||||
"struct QGLMaterial {\n"
|
||||
" vec4 color_diffuse;\n"
|
||||
" vec4 color_specular;\n"
|
||||
//" vec4 color_specular;\n"
|
||||
" vec4 color_emission;\n"
|
||||
" float transparency;\n"
|
||||
" float reflectivity;\n"
|
||||
|
||||
@@ -29,8 +29,7 @@ QGLEngineShaders::QGLMap::QGLMap() {
|
||||
|
||||
|
||||
QGLEngineShaders::QGLMaterial::QGLMaterial() {
|
||||
color_diffuse = QVector4D(.5, .5, .5, 0.);
|
||||
color_specular = QVector4D(.5, .5, .5, 0.);
|
||||
color_diffuse = QVector4D(1., 1., 1., 0.);
|
||||
color_emission = QVector4D(0., 0., 0., 0.);
|
||||
transparency = 0.;
|
||||
reflectivity = 0.;
|
||||
@@ -38,6 +37,7 @@ QGLEngineShaders::QGLMaterial::QGLMaterial() {
|
||||
dispersion = 0.;
|
||||
map[mtNormal].map_index = emrBlue;
|
||||
map[mtRoughness].amount = 0.75;
|
||||
map[mtMetalness].amount = 0.25;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ enum BindingPoints {
|
||||
enum MapType {
|
||||
mtDiffuse = 0,
|
||||
mtNormal = 1,
|
||||
mtSpecular = 2,
|
||||
mtMetalness = 2,
|
||||
mtRoughness = 3,
|
||||
mtEmission = 4,
|
||||
mtRelief = 5,
|
||||
@@ -114,7 +114,6 @@ struct QGLMap {
|
||||
struct QGLMaterial {
|
||||
QGLMaterial();
|
||||
QVector4D color_diffuse;
|
||||
QVector4D color_specular;
|
||||
QVector4D color_emission;
|
||||
GLfloat transparency;
|
||||
GLfloat reflectivity;
|
||||
|
||||
Reference in New Issue
Block a user