201

(2 replies, posted in General)

Ender wrote:

So I am new to Maratis. I have a few questions.
does the mesh have to be triangulated before i give it to maratis. or does the system do that its self
and does it autosmooth the normal edges
or should i set up smoothing groups in 3dsmax.

Hope you can help me out here thanks
Ender

http://forum.maratis3d.com/viewtopic.php?id=134&p=6 < here is the max exporter page for max 2013. The author had a few other ones, but it grew tobe a lot of work so atm 2013 is the one.

I've not idea about your specific questions, but I am positive the max author will have all your answers ( &/or others more familiar ).

Good luck and welcome to Maratis wink

cu
gm

I just posted here:

http://www.united3dartists.com/forum/vi … 447#p37447 , because I noted that the free engines listed didn't mention Maratis3d, so I added it just now.

I also want to say a quick word about truespace 3d.

I was given a copy of TS 4.3 by a client of mine (Landscape Architect) including the book  ( all legit), and while I never took the time  to adequately try it out, I've later become interested in it, because well its now completely free & open source, in regards to the fact that you can write your own TSX plugins/sripts for TS7.61 beta8 ( update for it after download) ( using freebasic if you want) , using the TS c++ SDK, so basically practically any extra features can be added as I understand.

I absolutely love this app's workspace visual and flow and I can't wait to start learning it again wink

I thought you all might find it fascinating to try at least, no matter which 3d app you use right now.

If you decided to try it &/or use it along with other 3d apps, you need to grab it here:

http://www.moddb.com/downloads/truespace-761-beta-8 , because atm the unitedartists links are incorrect.

Again, if interested in any of this, you should follow these directions here first:

http://www.united3dartists.com/forum/vi … 448#p37448 < and once there,  see 'Trueblues's post on 11/1/2012

As noted, its great to have more than one 3d app sometimes, as they all have niches they serve and do so quite well, and having tried and really liked TS, I thought others might too, and given there are clearly other TS users out there, that this would possibly make the whole collada exporter TODO thing seem a tad more important and useful wink

cu
Gm

203

(0 replies, posted in General)

Hi there Maratis Fans wink

I thought it might be a nice idea to help Maratis gain a bit of popularity ( gaining now quite clearly, but more is good) by going here and voicing your interest &/or tweeting for us:

http://devmaster.net/devdb/engines/maratis

ttyl
Gm

204

(27 replies, posted in General)

Hi there anael,

Thx so much for taking time to fix this, so yes now it works fine smile))

I'ts great to have this functioning as now I can move onto other things .

Thx so much.

Gm

205

(27 replies, posted in General)

STill crashing. Is it possible I have something wrong with scene  I wonder ?

Its just my mesh, with physics enabled for player walk, all taken from sponzaFPS example.

206

(27 replies, posted in General)

Hi there,

If this is just a 'no texture' issue, Im happy to texture the mesh, but I thought I'd seen tutorials a few of vegas tuts that ( door demo) that had none, so I guess we should be consistent if so; but Im willing to do whatever is best.

When running the new 'fix' exe, I get this:

---------------------------
Maratis.exe - Entry Point Not Found
---------------------------
The procedure entry point ?createDirectory@@YA_NPBD_N@Z could not be located in the dynamic link library MCore.dll.
---------------------------
OK   
---------------------------

Sorry I wish  I could say it worked  of course.

cheers
gmLee


anael wrote:

ok, I think I have a fix,
try to replace Maratis and MaratisPlayer exe by this : http://maratis3d.com/download/Maratis3.1b-fix-win32.zip

I think it was not what I taught, but just a fixed-renderer bug happening sometimes if the mesh has no textures.

207

(27 replies, posted in General)

So glad to hear you're able to replicate on your end Anael.

I tried: top view>B (and grab half of mesh down the middle), press 'P' > "selection", but on export and import into maratis editor, and then pressing pacman, I still get a crash.

