GLSLによるフォンシェーディング
をテンプレートにして作成
[
トップ
|
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
----
#contents
----
#ref(eq_Is.gif)
#ref(reflection.gif)
#ref(eq_Phong.gif)
#ref(eq_R.gif)
#ref(eq_BlinnPhong.gif)
#ref(eq_H.gif)
#ref(eq_Blinn.gif)
#ref(eq_G.gif)
#ref(eq_F1.gif)
#ref(eq_F2.gif)
#ref(eq_CookTorrance.gif)
#code(C){{
/*!
@file phong.vs
@author Makoto Fujisawa
@date 2011
*/
#version 120
varying vec3 vPos;
varying vec3 vNrm;
void main(void)
{
vPos = (gl_ModelViewMatrix*gl_Vertex).xyz;
vNrm = gl_NormalMatrix*gl_Normal;
gl_Position = ftransform();
}
}}
#code(C){{
/*!
@file phong.fs
@author Makoto Fujisawa
@date 2011
*/
#version 120
varying vec3 vPos;
varying vec3 vNrm;
void main(void)
{
float shine = gl_FrontMaterial.shininess;
vec3 emissive = Ke;
vec3 ambient = Ka*La; // gl_FrontLightProduct[0].ambent...
float diffuseLight = max(dot(L, N), 0.0);
vec3 diffuse = Kd*Ld*diffuseLight;
vec3 specular = vec3(0.0);
if(diffuseLight > 0.0){
//vec3 R = reflect(-L, N);
//float specularLight = pow(max(dot(R, N), 0.0), shine);
vec3 H = normalize(L+V);
float specularLight = pow(max(dot(H, N), 0.0), shine);
specular = Ks*Ls*specularLight;
}
gl_FragColor.xyz = emissive+ambient+diffuse+specular;
gl_FragColor.w = 1.0;
}
}}
#code(C){{
/*!
@file cook_torrance.fs
@author Makoto Fujisawa
@date 2011
*/
#version 120
uniform float m;
uniform float refrac;
varying vec3 vPos;
varying vec3 vNrm;
void main(void)
{
float shine = gl_FrontMaterial.shininess;
vec3 emissive = Ke;
vec3 ambient = Ka*La; // gl_FrontLightProduct[0].ambent...
float diffuseLight = max(dot(L, N), 0.0);
vec3 diffuse = Kd*Ld*diffuseLight;
vec3 specular = vec3(0.0);
if(diffuseLight > 0.0){
float NH = dot(N, H);
float VH = dot(V, H);
float NV = dot(N, V);
float NL = dot(N, L);
float alpha = acos(NH);
float D = (1.0/(4*m*m*NH*NH*NH*NH))*exp((NH*NH-1)/(m*m*...
float G = min(1, min((2*NH*NV)/VH, (2*NH*NL)/VH));
float c = VH;
float g = sqrt(refrac*refrac+c*c-1);
float F = ((g-c)*(g-c)/((g+c)*(g+c)))*(1+(c*(g+c)-1)*(c...
float specularLight = D*G*F/NV;
specular = Ks*Ls*specularLight;
}
gl_FragColor.xyz = emissive+ambient+diffuse+specular;
gl_FragColor.w = 1.0;
}
}}
&ref(gouraud_shading_1.jpg); &ref(phong_shading_1.jpg); &...
#ref(glsl_phong.zip)
終了行:
----
#contents
----
#ref(eq_Is.gif)
#ref(reflection.gif)
#ref(eq_Phong.gif)
#ref(eq_R.gif)
#ref(eq_BlinnPhong.gif)
#ref(eq_H.gif)
#ref(eq_Blinn.gif)
#ref(eq_G.gif)
#ref(eq_F1.gif)
#ref(eq_F2.gif)
#ref(eq_CookTorrance.gif)
#code(C){{
/*!
@file phong.vs
@author Makoto Fujisawa
@date 2011
*/
#version 120
varying vec3 vPos;
varying vec3 vNrm;
void main(void)
{
vPos = (gl_ModelViewMatrix*gl_Vertex).xyz;
vNrm = gl_NormalMatrix*gl_Normal;
gl_Position = ftransform();
}
}}
#code(C){{
/*!
@file phong.fs
@author Makoto Fujisawa
@date 2011
*/
#version 120
varying vec3 vPos;
varying vec3 vNrm;
void main(void)
{
float shine = gl_FrontMaterial.shininess;
vec3 emissive = Ke;
vec3 ambient = Ka*La; // gl_FrontLightProduct[0].ambent...
float diffuseLight = max(dot(L, N), 0.0);
vec3 diffuse = Kd*Ld*diffuseLight;
vec3 specular = vec3(0.0);
if(diffuseLight > 0.0){
//vec3 R = reflect(-L, N);
//float specularLight = pow(max(dot(R, N), 0.0), shine);
vec3 H = normalize(L+V);
float specularLight = pow(max(dot(H, N), 0.0), shine);
specular = Ks*Ls*specularLight;
}
gl_FragColor.xyz = emissive+ambient+diffuse+specular;
gl_FragColor.w = 1.0;
}
}}
#code(C){{
/*!
@file cook_torrance.fs
@author Makoto Fujisawa
@date 2011
*/
#version 120
uniform float m;
uniform float refrac;
varying vec3 vPos;
varying vec3 vNrm;
void main(void)
{
float shine = gl_FrontMaterial.shininess;
vec3 emissive = Ke;
vec3 ambient = Ka*La; // gl_FrontLightProduct[0].ambent...
float diffuseLight = max(dot(L, N), 0.0);
vec3 diffuse = Kd*Ld*diffuseLight;
vec3 specular = vec3(0.0);
if(diffuseLight > 0.0){
float NH = dot(N, H);
float VH = dot(V, H);
float NV = dot(N, V);
float NL = dot(N, L);
float alpha = acos(NH);
float D = (1.0/(4*m*m*NH*NH*NH*NH))*exp((NH*NH-1)/(m*m*...
float G = min(1, min((2*NH*NV)/VH, (2*NH*NL)/VH));
float c = VH;
float g = sqrt(refrac*refrac+c*c-1);
float F = ((g-c)*(g-c)/((g+c)*(g+c)))*(1+(c*(g+c)-1)*(c...
float specularLight = D*G*F/NV;
specular = Ks*Ls*specularLight;
}
gl_FragColor.xyz = emissive+ambient+diffuse+specular;
gl_FragColor.w = 1.0;
}
}}
&ref(gouraud_shading_1.jpg); &ref(phong_shading_1.jpg); &...
#ref(glsl_phong.zip)
ページ名: