shaders
- #extension to enable extensions such as shadow2DEXT -> percentage closest sampling kind of thing
- #defines to enable/disable features and to redefine things
- structs to pass in parameter blocks such as for params to lighting params, lambert terms, fresnel terms,
specular, environment mapping etc.
- bone weights to array of vecs. Can have arrays in shaders
- varying in a common shader code shared between vertex and pixel shader, eg: common.gls
- then always variables match up, such as for uv0, tangent, normal and binormal, color, worldPosition, and ???
- t,b,n are originally input parameters with each vertex and are transformed ??? need to check ??? by world matrix
- t,b,n are interpolated by pixel shader, and each pixel the vec3s are put together to create a mat3
- the mat3 is called the tangent matrix
- uv0 is looked up in the normal map for the object, then xyz values * 2.0 and -1.0 to make them go from -1 to 1
- this texture space normal is then transformed by the tangent matrix ( normal * tagentMatrix )
- the resulting normal is normalized and that is the final result of the normal calculations
- bone weights
- some fixed number of bones - depends on openGLES version
- eg: ES2, might have 32 matrixes, or for ES3 might have 128
- each vertex then has some fixed number of bone weights and indexes
- eg: might have 2 bones
- a vertex then needs to have a weight and an index for 2 bones, so for example this could go in a vec4
- eg: vec4 boneData; indexA = int(boneData.x); weightA = boneData.y;
indexB = int(boneData.z); weightB = boneData.z;
- then the index is used to look up a matrix in the array of bones (which might actually be and array of vec3)
- then the vertex is multiplied by that matrix and also multiplied by the weight
- repeated for the 2nd index and weight and added together
- the result is the vertex position