Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

UniformTypeLocated InPurpose
bboxMin/bboxMaxvec3inc_common

Give access to local bounds of a given rendered mesh in xyz. 
note: this was added in 89.8193.37-3 , which as of the date of this entry is still in development testing

texFBColorsampler2Dinc_common

Frame buffer (screen pixel color).

This buffer is an image with width and height in unit space (0 to 1) as opposed to your screen dimensions.

Each fragment contains the pixel color of that pixel on your screen from a previously drawn frame.

The color buffer does not contain information from emitter particles.

texFBDepthsampler2Dinc_common

Depth Buffer.

This buffer is an image with width and height in unit space (0 to 1) as opposed to your screen dimensions.

Each fragment contains the depth of field at that pixel on your screen from a previously drawn frame.

The depth buffer does not contain information from emitter particles.

fogParamsvec4inc_common

Contains XYZW =  [fogEnabled, fogStart, FogEnd, fogInvEndMinusStart].

In older shaders these values were separate uniforms.

playerPositionvec3inc_commonplayer position in world coordinates
playerCameraDistfloatinc_commondistance between player and camera position
playerInCutsceneintinc_commonflag denoting if player is in cutscene camera mode
cameraPositionvec3inc_commonposition of the camera in world coordinates
cameraPitchfloatinc_common
cameraYawfloatinc_common
cameraFocusvec3inc_commonthe vector the camera is focused toward (ie. camera facing)
cameraViewAnglefloatinc_common
cameraDialogStateintinc_common
userinputMousePositionivec2inc_commonscreenspace coordinates of mouse pointer (lower left is 0,0)
screenParamsvec2inc_commoncontains XY = [screenWidth, screenHeight]. In older shaders these values were separate uniforms.
pixelParamsvec3inc_common

contains XYZ = [invScreenWidth, invScreenHeight, fAspectRatio]
and XY = vPixelSize

In older shaders these values were separate uniforms.

clipParamsvec3inc_common

contains XYZ = [nearClip, farClip, fDepthToLinearModifier]

fDepthToLinearModifier = 1-near/far

In older shaders these values were separate uniforms.

m_projmat4inc_commonmatrix for converting from view to screen projection
m_proj_invmat4inc_commonmatrix for converting from screen projection to view
m_vp_invmat4inc_commonmatrix for converting from screen projection to world
m_view_invmat4inc_commonmatrix for converting from view to world
m_viewmat4inc_common

matrix for converting from world to view

m_texturemat4inc_commonmatrix for applying uv orientation
m_mvmat4inc_commonmatrix for converting from model to view
m_mvpmat4inc_commonmatrix for converting from model to screen projection
texNoiseBoundintinc_commonEquals 1 if noise texture was bound

texture<n>Bound {1..16}


intinc_common11 separate uniforms identifying if texture n is bound, where <n> = 0 to 10
texEnvCubeBoundintinc_commonEquals 1 if an environment cubemap is bound
texEnvBoundintinc_commonEquals 1 if an environment flatmap is bound
m_boneRotations[]vec4inc_commonContains orientations of bones at the current frame for use with Mobile version
m_bonePositions[]vec4inc_commonContains positions of bones at the current frame for use with Mobile version
m_bonesmat4inc_commonContains matrix transforms for bones (both position and rotation) for use with non-Mobile versions
texUnit<n>sampler2Dinc_common11 separate uniforms containing the texture sampler for texture n, where <n> = 0 to 10
DisplacementOffsetfloatinc_commonDefines the offset from which height map displacement will begin. Can be modified in the material file using "parameter" lines
texUnitEnvsampler2Dinc_commoncontains the texture sampler for the environment map
texUnitEnvCubesamplerCubeinc_commoncontains the cubemap sampler for a cubemap environment
texUnitNoisesampler2Dinc_commoncontains the noise texture sampler
envMapCubeintinc_commonEquals 1 if environment map type is cubemap, otherwise type is flatmap
fAlphaDiscardValuefloatinc_commonContains the minimum alpha level to draw. Any value below this will be dropped, greatly speeding up rendering of transparent objects as they stack up over distance.
skinmeshintinc_commonEquals 1 if the mesh type is a skinmesh
Specularityfloatinc_materialContains a specularity override value, as passed in from a material file. If not provided, specularity will be imported from texUnit2 red channel, or in the case that specularity is based on the environment map, it will be calculated from there. Positive values only.
Roughnessfloatinc_materialContains a roughness override value, as passed in from a material file. If not provided, roughness will be imported from texUnit3 red channel, or in the case that roughness is also included in the spec map, it will be read from texUnit2 green channel. Positive values only.

