git-svn-id: svn://db.shs.com.ru/libs@47 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -54,9 +54,14 @@ const char qgl_uniform[] =
|
||||
const char qgl_structs[] =
|
||||
"const int qgl_MaxLights = 16;\n"
|
||||
"struct QGLLight {\n"
|
||||
" vec4 position;\n"
|
||||
" vec4 color;\n"
|
||||
" vec4 position;\n"
|
||||
" vec4 direction;\n"
|
||||
" float intensity;\n"
|
||||
" float startAngle;\n"
|
||||
" float startAngleCos;\n"
|
||||
" float endAngle;\n"
|
||||
" float endAngleCos;\n"
|
||||
" float constantAttenuation;\n"
|
||||
" float linearAttenuation;\n"
|
||||
" float quadraticAttenuation;\n"
|
||||
@@ -192,19 +197,31 @@ void setUniformLights(QGLShaderProgram * prog, const QVector<Light*> & lights, c
|
||||
}
|
||||
/*
|
||||
" vec3 position;\n"
|
||||
" vec3 direction;\n"
|
||||
" vec4 color;\n"
|
||||
" float intensity;\n"
|
||||
" float startAngle;\n"
|
||||
" float endAngle;\n"
|
||||
" float constantAttenuation;\n"
|
||||
" float linearAttenuation;\n"
|
||||
" float quadraticAttenuation;\n"
|
||||
*/
|
||||
void setUniformLight(QGLShaderProgram * prog, Light * light, QString ulightn, const QMatrix4x4 & mat, const QVector4D & dp) {
|
||||
QMatrix4x4 m = mat * light->worldTransform();
|
||||
QVector4D pos(0, 0, 0, 1.);
|
||||
QVector4D pos(0, 0, 0, 1.), dir(light->direction);
|
||||
pos = m * pos;
|
||||
dir = (m * dir).normalized();
|
||||
double ang_start = light->angle_start / 2., ang_end = light->angle_end / 2.;
|
||||
if (light->light_type == Light::Omni)
|
||||
ang_start = ang_end = 180.;
|
||||
//qDebug() << "light" << light->name() << ulightn << pos;
|
||||
prog->setUniformValue((ulightn + ".position").toLatin1().constData(), pos);
|
||||
prog->setUniformValue((ulightn + ".direction").toLatin1().constData(), dir);
|
||||
prog->setUniformValue((ulightn + ".intensity").toLatin1().constData(), GLfloat(light->intensity));
|
||||
prog->setUniformValue((ulightn + ".startAngle").toLatin1().constData(), GLfloat(ang_start));
|
||||
prog->setUniformValue((ulightn + ".startAngleCos").toLatin1().constData(), GLfloat(cos(ang_start * deg2rad)));
|
||||
prog->setUniformValue((ulightn + ".endAngle").toLatin1().constData(), GLfloat(ang_end));
|
||||
prog->setUniformValue((ulightn + ".endAngleCos").toLatin1().constData(), GLfloat(cos(ang_end * deg2rad)));
|
||||
prog->setUniformValue((ulightn + ".color").toLatin1().constData(), light->color());
|
||||
prog->setUniformValue((ulightn + ".constantAttenuation").toLatin1().constData(), GLfloat(light->decay_const));
|
||||
prog->setUniformValue((ulightn + ".linearAttenuation").toLatin1().constData(), GLfloat(light->decay_linear));
|
||||
|
||||
Reference in New Issue
Block a user