- All Implemented Interfaces:
Icon
,IconSource
,Scattering
,Shader
,Manageable
,Shareable
,Scattering
,Shader
,Serializable
,Cloneable
RGBAShader
implements a simple lambertian
material with a single color and an alpha-value for the
transparency. Some methods which are related to the color
palette of the EGA graphics card are declared, they are used
in the context of the emulation of the GROGRA software.- Author:
- Ole Kniemeyer
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ManageableType
static final RGBAShader
RGBAShader
whose color isColor.BLACK
.static final RGBAShader
RGBAShader
whose color isColor.BLUE
.static final RGBAShader
RGBAShader
whose color isColor.CYAN
.static final RGBAShader
RGBAShader
whose color isColor.DARK_GRAY
.static final RGBAShader
RGBAShader
whose color is EGA color number 0.static final RGBAShader
RGBAShader
whose color is EGA color number 1.static final RGBAShader
RGBAShader
whose color is EGA color number 10.static final RGBAShader
RGBAShader
whose color is EGA color number 11.static final RGBAShader
RGBAShader
whose color is EGA color number 12.static final RGBAShader
RGBAShader
whose color is EGA color number 13.static final RGBAShader
RGBAShader
whose color is EGA color number 14.static final RGBAShader
RGBAShader
whose color is EGA color number 15.static final RGBAShader
RGBAShader
whose color is EGA color number 2.static final RGBAShader
RGBAShader
whose color is EGA color number 3.static final RGBAShader
RGBAShader
whose color is EGA color number 4.static final RGBAShader
RGBAShader
whose color is EGA color number 5.static final RGBAShader
RGBAShader
whose color is EGA color number 6.static final RGBAShader
RGBAShader
whose color is EGA color number 7.static final RGBAShader
RGBAShader
whose color is EGA color number 8.static final RGBAShader
RGBAShader
whose color is EGA color number 9.static final RGBAShader
RGBAShader
whose color isColor.GRAY
.static final RGBAShader
RGBAShader
whose color isColor.GREEN
.static final RGBAShader
RGBAShader
whose color isColor.LIGHT_GRAY
.static final RGBAShader
RGBAShader
whose color isColor.MAGENTA
.static final RGBAShader
RGBAShader
whose color isColor.ORANGE
.static final RGBAShader
RGBAShader
whose color isColor.PINK
.static final RGBAShader
RGBAShader
whose color isColor.RED
.static final RGBAShader
RGBAShader
whose color isColor.WHITE
.static final RGBAShader
RGBAShader
whose color isColor.YELLOW
.Fields inherited from interface de.grogra.ray.physics.Scattering
DELTA_FACTOR, IS_NON_OPAQUE, MIN_UNUSED_FLAG, NEEDS_NORMAL, NEEDS_POINT, NEEDS_TANGENTS, NEEDS_TRANSFORMATION, NEEDS_UV, RANDOM_RAYS_GENERATE_ORIGINS
Fields inherited from interface de.grogra.ray.physics.Shader
LAMBERTIAN_VARIANCE
-
Constructor Summary
ConstructorsConstructorDescriptionRGBAShader
(float red, float green, float blue) RGBAShader
(float red, float green, float blue, float alpha) RGBAShader
(int rgba) Specify colors as ARGB integer.RGBAShader
(Shader a) RGBAShader
(Color4f color) -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(ShaderVisitor visitor) void
void
appendReferencesTo
(List out) clone()
float
computeBSDF
(Environment env, Vector3f in, Spectrum specIn, Vector3f out, boolean adjoint, Spectrum bsdf) Evaluates bidirectional scattering distribution function for given input.void
computeMaxRays
(Environment env, Vector3f in, Spectrum specIn, Ray reflected, Tuple3f refVariance, Ray transmitted, Tuple3f transVariance) Computes, for the given input, the reflected and transmitted importance rays for which the reflection/transmission probability densities (integrated over the spectrum) attain a maximum.void
fieldModified
(PersistenceField field, int[] indices, Transaction t) static final RGBAShader
forEGAColor
(int index) Returns theRGBAShader
whose color has the specified index in the palette of the EGA graphics card.void
generateRandomRays
(Environment env, Vector3f out, Spectrum specOut, RayList rays, boolean adjoint, Random rnd) Pseudorandomly generates, for the given input, a set of scattered rays.int
Returns an average color for the scattering entity.static final int
getEGAColorIndex
(float r, float g, float b) Returns the index of the color in the palette of the EGA graphics card which is closest to the specified color.static final int
Returns the index of the color in the palette of the EGA graphics card which is closest to the specified color.static final int
Returns the index of the color in the palette of the EGA graphics card which is closest to the specified color.int
getFlags()
getImage()
getImage
(int w, int h) getPreferredIconSize
(boolean small) int
getStamp()
Returns a stamp for this object.void
initProvider
(SharedObjectProvider provider) boolean
boolean
boolean
void
paintIcon
(Component c, Graphics2D g, int x, int y, int w, int h, int state) void
void
void
void
Computes color of outgoing light ray for given input.Methods inherited from class javax.vecmath.Tuple4f
absolute, absolute, add, add, clamp, clamp, clampMax, clampMax, clampMin, clampMin, epsilonEquals, equals, equals, get, get, hashCode, interpolate, interpolate, negate, negate, scale, scale, scaleAdd, scaleAdd, set, set, set, set, sub, sub, toString
-
Field Details
-
BLACK
RGBAShader
whose color isColor.BLACK
. -
BLUE
RGBAShader
whose color isColor.BLUE
. -
CYAN
RGBAShader
whose color isColor.CYAN
. -
DARK_GRAY
RGBAShader
whose color isColor.DARK_GRAY
. -
GRAY
RGBAShader
whose color isColor.GRAY
. -
GREEN
RGBAShader
whose color isColor.GREEN
. -
LIGHT_GRAY
RGBAShader
whose color isColor.LIGHT_GRAY
. -
MAGENTA
RGBAShader
whose color isColor.MAGENTA
. -
ORANGE
RGBAShader
whose color isColor.ORANGE
. -
PINK
RGBAShader
whose color isColor.PINK
. -
RED
RGBAShader
whose color isColor.RED
. -
YELLOW
RGBAShader
whose color isColor.YELLOW
. -
WHITE
RGBAShader
whose color isColor.WHITE
. -
EGA_0
RGBAShader
whose color is EGA color number 0. -
EGA_1
RGBAShader
whose color is EGA color number 1. -
EGA_2
RGBAShader
whose color is EGA color number 2. -
EGA_3
RGBAShader
whose color is EGA color number 3. -
EGA_4
RGBAShader
whose color is EGA color number 4. -
EGA_5
RGBAShader
whose color is EGA color number 5. -
EGA_6
RGBAShader
whose color is EGA color number 6. -
EGA_7
RGBAShader
whose color is EGA color number 7. -
EGA_8
RGBAShader
whose color is EGA color number 8. -
EGA_9
RGBAShader
whose color is EGA color number 9. -
EGA_10
RGBAShader
whose color is EGA color number 10. -
EGA_11
RGBAShader
whose color is EGA color number 11. -
EGA_12
RGBAShader
whose color is EGA color number 12. -
EGA_13
RGBAShader
whose color is EGA color number 13. -
EGA_14
RGBAShader
whose color is EGA color number 14. -
EGA_15
RGBAShader
whose color is EGA color number 15. -
$TYPE
-
-
Constructor Details
-
RGBAShader
public RGBAShader(float red, float green, float blue, float alpha) -
RGBAShader
public RGBAShader(float red, float green, float blue) -
RGBAShader
public RGBAShader() -
RGBAShader
-
RGBAShader
-
RGBAShader
public RGBAShader(int rgba) Specify colors as ARGB integer. This means the bits 31-24 are alpha, 23-16 are red, 15-8 are green and 7-0 are blue.- Parameters:
rgba
- color as 0xAARRGGBB
-
-
Method Details
-
getEGAColorIndex
public static final int getEGAColorIndex(float r, float g, float b) Returns the index of the color in the palette of the EGA graphics card which is closest to the specified color.- Parameters:
r
- red value of color (between 0 and 1)g
- green value of color (between 0 and 1)b
- blue value of color (between 0 and 1)- Returns:
- index of closest EGA color
-
getEGAColorIndex
Returns the index of the color in the palette of the EGA graphics card which is closest to the specified color.- Parameters:
c
- a color- Returns:
- index of closest EGA color
-
getEGAColorIndex
Returns the index of the color in the palette of the EGA graphics card which is closest to the specified color.- Parameters:
c
- a color- Returns:
- index of closest EGA color
-
forEGAColor
Returns theRGBAShader
whose color has the specified index in the palette of the EGA graphics card.- Parameters:
index
- palette index (only the lowest 4 bits are used)- Returns:
- corresponding shader
-
scale
-
clone
-
isPredefined
public boolean isPredefined() -
getAverageColor
public int getAverageColor()Description copied from interface:Scattering
Returns an average color for the scattering entity. This color is used for simplified graphical representations of the corresponding objects.- Specified by:
getAverageColor
in interfaceScattering
- Returns:
- an average color in Java's default sRGB color space, encoded as an int (0xAARRGGBB).
-
getFlags
public int getFlags()- Specified by:
getFlags
in interfaceScattering
-
getProvider
- Specified by:
getProvider
in interfaceShareable
-
appendReferencesTo
- Specified by:
appendReferencesTo
in interfaceShareable
-
getManageableType
- Specified by:
getManageableType
in interfaceManageable
-
fieldModified
- Specified by:
fieldModified
in interfaceManageable
-
getStamp
public int getStamp()Description copied from interface:Manageable
Returns a stamp for this object. Each modification to this object increments the stamp. The initial stamp is non-negative.- Specified by:
getStamp
in interfaceManageable
- Returns:
- a stamp
-
manageableReadResolve
- Specified by:
manageableReadResolve
in interfaceManageable
-
manageableWriteReplace
- Specified by:
manageableWriteReplace
in interfaceManageable
-
getIcon
- Specified by:
getIcon
in interfaceIconSource
-
getPreferredIconSize
- Specified by:
getPreferredIconSize
in interfaceIconSource
-
paintIcon
-
getIconSource
- Specified by:
getIconSource
in interfaceIcon
-
prepareIcon
public void prepareIcon()- Specified by:
prepareIcon
in interfaceIcon
-
isMutable
public boolean isMutable() -
getImage
-
getImage
-
getImageSource
- Specified by:
getImageSource
in interfaceIcon
-
getIconBounds
- Specified by:
getIconBounds
in interfaceIcon
-
shade
Description copied from interface:Shader
Computes color of outgoing light ray for given input. The computed value is, for each color component j = R, G, B, the following sum over all incident rays k:∑k |cos θk| BSDFj(ωk, where BSDFj is the bidirectional scattering distribution function (= BRDF + BTDF) at the pointout
) ck,jenv.point
, ωk and ck the direction and color of ray k, and θk the angle between the surface normal and ωk.The computation may include physically invalid contributions, which may not fit into the formula above, e.g., ambient or emissive light contributions.
-
computeMaxRays
public void computeMaxRays(Environment env, Vector3f in, Spectrum specIn, Ray reflected, Tuple3f refVariance, Ray transmitted, Tuple3f transVariance) Description copied from interface:Shader
Computes, for the given input, the reflected and transmitted importance rays for which the reflection/transmission probability densities (integrated over the spectrum) attain a maximum. The reflection probability density (measured with respect to solid angle) for the outgoing importance direction (i.e., incoming light direction) ω, given a fixed incident directionin
, ispr(ω) = cos θ BRDF(ω, where BRDF is the bidirectional reflectivity distribution function, θ the angle between the surface normal and ω, and R the total reflectivity for the incident direction, i.e., the integral over cos θ BRDF(ω,in
) / Rin
). The transmission probability density is defined correspondingly.The
color
-fields are set to the total reflectivity/transparency for the incident direction for each color component R, G, B. Thus, for physically plausible BRDF/BTDF, the component-wise sum ofreflected.color
andtransmitted.color
lies in the interval [0, 1], and the difference to 1 is the amount absorbed.The
color
may be zero if there is no reflected or transmitted ray, respectively, i.e., if the surface is fully transparent, opaque, or absorbing. The origin-fields of the rays will never be set.The computed variances are defined to be, for each color component, (approximations for) the angular mean quadratic deviations of the densities from the returned maximal ray directions. E.g., for perfect reflection/transmission, these variances are zero, whereas for a perfect lambertian reflector, the variance of reflection is ∫ cos θ (1 / π) θ2 dω = (π2 - 4) / 8. This is the value of
Shader.LAMBERTIAN_VARIANCE
.The ray properties which are not mentioned are neither used nor modified. These are the origin and its density, and the direction density.
- Specified by:
computeMaxRays
in interfaceShader
- Parameters:
env
- the environment for scatteringin
- the (negated) direction unit vector of the incoming ray (i.e., pointing away from the surface)specIn
- spectrum of incoming rayreflected
- the reflected ray with maximal probabilityrefVariance
- the angular mean quadratic deviation fromreflected
transmitted
- the transmitted ray with maximal probabilitytransVariance
- the angular mean quadratic deviation fromtransmitted
-
generateRandomRays
public void generateRandomRays(Environment env, Vector3f out, Spectrum specOut, RayList rays, boolean adjoint, Random rnd) Description copied from interface:Scattering
Pseudorandomly generates, for the given input, a set of scattered rays. The scattered rays are generated such that they can be used for a Monte Carlo integration of a function f(ω;ν) over cos θ BSDF(ωi, νi; ωo, νo) in the following way:-
If
adjoint
isfalse
,out
= ωo describes the direction of an outgoing light ray. In this case, the integration is with respect to ωi. Let g(ω, ν;out
, μ) = BSDF(ω, ν;out
, μ) -
Otherwise,
adjoint
istrue
. In this case,out
= ωi describes the direction of an outgoing importance ray (an inverse light ray). Now the integration is with respect to ωo. Let g(ω, ν;out
, μ) = BSDF(out
, μ; ω, ν)
rays.size
). Then, for every frequency ν the sum1 / N ∑i si(ν) f(di; ν) is an unbiased estimate for the integral∫ cos θ f(ω; ν) g(ω, ν; θ is the angle between the surface normal and ω. The domain of integration is the whole sphere, since the bidirectional scattering distribution includes both reflection and transmission (BSDF = BRDF + BTDF).out
, μ)specOut
(μ) dμ dωIf this
Scattering
instance is in fact aLight
source,adjoint
istrue
, and the BSDF is defined as BSDF(out
, μ; ω, ν) = L1(ω, ν) δ(μ - ν), i.e., the directional distribution of the emitted radiance atenv.point
, seeEmitter
. In this case,out
is not used.If this
Scattering
instance is in fact aSensor
,adjoint
isfalse
, and the BSDF is defined as BSDF(ω, ν;out
, μ) = W1(ω, ν) δ(μ - ν), i.e., the directional distribution of the emitted importance atenv.point
, seeEmitter
. In this case,out
is not used.Let pω be the probability density used for the ray direction (measured with respect to solid angle ω), then the field
directionDensity
of the ray i is set to pω(di). For ideal specular reflection or transmission, or for directional lights or sensors, pω is not a regular function, the valuedirectionDensity
will be set to a multiple ofScattering.DELTA_FACTOR
.The ray properties which are not mentioned in the given formulas are neither used nor modified. These are the origin and its density.
- Specified by:
generateRandomRays
in interfaceScattering
- Parameters:
env
- the environment for scatteringout
- the direction unit vector of the outgoing ray (i.e., pointing away from the surface)specOut
- the spectrum of the outgoing rayrays
- the rays to be generatedadjoint
- representsout
a light ray or an importance ray?rnd
- pseudorandom generator- See Also:
-
If
-
computeBSDF
public float computeBSDF(Environment env, Vector3f in, Spectrum specIn, Vector3f out, boolean adjoint, Spectrum bsdf) Description copied from interface:Scattering
Evaluates bidirectional scattering distribution function for given input.The computed spectrum is an integral over the spectrum of the following product:
|cos θ| BSDF(ωi, νi; ωo, νo) where BSDF is the bidirectional scattering distribution function (= BRDF + BTDF) at the pointenv.point
, ωi the (negated) direction of the incoming light ray, νi the frequency where the incoming ray is sampled, ωo the direction of the outgoing light ray, νo the frequency where the outgoing ray is sampled, and θ the angle between the surface normal andout
.If
adjoint
isfalse
,in
andout
describe true light rays from light sources to sensors. In this case, ωi =in
, ωo =out
, and the integral isbsdf
(ν) = |cos θ| ∫ BSDF(in
, νi;out
, ν)specIn
(νi) dνiadjoint
istrue
.in
andout
then describe importance rays (inverse light rays from sensors to light sources). In this case, ωi =out
, ωo =in
, and the integral isbsdf
(ν) = |cos θ| ∫ BSDF(out
, ν;in
, νo)specIn
(νo) dνoIf this
Scattering
instance is in fact aLight
source,adjoint
isfalse
, and the BSDF is defined as BSDF(in
, μ; ω, ν) = L1(ω, ν) δ(μ - ν), i.e., the directional distribution of the emitted radiance atenv.point
, seeEmitter
. In this case,in
is not used.If this
Scattering
instance is in fact aSensor
,adjoint
istrue
, and the BSDF is defined as BSDF(ω, ν;in
, μ) = W1(ω, ν) δ(μ - ν), i.e., the directional distribution of the emitted importance atenv.point
, seeEmitter
. In this case,in
is not used.The computation should be physically valid. This excludes, e.g., ambient or emissive light contributions.
The returned value is the value of the probability density pω that would be calculated by
Scattering.generateRandomRays(de.grogra.ray.physics.Environment, javax.vecmath.Vector3f, de.grogra.ray.physics.Spectrum, de.grogra.ray.util.RayList, boolean, java.util.Random)
if the ray happened to be one of the randomly generated rays.- Specified by:
computeBSDF
in interfaceScattering
- Parameters:
env
- the environment for scatteringin
- the (negated) direction unit vector of the incoming ray (i.e., pointing away from the surface)specIn
- the spectrum of the incoming rayout
- the direction unit vector of the outgoing ray (i.e., pointing away from the surface)adjoint
- light ray or importance ray?bsdf
- the computed spectrum of the outgoing ray will be placed in here- Returns:
- the value of the probability density for the ray direction
-
isTransparent
public boolean isTransparent()- Specified by:
isTransparent
in interfaceShader
-
accept
-