Skip to content

Shader Data

Emd4600 edited this page Mar 23, 2019 · 3 revisions

Many shaders require data from the game, such as the current time, the model position, etc. This is known as Shader Data, and it is one of the most useful features in shader creating. Using it is quite easy: you just need to declare it in the shader code, preceded by extern uniform. For example:

extern uniform float4 skinWeigts;

When the game sees your code requires data, it will send it to the shader. Keep in mind that not all data is always available: for example, using cliffColor will give unexpected results if you are in the editor and there is no planet.

Note: in Shader Builders, shader data goes in the declareCode block.

Available Shader Data

Below is a list of al the shader data used by Spore. There might be more variables that haven't been found/documented yet. Most of them also have the variable type, but some others don't; in those cases, you might need to find a shader that uses them to know their correct type.

float4 skinWeights;

float4 SkinBones[192];

float4x4 modelToClip;

float4x3 modelToCamera;

float4x3 modelToWorld;

float4x4 worldToClip;

float4x3 cameraToWorld;

float4x3 worldToCamera;

float4x4 worldToClipTranspose;

float3x4 cameraToWorldTranspose;

float3x3 worldToCameraTranspose;

float4x4 cameraToClip;

float4 lightPosModel;


float4 worldCameraPosition;

float4 worldCameraDirection;

float4 materialColor;

float4 ambient;

float time;

float pulse;

float4x3 worldToModel;

float4 objectTypeColor;

float4 frameInfo;

float4 screenInfo;

	float4 mFrequencyMag;
	float mTime;
} mNoiseScale;

half4 customParams[2];
float4 customParams[16];

The amount of custom params available depends on the shader.

float4x3 geomToRTT;

float4x4 geomToRTTViewTrans;

float4 tintParams;

float4 region;

float4 materialParams;

float4 uvTweak;

float4 editorColors[2];

	float4 mColor1; 
	float4 mColor2; 
	float4 mParams; 
} editorColors;

	float4 mDir; 
	float4 mColor; 
} dirLightsWorld[4];


float4 sunDirAndCelStrength;

float4 shCoeffs[16];
float4 lightingInfoCoeffs[9];

Sometimes less, sometimes more.

float cameraDistance;

float4 bakedPaint[2];

float4 uvSubRect;

float4 mousePosition;

float4 expandAmount;

half4 cameraParams[1];
float4 cameraParams;

	float4 mRangeAndStrength;
	float4 mShadowDir;
	float4 mNestInfo;
	float4x4 mWorldToShadowClip;
	float4x3 mWorldToShadowCamera;
} shadowMapInfo;

float4 foggingCPU;

float4 patchLocation;

float4x4 clipToWorld;

float4x4 clipToCamera;

float4 identityColor;

	float4x4 pcaBasis0;
	float4x4 pcaBasis1;
	float4x4 pcaBasis2;
	float4x4 pcaBasis3;
	float4 pcaMean;
} pcaTexture;

float4 rolloverRegion;

float4 renderDepth;

float4 terrainTint;

	float4 mColorAlpha;
	row_major float4x4 mTransform;
	float4 mClipRect;
} utfWin[16];

float4 deadTerrainTint;

float4 cellStage;


float4 terraformValues;

float4x3 worldToPatch;

float4x4 terrainBrushCubeMapRot;

	float4 mBrushValues;
	float4 mInnerParams;
	float4 mEpsilonValue;
	float4 mXForm;
} terrainSynthParams;

float4 debugPSColor;

float4 gameInfo;

	float4 envelope;
	float4 values2;
	float4 values3;
} ramp;

float4 sunDir;

	float4 vSunDir;
	float4 nightLightTint;
	float4 nightLightColor;
	float4 duskLightColor;
	float4 dayLightColor;
	float4 nightShadowColor;
	float4 duskShadowColor;
	float4 dayShadowColor;
	float4 duskDawnStartEnd;
} terrainLighting;

float4 tramp[8];

float4 beachColor;

float4 cliffColor;

float4x4 viewTransform;

float4 minWater[2];

float4 worldCameraNormal;

	float4x4 worldViewProjection;
	float4 QuadFaceUVXform;
	float4 QuadMorphValue;
	float4 QuadFaceElemMap;
	float4 QuadFaceSignMap;
	float4 QuadFaceXForm[3];
} terrainTransform;

	float4 DecalColorTint;
	float4 dirScaleU;
	float4 dirScaleV;
} decalState;

	float4 vSunDir;
	float4 waterColor;
	float4 innerParms;
	float4 vCamPos;
	float4 sphereParms;
	float4 camParms;
	float4 illumParms;
	float4 fogParms;
	float4 nightLightTint;
	float4 nightLightColor;
	float4 duskLightColor;
	float4 dayLightColor;
	float4 nightShadowColor;
	float4 duskShadowColor;
	float4 dayShadowColor;
	float4 duskDawnStartEnd;
	float4x4 viewTransform;
} terrainState;
You can’t perform that action at this time.