Use flag MATERIAL_READ_ROUGHNESS_FROM_SPECULAR_MAP = 1 to force reading from texUnit2 green channel.
Metallicnessfloatinc_materialContains a metallicness override value, as passed in from a material file. If not provided, metallicness will be calculated from specularity. Positive values only.
CustomSpecularColorvec4inc_materialContains a specular color override value, as passed in from a material file. Prevents specular color from being derived from albedo, height, and metallicness.
lightColor[]vec4inc_lightingContains the light color for each light passed to the shader for the scene. Used if gamma correction is enabled.
lightMaxIntensityInvfloatinc_lighting
lightFalloffFactorfloatinc_lighting
lightAmbient[]vec4inc_lightingContains the ambient light color for each light passed to the shader for the scene. Used if gamma correction is not enabled.
lightDiffuse[]vec4inc_lightingContains the diffuse light color for each light passed to the shader for the scene. Used if gamma correction is not enabled.
lightQuadraticAtten[]floatinc_lightingContains the light light falloff calculation for each light in the scene.
lightPosition[]vec4inc_lightingContains the position of each light in the scene in world coordinates.
numLightsintinc_lightingNumber of lights passed to the shader for the scene.
staticLightingintinc_lighting
lightAreaAmbientvec3inc_lightingThe color of the area ambient lighting at this fragment
lightAreaDiffusevec3inc_lightingThe color of the area diffuse lighting at this fragment
lightAreaDiffuseDirectionvec3inc_lightingEffectively the sun angle for the diffuse light from the sun
materialFrontAmbientvec4inc_lightingThe ambient light color of the fragment based on vertex color
materialFrontDiffusevec4inc_lightingThe diffuse light color of the fragment based on vertex color
materialFrontEmissivevec4inc_lightingThe self illumination color of the fragment based on the self illumination value of the mesh. Added to total light of that fragment.
frontLightModelProductSceneColorvec4inc_lightingUsed mostly for GUI elements. Used to calculate constant light for those elements.
keyholeCanDissolveintinc_keyholeEquals 1 if keyholing is enabled and the material can be dissolved
keyholeDiameterMaxfloatinc_keyhole
keyholeDiameterMinfloatinc_keyhole
sceneCurrentFrameint

inc_water

inc_uniforms

As of preview build  v.87.8193.35[dd1322cd], this uniform was removed from inc_water and placed into inc_uniforms
worldtimerTimeOfDayint

inc_water

inc_uniforms

This value is the number of ticks since the client was started and does NOT represent anything related to module time. There are 144000 ticks per day divided by moduleMinutesPerHour.

There is a potential for time error when the module does not load cleanly, causing a large delay.

Setting module time with NWScript or debug functions will also not update this value.

As of preview build  v.87.8193.35[dd1322cd], this uniform was removed from inc_water and placed into inc_uniforms

moduleYearint

inc_water

inc_uniforms

Testing of moduleYear has shown that it does not always get sent to the shader with correct value. Using this value for any purpose can result in counted effects being misrendered.

As of preview build  v.87.8193.35[dd1322cd], this uniform was removed from inc_water and placed into inc_uniforms

moduleMonthint

inc_water

inc_uniforms

Integer value of module month.

Setting module time with NWScript or debug functions will also not update this value correctly.

As of preview build  v.87.8193.35[dd1322cd], this uniform was removed from inc_water and placed into inc_uniforms

moduleDayint

inc_water

inc_uniforms

Integer value of module day.

Setting module time with NWScript or debug functions will also not update this value correctly.

As of preview build  v.87.8193.35[dd1322cd], this uniform was removed from inc_water and placed into inc_uniforms

moduleHourint

inc_water

inc_uniforms

Integer value of the module time.

Merricksdad:
moduleHour is the integer value of the true* module time.

*Being converted from a float originally, this value will have loss.
Testing has shown the offset in module hour to be multiple seconds forward or backward, meaning this value cannot be used as an exact match for the true moduleHour.
The lower moduleMinutesPerHour is, the larger the error will appear.

moduleHour can also become bugged if the module does not load smoothly, causing a large delay. In that case, the module time in game will also be incorrect.

Setting module time with NWScript or debug functions will also not update this value correctly.


As of preview build  v.87.8193.35[dd1322cd], this uniform was removed from inc_water and placed into inc_uniforms

windPointSourcesCountintinc_waterNumber of wind point sources in the scene
windPointSourcesPosition[]vec3inc_waterContains the position of all wind sources in the scene
windPointSourcesRadius[]floatinc_waterContains the radius of all wind sources in the scene
windPointSourcesDuration[]floatinc_waterContains the expected duration of each wind source in the scene
windPointSourcesIntensity[]floatinc_waterContains the wind intensity of each wind source in the scene
windPointSourcesTimeRemaining[]floatinc_waterContains the remaining time allowed to each wind source in the scene
moduleDawnHourint

