seedy projeckt jolked
This commit is contained in:
119
src/main/resources/lit.vert.glsl
Normal file
119
src/main/resources/lit.vert.glsl
Normal file
@@ -0,0 +1,119 @@
|
||||
attribute vec3 a_position;
|
||||
uniform mat4 u_projViewTrans;
|
||||
|
||||
#ifdef normalFlag
|
||||
attribute vec3 a_normal;
|
||||
uniform mat3 u_normalMatrix;
|
||||
varying vec3 v_normal;
|
||||
#endif // normalFlag
|
||||
|
||||
#ifdef colorFlag
|
||||
varying vec4 v_color;
|
||||
attribute vec4 a_color;
|
||||
#endif // colorFlag
|
||||
|
||||
#if defined(diffuseTextureFlag) || defined(specularTextureFlag) || defined(emissiveTextureFlag)
|
||||
#define textureFlag
|
||||
#endif
|
||||
|
||||
#if defined(ambientLightFlag) || defined(ambientCubemapFlag) || defined(sphericalHarmonicsFlag)
|
||||
#define ambientFlag
|
||||
#endif // ambientFlag
|
||||
|
||||
#ifdef textureFlag
|
||||
attribute vec2 a_texCoord0;
|
||||
#endif // textureFlag
|
||||
|
||||
#ifdef diffuseTextureFlag
|
||||
uniform vec4 u_diffuseUVTransform;
|
||||
varying vec2 v_diffuseUV;
|
||||
#endif
|
||||
|
||||
#ifdef emissiveTextureFlag
|
||||
uniform vec4 u_emissiveUVTransform;
|
||||
varying vec2 v_emissiveUV;
|
||||
#endif
|
||||
|
||||
#ifdef specularTextureFlag
|
||||
uniform vec4 u_specularUVTransform;
|
||||
varying vec2 v_specularUV;
|
||||
#endif
|
||||
|
||||
uniform mat4 u_worldTrans;
|
||||
|
||||
#ifdef lightingFlag
|
||||
|
||||
#ifdef ambientLightFlag
|
||||
uniform vec3 u_ambientLight;
|
||||
#endif // ambientLightFlag
|
||||
|
||||
#ifdef ambientLightFlag
|
||||
uniform vec3 u_ambientLight;
|
||||
#endif // ambientLightFlag
|
||||
|
||||
#ifdef ambientCubemapFlag
|
||||
uniform vec3 u_ambientCubemap[6];
|
||||
#endif // ambientCubemapFlag
|
||||
|
||||
/*
|
||||
#ifdef sphericalHarmonicsFlag
|
||||
uniform vec3 u_sphericalHarmonics[9];
|
||||
#endif // sphericalHarmonicsFlag
|
||||
*/
|
||||
|
||||
#ifdef ambientFlag
|
||||
varying vec3 v_ambient;
|
||||
#endif // ambientFlag
|
||||
|
||||
#endif // lightingFlag
|
||||
|
||||
#if defined(lightingFlag) || defined(fogFlag)
|
||||
varying vec4 v_worldPosition;
|
||||
#endif // lightingFlag || fogFlag
|
||||
|
||||
void main()
|
||||
{
|
||||
#ifdef normalFlag
|
||||
//vec3 normal = u_normalMatrix * a_normal;
|
||||
vec3 normal = normalize(u_normalMatrix * a_normal);
|
||||
v_normal = normal;
|
||||
#endif // normalFlag
|
||||
|
||||
#ifdef colorFlag
|
||||
v_color = a_color;
|
||||
#endif // colorFlag
|
||||
|
||||
#ifdef diffuseTextureFlag
|
||||
v_diffuseUV = u_diffuseUVTransform.xy + a_texCoord0 * u_diffuseUVTransform.zw;
|
||||
#endif // diffuseTextureFlag
|
||||
|
||||
#ifdef emissiveTextureFlag
|
||||
v_emissiveUV = u_emissiveUVTransform.xy + a_texCoord0 * u_emissiveUVTransform.zw;
|
||||
#endif // emissiveTextureFlag
|
||||
|
||||
#ifdef specularTextureFlag
|
||||
v_specularUV = u_specularUVTransform.xy + a_texCoord0 * u_specularUVTransform.zw;
|
||||
#endif // specularTextureFlag
|
||||
|
||||
#ifdef ambientLightFlag
|
||||
v_ambient = u_ambientLight;
|
||||
#else // !ambientLightFlag
|
||||
v_ambient = vec3(0.0);
|
||||
#endif // ambientLightFlag
|
||||
|
||||
#ifdef ambientCubemapFlag
|
||||
vec3 norm2 = normal * normal;
|
||||
vec3 isPositive = step(0.0, normal);
|
||||
v_ambient +=
|
||||
norm2.x * mix(u_ambientCubemap[0], u_ambientCubemap[1], isPositive.x) +
|
||||
norm2.y * mix(u_ambientCubemap[2], u_ambientCubemap[3], isPositive.y) +
|
||||
norm2.z * mix(u_ambientCubemap[4], u_ambientCubemap[5], isPositive.z);
|
||||
#endif // ambientCubemapFlag
|
||||
|
||||
vec4 worldPos = u_worldTrans * vec4(a_position, 1.0);
|
||||
#if defined(lightingFlag) || defined(fogFlag)
|
||||
v_worldPosition = worldPos;
|
||||
//v_cameraPosition = u_cameraPosition;
|
||||
#endif // lightingFlag || fogFlag
|
||||
gl_Position = u_projViewTrans * worldPos;
|
||||
}
|
||||
Reference in New Issue
Block a user