demotool/test/lib/shading-blinnphong.glsl
Emmanuel BENOîT 68d01ca42e Shaders - Relative paths
Shaders are no longer found under /shaders in the project; they can be
anywhere. In addition, paths for both (program) instructions in the
script and include directives in shader source code are relative to the
file which contains them.
2017-12-29 11:33:15 +01:00

23 lines
548 B
GLSL

//! type library
struct T_BPMaterial
{
vec3 cAlbedo, cSpecular;
float specPower , ambient;
};
vec3 BP_Shade(
in T_BPMaterial material ,
in vec3 rayDir ,
in vec3 normal ,
in vec3 lightDir )
{
const vec3 halfVec = normalize( rayDir + lightDir );
const float nDotL = dot( normal , lightDir ) ,
nDotH = dot( normal , halfVec ) ,
si = pow( clamp( nDotH , 0 , 1 ) , material.specPower ) ,
di = material.ambient + ( 1 - material.ambient )
* clamp( nDotL , 0 , 1 );
return mix( material.cAlbedo * di , material.cSpecular , si );
}