mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-02-23 03:41:03 +00:00
Trying to fix the invalid use of 'for' statement in the shader, GLES2 has strict requirements on 'for' loops and how the are constructed..this might fix it
This commit is contained in:
parent
2b42450f3b
commit
5de9616c70
5 changed files with 14 additions and 13 deletions
|
@ -110,6 +110,9 @@ bool FGLRenderState::ApplyShader()
|
|||
modLights = int(lightPtr[1]) / LIGHT_VEC4_NUM;
|
||||
subLights = (int(lightPtr[2]) - int(lightPtr[1])) / LIGHT_VEC4_NUM;
|
||||
addLights = (int(lightPtr[3]) - int(lightPtr[2])) / LIGHT_VEC4_NUM;
|
||||
|
||||
// Skip passed the first 4 floats so the upload below only contains light data
|
||||
lightPtr += 4;
|
||||
}
|
||||
|
||||
ShaderFlavourData flavour;
|
||||
|
@ -208,7 +211,6 @@ bool FGLRenderState::ApplyShader()
|
|||
activeShader->cur->muInterpolationFactor.Set(mStreamData.uInterpolationFactor);
|
||||
activeShader->cur->muTimer.Set((double)(screen->FrameTime - firstFrame) * (double)mShaderTimer / 1000.);
|
||||
activeShader->cur->muAlphaThreshold.Set(mAlphaThreshold);
|
||||
activeShader->cur->muLightIndex.Set(-1);
|
||||
activeShader->cur->muClipSplit.Set(mClipSplit);
|
||||
activeShader->cur->muSpecularMaterial.Set(mGlossiness, mSpecularLevel);
|
||||
activeShader->cur->muAddColor.Set(mStreamData.uAddColor);
|
||||
|
@ -294,7 +296,7 @@ bool FGLRenderState::ApplyShader()
|
|||
int totalLights = modLights + subLights + addLights;
|
||||
|
||||
// Calculate the total number of vec4s we need
|
||||
int totalVectors = totalLights * LIGHT_VEC4_NUM + 1;
|
||||
int totalVectors = totalLights * LIGHT_VEC4_NUM;
|
||||
|
||||
// TODO!!! If there are too many lights we need to remove some of the lights and modify the data
|
||||
// At the moment the shader will just try to read off the end of the array...
|
||||
|
@ -303,7 +305,8 @@ bool FGLRenderState::ApplyShader()
|
|||
|
||||
glUniform4fv(activeShader->cur->lights_index, totalVectors, lightPtr);
|
||||
|
||||
activeShader->cur->muLightIndex.Set(0);
|
||||
int range[4] = { 0, modLights * LIGHT_VEC4_NUM, subLights * LIGHT_VEC4_NUM, addLights * LIGHT_VEC4_NUM };
|
||||
activeShader->cur->muLightRange.Set(range);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -322,7 +322,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump_, const char *
|
|||
//uniform int uFogEnabled;
|
||||
|
||||
// dynamic lights
|
||||
uniform int uLightIndex;
|
||||
uniform ivec4 uLightRange;
|
||||
|
||||
// Blinn glossiness and specular level
|
||||
uniform vec2 uSpecularMaterial;
|
||||
|
@ -610,7 +610,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump_, const char *
|
|||
shaderData->muTextureMode.Init(shaderData->hShader, "uTextureMode");
|
||||
shaderData->muLightParms.Init(shaderData->hShader, "uLightAttr");
|
||||
shaderData->muClipSplit.Init(shaderData->hShader, "uClipSplit");
|
||||
shaderData->muLightIndex.Init(shaderData->hShader, "uLightIndex");
|
||||
shaderData->muLightRange.Init(shaderData->hShader, "uLightRange");
|
||||
shaderData->muFogColor.Init(shaderData->hShader, "uFogColor");
|
||||
shaderData->muDynLightColor.Init(shaderData->hShader, "uDynLightColor");
|
||||
shaderData->muObjectColor.Init(shaderData->hShader, "uObjectColor");
|
||||
|
|
|
@ -316,7 +316,7 @@ public: class ShaderVariantData
|
|||
FBufferedUniform1i muTextureMode;
|
||||
FBufferedUniform4f muLightParms;
|
||||
FBufferedUniform2f muClipSplit;
|
||||
FBufferedUniform1i muLightIndex;
|
||||
FBufferedUniform4i muLightRange;
|
||||
FBufferedUniformPE muFogColor;
|
||||
FBufferedUniform4f muDynLightColor;
|
||||
FBufferedUniformPE muObjectColor;
|
||||
|
|
|
@ -110,8 +110,8 @@ namespace OpenGLESRenderer
|
|||
gles.max_texturesize = 1024 * 4;
|
||||
gles.modelstring = (char*)"MODEL";
|
||||
gles.vendorstring = (char*)"EMILES";
|
||||
gles.maxlights = 32;
|
||||
gles.numlightvectors = (gles.maxlights * 4) + 1; // maxlights lights, + size vector at the beginning
|
||||
gles.maxlights = 32; // TODO, calcualte this
|
||||
gles.numlightvectors = (gles.maxlights * LIGHT_VEC4_NUM);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,11 +50,9 @@ vec3 ProcessMaterialLight(Material material, vec3 color)
|
|||
vec4 dynlight = uDynLightColor;
|
||||
vec3 normal = material.Normal;
|
||||
|
||||
ivec4 lightRange = ivec4(lights[uLightIndex]) + ivec4(uLightIndex + 1);
|
||||
|
||||
#if (DEF_DYNAMIC_LIGHTS_MOD == 1)
|
||||
// modulated lights
|
||||
for(int i=lightRange.x; i<lightRange.y; i+=4)
|
||||
for(int i=uLightRange.x; i<uLightRange.y; i+=4)
|
||||
{
|
||||
dynlight.rgb += lightContribution(i, normal);
|
||||
}
|
||||
|
@ -62,7 +60,7 @@ vec3 ProcessMaterialLight(Material material, vec3 color)
|
|||
|
||||
#if (DEF_DYNAMIC_LIGHTS_SUB == 1)
|
||||
// subtractive lights
|
||||
for(int i=lightRange.y; i<lightRange.z; i+=4)
|
||||
for(int i=uLightRange.y; i<uLightRange.z; i+=4)
|
||||
{
|
||||
dynlight.rgb -= lightContribution(i, normal);
|
||||
}
|
||||
|
@ -74,7 +72,7 @@ vec3 ProcessMaterialLight(Material material, vec3 color)
|
|||
vec4 addlight = vec4(0.0,0.0,0.0,0.0);
|
||||
|
||||
// additive lights
|
||||
for(int i=lightRange.z; i<lightRange.w; i+=4)
|
||||
for(int i=uLightRange.z; i<uLightRange.w; i+=4)
|
||||
{
|
||||
addlight.rgb += lightContribution(i, normal);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue