Jump to content
Sign in to follow this  
emoglobinsky

Oxygen 2 : Ambient occlusion map and rvmats

Recommended Posts

Hi,

I wondered how to add ambient occlusion map to my model ?

I created a model with 2 uvset : first uvset is for tileable textures, then second uvset is for ambient occlusion map (example of an AO map : http://www.filterforge.com/filters/8578-ambientocclusion.jpg).

But no idea how to configure that rvmat to multiply the AO map over the first tileable textures.

Here is my try at rvmat, but i have to admit that i have no idea what 'im doing :p

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,1.000000};
emmisive[]={0.000000,0.000000,0.000000,1.000000};
specular[]={0.750000,0.800000,0.700000,1.000000};
specularPower=60.000000;
PixelShaderID="Super";
VertexShaderID="Super";

class Stage1
{
texture="/textures\ao_building_03.paa";
uvSource="tex1";
class uvTransform
{
	aside[] = {1,0,0};
	up[] = {0,1,0};
	dir[] = {0,0,0};
	pos[] = {0,0,0};
};
};

Share this post


Link to post
Share on other sites

That really bother me do not manage to get it working :/

1024x576.resizedimage

http://steamcommunity.com/sharedfiles/filedetails/?id=170659379

this is what i get with this rvmat :

i'm using a lightmap texture in Black and white. I tried different settings like only Green channel, or only blue, etc.. but i keep having trouble to see a correct lightmap...

ambient[]={1,1,1,1};
diffuse[]={1,1,1,1};
forcedDiffuse[]={0,0,0,0};
emmisive[]={0,0,0,0};
specular[]={0,0,0,0};
specularPower=90;
PixelShaderID="NormalMapDetailSpecularDIMap";
VertexShaderID="NormalMap";
class Stage2
{
texture="EM_buildings\textures\building_03_PR.paa";
uvSource="tex1";
class uvTransform
{
	aside[]={1,0,0};
	up[]={0,1,0};
	dir[]={0,0,1};
	pos[]={0,0,0};
};
};

Share this post


Link to post
Share on other sites
Not sure how AO works on buildings but this is how it works with super shader - http://forums.bistudio.com/showthread.php?77685-Using-the-quot-Super-quot-Shader-(RVMAT-material)

and if you want the AO to be visible all the time then just multiply the AO on your diffuse map

Super shader dont seems to work... I tried this settings but didnt achieve to have better render of what i want than with this previous rvmat...

And i can't afford to bake my lightmap into my diffuse, this would be an amazing waste of pixels (and so waste of files weight).

Share this post


Link to post
Share on other sites

Texture needs to be named properly for starters or Texview wont convert it to the proper format used for AO maps (called AS maps in Arma - for Ambient Shadow). The texture needs to be called mytexturename_as.tga before you convert it to mytexturename_as.paa. "ao_building_03.paa" is not a valid texture name.

Arma has a defined set of conventions for textures that you have to follow or things wont render correctly.

RVMAT stage I used for a model of mine with a working AS map:

class Stage4 {
texture = "acre_m_bowman\data\tecmac_as.paa";
uvSource = "tex";

class uvTransform {
	aside[] = {1, 0, 0};
	up[] = {0, 1, 0};
	dir[] = {0, 0, 0};
	pos[] = {0, 0, 0};
};
};

I'm not sure how the PR maps should work - I've not looked at an example of one in any of BIS' .pbos.

AFAIK you can't just have a single stage for your super shader though. I think you need at least a NOHQ and SMDI stage, even if they're only procedural.

As RH said, the AS map is usually at its most discernible in the presence of shadows cast by the Shadow LOD, so you might also need a shadow LOD before you can see the AS render properly.

Edited by da12thMonkey

Share this post


Link to post
Share on other sites

Can you show me how your ojbect is rendered with this as map ? and give me full rvmat for this ?

this is what i want to achieve : a simple lightmap that multiply over diffure/color texture... Pretty simple !

http://www.independentdeveloper.com/images/ambient-occlusion.jpg

I'll try to directly convert those textures into paa with right naming _PR, etc..

Maybe someone from BIS will see that thread and help me ? :p

---------- Post added at 09:28 ---------- Previous post was at 09:03 ----------

