seedy projeckt jolked
This commit is contained in:
BIN
src/main/resources/Comic Sans MS.ttf
Normal file
BIN
src/main/resources/Comic Sans MS.ttf
Normal file
Binary file not shown.
BIN
src/main/resources/cobblestone.png
Normal file
BIN
src/main/resources/cobblestone.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 307 KiB |
BIN
src/main/resources/colin.png
Normal file
BIN
src/main/resources/colin.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 74 KiB |
BIN
src/main/resources/jolkmeup.jpg
Normal file
BIN
src/main/resources/jolkmeup.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.7 KiB |
241
src/main/resources/lit.frag.glsl
Normal file
241
src/main/resources/lit.frag.glsl
Normal file
@@ -0,0 +1,241 @@
|
||||
#ifdef GL_ES
|
||||
#define LOWP lowp
|
||||
#define MEDP mediump
|
||||
#define HIGHP highp
|
||||
precision mediump float;
|
||||
#else
|
||||
#define LOWP
|
||||
#define MEDP
|
||||
#define HIGHP
|
||||
#endif
|
||||
|
||||
#ifdef normalFlag
|
||||
varying vec3 v_normal;
|
||||
#endif // normalFlag
|
||||
|
||||
#ifdef colorFlag
|
||||
varying vec4 v_color;
|
||||
#endif // colorFlag
|
||||
|
||||
#if defined(diffuseTextureFlag) || defined(specularTextureFlag) || defined(emissiveTextureFlag)
|
||||
#define textureFlag
|
||||
#endif
|
||||
#ifdef diffuseTextureFlag
|
||||
varying MEDP vec2 v_diffuseUV;
|
||||
uniform sampler2D u_diffuseTexture;
|
||||
#endif // diffuseTextureFlag
|
||||
#ifdef specularTextureFlag
|
||||
varying MEDP vec2 v_specularUV;
|
||||
uniform sampler2D u_specularTexture;
|
||||
#endif // specularTextureFlag
|
||||
/*
|
||||
#ifdef emissiveTextureFlag
|
||||
varying MEDP vec2 v_emissiveUV;
|
||||
uniform sampler2D u_emissiveTexture;
|
||||
#endif // emissiveTextureFlag
|
||||
*/
|
||||
|
||||
#ifdef diffuseColorFlag
|
||||
uniform vec4 u_diffuseColor;
|
||||
#endif // diffuseColorFlag
|
||||
|
||||
#ifdef specularColorFlag
|
||||
uniform vec4 u_specularColor;
|
||||
#endif
|
||||
|
||||
#ifdef lightingFlag
|
||||
varying vec3 v_lightDiffuse;
|
||||
|
||||
#ifdef shininessFlag
|
||||
uniform float u_shininess;
|
||||
#else
|
||||
const float u_shininess = 20.0;
|
||||
#endif // shininessFlag
|
||||
|
||||
#if numDirectionalLights > 0
|
||||
struct DirectionalLight
|
||||
{
|
||||
vec3 color;
|
||||
vec3 direction;
|
||||
};
|
||||
uniform DirectionalLight u_dirLights[numDirectionalLights];
|
||||
#endif // numDirectionalLights
|
||||
|
||||
#if numPointLights > 0
|
||||
struct PointLight
|
||||
{
|
||||
vec3 color;
|
||||
vec3 position;
|
||||
};
|
||||
uniform PointLight u_pointLights[numPointLights];
|
||||
#endif // numPointLights
|
||||
|
||||
#if defined(ambientLightFlag) || defined(ambientCubemapFlag) || defined(sphericalHarmonicsFlag)
|
||||
#define ambientFlag
|
||||
varying vec3 v_ambient;
|
||||
#endif // ambientFlag
|
||||
|
||||
#if defined(specularTextureFlag) || defined(specularColorFlag)
|
||||
#define specularFlag
|
||||
#endif
|
||||
|
||||
#endif // lightingFlag
|
||||
|
||||
#if defined(specularFlag) || defined(fogFlag)
|
||||
varying vec4 v_worldPosition;
|
||||
uniform vec4 u_cameraPosition;
|
||||
#endif // lightingFlag || fogFlag
|
||||
|
||||
#ifdef fogFlag
|
||||
uniform vec4 u_fogColor;
|
||||
varying float v_fog;
|
||||
#endif // fogFlag
|
||||
|
||||
uniform mat4 u_projViewTrans;
|
||||
uniform mat4 u_worldTrans;
|
||||
|
||||
vec3 linearEncode(vec3 v) { return vec3(pow(v.r, 2.2), pow(v.g, 2.2), pow(v.b, 2.2)); }
|
||||
vec3 linearDecode(vec3 v) { return vec3(pow(v.r, 1.0 / 2.2), pow(v.g, 1.0 / 2.2), pow(v.b, 1.0 / 2.2)); }
|
||||
|
||||
void main()
|
||||
{
|
||||
#if defined(diffuseTextureFlag) && defined(diffuseColorFlag) && defined(colorFlag)
|
||||
vec4 diffuse = texture2D(u_diffuseTexture, v_diffuseUV) * u_diffuseColor * v_color;
|
||||
#elif defined(diffuseTextureFlag) && defined(diffuseColorFlag)
|
||||
vec4 diffuse = texture2D(u_diffuseTexture, v_diffuseUV) * u_diffuseColor;
|
||||
#elif defined(diffuseTextureFlag) && defined(colorFlag)
|
||||
vec4 diffuse = texture2D(u_diffuseTexture, v_diffuseUV) * v_color;
|
||||
#elif defined(diffuseTextureFlag)
|
||||
vec4 diffuse = texture2D(u_diffuseTexture, v_diffuseUV);
|
||||
#elif defined(diffuseColorFlag) && defined(colorFlag)
|
||||
vec4 diffuse = u_diffuseColor * v_color;
|
||||
#elif defined(diffuseColorFlag)
|
||||
vec4 diffuse = u_diffuseColor;
|
||||
#elif defined(colorFlag)
|
||||
vec4 diffuse = v_color;
|
||||
#else
|
||||
vec4 diffuse = vec4(1.0);
|
||||
#endif
|
||||
diffuse.rgb = linearEncode(diffuse.rgb);
|
||||
|
||||
#ifdef lightingFlag
|
||||
|
||||
#ifdef normalFlag
|
||||
vec3 normal = normalize(v_normal);
|
||||
#endif // normalFlag
|
||||
|
||||
#ifdef ambientFlag
|
||||
vec3 accum = v_ambient;
|
||||
#else // !ambientFlag
|
||||
vec3 accum = vec3(0.0);
|
||||
#endif // ambientFlag
|
||||
|
||||
#ifdef specularFlag
|
||||
vec3 eyeVec = normalize(u_cameraPosition.xyz - v_worldPosition.xyz);
|
||||
vec3 specAccum = vec3(0.0);
|
||||
#endif // specularFlag
|
||||
|
||||
#if defined(normalFlag) && (numDirectionalLights > 0)
|
||||
for (int i = 0; i < numDirectionalLights; ++i)
|
||||
{
|
||||
vec3 lightVec = -u_dirLights[i].direction;
|
||||
float lambert = dot(normal, lightVec);
|
||||
float phongTerm = max(lambert, 0.0);
|
||||
vec3 value = u_dirLights[i].color * phongTerm;
|
||||
value = linearEncode(value);
|
||||
value *= phongTerm;
|
||||
accum += value;
|
||||
#ifdef specularFlag
|
||||
vec3 halfDir = normalize(lightVec + eyeVec);
|
||||
float specAngle = max(dot(halfDir, normal), 0.0);
|
||||
float specTerm = pow(specAngle, u_shininess);
|
||||
specAccum += value * specTerm;
|
||||
#endif // specularFlag
|
||||
}
|
||||
#endif // normalFlag && numDirectionalLights
|
||||
|
||||
vec3 fragment;
|
||||
#ifdef specularFlag
|
||||
#ifdef specularTextureFlag
|
||||
vec3 specularColorTex = texture2D(u_specularTexture, v_specularUV).rgb;
|
||||
specularColorTex = linearEncode(specularColorTex);
|
||||
specAccum *= specularColorTex;
|
||||
#endif // specularTextureFlag
|
||||
#ifdef specularColorFlag
|
||||
vec3 specularColor = u_specularColor.rgb;
|
||||
specularColor = linearEncode(specularColor);
|
||||
specAccum *= specularColor;
|
||||
#endif // specularColorFlag
|
||||
fragment = diffuse.rgb * accum + specAccum;
|
||||
#else // !specularFlag
|
||||
fragment = diffuse.rgb * accum;
|
||||
#endif // specularFlag
|
||||
#else // !lightingFlag
|
||||
fragment = diffuse.rgb;
|
||||
#endif // lightingFlag
|
||||
|
||||
#ifdef fogFlag
|
||||
#define fogDistance
|
||||
//#define fogDepth
|
||||
|
||||
//#define fogOriginal
|
||||
//#define fogLinear
|
||||
#define fogSmooth
|
||||
//#define fogInvSquare
|
||||
//#define fogExp
|
||||
//#define fogExp2
|
||||
|
||||
#if defined(fogLinear) || defined(fogSmooth) || defined(fogInvSquare)
|
||||
float near = 1.5;
|
||||
float far = 20.5;
|
||||
#elif defined(fogExp) || defined(fogExp2)
|
||||
float density = 0.12;
|
||||
#endif
|
||||
|
||||
#ifdef fogOriginal
|
||||
vec3 fvec = u_cameraPosition.xyz - v_worldPosition.xyz;
|
||||
float flen = dot(fvec, fvec);
|
||||
float fog = min(flen * u_cameraPosition.w, 1.0);
|
||||
#elif defined(fogDistance)
|
||||
float flen = length(v_worldPosition.xyz - u_cameraPosition.xyz);
|
||||
#elif defined(fogDepth)
|
||||
float flen = gl_FragCoord.z / gl_FragCoord.w;
|
||||
#endif // fogOriginal || fogDistance || fogDepth
|
||||
|
||||
#ifdef fogLinear
|
||||
// fog = saturate(linearstep(near, far, x))
|
||||
float fog = clamp((flen - near) / (far - near), 0.0, 1.0);
|
||||
#elif defined(fogSmooth)
|
||||
// fog = smoothstep(saturate(linearstep(near, far, x)))
|
||||
float fog = clamp((flen - near) / (far - near), 0.0, 1.0);
|
||||
fog = fog * fog * (3.0 - 2.0 * fog);
|
||||
//fog = fog * fog * fog * (fog * (6.0 * fog - 15.0) + 10.0);
|
||||
#elif defined(fogInvSquare)
|
||||
// fog = isqstep(saturate(linearstep(near, far, x)))
|
||||
float fog = clamp((flen - near) / (far - near), 0.0, 1.0);
|
||||
fog = 1.0 - fog;
|
||||
fog = 1.0 - fog * fog;
|
||||
#elif defined(fogExp)
|
||||
float fog = max(1.0 - exp(-density * flen), 0.0);
|
||||
#elif defined(fogExp2)
|
||||
float dz = density * flen;
|
||||
float fog = max(1.0 - exp(-dz * dz), 0.0);
|
||||
#endif // fogLinear || fogSmooth || fogInvSquare || fogExp || fogExp2
|
||||
|
||||
vec3 fogColor = u_fogColor.rgb;
|
||||
fogColor = linearEncode(fogColor);
|
||||
fragment = mix(fragment, fogColor, fog);
|
||||
#endif // fogFlag
|
||||
gl_FragColor = vec4(linearDecode(fragment), diffuse.a);
|
||||
/*
|
||||
if (gl_FragCoord.x > 1280.0)
|
||||
{
|
||||
if (fog <= 0.0)
|
||||
gl_FragColor = vec4(1.0, 0.0, 1.0, diffuse.a);
|
||||
else if (fog >= 1.0)
|
||||
gl_FragColor = vec4(1.0, 0.0, 0.0, diffuse.a);
|
||||
else
|
||||
gl_FragColor = vec4(fog, fog, 0.0, diffuse.a);
|
||||
}
|
||||
*/
|
||||
}
|
||||
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;
|
||||
}
|
||||
BIN
src/main/resources/nut.wav
Normal file
BIN
src/main/resources/nut.wav
Normal file
Binary file not shown.
BIN
src/main/resources/suzanne.g3db
Normal file
BIN
src/main/resources/suzanne.g3db
Normal file
Binary file not shown.
BIN
src/main/resources/wall.png
Normal file
BIN
src/main/resources/wall.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
Reference in New Issue
Block a user