Jump to content
Sign in to follow this  
Indy

Using shaders in ArmA

Recommended Posts

Hi all, maybe you already know that but since there isn't a topic about this i decided to share with you some things i discovered...

First of all i was trying to convert some old addons i did for OFP to ArmA and i was searching for a way to implement normal and specular maps on my models so i took a look at those new rvmat files. Since without the proper tools we are unable to use them as they are used directly by the p3d i began searching for another way. I remembered the old cfgTextureToMaterial that we were using in OFP to add shiny effects on our models and i noticed that some new materials in ArmA do look exactly like the rvmat files. So i tryied to do my own material based on the Javelin rvmat file and i tested it over a BIS LAW model imported from ofp. Here's how it looks like with a fast normal map done with nvidia plugin for photoshop.

law2qi4.th.jpg

And here's the code to add on your config:

Note that you'll have to recalculate normals on your p3d

Quote[/b] ]

class CfgTextureToMaterial

{

class LAWMetal

{

textures[] = {"LAW_TEST\law_side.pac"};

material = "#LAWMetal";

};

};

class CfgMaterials

{

class LAWMetal

{

ambient[] = {1.000000, 1.000000, 1.000000, 1.000000};

diffuse[] = {1.000000, 1.000000, 1.000000, 1.000000};

forcedDiffuse[] = {0.000000, 0.000000, 0.000000, 0.000000};

emmisive[] = {0.000000, 0.000000, 0.000000, 1.000000};

specular[] = {0.746000, 0.746000, 0.746000, 1.000000};

specularPower = 60.000000;

PixelShaderID = "NormalMapSpecularDIMap";

VertexShaderID = "NormalMap";

class Stage1 {

texture = "LAW_TEST\LAW_side_nohq.paa";

uvSource = "tex";

class uvTransform {

aside[] = {1.000000, 0.000000, 0.000000};

up[] = {0.000000, 1.000000, 0.000000};

dir[] = {0.000000, 0.000000, 0.000000};

pos[] = {0.000000, 0.000000, 0.000000};

};

};

class Stage2 {

texture = "LAW_TEST\LAW_side_smdi.paa";

uvSource = "tex";

class uvTransform {

aside[] = {1.000000, 0.000000, 0.000000};

up[] = {0.000000, 1.000000, 0.000000};

dir[] = {0.000000, 0.000000, 0.000000};

pos[] = {0.000000, 0.000000, 0.000000};

};

};

};

};

I'm not going to release this as it was just a test to see if it was possible for us to use normal maps before the official tools are released. Hope you found this usefull.

Share this post


Link to post
Share on other sites
Guest Ti0n3r

Woh, that looks pretty good for a 2001 model. Cheers! biggrin_o.gif

Share this post


Link to post
Share on other sites

another thing that might come useful: by adding a point in the memory lod with selection name "eye" in the position where the eye should look it is possible to use 3d optics on custom addons.

eyeyn7.th.jpg eye2lo4.th.jpg

Share this post


Link to post
Share on other sites

wicked thumbs-up.gif

too bad that ofp models have that many single textures for one model, would be great to have a M16A4 that just uses maybe 2 Textures and not sharing 5-6 textures. confused_o.gif

Share this post


Link to post
Share on other sites
wicked thumbs-up.gif

too bad that ofp models have that many single textures for one model, would be great to have a M16A4 that just uses maybe 2 Textures and not sharing 5-6 textures. confused_o.gif

what about using the "merge textures" function from OË› ?

http://www.flashpoint1985.com/cgi-bin....extures

its woriking very well!

if your uvmapping is good, you don't need to do that. smile_o.gif

Share this post


Link to post
Share on other sites
wicked thumbs-up.gif

too bad that ofp models have that many single textures for one model, would be great to have a M16A4 that just uses maybe 2 Textures and not sharing 5-6 textures. confused_o.gif

what about using the "merge textures" function from OË› ?

http://www.flashpoint1985.com/cgi-bin....extures

its woriking very well!

if your uvmapping is good, you don't need to do that. smile_o.gif

