GLSLで不透明物体のレンダリング
をテンプレートにして作成
[
トップ
|
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
[[GPU Gems - Chapter 16:http://http.developer.nvidia.com/...
----
#contents
----
#ref(translucent.jpg,nolink,100%)
#code(C){{
uniform float offset;
void main(void)
{
vec3 pos = vec3(gl_Vertex)+gl_Normal*offset;
gl_Position = gl_ModelViewProjectionMatrix*vec4(pos, gl_...
}
}}
#code(C){{
void main(void)
{
gl_FragColor = gl_Color;
}
}}
exp(-si*sigma_t)*gl_FrontLightProduct[0].diffuse;
#code(C){{
/*!
*/
float LightDepth(void)
{
vec4 shadow_coord1 = vShadowCoord/vShadowCoord.w;
float view_d = shadow_coord1.z;
float light_d = texture2D(depth_tex, shadow_coord1.xy).z;
return view_d-light_d;
}
/*!
*/
vec4 TranslucentShading(void)
{
vec3 L = normalize(gl_LightSource[0].position.xyz-vPos.x...
vec4 ambient = gl_FrontLightProduct[0].ambient;
float dcoef = max(dot(L, N), 0.0);
float si = LightDepth();
vec4 diffuse = exp(-si*sigma_t)*gl_FrontLightProduct[0]....
vec4 specular = vec4(0.0);
if(dcoef > 0.0){
vec3 R = reflect(-L, N);
float specularLight = pow(max(dot(R, V), 0.0), gl_Front...
specular = gl_FrontLightProduct[0].specular*specularLig...
}
return ambient+diffuse+specular;
}
void main(void)
{
gl_FragColor = TranslucentShading();
}
}}
#ref(translucent_result1.jpg,,50%)
#ref(translucent_result2.jpg,,50%)
#ref(glsl_translucent.zip)
終了行:
[[GPU Gems - Chapter 16:http://http.developer.nvidia.com/...
----
#contents
----
#ref(translucent.jpg,nolink,100%)
#code(C){{
uniform float offset;
void main(void)
{
vec3 pos = vec3(gl_Vertex)+gl_Normal*offset;
gl_Position = gl_ModelViewProjectionMatrix*vec4(pos, gl_...
}
}}
#code(C){{
void main(void)
{
gl_FragColor = gl_Color;
}
}}
exp(-si*sigma_t)*gl_FrontLightProduct[0].diffuse;
#code(C){{
/*!
*/
float LightDepth(void)
{
vec4 shadow_coord1 = vShadowCoord/vShadowCoord.w;
float view_d = shadow_coord1.z;
float light_d = texture2D(depth_tex, shadow_coord1.xy).z;
return view_d-light_d;
}
/*!
*/
vec4 TranslucentShading(void)
{
vec3 L = normalize(gl_LightSource[0].position.xyz-vPos.x...
vec4 ambient = gl_FrontLightProduct[0].ambient;
float dcoef = max(dot(L, N), 0.0);
float si = LightDepth();
vec4 diffuse = exp(-si*sigma_t)*gl_FrontLightProduct[0]....
vec4 specular = vec4(0.0);
if(dcoef > 0.0){
vec3 R = reflect(-L, N);
float specularLight = pow(max(dot(R, V), 0.0), gl_Front...
specular = gl_FrontLightProduct[0].specular*specularLig...
}
return ambient+diffuse+specular;
}
void main(void)
{
gl_FragColor = TranslucentShading();
}
}}
#ref(translucent_result1.jpg,,50%)
#ref(translucent_result2.jpg,,50%)
#ref(glsl_translucent.zip)
ページ名: