urn:xml3d:shader:flat
Lc = Le = emissiveColor
Example:
<shader id="flat" script="urn:xml3d:shader:matte">
<float3 name="emissiveColor">1.0 0.0 0.0</float3>
</shader>
| Name | Type | Default Value | Description |
|---|---|---|---|
| emissiveColor | <float3> | 1 1 1 |
Defines the emissive color of the surface. |
urn:xml3d:shader:diffuse
Lc(p) = Le + Ld(p)
The shading depends on the incident radiance and the angle between the light source and the surface normal. The diffuse term Ld(p) models the perfect diffuse response of a Lambertian surface:
| Ld(p) = | ∫ Ω(p) |
kd(p) Li(p; ωi) cosθidωi |
where
| kd(p) is diffuseColor * | { |
|
kd(p) = diffuseColor * ( useVertexColor ? va("color") : diffuseTexture ? sample(diffuseTexture, va("texcoord")) : 1.0 )
A possible alpha value in the diffuseTexture sample is ignored.
Example:
<shader id="flat" script="urn:xml3d:shader:diffuse">
<float3 name="diffuseColor">1.0 0.0 0.0</float3>
<texture name="diffuseTexture"><img src="logo.png"/></texture>
</shader>
| Name | Type | Default Value | Description |
|---|---|---|---|
| emissiveColor | <float3> | 0 0 0 |
Defines the emissive color of the surface. |
| diffuseColor | <float3> | 1 1 1 |
Defines the base color of the surface. |
| diffuseTexture | <texture> | - | Defines the texture to sample the diffuse color from. |
| useVertexColor | <bool> | false |
Turns on/off usage of the vertex attribute "color" as diffuseColor. |
urn:xml3d:shader:phong
Lp(p,w) = Le + Ld(p) + Lg(p,w)
Lgis calculated using the specular highlight term of the Phong reflection model:
| Lg(p,ωi) = | ∫ Ω(p) |
ks (cosθv)n Li(p; ωi) cosθidωi |
where
| Lr(p,ωi) = kr L(p',ωi') |
where
Lc(p,w) = (1-t(p)) * Lp(p,w) + t(p) * Lc(p',w)
where t is the transparency of the surface at point p. If diffuseTexture is defined and has an alpha channel, t is 1 - alpha value at the sample defined by vertex attribute "texcoord". Otherwise the transparency parameter is used.
Example:
<shader id="myPhong" script="urn:xml3d:shader:phong">
</shader>
| Name | Type | Default Value | Description |
|---|---|---|---|
| emissionColor | <float3> | 0 0 0 |
Defines the self-emission of the surface. |
| ambientColor | <float3> | 0 0 0 |
Defines the ambient color of the surface. |
| diffuseColor | <float3> | 1 1 1 |
Defines the diffuse color of the surface. |
| diffuseTexture | <texture> | - | Defines the texture to sample the diffuse color from. |
| specularColor | <float3> | 0 0 0 |
Defines the specular value of the surface |
| shininess | <float> | 0.2 |
Shininess of the surface (values in [0,1]) |
| reflectionColor | <float3> | 0 0 0 |
Factor to scale the contribution from the perfect reflection. |
| transparency | <float> | 0 0 0 |
Factor to scale the contribution from the perfect reflection. |
| castShadow | <int> | ≥1 |
Turns on/off shadow cast. Specify 0 to activate shadow cast and a value ≥1 otherwise. |