mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 20:58:38 +02:00
Merged from master. Get rid of redundant GL fog states. Moved local light parameters to shader uniform arrays.
This commit is contained in:
parent
56eadcb0dc
commit
ef4b95c6e0
12 changed files with 16 additions and 15 deletions
|
@ -23,19 +23,19 @@ function keyPressEvent(event) {
|
||||||
|
|
||||||
if (event.text == "1") {
|
if (event.text == "1") {
|
||||||
currentSelection = 0;
|
currentSelection = 0;
|
||||||
print("selection = " + currentSelection);
|
print("light election = " + currentSelection);
|
||||||
}
|
}
|
||||||
else if (event.text == "2" ) {
|
else if (event.text == "2" ) {
|
||||||
currentSelection = 1;
|
currentSelection = 1;
|
||||||
print("selection = " + currentSelection);
|
print("light selection = " + currentSelection);
|
||||||
}
|
}
|
||||||
else if (event.text == "3" ) {
|
else if (event.text == "3" ) {
|
||||||
currentSelection = 2;
|
currentSelection = 2;
|
||||||
print("selection = " + currentSelection);
|
print("light selection = " + currentSelection);
|
||||||
}
|
}
|
||||||
else if (event.text == "4" ) {
|
else if (event.text == "4" ) {
|
||||||
currentSelection = 3;
|
currentSelection = 3;
|
||||||
print("selection = " + currentSelection);
|
print("light selection = " + currentSelection);
|
||||||
}
|
}
|
||||||
else if (event.text == "5" ) {
|
else if (event.text == "5" ) {
|
||||||
localLightColors[currentSelection].x += 0.01;
|
localLightColors[currentSelection].x += 0.01;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
uniform sampler2D diffuseMap;
|
uniform sampler2D diffuseMap;
|
||||||
|
|
||||||
// local lights
|
// local lights
|
||||||
const int MAX_LOCAL_LIGHTS = 2; // 2 lights for now, will probably need more later on
|
const int MAX_LOCAL_LIGHTS = 2; // 2 lights for now, will probably need more later on
|
||||||
uniform int numLocalLights;
|
uniform int numLocalLights;
|
||||||
uniform vec3 localLightDirections[MAX_LOCAL_LIGHTS];
|
uniform vec3 localLightDirections[MAX_LOCAL_LIGHTS];
|
||||||
uniform vec3 localLightColors[MAX_LOCAL_LIGHTS];
|
uniform vec3 localLightColors[MAX_LOCAL_LIGHTS];
|
||||||
|
|
|
@ -39,3 +39,4 @@ void main(void) {
|
||||||
// use standard pipeline transform
|
// use standard pipeline transform
|
||||||
gl_Position = ftransform();
|
gl_Position = ftransform();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
//
|
//
|
||||||
const int MAX_LOCAL_LIGHTS = 2;
|
const int MAX_LOCAL_LIGHTS = 2;
|
||||||
|
|
||||||
|
uniform int numLocalLights;
|
||||||
uniform vec3 localLightDirections[MAX_LOCAL_LIGHTS];
|
uniform vec3 localLightDirections[MAX_LOCAL_LIGHTS];
|
||||||
uniform vec3 localLightColors[MAX_LOCAL_LIGHTS];
|
uniform vec3 localLightColors[MAX_LOCAL_LIGHTS];
|
||||||
|
|
||||||
|
@ -35,7 +36,7 @@ void main(void) {
|
||||||
|
|
||||||
// the local light that is always present
|
// the local light that is always present
|
||||||
vec4 totalLocalLight = vec4(0.0, 0.0, 0.0, 1.0);
|
vec4 totalLocalLight = vec4(0.0, 0.0, 0.0, 1.0);
|
||||||
for (int i = 0; i < MAX_LOCAL_LIGHTS; i++) {
|
for (int i = 0; i < numLocalLights; i++) {
|
||||||
float localDiffuse = dot(normalizedNormal, vec4(localLightDirections[i], 1.0));
|
float localDiffuse = dot(normalizedNormal, vec4(localLightDirections[i], 1.0));
|
||||||
float localLight = step(0.0, localDiffuse);
|
float localLight = step(0.0, localDiffuse);
|
||||||
float localLightVal = localDiffuse * localLight;
|
float localLightVal = localDiffuse * localLight;
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
const int MAX_CLUSTERS = 128;
|
const int MAX_CLUSTERS = 128;
|
||||||
const int INDICES_PER_VERTEX = 4;
|
const int INDICES_PER_VERTEX = 4;
|
||||||
const int MAX_LOCAL_LIGHTS = 4;
|
|
||||||
|
|
||||||
uniform mat4 clusterMatrices[MAX_CLUSTERS];
|
uniform mat4 clusterMatrices[MAX_CLUSTERS];
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ void Avatar::init() {
|
||||||
|
|
||||||
for (int i = 0; i < MAX_LOCAL_LIGHTS; i++) {
|
for (int i = 0; i < MAX_LOCAL_LIGHTS; i++) {
|
||||||
_localLightColors[i] = glm::vec3(0.0f, 0.0f, 0.0f);
|
_localLightColors[i] = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||||
_localLightDirections[i] = glm::vec3(0.0f, 0.0f, 1.0f);
|
_localLightDirections[i] = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 darkGrayColor(0.3f, 0.3f, 0.3f);
|
glm::vec3 darkGrayColor(0.3f, 0.3f, 0.3f);
|
||||||
|
|
|
@ -184,7 +184,7 @@ protected:
|
||||||
// always-present local lighting for the avatar
|
// always-present local lighting for the avatar
|
||||||
glm::vec3 _localLightDirections[MAX_LOCAL_LIGHTS];
|
glm::vec3 _localLightDirections[MAX_LOCAL_LIGHTS];
|
||||||
glm::vec3 _localLightColors[MAX_LOCAL_LIGHTS];
|
glm::vec3 _localLightColors[MAX_LOCAL_LIGHTS];
|
||||||
int _numLocalLights;
|
int _numLocalLights;
|
||||||
|
|
||||||
// protected methods...
|
// protected methods...
|
||||||
glm::vec3 getBodyRightDirection() const { return getOrientation() * IDENTITY_RIGHT; }
|
glm::vec3 getBodyRightDirection() const { return getOrientation() * IDENTITY_RIGHT; }
|
||||||
|
|
|
@ -1489,7 +1489,7 @@ void Model::renderMeshes(float alpha, RenderMode mode, bool translucent, bool re
|
||||||
program->setUniform(skinLocations->shadowDistances, Application::getInstance()->getShadowDistances());
|
program->setUniform(skinLocations->shadowDistances, Application::getInstance()->getShadowDistances());
|
||||||
}
|
}
|
||||||
|
|
||||||
// local light
|
// local light uniforms
|
||||||
skinProgram->setUniformValue("numLocalLights", _numLocalLights);
|
skinProgram->setUniformValue("numLocalLights", _numLocalLights);
|
||||||
skinProgram->setUniformArray("localLightDirections", _localLightDirections, MAX_LOCAL_LIGHTS);
|
skinProgram->setUniformArray("localLightDirections", _localLightDirections, MAX_LOCAL_LIGHTS);
|
||||||
skinProgram->setUniformArray("localLightColors", _localLightColors, MAX_LOCAL_LIGHTS);
|
skinProgram->setUniformArray("localLightColors", _localLightColors, MAX_LOCAL_LIGHTS);
|
||||||
|
|
|
@ -166,8 +166,8 @@ protected:
|
||||||
|
|
||||||
glm::vec3 _localLightDirections[MAX_LOCAL_LIGHTS];
|
glm::vec3 _localLightDirections[MAX_LOCAL_LIGHTS];
|
||||||
glm::vec3 _localLightColors[MAX_LOCAL_LIGHTS];
|
glm::vec3 _localLightColors[MAX_LOCAL_LIGHTS];
|
||||||
int _numLocalLights;
|
int _numLocalLights;
|
||||||
|
|
||||||
QVector<JointState> _jointStates;
|
QVector<JointState> _jointStates;
|
||||||
|
|
||||||
class MeshState {
|
class MeshState {
|
||||||
|
|
|
@ -26,7 +26,7 @@ void ProgramObject::setUniform(const char* name, const glm::vec3& value) {
|
||||||
void ProgramObject::setUniformArray(const char* name, const glm::vec3* values, int count) {
|
void ProgramObject::setUniformArray(const char* name, const glm::vec3* values, int count) {
|
||||||
GLfloat* floatVal = new GLfloat[count*3];
|
GLfloat* floatVal = new GLfloat[count*3];
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for(int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
assert(index < count*3);
|
assert(index < count*3);
|
||||||
const float* valPtr = glm::value_ptr(values[i]);
|
const float* valPtr = glm::value_ptr(values[i]);
|
||||||
floatVal[index++] = valPtr[0];
|
floatVal[index++] = valPtr[0];
|
||||||
|
|
|
@ -23,7 +23,7 @@ public:
|
||||||
|
|
||||||
void setUniform(int location, const glm::vec3& value);
|
void setUniform(int location, const glm::vec3& value);
|
||||||
void setUniform(const char* name, const glm::vec3& value);
|
void setUniform(const char* name, const glm::vec3& value);
|
||||||
void setUniformArray(const char* name, const glm::vec3* values, int count);
|
void setUniformArray(const char* name, const glm::vec3* values, int count);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_ProgramObject_h
|
#endif // hifi_ProgramObject_h
|
||||||
|
|
|
@ -540,7 +540,7 @@ void VoxelSystem::initVoxelMemory() {
|
||||||
_readArraysLock.unlock();
|
_readArraysLock.unlock();
|
||||||
|
|
||||||
// fog for haze
|
// fog for haze
|
||||||
if(_drawHaze) {
|
if (_drawHaze) {
|
||||||
GLfloat fogColor[] = {_hazeColor.x, _hazeColor.y, _hazeColor.z, 1.0f};
|
GLfloat fogColor[] = {_hazeColor.x, _hazeColor.y, _hazeColor.z, 1.0f};
|
||||||
glFogi(GL_FOG_MODE, GL_LINEAR);
|
glFogi(GL_FOG_MODE, GL_LINEAR);
|
||||||
glFogfv(GL_FOG_COLOR, fogColor);
|
glFogfv(GL_FOG_COLOR, fogColor);
|
||||||
|
|
Loading…
Reference in a new issue