Overview
// Example code@ifdef UseTextureuniform cTexture2D aColorMap : 0;@endifvoid main(in cVector4f px_vPosition,in cVector4f px_vColor,in cVector4f px_vTexCoord0,out cVector4f out_vColor : 0){cVector4f vColor = px_vColor;@ifdef UseTexturevColor *= sample(aColorMap, px_vTexCoord0.xy);@endifout_vColor = vColor;}
//Preproccess stepvoid main(in cVector4f px_vPosition,in cVector4f px_vColor,in cVector4f px_vTexCoord0,out cVector4f out_vColor : 0){cVector4f vColor = px_vColor;out_vColor = vColor;}
// Translation step#version 330#extension GL_ARB_explicit_attrib_location : enablein vec4 px_vColor;in vec4 px_vTexCoord0;layout(location = 0) out vec4 out_vColor;void main(){vec4 px_vPosition = gl_FragCoord;bool px_bFrontFacing = gl_FrontFacing;int px_lPrimitiveID = gl_PrimitiveID;vec4 vColor = px_vColor;out_vColor = vColor;}
Preprocessing
// SSAO codefor(float d = 0.0; d < $kNumSamples; d+=4.0){// perform SSAO…}
Translation
Compilation
Summary
HPSL Reference
Syntax
Variable Type
|
Description
|
int
|
32 bit signed integer
|
uint
|
32 bit unsigned integer
|
bool
|
Stores true or false
|
float
|
32 bit float
|
double
|
64 bit float
|
cVectorXf
|
Vector of floats
|
cVectorXl
|
Vector of signed integers
|
cVectorXu
|
Vector of unsigned intergers
|
cMatrixXf
|
Square float matrix
|
cMatrixXxXf
|
Non-square matrix (Ex cMatrix2x4f)
|
cBuffer
|
Container of multiple variables
that get set by the CPU
|
Texture Type
|
Description
|
cTexture1D
|
Single dimension texture
|
cTexture2D
|
Standard 2D texture
|
cTexture3D
|
Volume texture
|
cTextureCube
|
Cubemap texture
|
cTextureBuffer
|
A large single dimension texture
used to store variables
|
cTexture2DMS
|
A 2D render target with MSAA
support
|
cTextureXCmp
|
A shadow map texture used for
comparison operations
|
cTextureXArray
|
Array of cTextureX textures
|
//bind diffuse map to slot 0uniform cTexture2D aDiffuseMap : 0;
Variable Type Modifier
|
Description
|
uniform
|
A variable or texture that is set
by the CPU
|
in
|
Read only input to a function
|
out
|
Output of a function
|
inout
|
Read and write input and output to
a function
|
const
|
A constant value that must be
initialized in the declaration and can’t be changed
|
Entry Point and Semantics
System Semantic
|
Description
|
Type
|
Shader Type
|
px_vPosition
|
Vertex position output. Pixel
shader input as screen position. This is required by all shaders
|
cVector4f
|
Vertex (out), Pixel (in)
|
: X
|
Output color slot, where X must be
in the range 0-3
|
cVector4
|
Pixel (out)
|
vtx_lVertexID
|
Index of the current vertex
|
int
|
Vertex (in)
|
vtx_lInstanceID
|
Index of the current instance
|
int
|
Vertex (in)
|
px_lPrimitiveID
|
Index of the triangle this pixel
belongs to
|
int
|
Pixel (in)
|
px_bFrontFacing
|
Indicates if the pixel belongs to
the front or back of the primitive
|
bool
|
Pixel (in)
|
Mesh Semantic
|
Description
|
Type
|
vtx_vPosition
|
Position
of the vertex
|
cVector4f
|
vtx_vTexCoord0
|
Primary UV
coord
|
cVector4f
|
vtx_vTexCoord1
|
Secondary UV coord
|
cVector4f
|
vtx_vNormal
|
World
space normal
|
cVector3f
|
vtx_vTangent
|
World space tangent, w contains
binormal direction
|
cVector4f
|
vtx_vColor
|
Color
|
cVector4f
|
vtx_vBoneIndices
|
Index of the bones used to modify
this vertex
|
cVector4l
|
vtx_vBoneWeight
|
Weight to multiply the bones with
|
cVector4f
|
//vertex shaderuniform cMatrixf a_mtxModelViewProjection;void main(in cVector4f vtx_vPosition,in cVector4f vtx_vColor,in cVector4f vtx_vTexCoord0,out cVector4f px_vColor,out cVector4f px_vTexCoord0,out cVector4f px_vPosition){px_vPosition = mul(a_mtxModelViewProjection, vtx_vPosition);px_vColor = vtx_vColor;px_vTexCoord0 = vtx_vTexCoord0;}//pixel shaderuniform cTexture2D aColorMap : 0;void main(in cVector4f px_vPosition,in cVector4f px_vColor,in cVector4f px_vTexCoord0,out cVector4f out_vColor : 0){out_vColor = px_vColor * sample(aColorMap, px_vTexCoord0.xy);}
Functions
Arithmetic Function
|
Description
|
mul(x, y)
|
Multiplies two matrices together
(multiplying by using * not supported for matrices)
|
lerp(x, y, t)
|
Interpolates between two values
|
Texture Function
|
Description
|
sample(texture, uv)
sample(texture, uv, offset)
|
Samples a texture at the specified
uv coordinate. Can be used with an integet offset
|
sampleGather(texture, uv)
sampleGather(texture, uv, offset)
|
Samples a texture but returns only
the red component of each texel corner
|
sampleGrad(texture, uv, dx, dy)
sampleGrad(texture, uv, dx, dy,
offset)
|
Performs texture lookup with
explicit gradients
|
sampleLod(texture,
uv, lod)
sampleLod(texture,
uv, lod, offset)
|
Samples the texture at a specific
mipmap level
|
sampleCmp(texture, uv, comp_value)
sampleCmp(texture, uv, comp_value,
offset)
|
Performs texture lookup and
compares it with the comparison value and returns result
|
load(texture, position)
|
Gets the value of a texel at
the integer position
|
getTextureSize(texture, lod)
|
Returns the width and height of
the texture lod
|
getTextureLod(texture, uv)
|
Gets the lod that would get
sampled if that uv coord is used
|
getTextureLevelCount
|
Gets the number of MipMap levels
|
@ifdef Lang_GLSLvec4 vModifier = vec4(lessThan(vValue, vLimit));@elsecVector4f vModifier = step(vValue, vLimit);@endif