Sorry for double post but i manage to get it partially working now :p

first here is what it should like : its a render from maya :

http://farm4.staticflickr.com/3682/9526770715_43cf9c7447_c.jpg

And now, what i have in A3 :

http://farm6.staticflickr.com/5326/9546063146_5b78d4e9d1_c.jpg

http://farm8.staticflickr.com/7338/9543271761_b61177700d_c.jpg

http://farm8.staticflickr.com/7362/9546062842_7487abf4a2_c.jpg

http://farm8.staticflickr.com/7289/9543271567_24bee98355_c.jpg

And my rvmat now :

ambient[]={1,1,0.99999994,1};
diffuse[]={1,1,1,1};
forcedDiffuse[]={0,0,0,0};
emmisive[]={0,0,0,0};
specular[]={0,0,0,0};
specularPower=90;
PixelShaderID="NormalMapDetailSpecularDIMap";
VertexShaderID="NormalMap";
class Stage2
{
texture="EM_buildings\textures\building_03_PR.paa";
uvSource="tex1";
class uvTransform
{
	aside[]={1,0,0};
	up[]={0,1,0};
	dir[]={0,0,1};
	pos[]={0,0,0};
};
};

So my lightmap is showing up ingame, black is multiplied over the diffuse. But i got some srange artefact on one texture, seems like the lightmap is reversed only for this texture (the darker part of the building).

Edited by Emoglobinsky

Share this post


Link to post
Share on other sites