inc_water

inc_uniforms

The hour at which Dawn-related sky mixing occurs. Sent over to shader from module properties.

As of preview build  v.87.8193.35[dd1322cd], this uniform was removed from inc_water and placed into inc_uniforms

moduleDuskHourint

inc_water

inc_uniforms

The hour at which Dusk-related sky mixing occurs. Sent over to shader from module properties.

As of preview build  v.87.8193.35[dd1322cd], this uniform was removed from inc_water and placed into inc_uniforms

moduleMinutesPerHourint

inc_water

inc_uniforms

Time scale of the module.

Also directly related to transition timers.

Sent over to shader from module properties.

As of preview build  v.87.8193.35[dd1322cd], this uniform was removed from inc_water and placed into inc_uniforms

moduleTimeIntoTransition float???

This value counts up from the last known transition, such as moduleDuskHour or moduleDawnHour.

It also counts up from zero after those transitions end, and so will tick all day long.

At these points it resets to 0.0: moduleDawnHour, moduleDawnHour+1, moduleDuskHour, and moduleDuskHour+1.


It also starts at 0.0 when the client enters the game, so its initial value is not useful before the first transition it reached. Meaning that if a player starts at 13:24 module time, then the value is worthless as a timer until moduleDuskHour is reached.

Otherwise, we can say that the following formula can almost match the module time since the last transition began or ended:
float transTimer = moduleTimeIntoTransition / moduleTransitionTime / moduleMinutesPerHour;

Beware adding this to moduleHour to correct to the true module time, since moduleHour can tick faster or slower than expected due to server→client information coming out of order.

moduleTransitionTimefloat???

The scale of the transition time.

For example, 1 hour is 60 units when moduleMinutesPerHour = 1.

moduleTimeIntoTransition / moduleTransitionTime gives a value from 0.0 to 1.0

areaGlobalWindvec3inc_waterContains the global wind vector for the area
areaWeatherDensityfloatinc_waterContains the intensity of current weather
areaFlagsintinc_water1=Interior, 2=Underground, 4=Natural
areaWeatherTypeintinc_water0=Clear/none, 2=Rain, 3=Snow
m_mmat4various / post processingMatrix for converting from model to world coordinates
projectionSourcevec4

vs_beamvol

vs_shadowvol


projectionWorldZClipfloat

vs_beamvol

vs_shadowvol


particleSizeMaxfloatvsparticle
particleSoftenintvsparticleUsed for non-Mobile version when equals 1.
DOFAmountfloatinc_postpr_dof
DOFDeadZonefloatinc_postpr_dof
DOFVignettefloatinc_postpr_dofedge of screen blur
DOFFocusTypeintinc_postpr_dofset to camera pitch by default
DynamicContrastMidpointfloatinc_postpr_dyn_c
DynamicContrastIntensityfloatinc_postpr_dyn_c
Gammafloatinc_postpr_gam
Vibrancefloatinc_postpr_vibr
globalColorvec4

fs

vsfbdof

vsfblvls

vsfbshrp

vsfbvib

The default color when one is otherwise not supplied
PLTScheme[15]floatfs_pltgenThe PLT color scheme info

PLT based diffuse is a composite of a grayscale value from the PLT red channel and a color by number value from the green channel of the PLT, which is passed via texUnit0.

The actual color picked is the XY vector equal to RG color vector, and is picked from the gradient map provided in texUnit1.

First step is converting the texUnit0 green value through the PLT scheme info, thereby converting it to the proper Y coordinate (gradient row) in texUnit1.
AOIntensityfloatfsfbssao
scriptableInt<n> {1..16}Intinc_scriptableA global integer value which can be set per-player via nwscript and passed into all shaders run by that player.
The data type appears to be signed integer (Int32), with maximum values of −2,147,483,648 (−231) through 2,147,483,647 (231 − 1)

As of preview v.87.8193.35[869dfc51] - 15 Jul 2022 there are 16 of these global uniforms.
scriptableFloat<n> {1..16}floatinc_scriptable

A global float value which can be set per-player via nwscript and passed into all shaders run by that player.

The data type appears to be signed float (Float32), with expected maximum values of 3.402823466e+38 through 1.175494351e-38

As of preview v.87.8193.35[869dfc51] - 15 Jul 2022 there are 16 of these global uniforms.
scriptableVec<n> {1..16}vec4inc_scriptable

A global vec4 value which can be set per-player via nwscript and passed into all shaders run by that player.