..beyond that all I could do would be to compile current beta3.1 maratis and then run maratis in debug mode in VS, and see if I can see anything helpful.

cheers
lee
Gm EXTRaordinaire <wink>

anael wrote:

Hi,

I'll continue looking on the GL_MAX_ELEMENTS_INDICES,
the funny thing is that I have windows installed on mac laptop,
and where it doesn't crash on macosx, it crashed on windows, so at least I can replicate the bug.

I'll let you know if I found a fix, tell me if splitting the mes works.

208

(27 replies, posted in General)

Awesome, thanks for follow up on this appreciate it indeed.

For now yes, I shall split mesh up and see how that goes.

One thing to note, my hardware is all recent,,,everything is new except for cdrom drive, and my GL driver is new, albeit my GPU of course is 'slightly' old but still in solid mainstream use Im pretty sure. It's a solid card and still allows me to play current games on the market , often at max settings.

Thx for looking into all of this Anael wink)

cheers
Lee



anael wrote:

I maybe found something, that can be a bit of a pain to deal with but that's maybe why it crashes.

There is apparently a limit of triangles that can be send and that can be different depending on the driver, machine or opengl version (didn't know about it) : GL_MAX_ELEMENTS_INDICES

I'll see if I can modify the code to take this in account and split the rendering if needed.

In the meanwhile, what you can do to make it work is to split your model in multiple parts so each part don't exceed 64 000 triangles (a possible 16bit limitation on old hardware or old drivers).

209

(27 replies, posted in General)

Just wondering if you had any luck with this ?

thx
lee


anael wrote:

Thanks,
this one is also working here, but tomorrow ill try on another machine on windows to see if it crash.

the vertice/index number seems strange too like if there was a lot of double triangles, but im not sure.

210

(61 replies, posted in Editor)

Ya, blender can take a bit of getting used to if you are coming from another 3d product, and many flat refuse to use it ( rarely , if at all, used in most game studios , that Im aware of ).

I know others mirror this opinion, and I'll add my voice to it, saying we really could use a good collada import, as in so doing you would get people from every walk of 3d life using Maratis. It's one thing to ask them to import their objects into blender, but that is no guarantee I believe, that the porting process is going to be good.

https://github.com/jefftrull/ColladaOgreImporter < This is the best I can find source wize, so maybe its a good place to start from a porting POV ?



Wrapscallion wrote:

If you want more people to use it, my idea is to take it as far away from blender as you can. You guys are going for ease of use, right?Scrap the antiquated save/load system. Only real problem I see with this product right now.

211

(27 replies, posted in General)

I remade it, and here is the new zipfile:

http://heartseed.sf.net/SponzaGood.zip

Its also now crashing, just using the editor , moving mouse around, etc. Not doing anything but keys/mouse movement in scene. I wonder if this is a beta 3.1 issue ?

If need be I can try compiling editor and get a debug, because atm, with VS express having no JIT module, I can't get that.

Let me know.

Thx
Gm

anael wrote:

There is one thing a bit bizarre though in the mesh file,
The mesh have only 6664 vertices but 39513 indices...
In Blender, if you have modifiers on the mesh, try to apply them all before exporting, it's maybe that.

212

(27 replies, posted in General)

Yup, it works fine with sponza mesh, which is puzzling.

That would possibly indicate that its my mesh, but its just a mesh like sponza basically.

The only thing different, is its a mesh that had a displace modifier put on it to create the terrain effect.

If that's the problem, was their something I needed to add to maps or mesh DIR that I haven't done ?

thx
Gm


anael wrote:

mh... what can it be so...
I don't see why the script would crash, except is there is a bad encoding, but it works fine with the sponza mesh ?

213

(59 replies, posted in General)

Any word on this, or should I just try using the shader code as suggested by anael, as in choosing that text file, inside maratis GUI in blender ?

cheers
Gm



Alinor wrote:

This blend shader is only useful for terrain with a single diffuse map, and blend several specular and normal map.

At first, I have thought that is the best solution to make complex terrain, but after I changed my mind to a shader who blend :

1 : blend map (use r, g, b and dark compound)
2 : diffuse 1
3 : normal 1
4 : diffuse 2
5 : normal 2
6 : diffuse 3
7 : normal 3
8 : diffuse 4

I'll post it, when I'll return to my home wink

214

(27 replies, posted in General)

It does still crash , even If I turn off physics.

cheers
gm


anael wrote:

ok, so I guess what crashes is the physics, but there is a way to be sure :
If you disable the physics on the CouncilBluffsDEC mesh, do it still crash ?

215

(27 replies, posted in General)

It crashes on press of pacman.

Thanks anael wink

cheers
gm


anael wrote:

Thank you,
I opened the project an lauched it without a crash (on macosx),
the mesh seems ok to me in a fast glimpse.

In what case do it crash for you ? when you import the mesh "CouncilBluffsDEC.mesh" ? or only when you press the pacman button ?

216

(27 replies, posted in General)

Yup I can do that and thx for a speedy reply anael wink

I'll post it on my sf.net website, and here is the URL

I hope I haven't done something embarrasingly nutty;)

http://heartseed.sourceforge.net/maratis/SponzaGood.zip

thx
smile
gm


anael wrote:

Hi, is it possible for you to send me the file that makes it crash ?
I'll try to debug it.

217

(27 replies, posted in General)

ATm  I am using sponza example, as I like the camera movement system ( but I'd also like mouse click movement later).
I've looked at several of the examples , so I am getting a much better idea of whats going on.
When I change out the building model for my terrain model ( preserving triangle mesh and all other settings), I get a crash on starting maratis player.
I've rechecked values from building but I see no issues, or have I forgot to do something after replacing default building in that example ( I also decimated mesh in blender before exporting thinking maybe the crash wa due to too many verts, but it had no effect on  ending crash. )?

Later on as recommended by nistur, im going to try compiling beta 3.1 of maratis ( which im using in this case here), and then load it into VS 2010 in debug mode and hope I get something better than just a crash with no info.

STill, if anyone has any idea whats up, please reply;)

thx
gm

218

(21 replies, posted in Tutorials/Examples)

Im sorry if I offended the video creator Anael, and I honestly didn't notice that he said he was 'german', and that his style and language might be off, but to be fair to me, he never apologized like I think he should, for cussing so harshly, nor for attacking me so harshly in his opening reply. I most certainly did not deserve that , as he claims he didnt derserve his treatment.

EVen when I was telling him its not right to cuss, I still thanked him for the videos, so it would be nice to at least get credit, for that wink

At any rate, I do welcome you to the forums and look fwd to your continued pleasing offerings to make the engine more useful. To reiterate, I didn't notice you said you were German and your style and language might be off. I accept that caused the cussing ,and that you regret that.

I will happily now given those facts, watch your videos wink

I've been wanting to do something along those lines anyway , so I thank you for taking the time to make them , and I also publicly acknowledge that you fixed the error in video 1, and appreciate that wink

cheers
gm



anael wrote:

I will add something that I hope will close this non constructive talk.
Special_ops comes here to share something out of free kindness, I think very important to control langage but there is a line to draw between mistake and offense. Mistakes are mistakes, and can be corrected, there is no reason to be rude, it's not a way to say things, much important the thing is, and welcome people.

Now, lets continue on the original topic, and discuss this work, ideas, and mistakes if there is.

219

(21 replies, posted in Tutorials/Examples)

Im so sorry its SO inconvenient for you, to not talk like someone needing soap to wash your mouth out with.

Would it really have been so hard, or SO inconvenient for you, to say 'what the heck!', and let it go at that, or is cussing some macho necessity these days ?

If you think its amusing to mock people that dont like to cuss to 'get their point across' then I feel very sorry for you, but you should know, that I am not alone:

http://www.nocussing.com/
http://www.micheleborba.com/blog/2011/0 … at-school/
http://today.msnbc.msn.com/id/43678114/ … IBWXXjNmDk

THis is nothing against you, obviously, its against the attitude that cussing is just fine; its not.

AS I said, Im quite glad you are doing the videos as they are needed by Im sure a significant amount of the maratis community that may have small amounts of programming skills, and until better docs are forthcoming for maratis.

And btw, ignoring is immoral to me, because that just means I think its 'ok', and I do not. I see it as a civic duty to stop abusive words everywhere.

Sorry if I sound like a grammar nazi to you, but I think most adults  who have kids, don't raise them to cuss like a sailor. I know my parents most certainly did not.

smile

cu
gm


special_ops wrote:

I've just uploaded the fourth video and will soon add the fifth one, too, as soon as it finishes uploading. It's sad that there are people like you out there, gamemaker, thinking that it would not be mature at all to just ignore such a thing. Anyways, I've edited the word out of the sentence and reuploaded the first video. As I'm saying somewhere in the second one, I guess, I'm German, so my English sometimes is incorrect, both in the language part and the style (:

220

(21 replies, posted in Tutorials/Examples)

Maybe where you live such things don't matter, but I won't listen any further to your videos, unless you remove fuc* from the first one. I didn't listen any further so I have no idea about 2 or 3, but I hope its just an oversight, but otherwise I find it very offensive and immature you would allow such wording to enter in the video.

I'm glad you're doing this as it will certainly help people with such needs.

cheers
gm


special_ops wrote:

Hi.
I've lately been creating several video tutorials on the usage of Maratis. The aim of my tutorials will be to create a basic third person game based on a LUA script. If you are having ideas on topics I should talk about or just general critique just post them here.
Part 1: http://www.youtube.com/watch?v=iKsD-JxuMWc
Part 2: http://www.youtube.com/watch?v=hHW3q5GxFIc
Part 3: http://www.youtube.com/watch?v=D1SmQk0Ifms

-- to be continued.

221

(7 replies, posted in Tutorials/Examples)

It's really hard to know where to start with maratis, given there are zero tuts out there, that aren't 'simplisitc' in nature. We need a tutorial , showing the very minimal of code needed toget a player in the game and move player around...it would be nice for example, if we had a TUT that gave script examples of say how yofrankie was done.

A very simple mproj yes, but it would go a long ways to getting people started, or is there one somewhere that I missed ? I would dig into the code/scripting, but I think I'd be lost.

If I understood the system, I'd be happy to do that, but its impossible knowing where to start wink

thx for updating door btw, Ill tinker a bit (prob. in utter confusion) till you make that and upload it.



cu
gm


Vegas wrote:

Hi, well, i just realize these examples are quite confusing (too many variables),
i'm gonna make a better version today.
For now, to answer you :

I see that if I disable the player physics and run player, that it doesn't work as expected, but then reenabling the player and running example again, causes player to continue not to be able to move when pressing keys.

That's because the object "mass" got reset to 0 when you disable/enable physics

I also don't understand what 'locker' is doing.

locker is here to block the door (addforce on Z when door and locker are in collision), but you shouldn't go that way honestly =P

HOw does entity0 work and where can I see the code ?

I don't get what you mean here ? scripts are located under project/scripts

222

(7 replies, posted in Tutorials/Examples)

Hi and thx for TUT,

Trying to go through this a bit to have a better understanding of how Maratis works, but Im experiencing some difficulty;

HOw does entity0 work and where can I see the code ?

I see that if I disable the player physics and run player, that it doesn't work as expected, but then reenabling the player and running example again, causes player to continue not to be able to move when pressing keys.

I also don't understand what 'locker' is doing.

Would you mind terribly explaning what all this does, as I think that would go along way to allowing new users to work with maratis wink

thx
gm




Vegas wrote:

Hello, 3 quick examples (very poorly made) but working ones.

OPENING A DOOR
http://img64.imageshack.us/img64/1315/doorcompressed.jpg
Description : Open a door when walking on the large rectangle (door also have sounds) this is made using physics (gonna make another one using translate later on)
Project : http://dl.dropbox.com/u/19970067/Maratis/Door.rar

223

(59 replies, posted in General)

Ok thanks wink)