The object I had the AS map applied to looks like this in Buldozer (I've not put it in Arma 3 as it was designed as an Arma 2 addon):

http://downloads.rkslstudios.info/RKSL/da12th/WIP/ACRE/TECMAC_7.jpg

AS is in evidence around the edges of the side pouches and under the 3D compression straps, though I did also multiply the black+white AO texture onto my diffuse texture(_CO.paa) as well, with something like a 30-40% opacity (this is mainly in evidence on the part under the front straps).

Full .rvmat was as follows:

ambient[] = {1.0, 1.0, 1.0, 1.0};
diffuse[] = {1.0, 1.0, 1.0, 1.0};
forcedDiffuse[] = {0.0, 0.0, 0.0, 0.0};
emmisive[] = {0.0, 0.0, 0.0, 1.0};
specular[] = {1.0, 1.0, 1.0, 1.0};
specularPower = 56.0;
PixelShaderID = "Super";
VertexShaderID = "Super";

class Stage1 {
texture = "acre_m_bowman\data\tecmac_nohq.paa";
uvSource = "tex";

class uvTransform {
	aside[] = {1, 0, 0};
	up[] = {0, 1, 0};
	dir[] = {0, 0, 0};
	pos[] = {0, 0, 0};
};
};

class Stage2 {
texture = "#(argb,8,8,3)color(0.5,0.5,0.5,1,DT)";
uvSource = "tex";

class uvTransform {
	aside[] = {1, 0, 0};
	up[] = {0, 1, 0};
	dir[] = {0, 0, 0};
	pos[] = {0, 0, 0};
};
};

class Stage3 {
texture = "#(argb,8,8,3)color(0,0,0,0,MC)";
uvSource = "tex";

class uvTransform {
	aside[] = {1, 0, 0};
	up[] = {0, 1, 0};
	dir[] = {0, 0, 0};
	pos[] = {0, 0, 0};
};
};

class Stage4 {
texture = "acre_m_bowman\data\tecmac_as.paa";
uvSource = "tex";

class uvTransform {
	aside[] = {1, 0, 0};
	up[] = {0, 1, 0};
	dir[] = {0, 0, 0};
	pos[] = {0, 0, 0};
};
};

class Stage5 {
texture = "acre_m_bowman\data\tecmac_smdi.paa";
uvSource = "tex";

class uvTransform {
	aside[] = {1, 0, 0};
	up[] = {0, 1, 0};
	dir[] = {0, 0, 0};
	pos[] = {0, 0, 0};
};
};

class Stage6 {
texture = "#(ai,64,64,1)fresnel(1,0.7)";
uvSource = "none";
};

class Stage7 {
texture = "ca\data\env_land_co.paa";
uvSource = "tex";

class uvTransform {
	aside[] = {1.0, 0.0, 0.0};
	up[] = {0.0, 1.0, 0.0};
	dir[] = {0.0, 0.0, 0.0};
	pos[] = {0.0, 0.0, 0.0};
};
};

class StageTI {
texture = "ca\weapons_e\ammoboxes\data\backpacks_ti_ca.paa";
};

That's using super shader for the vertex and pixel shader and contains all the maps necessary for the Arma 2 super shader - _NOHQ.paa, DT (procedurally generated), MC (also procedural), _AS.pass, _SMDI.paa plus the fresnel, environment and TI stages. I based it on the .rvmat of a similar object in one of BIS' .pbos rather than writing it all from scratch in order to make sure I had all the appropriate stages to achieve a similar look to their model.

Edited by da12thMonkey

Share this post


Link to post
Share on other sites

I have the same result with your rvmat (but without all those maps thati don't have)...

Can you explain me what this means :

texture = "#(argb,8,8,3)color(0,0,0,0,MC)";

My render is altered when i change those settings, but no idea what each do.

Share this post


Link to post
Share on other sites

That's a procedurally generated Macro Texture stage. The colour settings color(0,0,0,0,MC), just mean it's plain black in all channels (including the alpha channel - so any _MC.paa using these values would actually be transparent). Being plain black means there's no actual detail in it, but I guess it needs to be there since all other shaders that use the AS stage also require a MC stage.

You'll notice that the procedural code has the same MC suffix that you would add to the _MC.paa if you did actually make a Macro Texture with image detail - like the texture naming conventions I pointed out earlier, this suffix is necessary to make the stage render as intended.

Not exactly sure what #(argb,8,8,3) means (obviously argb means alpha, red, blue, green, but not so clued up on that the 8,8,3 is). However, all single-colour procedurals you make in the O2's Face properties window or the Material Editor, start with #(argb,8,8,3) and only the color(r,g,b,a,suffix) settings change. I assume it 8,8,3 some sort of additional formatting code to generate the procedural algorithm - maybe different values create different patterns instead of solid colour.

I have the same result with your rvmat (but without all those maps thati don't have)...

I suggest you start adding all the material maps before you try seeing what the .rvmat looks like. Most of the shaders are dependant on having all the maps required in order to render properly.

If you don't have an SMDI use:

texture = "#(argb,8,8,3)color(1,0,1,1,SMDI)";

If you don't have a NOHQ use:

texture = "#(argb,8,8,3)color(0.5,0.5,1,1,NOHQ)";

...and so on to generate blank materials of the correct colour.

At least I think these are the correct codes to generate appropriate colours for blank SMDI and NOHQ maps

Edited by da12thMonkey

Share this post


Link to post
Share on other sites

I suggest you start adding all the material maps before you try seeing what the .rvmat looks like. Most of the shaders are dependant on having all the maps required in order to render properly.

Thx for the information about #argb stuff.

Now, i just think i have all my maps. I dont need normalmap or specular. So... All i have to have is my textures applied in O2 to faces, and a rvmat to multiply the lightmap. I dont know what you exactly suggesting about "material maps" :p

I'll try with those 2 lines later when i will able to use a3 ;)

---------- Post added at 15:47 ---------- Previous post was at 14:43 ----------

Yeahhhh, its working ! My lightmap is a bit darker, but just a matter of tweaks !

http://farm8.staticflickr.com/7326/9545531841_e66b1dcb55_h.jpg

http://farm4.staticflickr.com/3671/9545532229_a09a1b7f2b_h.jpg

http://farm8.staticflickr.com/7346/9548319578_f5663ba4d3_h.jpg

Thx a lot da12thMonkey

here is my rvmat, for info :

ambient[]={1,1,0.99999994,1};
diffuse[]={1,1,1,1};
forcedDiffuse[]={0,0,0,0};
emmisive[]={0,0,0,0};
specular[]={0.30000001,0.30000001,0.30000001,0};
specularPower=90;
PixelShaderID = "Super";
VertexShaderID = "Super";

class Stage1 {
texture = "#(argb,8,8,3)color(128,128,255,1,NOHQ)";
uvSource = "tex1";

class uvTransform {
	aside[] = {1, 0, 0};
	up[] = {0, 1, 0};
	dir[] = {0, 0, 0};
	pos[] = {0, 0, 0};
};
};

class Stage2 {
texture="EM_buildings\textures\building_03_PR.paa";
uvSource="tex1";
class uvTransform
{
	aside[]={1,0,0};
	up[]={0,1,0};
	dir[]={0,0,1};
	pos[]={0,0,0};
};
Filter="Linear";
};

class Stage3 {
texture = "#(argb,8,8,3)color(0,0,0,0,MC)";
uvSource = "tex";

class uvTransform {
	aside[] = {1, 0, 0};
	up[] = {0, 1, 0};
	dir[] = {0, 0, 0};
	pos[] = {0, 0, 0};
};
};

class Stage4 {
texture = "EM_buildings\textures\building_03_AS.paa";
uvSource="tex1";
class uvTransform
{
	aside[]={1,0,0};
	up[]={0,1,0};
	dir[]={0,0,1};
	pos[]={0,0,0};
};
};


class Stage5 {
texture = "#(argb,8,8,3)color(255,0,255,1,SMDI)";
uvSource = "tex1";

class uvTransform {
	aside[] = {1, 0, 0};
	up[] = {0, 1, 0};
	dir[] = {0, 0, 0};
	pos[] = {0, 0, 0};
};
};

class Stage6 {
texture = "#(ai,64,64,1)fresnel(0,0)";
uvSource = "none";
};

class Stage7 {
texture = "#(argb,8,8,3)color(0,0,0,0,CO)";
uvSource = "tex1";

class uvTransform {
	aside[] = {1.0, 0.0, 0.0};
	up[] = {0.0, 1.0, 0.0};
	dir[] = {0.0, 0.0, 0.0};
	pos[] = {0.0, 0.0, 0.0};
};
};

class StageTI {
texture = "#(argb,1,1,1)color(0,0,0,0,TI)";
};

Share this post


Link to post
Share on other sites

What does it look like at night? I'm curious what the effect that the _PR lightmap might have since I've never actually used one before. Looks good though, glad you got it sorted.

I dont know what you exactly suggesting about "material maps"

Well the .rvmat is the material file (RVMAT = Real Virtuality Material), so I call the various shader maps that are referenced by the .rvmat (normal map, specular map, ambient occlusion/shadow map etc.), "material maps".

I dont need normalmap

I reckon adding some normal map details for those air-conditioning units and the doors (both the roller door and the hinged one) will make them look much better up close if you can add one.

Share this post


Link to post
Share on other sites

I think you were alright to warry about lighting... I didnt test it with a sunset lighting :

http://farm6.staticflickr.com/5532/9545940461_40126ae4fd_z.jpg

Fucking engine, i have no idea why it's causing such thing... At night, this look like the same, those lines are enlighted and the rest is dark...

btw, here is my lightmap : white is for external parts, so it should multiply anything, and dark gray is for interior, full black is for occlusion.

http://uppix.net/X1AJAE.png

Share this post


Link to post
Share on other sites

From looking at it I assume anything over 50% grey is probably lit as though there is an additional, pre-rendered light source illuminating the those parts of the building, and it's not effected by a lack of other ambient light sources. I'd tweak the levels a bit to see if you can remove the illuminated parts

Otherwise, see how it looks with just the _AS map if you only need a lightmap for the shadows and not any other lighting effects.

Share this post


Link to post
Share on other sites

Found what was causing trouble, it was the NOHQ line, wrong color language i guess...

[color="#FF0000"]texture = "#(argb,8,8,3)color(128,128,255,1,NOHQ)";[/color]

[color="#008000"]texture = "#(argb,8,8,3)color(0.5,0.5,1,1,NOHQ)";[/color]

Here is a shot of 4 lighting settings, 6h, 12h, 17h and around 20h. Seems ok, i just need to upgrade the lightmap res and tweake some uvs...

9554676332_20fdf75a20_n.jpg

And 2 beauty shots !

9554676604_6e1f195dd9_n.jpg

9554676458_3d95e19934_n.jpg

Share this post


Link to post
Share on other sites

Oh aye, I forgot the colour codes values use Arithmetic notation (0 to 1) instead of 8-bit notation (0 to 255). The fact that I knew the Alpha channel is scaled 0 to 1 should have reminded me, but I could only remember the 8-bit RGB values off the top of my head having had to set them in photoshop many times. My apologies

In that case, the SMDI should be

texture = "#(argb,8,8,3)color(1,0,1,1,SMDI)";

... if you haven't amended it already.

I've edited the code in my previous post in case anyone else reads the thread in future and wants the correct values immediately.

Share this post


Link to post
Share on other sites

Alternately, you can set the green channel in your procedural smdi map to 1 and control the amount of specularity using the values in the rvmat. I believe that the values are multiplied per pixel, so if all pixels are 0, then no matter what you set the rvmat specularity to, the result will always be 0.

Share this post


Link to post
Share on other sites

Damn, it's a shame you lost those buildings... I seriously had this same idea about AS maps on another UVset, just haven't tried it yet. I can't believe you got it working!! This saves me loads of time, thank you guys! Emogoblinsky, I may PM you with a couple questions eventually if you don't mind. I've got a big building in the works I want to AS map.

Share this post


Link to post
Share on other sites

Sorry to dredge up an old thread from a year ago, but this thread is one of the only ones that discusses the rvmat for using ambient shadow maps for buildings.

I'm attempting to do the same, but all I get is pure black in areas where the shadow volume casts shadows on the interior of my building:

http://i.imgur.com/2w4r9PP.jpg (254 kB)

http://i.imgur.com/q4CVBAj.jpg (280 kB)

http://i.imgur.com/BXqmYQj.jpg (280 kB)

I'm using a repeatable linoleum texture and then have a baked AO 2048x2048 TGA texture:

http://i.imgur.com/QrCpC3J.jpg (149 kB)

As far as I have read, the AS map only utilizes the green channel? no alpha?

Here is the script in my rvmat:

ambient[] = {1.0, 1.0, 1.0, 1.0};
diffuse[] = {1.0, 1.0, 1.0, 1.0};
forcedDiffuse[] = {0.0, 0.0, 0.0, 0.0};
emmisive[] = {0.0, 0.0, 0.0, 1.0};
specular[] = {1.0, 1.0, 1.0, 1.0};
specularPower = 56.0;
PixelShaderID = "Super";
VertexShaderID = "Super";

class Stage1 {
 texture="#(argb,8,8,3)color(0.5,0.5,1,1,NOHQ)";
uvSource = "tex1";

class uvTransform {
	aside[] = {1, 0, 0};
	up[] = {0, 1, 0};
	dir[] = {0, 0, 0};
	pos[] = {0, 0, 0};
};
};

class Stage2 {
texture = "#(argb,8,8,3)color(0.5,0.5,0.5,1,DT)";
uvSource = "tex";

class uvTransform {
	aside[] = {1, 0, 0};
	up[] = {0, 1, 0};
	dir[] = {0, 0, 0};
	pos[] = {0, 0, 0};
};
};

class Stage3 {
texture = "#(argb,8,8,3)color(0,0,0,0,MC)";
uvSource = "tex1";

class uvTransform {
	aside[] = {1, 0, 0};
	up[] = {0, 1, 0};
	dir[] = {0, 0, 0};
	pos[] = {0, 0, 0};
};
};

class Stage4 {
 texture="vbs2\imms_biosim\structures\imms_biosim_bsl3_shadow\data\floor_grey_as.paa";
uvSource = "tex1";

class uvTransform {
	aside[] = {1, 0, 0};
	up[] = {0, 1, 0};
	dir[] = {0, 0, 0};
	pos[] = {0, 0, 0};
};
};

class Stage5 {
texture = "#(argb,8,8,3)color(1,0,1,1,SMDI";
uvSource = "tex1";

class uvTransform {
	aside[] = {1, 0, 0};
	up[] = {0, 1, 0};
	dir[] = {0, 0, 0};
	pos[] = {0, 0, 0};
};
};

class Stage6 {
texture = "#(ai,64,64,1)fresnel(1,0.7)";
uvSource = "none";
};

class Stage7 {
texture = "vbs2\data\env_land_co.paa";
uvSource = "tex";

class uvTransform {
	aside[] = {1.0, 0.0, 0.0};
	up[] = {0.0, 1.0, 0.0};
	dir[] = {0.0, 0.0, 0.0};
	pos[] = {0.0, 0.0, 0.0};
};
};

I'm not really sure what else to try. Any help would be excellent.

Share this post


Link to post
Share on other sites

green channel? No, red channel with the other ones usually white - so your map (in RGB) would look like a white-pink-ish nightmare.

Try converting your texture to .paa ; dont forget proper namesuffix ( _as ) to get the right conversion. Can't comment on the rvmat.

Share this post


Link to post
Share on other sites
green channel? No, red channel with the other ones usually white - so your map (in RGB) would look like a white-pink-ish nightmare..

if thats true then the bohemia community wiki is wrong:

https://community.bistudio.com/wiki/Super_shader

4. AmbientShadow map

Ambient shadow map _AS.

Ambient shadow texture contains stored information "how much ambient light is in given place'. White color means full ambient lighting. 0 means none.In fact only channel which is taken advantage of is G - it's thus important that information is correctly in him. Rest of channels doesn't matter and anything can be placed there (may be same as in G).

texture="#(argb,8,8,3)color(0,1,1,1)";

Placing white in both red and blue channels, and leaving the green Ambient Occlusion data in the green channel results in said pink nightmare which means that info is consistent:

http://i.imgur.com/jOYEehv.png (199 kB)

place that same data in red and fill green and blue results in a neon blue nightmare.

So, I do not think that was the issue. Also in my rvmat, I've already pointed to my .paa files converted with addon packer. I've also tried using textview to convert. both yield same end result of deep shadows that are pitch black and no apparent result of an ambient shadow "ambient occlusion" effect.

Any other ideas that I can try? anyone have experience using rvmats in VBS3?

I realize this is an arma forum, but the documentation for vbs3 is horrendous. Is even using the super shader in VBS3 possible?

If not is there another way to accomplish an AS map for VBS3?

Edited by eyssix

Share this post


Link to post
Share on other sites

The AS texture you have linked has a lot of solid pink, and the super shader is doing exactly what you are telling it to do, having the solid pink color, results in 100% occlusion when it crosses with the rendered shadow volume *too my understanding*.

You need to tone down the amount of solid pink, there should be a lot more white, with gradients of mid tones. I have uploaded a sample that is actually of a pistol, but you should get the idea, majority of the faces image is white. I would suggest that you need to mess around with the settings for the AO render, or modify it in Photoshop to tone down the levels until you get something that is similar to your expectations.

http://imgur.com/IYZvcPi

Share this post


Link to post
Share on other sites
The AS texture you have linked has a lot of solid pink, and the super shader is doing exactly what you are telling it to do, having the solid pink color, results in 100% occlusion when it crosses with the rendered shadow volume *too my understanding*.

I'll give this a try tomorrow once I'm in the office. I had my suspicions, but I figured it shouldnt end up entirely black. We'll see if I can get any results by toning down my ao pass.

Thanks for the help! I'll post again with some test results.

Share this post


Link to post
Share on other sites
I'll give this a try tomorrow once I'm in the office. I had my suspicions, but I figured it shouldnt end up entirely black. We'll see if I can get any results by toning down my ao pass.

Thanks for the help! I'll post again with some test results.

No problem, i had troubles figuring it out myself, not even sure i know what i think is correct, my first use of the AS maps was on a building object and i had all sorts of troubles with it going completly black, so i simply went into photoshop, took the Black/White AO texture and messed around with the Levels (Ctrl + L), then applied multiple blur and noise filters, and then placed a Gradient Overlay in the Layer panel to convert the black to the required pink.

Share this post


Link to post
Share on other sites

I would first look at your lods. Ensure that your visual lods are not producing a shadow, secondly ensure you have correctly setup a shadow lod. Then move onto as map.

Share this post


Link to post
Share on other sites
I would first look at your lods. Ensure that your visual lods are not producing a shadow, secondly ensure you have correctly setup a shadow lod. Then move onto as map.

good call, I know that my shadow lod is working as expected, but I think I need to check my visual lod render settings in oxygen.

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  

×