Jump to content
  • Advertisement
Sign in to follow this  

PBR Shader

This topic is 917 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

After many weeks of reading about this I coded a glsl shader with bkcore editor (I use the chrome extension. the site seems to be down).
Can I have comments on this? I plan to make a huge uber shader and framework out of it. Here's the code I used for the fragment shader.
I used the next link for different brdf terms: http://graphicrants.blogspot.co.il/2013/08/specular-brdf-reference.html
Particular questions:
1. Cspec is F0, right?
2. Do metals have a diffuse color of vec3(0)?
3. What's a good roughness parameter for metals and non-metals?
4. Is the BRDF block okay?
vec3 F = Fresnel_Schlick(dot(v,h), Cspec);
float D = GGX_NDF(roughness2, n, h);
float G = Geo_Implicit(l,v,n);
vec3 Eterm = E * dot(l,n);

//cook-torrance spec
Lo = ( (F * D * G) / (4.0 * dot(n,l) * dot(n,v)) ) * Eterm;
//lambert diffuse
Lo += (Cdiff / PI) * Eterm;
Edited by Pilpel

Share this post

Link to post
Share on other sites

Metals do not diffuse light. All metals and plastics have roughness from 0 to 100%. There is no good # , just one that matches the surface you are trying to mimic.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!