cheers
gm


anael wrote:

Hi,

I'll use 'P' in select mode, like you said.
Go to edit mode, in face mode, use the top-view, and the border select tool "B"
select the triangles you want to split, press 'P' > "selection"

You are not forced to split the mesh, but if your terrain is really big, it will be faster.

224

(59 replies, posted in General)

Im finally (ugh) getting around to doing this, but having googled on the subject of splitting mesh, all I find is doing 'p' in edit mode, and selecting from menu, but that menu won't apply well, unless I can find a way to apply a different material toeach of those , to be split areas.

So how would I do this for a plane , which has been displaced with a heightmap and is now a actual terrain ?

Thanks anyone wink

cheers
gm


anael wrote:

Hi gamemaler,

for now I don't have imediate plan for terrain support, my priority is on tutorials and doc,
you can of course export terrain from blender but it will be static triangles (so less optimized than a terrain algo).

If in Blender you split your mesh in multiple objects and export as 1 mesh it can work good (it will create sub-mesh in the mesh format wich are drawn only if visible).

You can use normal mapping to add visual relief if you want to limit triangles.
You can also bake lighmap in blender and use the texture as Emit texture.


I know it's not easy to know where to start, tutorials are my priority,
I'm trying to find some funds to be able to spend more time but I'm not waiting it to start.

