PBS materials, creating glass

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


User avatar
GlowingPotato
Goblin
Posts: 211
Joined: Wed May 08, 2013 2:58 pm
x 10

PBS materials, creating glass

Post by GlowingPotato »

Hi,

Iam trying to create some glass bottles, like wine bottles.

The transparent material is working, but I can't put a label or a detail map on it without multiplying by the diffuse color.

What i'am trying to do:

Create a transparent material.
Use the RGB diffuse color as the bottle color.
use detail map for dust/labels.

I fail at the detail map, the moment I connect the map, my bottle turns very, very dark, and the detail get multiplied by the diffuse color of the bottle.

Below, there are some images of the steps above using spookyboo HLMS Editor.

Image
Just a transparent green bottle, as you can see, I turned OFF Use alpha from textures because if I don't, when I connect the detail map, the diffuse color won't affect the glass, just the detail map. The idea is to use the diffuse color to get the glass color, so I can make a lot of different bottles without the use of textures.

Then, I connect the detail map, basically a cloud noise with transparency. You can see that the bottle turns almost black.
Image

Then, just for showing what is going on, I set the detail map weight to 5.
Image


Is this behavior expected? I don't actually see many people in here messing around with detail maps and transparency.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5550
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1402

Re: PBS materials, creating glass

Post by dark_sylinc »

Can we see both textures?
User avatar
GlowingPotato
Goblin
Posts: 211
Joined: Wed May 08, 2013 2:58 pm
x 10

Re: PBS materials, creating glass

Post by GlowingPotato »

dark_sylinc wrote:Can we see both textures?
Sure! by both textures you mean cube map and the detail map used?

here ->> https://www.dropbox.com/s/f1n0ohfgpg65c ... es.7z?dl=0
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5550
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1402

Re: PBS materials, creating glass

Post by dark_sylinc »

Without the full thing (mesh + texture + JSON material), I'll take a guess:

Darkening should be expected, but only in the regions where the scratches are strong. However I suspect your UVs are causing a lot of wrap (or very little) so in the end we actually may end up seeing the colour of one pixel (or a few) from your texture which happens do darken the whole thing.

Have you tried using the texture as a diffuse texture. Detail maps were meant to be applied on top of diffuse textures. You'll be burning a few extra GPU cycles by using the detail map as a diffuse map; and the behavior of the alpha mask is more predictable/controllable for diffuse.
GlowingPotato wrote:Just a transparent green bottle, as you can see, I turned OFF Use alpha from textures because if I don't, when I connect the detail map, the diffuse color won't affect the glass, just the detail map. The idea is to use the diffuse color to get the glass color, so I can make a lot of different bottles without the use of textures.
Enable alpha from textures, but set transparency to 1.0. Otherwise the alpha from the texture gets multiplied against your transparency value, causing a much stronger transparency than what you intend. Or just leave it turned off if there is not much visual difference (performance optimization)
User avatar
GlowingPotato
Goblin
Posts: 211
Joined: Wed May 08, 2013 2:58 pm
x 10

Re: PBS materials, creating glass

Post by GlowingPotato »

dark_sylinc wrote:Without the full thing (mesh + texture + JSON material), I'll take a guess:

Darkening should be expected, but only in the regions where the scratches are strong. However I suspect your UVs are causing a lot of wrap (or very little) so in the end we actually may end up seeing the colour of one pixel (or a few) from your texture which happens do darken the whole thing.

Have you tried using the texture as a diffuse texture. Detail maps were meant to be applied on top of diffuse textures. You'll be burning a few extra GPU cycles by using the detail map as a diffuse map; and the behavior of the alpha mask is more predictable/controllable for diffuse.
Yes, my uvs are indeed warped, but is not that much to cause the issue you said.

the mesh is here https://www.dropbox.com/s/l7v4fkbutg1fd ... .mesh?dl=0

and about the JSON, is not that really fancy, it is just what you can see in the images above.
Using a texture for the diffuse, is what want to avoid, we already have a lot of VRAM in use. The idea is to use the diffuse RGB color to color de glass.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5550
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1402

Re: PBS materials, creating glass

Post by dark_sylinc »

GlowingPotato wrote:Using a texture for the diffuse, is what want to avoid, we already have a lot of VRAM in use. The idea is to use the diffuse RGB color to color de glass.
No, I mean literally applying glass_DIFFA.tga in the diffuse slot instead of the detail map slot. It will still respect the green RGB you apply.
User avatar
GlowingPotato
Goblin
Posts: 211
Joined: Wed May 08, 2013 2:58 pm
x 10

Re: PBS materials, creating glass

Post by GlowingPotato »

But then, my texture will get multiplied by the green color, or any color I choose.
The idea is to have something on the surface of the glass, like labels or dust.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5550
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1402

Re: PBS materials, creating glass

Post by dark_sylinc »

Yes. I realized this morning it was a stupid suggestion.
Send me via pm the mesh and json material so I can take a look (I already have the textures). If possible in .blend format.
User avatar
GlowingPotato
Goblin
Posts: 211
Joined: Wed May 08, 2013 2:58 pm
x 10

Re: PBS materials, creating glass

Post by GlowingPotato »

I've sent you a PM.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5550
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1402

Re: PBS materials, creating glass

Post by dark_sylinc »

This is now fixed thanks to Scorg's PR.

Use "background" : [0, 1, 0, 1] to set a solid green colour (or in code, setBackgroundDiffuse). The traditional diffuse colour will tint over the final result, while background colour replaces diffuse textures (when not present) with a solid colour.

Cheers
Matias