User Tools

Site Tools


specular_lys

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
specular_lys [2017/05/07 20:39]
adavies
specular_lys [2017/05/23 03:49] (current)
Line 46: Line 46:
 ---- ----
  
 +
 +==== Image Based Lighting Sample Shader ====
 +
 +In the following we describe how to use cube maps generated with Lys in a shader for image based lighting. We also provide a free, complete IBL sample shader & associated source files.
 +
 +Please see the [[ibl_sample_shader_lys|Image Based Lighting Sample Shader]] page for more details.
  
 ==== Computing MIP Levels From Specular Power/​Roughness ==== ==== Computing MIP Levels From Specular Power/​Roughness ====
Line 125: Line 131:
 The top MIP level will always be used for a 100% sharp reflection (roughness 0.0) and the offset from the bottom MIP level specified using “MIP Offset” in the specular group determines where we have 100% blurriness (roughness 1.0). The default offset of 3 corresponds to MIP level 8x8. Checking “Coarse Irradiance” in the 3D Preview will enable using the MIP level at your chosen offset for diffuse lighting in the viewport. The top MIP level will always be used for a 100% sharp reflection (roughness 0.0) and the offset from the bottom MIP level specified using “MIP Offset” in the specular group determines where we have 100% blurriness (roughness 1.0). The default offset of 3 corresponds to MIP level 8x8. Checking “Coarse Irradiance” in the 3D Preview will enable using the MIP level at your chosen offset for diffuse lighting in the viewport.
  
-Note that our implementation of BurleyToMip() below differs from the more typical form as cube maps convolved in Lys are based on RdotL and not NdotH. You can find a more detailed description in [[specular_lys_new#​pre-convolved_cube_maps_vs_path_tracers|Pre-convolved Cube Maps vs Path Tracers]].+Note that our implementation of BurleyToMip() below differs from the more typical form as cube maps convolved in Lys are based on RdotL and not NdotH. You can find a more detailed description in [[specular_lys#​pre-convolved_cube_maps_vs_path_tracers|Pre-convolved Cube Maps vs Path Tracers]]
 + 
 +Despite the difference in distribution of MIPs the lit specular response resulting from the “roughness texture” will be identical to existing PBR based game engines and tools.
  
 <code glsl>​float BurleyToMip(float fPerceptualRoughness,​ int nMips, float NdotR) <code glsl>​float BurleyToMip(float fPerceptualRoughness,​ int nMips, float NdotR)
Line 136: Line 144:
 </​code>​ </​code>​
  
-As we can see this implementation has an intermediate step which is explained in section "[[specular_lys_new#​pre-convolved_cube_maps_vs_path_tracers|Pre-convolved Cube Maps vs Path Tracers]]"​.+As we can see this implementation has an intermediate step which is explained in section "[[specular_lys#​pre-convolved_cube_maps_vs_path_tracers|Pre-convolved Cube Maps vs Path Tracers]]"​.
 If this is considered too expensive then a cheaper close alternative is to use the following replacement. If this is considered too expensive then a cheaper close alternative is to use the following replacement.
  
Line 249: Line 257:
 [{{https://​s3.amazonaws.com/​docs.knaldtech.com/​docuwiki/​reflected_beam_new.png?​nolink&​1075 |The view direction v reflected by dH will result in dR. Given the existing symmetry the central direction r of dR will result in dV when reflected by dH.}}] [{{https://​s3.amazonaws.com/​docs.knaldtech.com/​docuwiki/​reflected_beam_new.png?​nolink&​1075 |The view direction v reflected by dH will result in dR. Given the existing symmetry the central direction r of dR will result in dV when reflected by dH.}}]
  
 +\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ 
  
- +\\ \\ As an approximation we can correlate size of solid angle with "blur strength"​and replace ''​h_dot_r''​ with ''​n_dot_r''​. So ultimately what we do is adjust our specular power in the following way:
-\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ +
- +
-As an approximation we can correlate size of solid angle with "blur strength"​and replace ''​h_dot_r''​ with ''​n_dot_r''​. So ultimately what we do is adjust our specular power in the following way:+
  
 <code glsl>​fSpecPow /= (4*max(dot(vN,​ vR), FLT_EPSILON));</​code>​ <code glsl>​fSpecPow /= (4*max(dot(vN,​ vR), FLT_EPSILON));</​code>​
- 
- 
- 
  
 This works because the specular power is roughly inversely proportional to the amount of blur. This works because the specular power is roughly inversely proportional to the amount of blur.
- 
- 
  
 Note we perform this correction inside the functions GetSpecPowToMip() and BurleyToMip() given above. This adjustment is of course just for the cube maps and should NOT be applied to the specular power used with ordinary lights since for these we simply use an n_dot_h based formulation as opposed to l_dot_r. Note we perform this correction inside the functions GetSpecPowToMip() and BurleyToMip() given above. This adjustment is of course just for the cube maps and should NOT be applied to the specular power used with ordinary lights since for these we simply use an n_dot_h based formulation as opposed to l_dot_r.
specular_lys.1494189580.txt.gz · Last modified: 2017/05/23 03:49 (external edit)