For now, the best is to look at the examples wich are included in the release,
and the links wish are there : http://www.maratis3d.com/?page_id=53

225

(59 replies, posted in General)

Just wondering and thx for doing this..

So, as a total non programmer for the most part < learning as I go>, so I simply copy/paste those into the right slots in the Blender<>maratis exporter, for my texture painted terrain, and then place in the correct subDIR's in maratis, and that should then show up correctly in the maratis editor ?

Sorry for posting on such a old thread,,but its relevant now, that I have time to pursue game development.

cheers
gm


Alinor wrote:

Hi, this is an example of a shader that can use to make terrain (derived from Anaël's CustomShaders example) :

1er slot : diffuse texture (1000*1000 pixels or less is good enough)
2em slot : blend texture (black, red, green, blue)
3em slot : normal texture n°1(color associated : black) (example : snow)
4em slot : specular texture n°1(color associated : black)
5em slot : normal texture n°2(color associated : red) (example : grass)
6em slot : specular texture n°2(color associated : red)
7em slot : normal texture n°3(color associated : green) (example : grass n°2)
8em slot : normal texture n°4(color associated : blue) (example : ground)


here an example of a blend texture  :
http://img4.hostingpics.net/pics/307203essaimix.png
and this is the script (cut, past and save in a .vert or .frag file) :
frag shader :

uniform bool AlphaTest;
uniform vec4 FogColor;
uniform float FogEnd;
uniform float FogScale;

uniform vec3 MaterialEmit;
uniform float MaterialShininess;
uniform float MaterialOpacity;

uniform vec4 LightPosition[4];
uniform vec3 LightDiffuseProduct[4];
uniform vec3 LightSpecularProduct[4];
uniform vec3 LightSpotDirection[4];
uniform float LightConstantAttenuation[4];
uniform float LightQuadraticAttenuation[4];
uniform float LightSpotCosCutoff[4];
uniform float LightSpotExponent[4];
uniform bool LightActive[4];

uniform sampler2D LightShadowMap[3];
uniform bool LightShadow[3];
uniform float LightShadowBias[3];
uniform float LightShadowBlur[3];

uniform sampler2D Texture[8];
uniform sampler2D RandTexture;

varying vec2 texCoord[8];
varying vec4 shadowCoord[3];
varying vec4 position, normal, tangent;

vec4 texture0 = texture2D(Texture[0], texCoord[0]);                    
vec4 texture1 = texture2D(Texture[1], texCoord[1]);
vec4 texture2 = texture2D(Texture[2], texCoord[2]);
vec4 texture3 = texture2D(Texture[3], texCoord[3]);
vec4 texture4 = texture2D(Texture[4], texCoord[4]);
vec4 texture5 = texture2D(Texture[5], texCoord[5]);
vec4 texture6 = texture2D(Texture[6], texCoord[6]);
vec4 texture7 = texture2D(Texture[7], texCoord[7]);

float calcule_oppose (float red, float green, float blue)
{
    if(red>green)
    {
        if (red>blue)
        {
        return (1.0-red);
        }
        else
        {
        return (1.0-blue);
        }
    }
    else if(green>blue) 
    {
    return (1.0-green);
    }    
    else
    {
    return (1.0-blue);
    }
}

float red = texture1.x;
float green = texture1.y;
float blue = texture1.z;
float oppose = calcule_oppose(red,green,blue);

vec3 diffuse = MaterialEmit;
vec3 specular = vec3(0.0, 0.0, 0.0);

vec3 nor = normalize(normal.xyz);
vec3 bi = normalize(-cross(normal.xyz, tangent.xyz));
vec3 tan = normalize(tangent.xyz);

vec3 bump = normalize((texture2.xyz*(oppose/(red+green+oppose+blue))+ texture4.xyz*(red/(red+green+oppose+blue))+texture6.xyz*(green/(red+green+oppose+blue))+texture7.xyz*(blue/(red+green+oppose+blue)))* 2.0 - 1.0);

vec3 N = normalize(tan*bump.x + bi*bump.y + nor*bump.z);
vec3 E = normalize(-position.xyz);


float lookup(vec4 shadCoord, sampler2D shadMap, vec2 offSet)
{
    float distanceFromLight = texture2D(shadMap, shadCoord.xy + offSet).z;
    return step(shadCoord.z, distanceFromLight);
}            
                                
float computeShadow(bool shad, vec4 shadCoord, sampler2D shadMap, float shadBias, float shadBlur)
{
    float shadow = 1.0;
    if(shad)
    {
        vec4 shadowCoordinateWdivide = shadCoord;
        shadowCoordinateWdivide.z -= shadBias;

        shadowCoordinateWdivide /= shadowCoordinateWdivide.w;
         
        float blur = (shadBlur*0.01);
        vec4 rand = texture2D(RandTexture, (shadowCoordinateWdivide.xy)*(500.0/(shadBlur+1.0)))*2.0 - 1.0;
        
        vec2 d = rand.xy;
        d = normalize(d)*blur;
                                
        vec2 dp = vec2(d.y, -d.x);
        
        shadow = lookup(shadowCoordinateWdivide, shadMap, rand.zw*blur);
        shadow += lookup(shadowCoordinateWdivide, shadMap,  d);
        shadow += lookup(shadowCoordinateWdivide, shadMap, -d);
        shadow += lookup(shadowCoordinateWdivide, shadMap,  dp);
        shadow += lookup(shadowCoordinateWdivide, shadMap, -dp);
        shadow *= 0.2;

    }                
    return shadow;
}
                                
void computeLight(vec3 lightPosition, float constantAttenuation, float quadraticAttenuation, vec3 lightDiffuse, vec3 lightSpecular, vec3 spotDir, float spotCos, float spotExp, bool shad, vec4 shadCoord, sampler2D shadMap, float shadBias, float shadBlur)
{
    vec3 lightDir = lightPosition - position.xyz;
    vec3 L = normalize(lightDir);

    float lambertTerm = max(dot(N, L), 0.0);
    if(lambertTerm > 0.0)
    {
        if(spotCos > 0.0)
        {
            float spot = dot(spotDir, -L);
            
            if(spot > spotCos)
            {
                float shadow = computeShadow(shad, shadCoord, shadMap, shadBias, shadBlur);
                                
                spot = clamp(pow(spot, spotExp), 0.0, 1.0);
                                
                float lightDirLength2 = dot(lightDir, lightDir);
                float attenuation = (spot / (constantAttenuation + (lightDirLength2 * quadraticAttenuation)))*shadow;

                diffuse = diffuse + (lightDiffuse * lambertTerm * attenuation);

                vec3 S = normalize(E + L);
                float spec = pow(max(dot(S, N), 0.0), MaterialShininess) * attenuation;
                specular = specular + (lightSpecular * spec);
            }
        }
        else
        {
            float lightDirLength2 = dot(lightDir, lightDir);
            float attenuation = (1.0 / (constantAttenuation + (lightDirLength2 * quadraticAttenuation)));

            diffuse = diffuse + (lightDiffuse * lambertTerm * attenuation);

            vec3 S = normalize(E + L);
            float spec = pow(max(dot(S, N), 0.0), MaterialShininess) * attenuation;
            specular = specular + (lightSpecular * spec);
        }
    }
}

void computeLightNoShadow(vec3 lightPosition, float constantAttenuation, float quadraticAttenuation, vec3 lightDiffuse, vec3 lightSpecular, vec3 spotDir, float spotCos, float spotExp)
{
    vec3 lightDir = lightPosition - position.xyz;
    vec3 L = normalize(lightDir);

    float lambertTerm = max(dot(N, L), 0.0);
    if(lambertTerm > 0.0)
    {
        if(spotCos > 0.0)
        {
            float spot = dot(spotDir, -L);
            
            if(spot > spotCos)
            {            
                spot = clamp(pow(spot, spotExp), 0.0, 1.0);
                                
                float lightDirLength2 = dot(lightDir, lightDir);
                float attenuation = (spot / (constantAttenuation + (lightDirLength2 * quadraticAttenuation)));

                diffuse = diffuse + (lightDiffuse * lambertTerm * attenuation);

                vec3 S = normalize(E + L);
                float spec = pow(max(dot(S, N), 0.0), MaterialShininess) * attenuation;
                specular = specular + (lightSpecular * spec);
            }
        }
        else
        {
            float lightDirLength2 = dot(lightDir, lightDir);
            float attenuation = (1.0 / (constantAttenuation + (lightDirLength2 * quadraticAttenuation)));

            diffuse = diffuse + (lightDiffuse * lambertTerm * attenuation);

            vec3 S = normalize(E + L);
            float spec = pow(max(dot(S, N), 0.0), MaterialShininess) * attenuation;
            specular = specular + (lightSpecular * spec);
        }
    }
}

void main(void)
{
    if(LightActive[0])
    {
        computeLight(
            LightPosition[0].xyz,
            LightConstantAttenuation[0],
            LightQuadraticAttenuation[0],
            LightDiffuseProduct[0],
            LightSpecularProduct[0],
            LightSpotDirection[0],
            LightSpotCosCutoff[0],
            LightSpotExponent[0],
            LightShadow[0],
            shadowCoord[0],
            LightShadowMap[0],
            LightShadowBias[0],
            LightShadowBlur[0]
        );

        if(LightActive[1])
        {
            computeLight(
                LightPosition[1].xyz,
                LightConstantAttenuation[1],
                LightQuadraticAttenuation[1],
                LightDiffuseProduct[1],
                LightSpecularProduct[1],
                LightSpotDirection[1],
                LightSpotCosCutoff[1],
                LightSpotExponent[1],
                LightShadow[1],
                shadowCoord[1],
                LightShadowMap[1],
                LightShadowBias[1],
                LightShadowBlur[1]
            );

            if(LightActive[2])
            {
                computeLight(
                    LightPosition[2].xyz,
                    LightConstantAttenuation[2],
                    LightQuadraticAttenuation[2],
                    LightDiffuseProduct[2],
                    LightSpecularProduct[2],
                    LightSpotDirection[2],
                    LightSpotCosCutoff[2],
                    LightSpotExponent[2],
                    LightShadow[2],
                    shadowCoord[2],
                    LightShadowMap[2],
                    LightShadowBias[2],
                    LightShadowBlur[2]
                );

                if(LightActive[3])
                {
                    computeLightNoShadow(
                        LightPosition[3].xyz,
                        LightConstantAttenuation[2],
                        LightQuadraticAttenuation[3],
                        LightDiffuseProduct[3],
                        LightSpecularProduct[3],
                        LightSpotDirection[3],
                        LightSpotCosCutoff[3],
                        LightSpotExponent[3]
                    );
                }
            }
        }
    }

    vec4 finalColor = vec4(diffuse*texture0.xyz + specular*(texture3.xyz*(oppose/(red+green+oppose+blue))+ texture5.xyz*(red/(red+green+oppose+blue))), MaterialOpacity*texture0.w);
    float fogFactor = clamp((FogEnd + position.z) * FogScale, 0.0, 1.0);
    gl_FragColor = mix(FogColor, finalColor, fogFactor);
}

vert shader :

attribute vec3 Vertex;
attribute vec3 Normal;
attribute vec3 Tangent;
attribute vec3 Color;

uniform bool LightShadow[3];
uniform mat4 LightShadowMatrix[3];

uniform mat4 TextureMatrix[8];
uniform mat4 ModelViewMatrix;
uniform mat4 ProjectionMatrix;
uniform mat4 NormalMatrix;
uniform mat4 ProjModelViewMatrix;

varying vec2 texCoord[8];
varying vec4 shadowCoord[3];
varying vec4 position, normal, tangent;

attribute vec2 TexCoord0;
attribute vec2 TexCoord1;
attribute vec2 TexCoord2;
attribute vec2 TexCoord3;
attribute vec2 TexCoord4;
attribute vec2 TexCoord5;
attribute vec2 TexCoord6;
attribute vec2 TexCoord7;

void main(void)
{
    if(LightShadow[0]) shadowCoord[0] = LightShadowMatrix[0] * vec4(Vertex, 1.0);
    if(LightShadow[1]) shadowCoord[1] = LightShadowMatrix[1] * vec4(Vertex, 1.0);
    if(LightShadow[2]) shadowCoord[2] = LightShadowMatrix[2] * vec4(Vertex, 1.0);

    normal = NormalMatrix * vec4(Normal, 1.0);
    position = ModelViewMatrix * vec4(Vertex, 1.0);
    gl_Position = ProjModelViewMatrix * vec4(Vertex, 1.0);

    texCoord[0] = (TextureMatrix[0] * vec4(TexCoord0, 1.0, 1.0)).xy;
    texCoord[1] = (TextureMatrix[1] * vec4(TexCoord1, 1.0, 1.0)).xy;
    texCoord[2] = (TextureMatrix[2] * vec4(TexCoord2, 1.0, 1.0)).xy;
    texCoord[3] = (TextureMatrix[3] * vec4(TexCoord3, 1.0, 1.0)).xy;
    texCoord[4] = (TextureMatrix[4] * vec4(TexCoord4, 1.0, 1.0)).xy;
    texCoord[5] = (TextureMatrix[5] * vec4(TexCoord5, 1.0, 1.0)).xy;
    texCoord[6] = (TextureMatrix[6] * vec4(TexCoord6, 1.0, 1.0)).xy;
    texCoord[7] = (TextureMatrix[7] * vec4(TexCoord7, 1.0, 1.0)).xy;
        
    tangent = NormalMatrix * vec4(Tangent, 1.0);
}

have fun with maratis wink