Jump to content

How to make an Opacity Map function?


Argorius
 Share

Recommended Posts

I got some assets from Dexsoft and am trying to get them ready for use in the 2.30 Editor. However, some of these assets have opaque maps and I can't get them to show up properly. There is one that has a diffuse map, normal map, specular, and an opaque map.

 

In the mat file I usually do the following:

 

texture0="abstract::fishnet1_diff.dds"
texture1="abstract::fishnet1_nmap.dds"
texture3="abstract::fishnet1_spec.dds"

blend=0
depthmask=1
overlay=0
zsort=0
cullface=1
castshadows=1
specular=3.33333
gloss=0.0
bumpscale=0.3
shader="abstract::mesh_diffuse.vert","abstract::mesh_diffuse_bumpmap_specular.frag"
shadowshader="abstract::mesh_shadow.vert" 

 

What do I have to write if I have an opaque map involved?

 

on a more general note...is there some documentation that allows me to make sense of what texture 0, 1, 3, etc. is? And what type of maps belong to which texture? I am doing this mostly by trial and error but I dont understand what I am actually doing...or is someone could explain this or point me to some cool link - I'd appreciate it!

 

Thanks!

Windows XP Home Edition Service Pack 3/ Intel Q9450 @ 2.67GHz / 3.5GB DDR3 SDRAM / GeForce 8800 GTS 512

Link to comment
Share on other sites

"abstract::mesh_diffuse_bumpmap_specular.frag"

 

try to set the blend value higher. 2 or 4 might do the trick.

 

tex1 = the diffuse color

tex2 = the normal mapping (bump map)

tex3 = specular map (for glossines, making it more shiny)

 

He is using "..specular.frag" not "..specularmap.frag. In "..specular.frag" the specular is set by the bumpmap's alpha multiplied by the specular value you set in the material file.

 

if he used the specularmap.frag, then it looks like its handled by texture2, where the diffuse is texture0 and the bumpmap is texture1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

For opacity you'll have to use one of the alpha shaders I believe. The best reference as to what to pass where is the shaders themselves. You can rename shaders.pak to shaders.zip and extract them to look at the .frag files and see what is used for what.

Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX

ZBrush - Blender

Link to comment
Share on other sites

Hmm, you're right. I only see .a in a couple of places....are the places it's at working properly? I remember someone saying that specular wasn't working for them somewhere, I suppose that could be a reason if they're not interchangeable. Really not sure.

Windows 7 x64 - Q6700 @ 2.66GHz - 4GB RAM - 8800 GTX

ZBrush - Blender

Link to comment
Share on other sites

Ok guys, I asked Argorious when he PMed me with the question to post here, so since I understand what he is asking, here is the full explanation on how to do this:

 

At lines 14- 20 in mesh.frag:

#ifdef LW_DIFFUSE
uniform sampler2D LW_DIFFUSE;
#endif

#ifdef LW_SPECULARMAP
uniform sampler2D LW_SPECULARMAP;
#endif

 

Add code to make it look like this:

#ifdef LW_DIFFUSE
uniform sampler2D LW_DIFFUSE;
#endif

#ifdef LW_OPACITYMAP
uniform sampler2D LW_OPACITYMAP;
#endif

#ifdef LW_SPECULARMAP
uniform sampler2D LW_SPECULARMAP;
#endif

 

At lines 102 - 104 in mesh.frag:

#ifdef LW_DIFFUSE
	diffuse *= texture2D(LW_DIFFUSE,texcoord);//*fOcclusionShadow;
#endif

 

Add a line to make it this:

#ifdef LW_DIFFUSE
	diffuse *= texture2D(LW_DIFFUSE,texcoord);//*fOcclusionShadow;
	diffuse.w *= texture2D(LW_OPACITYMAP,texcoord).r; // Assuming you map an opacity map properly, the RGB values will all be the same.
#endif

 

Now, in any of the mesh_x_y_z.frag shaders:

#define LW_OPACITYMAP texture4

 

In your .mat file:

texture4="abstract:myopacitymap.dds"

 

And to get the proper alpha blending:

blend=1

 

This is what we use in Jeklynn Heights to get transparent windows with glow.

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

On the note of the rgba, xyzw stuff:

 

In GLSL, if you read the specification, the following values are all interchangeable:

 

rgba -> xyzw -> uvst

 

.r = .x = .u

.g = .y = .v

.b = .z = .s

.a = .w = .t

 

They are just all there to make it obvious what that vector variable is (color, vector, texture coord respectively).

 

You can also do other things, like .rr, .xyxz, .yyyy, .wwst, .argb, .bgra, .uvzw

 

They can be combined and interchanged at no cost, and even reordered like I showed.

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

Thanks so much - that was a real helpful discussion in general for me - it made me realize a lot of things about the different maps and shaders!

 

One of the proposed solutions by Aggror actually worked too - not sure if it made it as good as it could but using the shader he suggested with no blending and only the diff texture made the model as it should look (I think). Here is what I changed it too and this worked:

 


texture0="abstract::fishnet1_diff.dds"
blend=0
depthmask=1
overlay=0
zsort=0
cullface=0
castshadows=1
specular=0
gloss=0.05
bumpscale=0.3
shader="abstract::mesh_diffuse.vert","abstract::mesh_diffuse_alphatest.frag"
shadowshader="abstract::mesh_shadow.vert"

 

I am going to have to try Tyler's approach next - thanks for answering this!

Windows XP Home Edition Service Pack 3/ Intel Q9450 @ 2.67GHz / 3.5GB DDR3 SDRAM / GeForce 8800 GTS 512

Link to comment
Share on other sites

Alpha test just discards pixels if the alpha of the diffuse map is < 0.3.

 

I was coming from the approach if you wanted to store your alpha map in an entirely separate file (i.e. the definition of opacity map).

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

Alpha test just discards pixels if the alpha of the diffuse map is < 0.3.

 

I was coming from the approach if you wanted to store your alpha map in an entirely separate file (i.e. the definition of opacity map).

 

thanks for the rgba->xyzw explanation... appreciate it. seems like using a consistent referencing tho inside LE shaders would be preferable... but :(

 

and i think its less than 0.5...

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...