Let shaders be returned as arrays
This commit is contained in:
parent
562ba9ebb7
commit
56d3cb3851
1 changed files with 125 additions and 133 deletions
|
@ -3,139 +3,131 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
make.shaders = {
|
make.shaders = {
|
||||||
fragment1: function () {
|
fragment1: [
|
||||||
return random.pick([
|
[
|
||||||
[
|
'#ifdef GL_ES',
|
||||||
'#ifdef GL_ES',
|
'precision mediump float;',
|
||||||
'precision mediump float;',
|
'#endif',
|
||||||
'#endif',
|
'varying vec4 vColor;',
|
||||||
'varying vec4 vColor;',
|
'void main() {',
|
||||||
'void main() {',
|
'gl_FragColor=vColor;',
|
||||||
'gl_FragColor=vColor;',
|
'}'
|
||||||
'}'
|
],
|
||||||
],
|
[
|
||||||
[
|
'varying highp vec2 vTextureCoord;',
|
||||||
'varying highp vec2 vTextureCoord;',
|
'varying highp vec3 vLighting;',
|
||||||
'varying highp vec3 vLighting;',
|
'uniform sampler2D uSampler;',
|
||||||
'uniform sampler2D uSampler;',
|
'void main(void) {',
|
||||||
'void main(void) {',
|
'highp vec4 texelColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));',
|
||||||
'highp vec4 texelColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));',
|
'gl_FragColor = vec4(texelColor.rgb * vLighting, texelColor.a);',
|
||||||
'gl_FragColor = vec4(texelColor.rgb * vLighting, texelColor.a);',
|
'}'
|
||||||
'}'
|
]
|
||||||
]
|
],
|
||||||
])
|
vertex1: [
|
||||||
},
|
[
|
||||||
vertex1: function () {
|
'attribute vec4 aVertex;',
|
||||||
return random.pick([
|
'attribute vec4 aColor;',
|
||||||
[
|
'varying vec4 vColor;',
|
||||||
'attribute vec4 aVertex;',
|
'void main(){',
|
||||||
'attribute vec4 aColor;',
|
'vColor=aColor;',
|
||||||
'varying vec4 vColor;',
|
'gl_Position=aVertex;',
|
||||||
'void main(){',
|
'}'
|
||||||
'vColor=aColor;',
|
],
|
||||||
'gl_Position=aVertex;',
|
[
|
||||||
'}'
|
'attribute highp vec3 aVertexNormal;',
|
||||||
],
|
'attribute highp vec3 aVertexPosition;',
|
||||||
[
|
'attribute highp vec2 aTextureCoord;',
|
||||||
'attribute highp vec3 aVertexNormal;',
|
'uniform highp mat4 uNormalMatrix;',
|
||||||
'attribute highp vec3 aVertexPosition;',
|
'uniform highp mat4 uMVMatrix;',
|
||||||
'attribute highp vec2 aTextureCoord;',
|
'uniform highp mat4 uPMatrix;',
|
||||||
'uniform highp mat4 uNormalMatrix;',
|
'varying highp vec2 vTextureCoord;',
|
||||||
'uniform highp mat4 uMVMatrix;',
|
'varying highp vec3 vLighting;',
|
||||||
'uniform highp mat4 uPMatrix;',
|
'void main(void) {',
|
||||||
'varying highp vec2 vTextureCoord;',
|
'gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);',
|
||||||
'varying highp vec3 vLighting;',
|
'vTextureCoord = aTextureCoord;',
|
||||||
'void main(void) {',
|
'highp vec3 ambientLight = vec3(0.6, 0.6, 0.6);',
|
||||||
'gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);',
|
'highp vec3 directionalLightColor = vec3(0.5, 0.5, 0.75);',
|
||||||
'vTextureCoord = aTextureCoord;',
|
'highp vec3 directionalVector = vec3(0.85, 0.8, 0.75);',
|
||||||
'highp vec3 ambientLight = vec3(0.6, 0.6, 0.6);',
|
'highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);',
|
||||||
'highp vec3 directionalLightColor = vec3(0.5, 0.5, 0.75);',
|
'highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0);',
|
||||||
'highp vec3 directionalVector = vec3(0.85, 0.8, 0.75);',
|
'vLighting = ambientLight + (directionalLightColor * directional);',
|
||||||
'highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);',
|
'}'
|
||||||
'highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0);',
|
]
|
||||||
'vLighting = ambientLight + (directionalLightColor * directional);',
|
],
|
||||||
'}'
|
fragment2: [
|
||||||
]
|
[
|
||||||
])
|
'varying highp vec2 vTextureCoord;',
|
||||||
},
|
'varying highp vec3 vLighting;',
|
||||||
fragment2: function () {
|
'uniform sampler2D uSampler;',
|
||||||
return random.pick([
|
'void main(void) {',
|
||||||
[
|
'highp vec4 texelColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));',
|
||||||
'varying highp vec2 vTextureCoord;',
|
'gl_FragColor = vec4(texelColor.rgb * vLighting, texelColor.a);',
|
||||||
'varying highp vec3 vLighting;',
|
'}'
|
||||||
'uniform sampler2D uSampler;',
|
],
|
||||||
'void main(void) {',
|
[
|
||||||
'highp vec4 texelColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));',
|
'#version proto-200',
|
||||||
'gl_FragColor = vec4(texelColor.rgb * vLighting, texelColor.a);',
|
'uniform sampler2D albedoMap;',
|
||||||
'}'
|
'uniform sampler2D normalMap;',
|
||||||
],
|
'varying vec3 varyingTangent;',
|
||||||
[
|
'varying vec3 varyingBitangent;',
|
||||||
'#version proto-200',
|
'varying vec3 varyingNormal;',
|
||||||
'uniform sampler2D albedoMap;',
|
'varying vec2 varyingUV;',
|
||||||
'uniform sampler2D normalMap;',
|
'void main(void) {',
|
||||||
'varying vec3 varyingTangent;',
|
'vec3 albedo=texture2D(albedoMap,varyingUV).rgb;',
|
||||||
'varying vec3 varyingBitangent;',
|
'vec3 normal=texture2D(normalMap,varyingUV).rgb*2.0-1.0;',
|
||||||
'varying vec3 varyingNormal;',
|
'float specularFactor=pow((albedo.r+albedo.g+albedo.b)*0.33,2.0);',
|
||||||
'varying vec2 varyingUV;',
|
'float specularHardness=2.0;',
|
||||||
'void main(void) {',
|
'vec3 spaceNormal=varyingTangent*normal.x+varyingBitangent*normal.y+varyingNormal*normal.z;',
|
||||||
'vec3 albedo=texture2D(albedoMap,varyingUV).rgb;',
|
'gl_FragData[0]=vec4(albedo,1.0);',
|
||||||
'vec3 normal=texture2D(normalMap,varyingUV).rgb*2.0-1.0;',
|
'gl_FragData[1]=vec4(spaceNormal*0.5 +0.5,1.0);',
|
||||||
'float specularFactor=pow((albedo.r+albedo.g+albedo.b)*0.33,2.0);',
|
'gl_FragData[2]=vec4(specularFactor,specularHardness*0.1,0.0,1.0);',
|
||||||
'float specularHardness=2.0;',
|
'}'
|
||||||
'vec3 spaceNormal=varyingTangent*normal.x+varyingBitangent*normal.y+varyingNormal*normal.z;',
|
]
|
||||||
'gl_FragData[0]=vec4(albedo,1.0);',
|
],
|
||||||
'gl_FragData[1]=vec4(spaceNormal*0.5 +0.5,1.0);',
|
vertex2: [
|
||||||
'gl_FragData[2]=vec4(specularFactor,specularHardness*0.1,0.0,1.0);',
|
[
|
||||||
'}'
|
'attribute highp vec3 aVertexNormal;',
|
||||||
]
|
'attribute highp vec3 aVertexPosition;',
|
||||||
])
|
'attribute highp vec2 aTextureCoord;',
|
||||||
},
|
'uniform highp mat4 uNormalMatrix;',
|
||||||
vertex2: function () {
|
'uniform highp mat4 uMVMatrix;',
|
||||||
return random.pick([
|
'uniform highp mat4 uPMatrix;',
|
||||||
[
|
'varying highp vec2 vTextureCoord;',
|
||||||
'attribute highp vec3 aVertexNormal;',
|
'varying highp vec3 vLighting;',
|
||||||
'attribute highp vec3 aVertexPosition;',
|
'void main(void) {',
|
||||||
'attribute highp vec2 aTextureCoord;',
|
'gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);',
|
||||||
'uniform highp mat4 uNormalMatrix;',
|
'vTextureCoord = aTextureCoord;',
|
||||||
'uniform highp mat4 uMVMatrix;',
|
'highp vec3 ambientLight = vec3(0.6, 0.6, 0.6);',
|
||||||
'uniform highp mat4 uPMatrix;',
|
'highp vec3 directionalLightColor = vec3(0.5, 0.5, 0.75);',
|
||||||
'varying highp vec2 vTextureCoord;',
|
'highp vec3 directionalVector = vec3(0.85, 0.8, 0.75);',
|
||||||
'varying highp vec3 vLighting;',
|
'highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);',
|
||||||
'void main(void) {',
|
'highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0);',
|
||||||
'gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);',
|
'vLighting = ambientLight + (directionalLightColor * directional);',
|
||||||
'vTextureCoord = aTextureCoord;',
|
'}'
|
||||||
'highp vec3 ambientLight = vec3(0.6, 0.6, 0.6);',
|
],
|
||||||
'highp vec3 directionalLightColor = vec3(0.5, 0.5, 0.75);',
|
[
|
||||||
'highp vec3 directionalVector = vec3(0.85, 0.8, 0.75);',
|
'#version proto-200',
|
||||||
'highp vec4 transformedNormal = uNormalMatrix * vec4(aVertexNormal, 1.0);',
|
'attribute vec3 vertexPosition;',
|
||||||
'highp float directional = max(dot(transformedNormal.xyz, directionalVector), 0.0);',
|
'attribute vec3 vertexTangent;',
|
||||||
'vLighting = ambientLight + (directionalLightColor * directional);',
|
'attribute vec3 vertexBitangent;',
|
||||||
'}'
|
'attribute vec3 vertexNormal;',
|
||||||
],
|
'attribute vec2 vertexUV;',
|
||||||
[
|
'uniform mat4 modelMatrix;',
|
||||||
'#version proto-200',
|
'uniform mat4 viewMatrix;',
|
||||||
'attribute vec3 vertexPosition;',
|
'varying vec3 varyingTangent;',
|
||||||
'attribute vec3 vertexTangent;',
|
'varying vec3 varyingBitangent;',
|
||||||
'attribute vec3 vertexBitangent;',
|
'varying vec3 varyingNormal;',
|
||||||
'attribute vec3 vertexNormal;',
|
'varying vec2 varyingUV;',
|
||||||
'attribute vec2 vertexUV;',
|
'void main(void){',
|
||||||
'uniform mat4 modelMatrix;',
|
'gl_Position=viewMatrix*(modelMatrix*vec4(vertexPosition,1.0));',
|
||||||
'uniform mat4 viewMatrix;',
|
'gl_Position.xy=gl_Position.xy*0.5+(float(gl_InstanceID)-0.5);',
|
||||||
'varying vec3 varyingTangent;',
|
'varyingTangent=(modelMatrix*vec4(vertexTangent,0.0)).xyz;',
|
||||||
'varying vec3 varyingBitangent;',
|
'varyingBitangent=(modelMatrix*vec4(vertexBitangent,0.0)).xyz;',
|
||||||
'varying vec3 varyingNormal;',
|
'varyingNormal=(modelMatrix*vec4(vertexNormal,0.0)).xyz;',
|
||||||
'varying vec2 varyingUV;',
|
'varyingUV = vertexUV;',
|
||||||
'void main(void){',
|
'}'
|
||||||
'gl_Position=viewMatrix*(modelMatrix*vec4(vertexPosition,1.0));',
|
]
|
||||||
'gl_Position.xy=gl_Position.xy*0.5+(float(gl_InstanceID)-0.5);',
|
],
|
||||||
'varyingTangent=(modelMatrix*vec4(vertexTangent,0.0)).xyz;',
|
|
||||||
'varyingBitangent=(modelMatrix*vec4(vertexBitangent,0.0)).xyz;',
|
|
||||||
'varyingNormal=(modelMatrix*vec4(vertexNormal,0.0)).xyz;',
|
|
||||||
'varyingUV = vertexUV;',
|
|
||||||
'}'
|
|
||||||
]
|
|
||||||
])
|
|
||||||
},
|
|
||||||
shaderPair: function (v, f) {
|
shaderPair: function (v, f) {
|
||||||
let i = random.number(v.length)
|
let i = random.number(v.length)
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue