uniform mat4 worldViewProjection; uniform mat4 world; uniform mat4 view; uniform vec3 sunPos; attribute vec4 position; attribute vec3 normal; varying vec4 v_pos; varying vec3 v_normal; varying vec3 v_sun; varying vec3 v_view; void main() { gl_Position = worldViewProjection * position; v_normal = (world * vec4(normal, 0)).xyz; vec3 worldPos = (world * position).xyz; v_sun = sunPos - worldPos; v_view = (view[3].xyz- worldPos); v_pos = gl_Position; } // #o3d SplitMarker varying vec4 v_pos; varying vec3 v_normal; varying vec3 v_sun; varying vec3 v_view; vec4 lit(float l, float h, float m) { return vec4(1.0, max(l, 0.0), (l > 0.0) ? pow(max(0.0, h), m) : 0.0, 1.0); } void main() { vec3 norm = normalize(v_normal); vec3 sun = normalize(v_sun); float light = dot(norm, sun); float lightSign = sign(light); float dayNight = 1.0 - sqrt(abs(light)); dayNight = dayNight * dayNight; dayNight = (1.0 - dayNight) * lightSign; dayNight = clamp(dayNight, 0.0, 1.0); vec3 view = normalize(v_view); vec3 r = normalize(reflect(norm, sun)); vec4 litR = vec4(lit(light, dot(r, view), 0.0).y); vec3 day = vec3(0.5, 0.5, 1.0) * litR.y + vec3(1,1,1) * litR.z; vec3 night = vec3(0.2, 0.2, 0.5); gl_FragColor = vec4(mix(night, day, dayNight),1); } // #o3d MatrixLoadOrder RowMajor
uniform mat4 worldViewProjection; uniform mat4 world; uniform mat4 view; uniform vec3 sunPos; attribute vec4 position; attribute vec3 normal; attribute vec2 texCoord0; varying vec2 v_uv; varying vec3 v_normal; varying vec3 v_sun; varying vec3 v_view; void main() { gl_Position = (worldViewProjection * position); v_uv = texCoord0; v_normal = (world * vec4(normal, 0)).xyz; vec3 worldPos = (world * position).xyz; v_sun = sunPos - worldPos; v_view = (view[3].xyz - worldPos); } // #o3d SplitMarker uniform float time; uniform sampler2D daySampler; varying vec2 v_uv; varying vec3 v_normal; varying vec3 v_sun; varying vec3 v_view; vec4 lit(float l, float h, float m) { return vec4(1.0, max(l, 0.0), (l > 0.0) ? pow(max(0.0, h), m) : 0.0, 1.0); } void main() { vec3 norm = normalize(v_normal); vec3 sun = normalize(v_sun); float light = dot(norm, sun); float lightSign = sign(light); float dayNight = 1.0 - sqrt(abs(light)); dayNight = dayNight * dayNight; dayNight = (1.0 - dayNight) * lightSign; dayNight = clamp(dayNight, 0.0, 1.0); vec3 view = normalize(v_view); vec3 r = normalize(reflect(norm, sun)); vec4 litR = vec4(lit(light, dot(r, view), 0.0).y); vec3 earth = texture2D(daySampler, v_uv).xyz; vec3 day = mix(vec3(0.5, 0.5, 1.0), earth, time); day = day * litR.y + vec3(1,1,1) * litR.z; vec3 night = mix(vec3(0.2, 0.2, 0.5), earth * 0.3, time); gl_FragColor = vec4(mix(night, day, dayNight),1); } // #o3d MatrixLoadOrder RowMajor
uniform mat4 worldViewProjection; uniform mat4 world; uniform mat4 view; uniform vec3 sunPos; attribute vec4 position; attribute vec3 normal; attribute vec2 texCoord0; varying vec2 v_uv; varying vec3 v_normal; varying vec3 v_sun; varying vec3 v_view; void main() { gl_Position = worldViewProjection * position; v_uv = texCoord0; v_normal = (world * vec4(normal, 0)).xyz; vec3 worldPos = (world * position).xyz; v_sun = sunPos - worldPos; v_view = (view[3].xyz - worldPos); } // #o3d SplitMarker uniform float time; uniform sampler2D daySampler; uniform sampler2D nightSampler; varying vec2 v_uv; varying vec3 v_normal; varying vec3 v_sun; varying vec3 v_view; vec4 lit(float l, float h, float m) { return vec4(1.0, max(l, 0.0), (l > 0.0) ? pow(max(0.0, h), m) : 0.0, 1.0); } void main() { vec3 norm = normalize(v_normal); vec3 sun = normalize(v_sun); float light = dot(norm, sun); float lightSign = sign(light); float dayNight = 1.0 - sqrt(abs(light)); dayNight = dayNight * dayNight; dayNight = (1.0 - dayNight) * lightSign; dayNight = clamp(dayNight, 0.0, 1.0); vec3 view = normalize(v_view); vec3 r = normalize(reflect(norm, sun)); vec4 litR = vec4(lit(light, dot(r, view), 0.0).y); vec3 earth = texture2D(daySampler, v_uv).xyz; vec3 day = texture2D(daySampler, v_uv).xyz; vec3 night = mix(day * 0.3, texture2D(nightSampler, v_uv).xyz, time); day = day * litR.y + vec3(1,1,1) * litR.z; gl_FragColor = vec4(mix(night, day, dayNight),1); } // #o3d MatrixLoadOrder RowMajor
uniform mat4 worldViewProjection; uniform mat4 world; uniform mat4 view; uniform vec3 sunPos; attribute vec4 position; attribute vec3 normal; attribute vec2 texCoord0; varying vec2 v_uv; varying vec3 v_normal; varying vec3 v_sun; varying vec3 v_view; void main() { gl_Position = worldViewProjection * position; v_uv = texCoord0; v_normal = (world * vec4(normal, 0)).xyz; vec3 worldPos = (world * position).xyz; v_sun = sunPos - worldPos; v_view = (view[3].xyz - worldPos); } // #o3d SplitMarker uniform float time; uniform sampler2D daySampler; uniform sampler2D nightSampler; uniform sampler2D maskSampler; varying vec2 v_uv; varying vec3 v_normal; varying vec3 v_sun; varying vec3 v_view; vec4 lit(float l, float h, float m) { return vec4(1.0, max(l, 0.0), (l > 0.0) ? pow(max(0.0, h), m) : 0.0, 1.0); } void main() { vec3 norm = normalize(v_normal); vec3 sun = normalize(v_sun); float light = dot(norm, sun); float lightSign = sign(light); float dayNight = 1.0 - sqrt(abs(light)); dayNight = dayNight * dayNight; dayNight = (1.0 - dayNight) * lightSign; dayNight = clamp(dayNight, 0.0, 1.0); vec3 view = normalize(v_view); vec3 r = normalize(reflect(norm, sun)); vec4 litR = vec4(lit(light, dot(r, view), 0.0).y); vec3 earth = texture2D(daySampler, v_uv).xyz; vec4 mask = texture2D(maskSampler, v_uv); vec3 day = mix(texture2D(daySampler, v_uv).xyz, mask.xyz, time); vec3 night = texture2D(nightSampler, v_uv).xyz; day = day * litR.y + vec3(1,1,1) * litR.z * (1.0 - mask.w * time); vec3 color = mix(night, day, dayNight); gl_FragColor = vec4(color, 1); } // #o3d MatrixLoadOrder RowMajor
uniform mat4 worldViewProjection; // time is used to scroll the UV coords uniform float time; // offset is used to allow each shard to scroll over a different part of the // texture. uniform float offset; attribute vec4 position; attribute vec4 color; attribute vec2 texCoord0; varying vec4 v_color; varying vec2 v_uv; void main() { gl_Position = worldViewProjection * position; v_uv = vec2(texCoord0.x, texCoord0.y + time + offset); v_color = color; } // #o3d SplitMarker // Sets the color of the shard. uniform vec4 colorMult; // Provides the dots on the shard. uniform sampler2D energySampler; varying vec4 v_color; varying vec2 v_uv; void main() { gl_FragColor = texture2D(energySampler, v_uv) * v_color * colorMult; } // #o3d MatrixLoadOrder RowMajor
uniform mat4 worldViewProjection; uniform mat4 worldView; attribute vec4 position; attribute vec3 normal; varying vec3 v_normal; void main() { gl_Position = worldViewProjection * position; v_normal = normalize((worldView * vec4(normal,0)).xyz); } // #o3d SplitMarker varying vec3 v_normal; void main() { float n = 1.0 - log(2.0 * normalize(v_normal).z); gl_FragColor = vec4(0.3, 0.3, 1, n * n * n * n); } // #o3d MatrixLoadOrder RowMajor