Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ protected int updateLightListUniforms(Shader shader, Geometry g, LightList light

Uniform lightData = shader.getUniform("g_LightData");
lightData.setVector4Length(numLights * 3);//8 lights * max 3
Uniform lightCount = shader.getUniform("g_LightCount");
Uniform ambientColor = shader.getUniform("g_AmbientLightColor");

// Matrix4f
Expand Down Expand Up @@ -231,6 +232,7 @@ protected int updateLightListUniforms(Shader shader, Geometry g, LightList light
}
}
vars.release();
lightCount.setValue(VarType.Int, lightDataIndex / 3);

// pad unused buffer space
while (lightDataIndex < numLights * 3) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ protected int updateLightListUniforms(Shader shader, Geometry g, LightList light

Uniform lightData = shader.getUniform("g_LightData");
lightData.setVector4Length(numLights * 3);//8 lights * max 3
Uniform lightCount = shader.getUniform("g_LightCount");
Uniform ambientColor = shader.getUniform("g_AmbientLightColor");

if (startIndex != 0) {
Expand Down Expand Up @@ -198,6 +199,7 @@ protected int updateLightListUniforms(Shader shader, Geometry g, LightList light
}
}
vars.release();
lightCount.setValue(VarType.Int, lightDataIndex / 3);
// pad unused buffer space
while (lightDataIndex < numLights * 3) {
lightData.setVector4InArray(0f, 0f, 0f, 0f, lightDataIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#endif

uniform vec4 g_LightData[NB_LIGHTS];
uniform int g_LightCount;
uniform vec3 g_CameraPosition;

#ifdef USE_FOG
Expand All @@ -38,6 +39,11 @@ void main(){

// Calculate direct lights
for(int i = 0;i < NB_LIGHTS; i+=3){
#if (defined(GL_ES) && __VERSION__ >= 300) || (!defined(GL_ES) && __VERSION__ >= 150)
if(i >= g_LightCount * 3){
break;
}
#endif
vec4 lightData0 = g_LightData[i];
vec4 lightData1 = g_LightData[i+1];
vec4 lightData2 = g_LightData[i+2];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ varying vec3 SpecularSum;
#ifndef VERTEX_LIGHTING
uniform mat4 g_ViewMatrix;
uniform vec4 g_LightData[NB_LIGHTS];
uniform int g_LightCount;
varying vec3 vPos;
#endif

Expand Down Expand Up @@ -197,6 +198,11 @@ void main(){
#endif

for( int i = 0;i < NB_LIGHTS; i+=3){
#if (defined(GL_ES) && __VERSION__ >= 300) || (!defined(GL_ES) && __VERSION__ >= 150)
if(i >= g_LightCount * 3){
break;
}
#endif
vec4 lightColor = g_LightData[i];
vec4 lightData1 = g_LightData[i+1];
vec4 lightDir;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ uniform float m_Shininess;

#if defined(VERTEX_LIGHTING)
uniform vec4 g_LightData[NB_LIGHTS];
uniform int g_LightCount;
#endif
uniform vec4 g_AmbientLightColor;
varying vec2 texCoord;
Expand Down Expand Up @@ -148,6 +149,11 @@ void main(){
vec4 diffuseColor;
vec3 specularColor;
for (int i =0;i < NB_LIGHTS; i+=3){
#if (defined(GL_ES) && __VERSION__ >= 300) || (!defined(GL_ES) && __VERSION__ >= 150)
if(i >= g_LightCount * 3){
break;
}
#endif
vec4 lightColor = g_LightData[i];
vec4 lightData1 = g_LightData[i+1];
#ifdef MATERIAL_COLORS
Expand Down Expand Up @@ -197,4 +203,4 @@ void main(){
#ifdef USE_FOG
fog_distance = distance(g_CameraPosition, (TransformWorld(modelSpacePos)).xyz);
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

//declare PBR Lighting vars
uniform vec4 g_LightData[NB_LIGHTS];
uniform int g_LightCount;
uniform vec3 g_CameraPosition;

#ifdef DEBUG_VALUES_MODE
Expand Down Expand Up @@ -133,6 +134,11 @@ void main(){

// Calculate direct lights
for(int i = 0;i < NB_LIGHTS; i+=3){
#if (defined(GL_ES) && __VERSION__ >= 300) || (!defined(GL_ES) && __VERSION__ >= 150)
if(i >= g_LightCount * 3){
break;
}
#endif
vec4 lightData0 = g_LightData[i];
vec4 lightData1 = g_LightData[i+1];
vec4 lightData2 = g_LightData[i+2];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ varying vec4 SpecularSum;

uniform mat4 g_ViewMatrix;
uniform vec4 g_LightData[NB_LIGHTS];
uniform int g_LightCount;
varying vec3 vTangent;
varying vec3 vBinormal;
varying vec3 vPos;
Expand Down Expand Up @@ -620,6 +621,11 @@ void main(){
//-----------------------
gl_FragColor = AmbientSum * diffuseColor;
for( int i = 0;i < NB_LIGHTS; i+=3){
#if (defined(GL_ES) && __VERSION__ >= 300) || (!defined(GL_ES) && __VERSION__ >= 150)
if(i >= g_LightCount * 3){
break;
}
#endif
vec4 lightColor = g_LightData[i];
vec4 lightData1 = g_LightData[i+1];
vec4 lightDir;
Expand Down
Loading