Jump to content

Contribution : metal shader for LE3


YouGroove
 Share

Recommended Posts

Modifying normal map shader and copying code from environment-alpha shader from downloads section , i made some metal shader like for LE3.

--------------------------------------

 

New Update :

New version with shaders for both static and animated models.

Shaders pack is available in Steam Workshop.

 

 

PBR.jpg

 

Download link :

http://www.leadwerks.com/werkspace/files/file/578-pbr-shader-effect/

  • Upvote 3

Stop toying and make games

Link to comment
Share on other sites

Better game model example from Substance in LE3 with Light intensity variation :

Low

Llow.jpg

 

Medium

Llow2.jpg

 

Stronger

Llow3.jpg

 

Very strong

Llow5.jpg

 

Over exposed

Llow7.jpg

 

Looks better in motion indeed.

 

This is not a real metal shader but some trick that do a really good job, so to change color of metal you'll have to play with the level of metal reflection (alpha of diffuse) , the less reflective the more you'll have your diffuse colors appearing. And also play or change the skycube bitmap with different color and intensity.

  • Upvote 1

Stop toying and make games

Link to comment
Share on other sites

The shader (feel free to modify or improve them)

It will enhance your metallic assets like Robots, vehicles , metal or Sci fi structures , weapons, space ships and any metallic objects.

 

Set up of the shader :

texture_slot.jpg

 

Diffuse map -> alpha settings

alpha.jpg

 

If some shader guru could invert the effect of the alpha it could be lot more logic and better : more alpha for more reflection and less texture colors showing.

 

If someone need it, i can show some Gimp2 use to get Specular fast and some ways to easy make the Alpha channel on diffuse. For the example model above if you can download it from Substance site , i can provide the Maps i made for you to test.

MetalShader.zip

  • Upvote 1

Stop toying and make games

Link to comment
Share on other sites

Thanks Shadmar.

It's based on your previous work wink.png (http://www.leadwerks.com/werkspace/files/file/531-environment-alpha/)

Some questions for you :

- How to invert alpha effect (multiply by -1 ?) to have more transparent = more reflection instead

 

Actually when reflection is strong we loose all diffuse color map, the skymap reflection totally replacing it, this is very good for full silver metal materials, but in some cases we could need some color painted metal to keep it's color even on full reflective metal parts. So here is some propositions :

- Uniform colored metal reflection : color multiply the skycube in the shader by a color constant (White for silver, yellow for gold etc ...)

- Actually the shader works with blending replacing diffuse by skycube depending on alpha; so another solution could be : Skycube reflection result on shader multiplied by diffuse map color ( ) ; this way the skycube would keep difffuse map colors as base even at full reflection effect.

Do you think it could work ?

