Emmanuel BENOîT
68d01ca42e
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.
23 lines
548 B
GLSL
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 );
|
|
}
|