vec4 can be read in the shader as an array of Float32 values in the order XYZW, or RGBA. Max values are expected to follow Float32 limits

As of preview v.87.8193.35[869dfc51] - 15 Jul 2022 there are 16 of these global uniforms.

targetObjectTypeintinc_target

Identifies the target type of the object under the cursor.

Only available in preview build  v.87.8193.35[dd1322cd]  or later

Value corresponds with TARGET_OBJECT_TYPE_* values in NwScript, added in the same build.

targetWorldCoordsvec3inc_target

Gives the world coordinates of the cursor. Presumably taken from the projection onto the underlying walkmesh. If no walkmesh exists, will possibly give the position of the skybox under the world, if one goes down that far.

Only available in preview build  v.87.8193.35[dd1322cd]  or later

targetShapeintinc_target

Identifies the target indicator shape. 

Only available in preview build  v.87.8193.35[dd1322cd]  or later

Value corresponds with TARGET_SHAPE_* values in NwScript, added in the same build.

targetShapeHarmsEnemiesintinc_targetSet to 1 if spell using this shape will harm enemies
targetShapeHarmsAlliesintinc_target

Set to 1 if spell using this shape will harm allies

targetShapeHelpsAlliesintinc_targetSet to 1 if spell using this shape will help allies
targetShapeIgnoreSelfintinc_target

Set to 1 if spell using this shape will ignore the caster

targetShapeOriginOnSelfintinc_targetSet to 1 if the spell origin is the caster
targetShapeXfloatinc_targetSpecifies the X axis dimensions in meters of the target shape
targetShapeYfloatinc_targetSpecifies the Y axis dimensions in meters of the target shape
targetShapeSpellIDintinc_targetCarries the ID of the spell or spell-like effect which is using this target shape
targetShapeFeatIDintinc_targetCarries the ID of the feat or feat-like effect which is using this target shape
targetShapeSpellRangeintinc_targetSpecifies the max range of the spell using this target, allowing the shader to draw a dotted line from caster to the point which they need to move to in order to cast the spell to the cursor position.

Standard Defines Available

...

Warning

As of preview build  v.87.8193.35[dd1322cd] custom shaders making use of uniforms copied from inc_water/fs_water will give "redefinition" error #198 in the toolset, such as:

ERROR: 1:4352: error(#198) Redefinition error: moduleMinutesPerHour

To fix that issue, simply remove any line using "uniform <type> <name>" where <name> is defined as a uniform within inc_uniforms

As of preview build v.87.8193.35[2070a8b9] an additional subset of uniforms was moved into inc_uniforms.

Include Files

FilenamePurpose
inc_standard

Contains standard shader application functions, as well as debug modes, and input initialization.

Works as an include hub, bringing in code from other important includes.

inc_lighting

Contains functions for calculating lighting.

Also includes the array of lights and their setup. Handles specular and fresnel content.

inc_material

Sets up standard material maps 0 to 5.

Handles environment mapping, initializes specular mapping, and begins height map displacement.

inc_common

Sets up enumerations and constant color values.

Makes sure many switches are at least set to 0 rather than null.

Contains uniforms related to screenspace, clipping, and projection matrices.

Contains functions related to matrix transforms and color correction.

inc_configShort file handling testing switches, such as light softening and specular distribution.
inc_keyholeSetup and use of keyholing.
inc_water

Works like inc_standard for fancy water.

inc_envmap

Sets up environment maps and cubes.

Includes functions for picking from those maps.

inc_fog

Handles construction and application of fog.

If not included, some important fog uniforms will not be available.

inc_transform

Sets up texture-handedness, handles bones for skins, and manages base transforms.

When requested, will also setup world, and projection positions for use in fragment shader.

inc_uniformsContains a bunch of uniforms previously dispersed throughout other files, such as fs_water.
inc_randomContains functions for producing random numbers, noise, and gradients.
inc_displacementHandles height map displacement
inc_targetHandles new spell targetning shapes
inc_tonemapContains a bunch of color correction functions previously found in inc_lighting and others.
inc_framebuffer

Sets up framebuffer for color and depth.

Includes functions for convering screenspace to worldspace and back again.

inc_scriptableIncludes global shader uniforms commandable via nwscript.
inc_postpr

The hub entrypoint for postprocessing shader.

Will include other post processing related files when enabled in client options.

Include Heirarchy

The current stable structure is:

...


In addition to the uniforms, the following vertex attributes are exposed:

* vec4 vPos
Vertex position in object space.   Note: As of 89.8193.37 (which is still in dev test as of the date of this update) vPos was changed to provide vertex position in world space, not object space.

* vec2 vTcIn
Texture coordinates for current texture.

...