(Actually we can modify the skymap colors to change the reflective effect, but that's not so great result).

Stop toying and make games

Link to comment
Share on other sites

It's more easy to work on alpha with channel inverted now.

 

alpha_Value7.jpg

 

Playing with shader alpha values also make different effects

 

Full metal

alpha_Value.jpg

 

Strong metal

alpha_Value2.jpg

 

Soft metal

 

alpha_Value4.jpg

 

Strong colors

alpha_Value_Two_Pass.jpg

 

alpha_Value_Two_Passcolors.jpg

 

We have blending :

outcolor = mix(outcolor,texture(texture4,cubecoord) * 1.5 , 1-outcolor.a );

 

Is there a way to have the color or multiply modes on blending like painting programs ?

 

Last shader version with new inverted Alpha : more alpha = more reflection, more opaque colors = less reflection and more texture opacity.

diffNorSpecMetal2.zip

Stop toying and make games

Link to comment
Share on other sites

  • 5 months later...

I have made some modifications to the shader in this topic to work with the output from Substance Painter. To use it just export the Unity 4 Diffuse with Gloss map along with the nrmal and height map. To get the full bump you will need ot convert the height to a normal map and then combine the height map normal with the existing normal map. Everything else is the same as above.

 

Here is an example:

 

Substance

substance.png

 

Leadwerks

leadwerks.png

 

You can download the updated shader here:

  • Upvote 4
Link to comment
Share on other sites

  • 2 weeks later...

Nice.

Can you explain what textures are needed in what slots of material editor ?

I tried but metal don't show up ?

 

At the very least you will need the following:

A color/diffuse in the diffuse slot 0 (Note: This needs to have an alpha channel where the more opaque the more metalness or shiny it will be)

A normal map in the normal slot 1

A specular map in the specular slot 2 (optional)

A skybox testure in slot 4

 

Hope that helps.

Link to comment
Share on other sites

Thanks, in fact it's same shader as mine almost.

I eported diffuse with roughtness as alpha (Unity4 gloss format), i put DXT5n for diffuse, but the shader remains black ?

fail.jpg

 

I uploaded the diffuse (+gloss in alpha) and normal map in case you would have some time to make a test.

export.zip

Stop toying and make games

Link to comment
Share on other sites

I will have a look either tonight or tomorrow morning when I get a few moments. In the meantime you could try setting the vertex color to white for your model. That may resolve your issue. If so I will see what I can do about the shader to resolve that.

 

Note: Please also try using the shader on a Leadwerks editor model,

 

Todd

Link to comment
Share on other sites

Why vertex ? Does your shader use vertex colors ?

It takes into effect vertex alpha in conjunction with the material diffuse color, but not the actual vertex colors. So... For it not to show up as black you will need to have something other than black as the diffuse color. As well it uses the specular for brightness so if your spec color in the material is black it will show as black.

You mean BSP ? The model i use is imported in LE and displaying fine if i use other standard shaders.

Sorry, at one point in my testing i used an external model and it was black until I changed the vertex colors. I noticed this initially as the BSP worked. That was fixe din the final shader though so vertex colors should have no effect, but as above the material diffuse and specular do. The reason for the specular is so that you don't need to change value sin the shader itself as the spec is used.

  • Upvote 1
Link to comment
Share on other sites

It's radeon on the 6700 HD series ( i run many today games even Unreal 4 and all shaders and effects).

So it works on your models , you mean it displays ok in LE3 editor 3D viewport applying it on models , not BSP.

I'll upload some model if you have some time to test ( but they are pretty standard FBX).

Stop toying and make games

Link to comment
Share on other sites

  • 2 weeks later...

Metal shader is broken, perhaps LE3 had many changes this year with shaders that could have impacted it ?

The skybox is not rendered on reflective parts , instead it's black.

 

metal_Shader.jpg

 

I'll try to fix it, or find if it is possible to make a new one ?

Stop toying and make games

Link to comment
Share on other sites

My bad, i read the shader and skybox texture must be in slot 4 huh.png , so the shader still works as expected.

reflective.jpg

 

What would be perfect would be to be able to colorize reflective parts with diffuse color ?

 

The ideal would be to succed having the reflective parts to be colorized by the diffuse color and using a metal And Control reflectivity using a metal map (black and white variations instead of alpha that complicates workflow)

Stop toying and make games

Link to comment
Share on other sites

Using TodGrayson shader smile.png

Substance Painter exporting Unity 4 format : Diffuse with roughness on alpha

Now the reflective parts gets colorized, it's lot more better.

 

colorized.jpg

 

But some non reflective parts are reflecftive ,so it will need manual alpha adjustements on the diffuse.

Stop toying and make games

Link to comment
Share on other sites

I modified the shader to work with a roughness map instead of using alpha channel that was hard visualize and tweak manually.

Now the rough parts stay not reflective in LE3, while metallic becomes reflective.

shader.jpg

 

The shader need some tweaks on reflection colors , but it is near to be really good for a standard shader trying some metallic PBR imitation.

 

 


//Uniforms
uniform sampler2D texture0;//diffuse map
uniform sampler2D texture1;//normal map
uniform sampler2D texture2;//specular map
uniform sampler2D texture3;//roughness map
...

//Roughness
   vec4 color_rought = texture(texture3,ex_texcoords0) ;
.....

outcolor =   mix( outcolor,   ( texture(texture4,cubecoord) *  color_rought   )  ,color_rought   )	  ;

Stop toying and make games

Link to comment
Share on other sites

Last iteration shader with texture maps :

- Diffuse

- normal

- specular

- metallic

 

You control roughness using standard specular map , while you indicate reflectivity using a metallic map

Only one thing i can't figure out how to do it is the ability to colorize the reflective part with color from the diffuse map.

shader3.jpg

  • Upvote 1

Stop toying and make games

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...