He was refering to using the texmerge function to reduce the texture count on OFP models, making them more "suitable" for use in ArmA (tho why you'd ever want to tounge2.gif )

Share this post


Link to post
Share on other sites
if your uvmapping is good, you don't need to do that. smile_o.gif

QFT!

I never understood why they said that my texture count was low when I said I have 3 textures on a large plane.

Then I opened up another addon to discover that it has 4 textures for the fuselage itself.

Ineffective uvmapping IMO.

Share this post


Link to post
Share on other sites
Then I opened up another addon to discover that it has 4 textures for the fuselage itself.

Ineffective uvmapping IMO.

You can't do much in Oxygen. You can limit texcount with texmerge function but their uv mapping is still bad sad_o.gif. Hopefully the new Oxygen has a better solution smile_o.gif.

Share this post


Link to post
Share on other sites

But there are other, better, free applications, such as LithUnwrap. You can use a p3d2obj converter or p3d2ms converter and unwrap it there, ofcourse merging the model into one large group first. Then you can import it back to o2 via the 3ds importer.

Share this post


Link to post
Share on other sites

New objective have unwrap function, but in old texmerge you still can merge textures, generate ptm file and load this file to O2, that will autamaticaly merge textures in all lods by definition in ptm file (this also posible in o3 - new objective)

Share this post


Link to post
Share on other sites

Its basic unwrap, main advatage is that u dont need to go back to max to maya if you want something remap, another good think is that it support multiple UV sets, so u can for example separately unwrap normal map or macro map with diferent UV in diferent layer from one material.

Share this post


Link to post
Share on other sites

aaah, that sounds good - I wasn't looking forward to having to learn unwrap in 3dsMax for the sake of modding in Arma, so this sound much better (assuming its easy enough to get to grips with)

Share this post


Link to post
Share on other sites
Its basic unwrap, main advatage is that u dont need to go back to max to maya if you want something remap, another good think is that it support multiple UV sets, so u can for example separately unwrap normal map or macro map with diferent UV in diferent layer from one material.

that's what oxygen was missing biggrin_o.gif can i ask you how are the new shadows handled in the p3d? I've been trying to make them work but without success. My guess is that there is a new lod dedicated for shadows but i'm not sure about this. Also i noticed that now weapon models do have "component" selections but i can't figure out in which lod and for what purpose. Is this related to shadows or to some other feature?

Share this post


Link to post
Share on other sites
that's what oxygen was missing  biggrin_o.gif can i ask you how are the new shadows handled in the p3d? I've been trying to make them work but without success. My guess is that there is a new lod dedicated  for shadows but i'm not sure about this.

There is a new LOD, you can use it in O2 lite by creating a new LOD with resolution of 10000. In it should be the model used to make the shadow volume, it needs to not have any holes in it (O2 lite 'structure/topology/find non-closed' can be used to find these) and it must be made of only triangles... If the shadow LOD is incorrect you get a whole bunch of warnings in the rpt file.

Share this post


Link to post
Share on other sites
that's what oxygen was missing biggrin_o.gif can i ask you how are the new shadows handled in the p3d? I've been trying to make them work but without success. My guess is that there is a new lod dedicated for shadows but i'm not sure about this.

There is a new LOD, you can use it in O2 lite by creating a new LOD with resolution of 10000. In it should be the model used to make the shadow volume, it needs to not have any holes in it (O2 lite 'structure/topology/find non-closed' can be used to find these) and it must be made of only triangles... If the shadow LOD is incorrect you get a whole bunch of warnings in the rpt file.

thanks it worked biggrin_o.gif

Share this post


Link to post
Share on other sites

Its little bit complicated, we can use 3 diferent kind of shadows. From original OFP u know CPU shadows, they are now used as hybrid shadows for vegetatin and they are casted on lanscape , when stencil shadows are casted on objects. Hybrid and stencil shadows are used when shadow detail are normal or lower, otherwise shadow buffer shadows (SB) are used. CPU shadows are same as was in OFP, stencil shadows use special lods as Kegetis wrote and there could be more stencil shadow lods with diferent detail. stencil shadows must be triangulated, must use sharp edges, model for shadow must have volume (must be closed). SB shadows have also special lod number and could by normal model (simplified), its good if have just one section, not using any materials. There must be property in geometry lod that will say what kind of shadow lod in what situation will be used. We will add full documentation to biki.

Share this post


Link to post
Share on other sites
We will add full documentation to biki.

aaah, excellent... I was already getting quite overwhelmed with the projected learning curve as it was

Share this post


Link to post
Share on other sites

Hi Indy, I've made a new weapon following your instructions about the shaders. But my weapon have no shadow? Do you have the same trouble with your LAW?

arma_frinf1.jpg

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×