Paste your logs.

Built for Minecraft & Hytale

Forge 1.18.1 Client Log

176 errors
20697 lines
Raw
Detected
Minecraft version: 1.18.1 Forge version: 39.0.17 Java version: 17.0.1
[11Jan2022 17:17:12.316] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, DvI_y, --version, 1.18.1-forge-39.0.17, --gameDir, C:\Users\PC\AppData\Roaming\.minecraft, --assetsDir, C:\Users\PC\AppData\Roaming\.minecraft\assets, --assetIndex, 1.18, --uuid, 5e8660f7df7b4aad8405bd65e7b7e8f5, --accessToken, ????????, --clientId, NTg2NDg1ODEtNTBmNC00YTk1LTgyN2EtMTdkZGI0Y2UyY2Yx, --xuid, 2535405237799348, --userType, msa, --versionType, release, --launchTarget, forgeclient, --fml.forgeVersion, 39.0.17, --fml.mcVersion, 1.18.1, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20211210.034407]
[11Jan2022 17:17:12.321] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 9.0.7+91+master.8569cdf starting: java version 17.0.1 by Microsoft
[11Jan2022 17:17:12.569] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFineTransformationService.onLoad
[11Jan2022 17:17:12.570] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFine ZIP file URL: union:/C:/Users/PC/AppData/Roaming/.minecraft/mods/OptiFine_1.18.1_HD_U_H4.jar%2352!
[11Jan2022 17:17:12.580] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFine ZIP file: C:\Users\PC\AppData\Roaming\.minecraft\mods\OptiFine_1.18.1_HD_U_H4.jar
[11Jan2022 17:17:12.582] [main/INFO] [optifine.OptiFineTransformer/]: Target.PRE_CLASS is available
[11Jan2022 17:17:12.653] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.5 Source=union:/C:/Users/PC/AppData/Roaming/.minecraft/libraries/org/spongepowered/mixin/0.8.5/mixin-0.8.5.jar%2319! Service=ModLauncher Env=CLIENT
[11Jan2022 17:17:12.662] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFineTransformationService.initialize
[11Jan2022 17:17:13.653] [main/INFO] [optifine.OptiFineTransformationService/]: OptiFineTransformationService.transformers
[11Jan2022 17:17:13.659] [main/INFO] [optifine.OptiFineTransformer/]: Targets: 342
[11Jan2022 17:17:14.110] [main/INFO] [optifine.OptiFineTransformationService/]: additionalClassesLocator: [optifine., net.optifine.]
[11Jan2022 17:17:14.553] [main/INFO] [mixin/]: Compatibility level set to JAVA_17
[11Jan2022 17:17:14.559] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'forgeclient' with arguments [--version, 1.18.1-forge-39.0.17, --gameDir, C:\Users\PC\AppData\Roaming\.minecraft, --assetsDir, C:\Users\PC\AppData\Roaming\.minecraft\assets, --uuid, 5e8660f7df7b4aad8405bd65e7b7e8f5, --username, DvI_y, --assetIndex, 1.18, --accessToken, ????????, --clientId, NTg2NDg1ODEtNTBmNC00YTk1LTgyN2EtMTdkZGI0Y2UyY2Yx, --xuid, 2535405237799348, --userType, msa, --versionType, release]
[11Jan2022 17:17:14.883] [main/WARN] [mixin/]: Error loading class: net/minecraft/client/renderer/LevelRenderer (java.lang.UnsupportedOperationException: PermittedSubclasses requires ASM9)
[11Jan2022 17:17:14.883] [main/WARN] [mixin/]: @Mixin target net.minecraft.client.renderer.LevelRenderer was not found flywheel.mixins.json:CancelEntityRenderMixin
[17:17:23] [Render thread/WARN]: Assets URL 'union:/C:/Users/PC/AppData/Roaming/.minecraft/libraries/net/minecraft/client/1.18.1-20211210.034407/client-1.18.1-20211210.034407-srg.jar%2357!/assets/.mcassetsroot' uses unexpected schema
[17:17:23] [Render thread/WARN]: Assets URL 'union:/C:/Users/PC/AppData/Roaming/.minecraft/libraries/net/minecraft/client/1.18.1-20211210.034407/client-1.18.1-20211210.034407-srg.jar%2357!/data/.mcassetsroot' uses unexpected schema
[11Jan2022 17:17:23.450] [Render thread/INFO] [com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService/]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD'
[17:17:24] [Render thread/INFO]: Setting user: DvI_y
[17:17:24] [Render thread/INFO]: [OptiFine] (Reflector) Class not present: net.minecraft.launchwrapper.Launch
[17:17:24] [Render thread/INFO]: Backend library: LWJGL version 3.2.2 SNAPSHOT
[17:17:25] [Render thread/INFO]: [OptiFine]
[17:17:25] [Render thread/INFO]: [OptiFine] OptiFine_1.18.1_HD_U_H4
[17:17:25] [Render thread/INFO]: [OptiFine] Build: 20211212-175054
[17:17:25] [Render thread/INFO]: [OptiFine] OS: Windows 10 (amd64) version 10.0
[17:17:25] [Render thread/INFO]: [OptiFine] Java: 17.0.1, Microsoft
[17:17:25] [Render thread/INFO]: [OptiFine] VM: OpenJDK 64-Bit Server VM (mixed mode), Microsoft
[17:17:25] [Render thread/INFO]: [OptiFine] LWJGL: 3.3.0 Win32 WGL EGL OSMesa VisualC DLL
[17:17:25] [Render thread/INFO]: [OptiFine] OpenGL: Radeon RX 580 Series, version 3.2.14761 Core Profile Forward-Compatible Context 21.10.2 30.0.13025.5005, ATI Technologies Inc.
[17:17:25] [Render thread/INFO]: [OptiFine] OpenGL Version: 3.2.14761
[17:17:25] [Render thread/INFO]: [OptiFine] Maximum texture size: 16384x16384
[17:17:25] [VersionCheck/INFO]: [OptiFine] Checking for new version
[17:17:25] [Render thread/INFO]: [Shaders] OpenGL Version: 3.2.14761 Core Profile Forward-Compatible Context 21.10.2 30.0.13025.5005
[17:17:25] [Render thread/INFO]: [Shaders] Vendor: ATI Technologies Inc.
[17:17:25] [Render thread/INFO]: [Shaders] Renderer: Radeon RX 580 Series
[17:17:25] [Render thread/INFO]: [Shaders] Capabilities: 2.0 2.1 3.0 3.2 -
[17:17:25] [Render thread/INFO]: [Shaders] GL_MAX_DRAW_BUFFERS: 8
[17:17:25] [Render thread/INFO]: [Shaders] GL_MAX_COLOR_ATTACHMENTS: 8
[17:17:25] [Render thread/INFO]: [Shaders] GL_MAX_TEXTURE_IMAGE_UNITS: 32
[17:17:25] [Render thread/INFO]: [Shaders] Load shaders configuration.
[17:17:25] [Render thread/INFO]: [Shaders] No shaderpack loaded.
[17:17:25] [Render thread/INFO]: [OptiFine] [Shaders] Delayed loading of item mappings after resources are loaded
[17:17:25] [Render thread/INFO]: [OptiFine] [Shaders] Delayed loading of entity mappings after resources are loaded
[17:17:26] [modloading-worker-0/INFO]: Forge mod loading, version 39.0.17, for MC 1.18.1 with MCP 20211210.034407
[17:17:26] [modloading-worker-0/INFO]: MinecraftForge v39.0.17 Initialized
[17:17:26] [modloading-worker-0/INFO]: Optifine detected.
[17:17:26] [modloading-worker-0/INFO]: Successfully loaded com.jozufozu.flywheel.mixin.PausedPartialTickAccessor
[17:17:26] [VersionCheck/INFO]: [OptiFine] java.io.FileNotFoundException: http://optifine.net/version/1.18.1/HD_U.txt
[17:17:26] [modloading-worker-0/INFO]: Detected new forge version, registering events reflectively.
[17:17:29] [Render thread/INFO]: Potentially Dangerous alternative prefix `minecraft` for name `milk`, expected `forge`. This could be a intended override, but in most cases indicates a broken mod.
[17:17:29] [Render thread/INFO]: Potentially Dangerous alternative prefix `minecraft` for name `flowing_milk`, expected `forge`. This could be a intended override, but in most cases indicates a broken mod.
[17:17:29] [Render thread/WARN]: [OptiFine] (Reflector) java.lang.ClassNotFoundException: sun.misc.SharedSecrets
[17:17:29] [Render thread/WARN]: [OptiFine] (Reflector) java.lang.ClassNotFoundException: jdk.internal.misc.SharedSecrets
[17:17:29] [Render thread/WARN]: [OptiFine] (Reflector) java.lang.ClassNotFoundException: sun.misc.VM
[17:17:29] [Render thread/WARN]: [OptiFine] (Reflector) java.lang.reflect.InaccessibleObjectException: Unable to make public static long jdk.internal.misc.VM.maxDirectMemory() accessible: module java.base does not "exports jdk.internal.misc" to module net.optifine
[11Jan2022 17:17:30.466] [Render thread/INFO] [com.mojang.text2speech.NarratorWindows/]: Narrator library for x64 successfully loaded
[17:17:30] [Render thread/INFO]: Reloading ResourceManager: Default, Mod Resources
[17:17:30] [Render thread/INFO]: [OptiFine] *** Reloading textures ***
[17:17:30] [Render thread/INFO]: [OptiFine] Resource packs: Mod Resources
[17:17:30] [Render thread/INFO]: [OptiFine] *** Reflector Forge ***
[17:17:30] [Render thread/INFO]: [OptiFine] (Reflector) Class not present: mods.betterfoliage.client.BetterFoliageClient
[17:17:31] [Render thread/INFO]: [OptiFine] *** Reflector Vanilla ***
[17:17:31] [Worker-Main-9/INFO]: [OptiFine] Multitexture: false
[17:17:31] [Worker-Main-15/INFO]: [OptiFine] Multitexture: false
[17:17:31] [Worker-Main-13/INFO]: [OptiFine] Multitexture: false
[17:17:31] [Worker-Main-12/INFO]: [OptiFine] Multitexture: false
[11Jan2022 17:17:31.876] [Forge Version Check/INFO] [net.minecraftforge.fml.VersionChecker/]: [forge] Starting version check at https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json
[17:17:32] [Worker-Main-12/INFO]: [OptiFine] Scaled non power of 2: jei:gui/icons/recipe_transfer, 7 -> 14
[17:17:32] [Worker-Main-15/INFO]: Loading Xaero's Minimap - Stage 1/2
[17:17:33] [Render thread/INFO]: Loading Xaero's Minimap - Stage 2/2
[11Jan2022 17:17:33.167] [Forge Version Check/INFO] [net.minecraftforge.fml.VersionChecker/]: [forge] Found status: BETA_OUTDATED Current: 39.0.17 Target: 39.0.18
[17:17:39] [Worker-Main-11/WARN]: [OptiFine] Unknown resource pack file: mod_resources
[17:17:39] [Worker-Main-11/WARN]: [OptiFine] Unknown resource pack file: mod_resources
[17:17:39] [Worker-Main-11/WARN]: [OptiFine] Unknown resource pack file: mod_resources
[17:17:39] [Worker-Main-11/WARN]: [OptiFine] Unknown resource pack file: mod_resources
[17:17:40] [Worker-Main-11/INFO]: [OptiFine] Multitexture: false
[17:17:40] [Worker-Main-11/WARN]: [OptiFine] Unknown resource pack file: mod_resources
[17:17:40] [Worker-Main-11/INFO]: [OptiFine] Multipass connected textures: false
[17:17:40] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/00_glass_white/glass_pane_white.properties
[17:17:40] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/00_glass_white/glass_white.properties
[17:17:40] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/01_glass_orange/glass_orange.properties
[17:17:40] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/01_glass_orange/glass_pane_orange.properties
[17:17:40] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/02_glass_magenta/glass_magenta.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/02_glass_magenta/glass_pane_magenta.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/03_glass_light_blue/glass_light_blue.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/03_glass_light_blue/glass_pane_light_blue.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/04_glass_yellow/glass_pane_yellow.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/04_glass_yellow/glass_yellow.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/05_glass_lime/glass_lime.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/05_glass_lime/glass_pane_lime.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/06_glass_pink/glass_pane_pink.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/06_glass_pink/glass_pink.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/07_glass_gray/glass_gray.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/07_glass_gray/glass_pane_gray.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/08_glass_light_gray/glass_light_gray.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/08_glass_light_gray/glass_pane_light_gray.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/09_glass_cyan/glass_cyan.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/09_glass_cyan/glass_pane_cyan.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/10_glass_purple/glass_pane_purple.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/10_glass_purple/glass_purple.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/11_glass_blue/glass_blue.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/11_glass_blue/glass_pane_blue.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/12_glass_brown/glass_brown.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/12_glass_brown/glass_pane_brown.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/13_glass_green/glass_green.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/13_glass_green/glass_pane_green.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/14_glass_red/glass_pane_red.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/14_glass_red/glass_red.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/15_glass_black/glass_black.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/15_glass_black/glass_pane_black.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/20_glass/glass.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/20_glass/glass_pane.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/21_tinted_glass/tinted_glass.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/30_bookshelf/bookshelf.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/40_sandstone/sandstone.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] ConnectedTextures: optifine/ctm/default/41_red_sandstone/red_sandstone.properties
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] Multipass connected textures: false
[17:17:41] [Worker-Main-11/INFO]: [OptiFine] BetterGrass: Parsing default configuration optifine/bettergrass.properties
[17:17:46] [Worker-Main-11/INFO]: [OptiFine] Mipmap levels: 4
[17:17:48] [Worker-Main-11/INFO]: [OptiFine] Multitexture: false
[17:17:48] [Worker-Main-11/INFO]: [OptiFine] Sprite size: 64
[17:17:48] [Worker-Main-11/INFO]: [OptiFine] Mipmap levels: 6
[17:17:48] [Worker-Main-11/WARN]: Unused frames in sprite minecraft:missingno: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
[17:17:48] [Worker-Main-11/INFO]: [OptiFine] Multitexture: false
[17:17:48] [Worker-Main-11/INFO]: [OptiFine] Sprite size: 64
[17:17:48] [Worker-Main-11/INFO]: [OptiFine] Mipmap levels: 6
[17:17:48] [Worker-Main-11/WARN]: Unused frames in sprite minecraft:missingno: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
[17:17:48] [Worker-Main-11/INFO]: [OptiFine] Multitexture: false
[17:17:48] [Worker-Main-11/INFO]: [OptiFine] Sprite size: 64
[17:17:48] [Worker-Main-11/INFO]: [OptiFine] Mipmap levels: 6
[17:17:48] [Worker-Main-11/WARN]: Unused frames in sprite minecraft:missingno: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
[17:17:48] [Worker-Main-11/INFO]: [OptiFine] Multitexture: false
[17:17:48] [Worker-Main-11/INFO]: [OptiFine] Sprite size: 64
[17:17:48] [Worker-Main-11/INFO]: [OptiFine] Mipmap levels: 6
[17:17:48] [Worker-Main-11/WARN]: Unused frames in sprite minecraft:missingno: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
[17:17:48] [Worker-Main-11/INFO]: [OptiFine] Multitexture: false
[17:17:48] [Worker-Main-11/INFO]: [OptiFine] Sprite size: 64
[17:17:48] [Worker-Main-11/INFO]: [OptiFine] Mipmap levels: 6
[17:17:48] [Worker-Main-11/WARN]: Unused frames in sprite minecraft:missingno: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
[17:17:48] [Worker-Main-11/INFO]: [OptiFine] Multitexture: false
[17:17:48] [Worker-Main-11/INFO]: [OptiFine] Sprite size: 64
[17:17:48] [Worker-Main-11/INFO]: [OptiFine] Mipmap levels: 6
[17:17:48] [Worker-Main-11/WARN]: Unused frames in sprite minecraft:missingno: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
[17:17:48] [Render thread/INFO]: Loading context 'flywheel:context/crumbling'
[17:17:48] [Render thread/ERROR]: Shader compilation log for flywheel:model: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:48] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Instance {
vec2 light;
vec4 color;
mat4 transform;
mat3 normalMat;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Instance i) {
vec4 worldPos = i.transform * vec4(v.pos, 1.);
vec3 norm = i.normalMat * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
norm = normalize(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = i.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = i.color;
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in mat4 a_i_transform;
in mat3 a_i_normalMat;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Instance i;
i.light = a_i_light;
i.color = a_i_color;
i.transform = a_i_transform;
i.normalMat = a_i_normalMat;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:48] [Render thread/ERROR]: Shader compilation log for flywheel:model: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:48] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Instance {
vec2 light;
vec4 color;
mat4 transform;
mat3 normalMat;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Instance i) {
vec4 worldPos = i.transform * vec4(v.pos, 1.);
vec3 norm = i.normalMat * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
norm = normalize(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = i.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = i.color;
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:48] [Render thread/ERROR]: Shader compilation log for flywheel:model: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:48] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Instance {
vec2 light;
vec4 color;
mat4 transform;
mat3 normalMat;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Instance i) {
vec4 worldPos = i.transform * vec4(v.pos, 1.);
vec3 norm = i.normalMat * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
norm = normalize(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = i.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = i.color;
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in mat4 a_i_transform;
in mat3 a_i_normalMat;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Instance i;
i.light = a_i_light;
i.color = a_i_color;
i.transform = a_i_transform;
i.normalMat = a_i_normalMat;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:48] [Render thread/ERROR]: Shader compilation log for flywheel:model: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:48] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Instance {
vec2 light;
vec4 color;
mat4 transform;
mat3 normalMat;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Instance i) {
vec4 worldPos = i.transform * vec4(v.pos, 1.);
vec3 norm = i.normalMat * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
norm = normalize(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = i.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = i.color;
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:48] [Render thread/ERROR]: Shader compilation log for flywheel:oriented: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:48] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Oriented {
vec2 light;
vec4 color;
vec3 pos;
vec3 pivot;
vec4 rotation;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Oriented o) {
vec4 worldPos = vec4(rotateVertexByQuat(v.pos - o.pivot, o.rotation) + o.pivot + o.pos, 1.);
vec3 norm = rotateVertexByQuat(v.normal, o.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = o.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = o.color;
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in vec3 a_i_pivot;
in vec4 a_i_rotation;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Oriented i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.pivot = a_i_pivot;
i.rotation = a_i_rotation;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:48] [Render thread/ERROR]: Shader compilation log for flywheel:oriented: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:48] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Oriented {
vec2 light;
vec4 color;
vec3 pos;
vec3 pivot;
vec4 rotation;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Oriented o) {
vec4 worldPos = vec4(rotateVertexByQuat(v.pos - o.pivot, o.rotation) + o.pivot + o.pos, 1.);
vec3 norm = rotateVertexByQuat(v.normal, o.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = o.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = o.color;
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:48] [Render thread/ERROR]: Shader compilation log for flywheel:oriented: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:48] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Oriented {
vec2 light;
vec4 color;
vec3 pos;
vec3 pivot;
vec4 rotation;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Oriented o) {
vec4 worldPos = vec4(rotateVertexByQuat(v.pos - o.pivot, o.rotation) + o.pivot + o.pos, 1.);
vec3 norm = rotateVertexByQuat(v.normal, o.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = o.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = o.color;
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in vec3 a_i_pivot;
in vec4 a_i_rotation;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Oriented i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.pivot = a_i_pivot;
i.rotation = a_i_rotation;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:48] [Render thread/ERROR]: Shader compilation log for flywheel:oriented: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:48] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Oriented {
vec2 light;
vec4 color;
vec3 pos;
vec3 pivot;
vec4 rotation;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Oriented o) {
vec4 worldPos = vec4(rotateVertexByQuat(v.pos - o.pivot, o.rotation) + o.pivot + o.pos, 1.);
vec3 norm = rotateVertexByQuat(v.normal, o.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = o.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = o.color;
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:48] [Render thread/ERROR]: Shader compilation log for create:rotating: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:48] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Rotating {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec3 axis;
};
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
float angle = fract(degrees / 360.) * PI * 2.;
return rotate(axis, angle);
}
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Rotating instance) {
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
vec4 worldPos = spin * vec4(v.pos - .5, 1.);
worldPos += vec4(instance.pos + .5, 0.);
vec3 norm = modelToNormal(spin) * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in float a_i_speed;
in float a_i_offset;
in vec3 a_i_axis;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Rotating i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.speed = a_i_speed;
i.offset = a_i_offset;
i.axis = a_i_axis;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:48] [Render thread/ERROR]: Shader compilation log for create:rotating: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:48] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Rotating {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec3 axis;
};
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
float angle = fract(degrees / 360.) * PI * 2.;
return rotate(axis, angle);
}
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Rotating instance) {
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
vec4 worldPos = spin * vec4(v.pos - .5, 1.);
worldPos += vec4(instance.pos + .5, 0.);
vec3 norm = modelToNormal(spin) * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:48] [Render thread/ERROR]: Shader compilation log for create:rotating: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:48] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_RAINBOW
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Rotating {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec3 axis;
};
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
float angle = fract(degrees / 360.) * PI * 2.;
return rotate(axis, angle);
}
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Rotating instance) {
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
vec4 worldPos = spin * vec4(v.pos - .5, 1.);
worldPos += vec4(instance.pos + .5, 0.);
vec3 norm = modelToNormal(spin) * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in float a_i_speed;
in float a_i_offset;
in vec3 a_i_axis;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Rotating i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.speed = a_i_speed;
i.offset = a_i_offset;
i.axis = a_i_axis;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:48] [Render thread/ERROR]: Shader compilation log for create:rotating: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:48] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_RAINBOW
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Rotating {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec3 axis;
};
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
float angle = fract(degrees / 360.) * PI * 2.;
return rotate(axis, angle);
}
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Rotating instance) {
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
vec4 worldPos = spin * vec4(v.pos - .5, 1.);
worldPos += vec4(instance.pos + .5, 0.);
vec3 norm = modelToNormal(spin) * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:48] [Render thread/ERROR]: Shader compilation log for create:rotating: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:48] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Rotating {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec3 axis;
};
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
float angle = fract(degrees / 360.) * PI * 2.;
return rotate(axis, angle);
}
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Rotating instance) {
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
vec4 worldPos = spin * vec4(v.pos - .5, 1.);
worldPos += vec4(instance.pos + .5, 0.);
vec3 norm = modelToNormal(spin) * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in float a_i_speed;
in float a_i_offset;
in vec3 a_i_axis;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Rotating i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.speed = a_i_speed;
i.offset = a_i_offset;
i.axis = a_i_axis;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:48] [Render thread/ERROR]: Shader compilation log for create:rotating: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:48] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Rotating {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec3 axis;
};
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
float angle = fract(degrees / 360.) * PI * 2.;
return rotate(axis, angle);
}
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Rotating instance) {
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
vec4 worldPos = spin * vec4(v.pos - .5, 1.);
worldPos += vec4(instance.pos + .5, 0.);
vec3 norm = modelToNormal(spin) * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:contraption_actor: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Actor {
vec3 pos;
vec2 light;
float offset;
vec3 axis;
vec4 rotation;
vec3 rotationCenter;
float speed;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Actor instance) {
float degrees = instance.offset + uTime * instance.speed / 20.;
//float angle = fract(degrees / 360.) * PI * 2.;
vec4 kineticRot = quat(instance.axis, degrees);
vec3 rotated = rotateVertexByQuat(v.pos - instance.rotationCenter, kineticRot) + instance.rotationCenter;
vec4 worldPos = vec4(rotateVertexByQuat(rotated - .5, instance.rotation) + instance.pos + .5, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, kineticRot), instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec3 a_i_pos;
in vec2 a_i_light;
in float a_i_offset;
in vec3 a_i_axis;
in vec4 a_i_rotation;
in vec3 a_i_rotationCenter;
in float a_i_speed;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Actor i;
i.pos = a_i_pos;
i.light = a_i_light;
i.offset = a_i_offset;
i.axis = a_i_axis;
i.rotation = a_i_rotation;
i.rotationCenter = a_i_rotationCenter;
i.speed = a_i_speed;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:contraption_actor: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Actor {
vec3 pos;
vec2 light;
float offset;
vec3 axis;
vec4 rotation;
vec3 rotationCenter;
float speed;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Actor instance) {
float degrees = instance.offset + uTime * instance.speed / 20.;
//float angle = fract(degrees / 360.) * PI * 2.;
vec4 kineticRot = quat(instance.axis, degrees);
vec3 rotated = rotateVertexByQuat(v.pos - instance.rotationCenter, kineticRot) + instance.rotationCenter;
vec4 worldPos = vec4(rotateVertexByQuat(rotated - .5, instance.rotation) + instance.pos + .5, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, kineticRot), instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:contraption_actor: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Actor {
vec3 pos;
vec2 light;
float offset;
vec3 axis;
vec4 rotation;
vec3 rotationCenter;
float speed;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Actor instance) {
float degrees = instance.offset + uTime * instance.speed / 20.;
//float angle = fract(degrees / 360.) * PI * 2.;
vec4 kineticRot = quat(instance.axis, degrees);
vec3 rotated = rotateVertexByQuat(v.pos - instance.rotationCenter, kineticRot) + instance.rotationCenter;
vec4 worldPos = vec4(rotateVertexByQuat(rotated - .5, instance.rotation) + instance.pos + .5, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, kineticRot), instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec3 a_i_pos;
in vec2 a_i_light;
in float a_i_offset;
in vec3 a_i_axis;
in vec4 a_i_rotation;
in vec3 a_i_rotationCenter;
in float a_i_speed;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Actor i;
i.pos = a_i_pos;
i.light = a_i_light;
i.offset = a_i_offset;
i.axis = a_i_axis;
i.rotation = a_i_rotation;
i.rotationCenter = a_i_rotationCenter;
i.speed = a_i_speed;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:contraption_actor: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Actor {
vec3 pos;
vec2 light;
float offset;
vec3 axis;
vec4 rotation;
vec3 rotationCenter;
float speed;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Actor instance) {
float degrees = instance.offset + uTime * instance.speed / 20.;
//float angle = fract(degrees / 360.) * PI * 2.;
vec4 kineticRot = quat(instance.axis, degrees);
vec3 rotated = rotateVertexByQuat(v.pos - instance.rotationCenter, kineticRot) + instance.rotationCenter;
vec4 worldPos = vec4(rotateVertexByQuat(rotated - .5, instance.rotation) + instance.pos + .5, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, kineticRot), instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:flap: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Flap {
vec3 instancePos;
vec2 light;
vec3 segmentOffset;
vec3 pivot;
float horizontalAngle;
float intensity;
float flapScale;
float flapness;
};
#if defined(VERTEX_SHADER)
float toRad(float degrees) {
return fract(degrees / 360.) * PI * 2.;
}
float getFlapAngle(float flapness, float intensity, float scale) {
float absFlap = abs(flapness);
float angle = sin((1. - absFlap) * PI * intensity) * 30. * flapness * scale;
float halfAngle = angle * 0.5;
float which = step(0., flapness); // 0 if negative, 1 if positive
float degrees = which * halfAngle + (1. - which) * angle; // branchless conditional multiply
return degrees;
}
BlockFrag vertex(Vertex v, Flap flap) {
float flapAngle = getFlapAngle(flap.flapness, flap.intensity, flap.flapScale);
vec4 orientation = quat(vec3(0., 1., 0.), -flap.horizontalAngle);
vec4 flapRotation = quat(vec3(1., 0., 0.), flapAngle);
vec3 rotated = rotateVertexByQuat(v.pos - flap.pivot, flapRotation) + flap.pivot + flap.segmentOffset;
rotated = rotateVertexByQuat(rotated - .5, orientation) + flap.instancePos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, flapRotation), orientation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = flap.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec3 a_i_instancePos;
in vec2 a_i_light;
in vec3 a_i_segmentOffset;
in vec3 a_i_pivot;
in float a_i_horizontalAngle;
in float a_i_intensity;
in float a_i_flapScale;
in float a_i_flapness;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Flap i;
i.instancePos = a_i_instancePos;
i.light = a_i_light;
i.segmentOffset = a_i_segmentOffset;
i.pivot = a_i_pivot;
i.horizontalAngle = a_i_horizontalAngle;
i.intensity = a_i_intensity;
i.flapScale = a_i_flapScale;
i.flapness = a_i_flapness;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:flap: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Flap {
vec3 instancePos;
vec2 light;
vec3 segmentOffset;
vec3 pivot;
float horizontalAngle;
float intensity;
float flapScale;
float flapness;
};
#if defined(VERTEX_SHADER)
float toRad(float degrees) {
return fract(degrees / 360.) * PI * 2.;
}
float getFlapAngle(float flapness, float intensity, float scale) {
float absFlap = abs(flapness);
float angle = sin((1. - absFlap) * PI * intensity) * 30. * flapness * scale;
float halfAngle = angle * 0.5;
float which = step(0., flapness); // 0 if negative, 1 if positive
float degrees = which * halfAngle + (1. - which) * angle; // branchless conditional multiply
return degrees;
}
BlockFrag vertex(Vertex v, Flap flap) {
float flapAngle = getFlapAngle(flap.flapness, flap.intensity, flap.flapScale);
vec4 orientation = quat(vec3(0., 1., 0.), -flap.horizontalAngle);
vec4 flapRotation = quat(vec3(1., 0., 0.), flapAngle);
vec3 rotated = rotateVertexByQuat(v.pos - flap.pivot, flapRotation) + flap.pivot + flap.segmentOffset;
rotated = rotateVertexByQuat(rotated - .5, orientation) + flap.instancePos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, flapRotation), orientation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = flap.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:flap: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Flap {
vec3 instancePos;
vec2 light;
vec3 segmentOffset;
vec3 pivot;
float horizontalAngle;
float intensity;
float flapScale;
float flapness;
};
#if defined(VERTEX_SHADER)
float toRad(float degrees) {
return fract(degrees / 360.) * PI * 2.;
}
float getFlapAngle(float flapness, float intensity, float scale) {
float absFlap = abs(flapness);
float angle = sin((1. - absFlap) * PI * intensity) * 30. * flapness * scale;
float halfAngle = angle * 0.5;
float which = step(0., flapness); // 0 if negative, 1 if positive
float degrees = which * halfAngle + (1. - which) * angle; // branchless conditional multiply
return degrees;
}
BlockFrag vertex(Vertex v, Flap flap) {
float flapAngle = getFlapAngle(flap.flapness, flap.intensity, flap.flapScale);
vec4 orientation = quat(vec3(0., 1., 0.), -flap.horizontalAngle);
vec4 flapRotation = quat(vec3(1., 0., 0.), flapAngle);
vec3 rotated = rotateVertexByQuat(v.pos - flap.pivot, flapRotation) + flap.pivot + flap.segmentOffset;
rotated = rotateVertexByQuat(rotated - .5, orientation) + flap.instancePos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, flapRotation), orientation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = flap.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec3 a_i_instancePos;
in vec2 a_i_light;
in vec3 a_i_segmentOffset;
in vec3 a_i_pivot;
in float a_i_horizontalAngle;
in float a_i_intensity;
in float a_i_flapScale;
in float a_i_flapness;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Flap i;
i.instancePos = a_i_instancePos;
i.light = a_i_light;
i.segmentOffset = a_i_segmentOffset;
i.pivot = a_i_pivot;
i.horizontalAngle = a_i_horizontalAngle;
i.intensity = a_i_intensity;
i.flapScale = a_i_flapScale;
i.flapness = a_i_flapness;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:flap: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Flap {
vec3 instancePos;
vec2 light;
vec3 segmentOffset;
vec3 pivot;
float horizontalAngle;
float intensity;
float flapScale;
float flapness;
};
#if defined(VERTEX_SHADER)
float toRad(float degrees) {
return fract(degrees / 360.) * PI * 2.;
}
float getFlapAngle(float flapness, float intensity, float scale) {
float absFlap = abs(flapness);
float angle = sin((1. - absFlap) * PI * intensity) * 30. * flapness * scale;
float halfAngle = angle * 0.5;
float which = step(0., flapness); // 0 if negative, 1 if positive
float degrees = which * halfAngle + (1. - which) * angle; // branchless conditional multiply
return degrees;
}
BlockFrag vertex(Vertex v, Flap flap) {
float flapAngle = getFlapAngle(flap.flapness, flap.intensity, flap.flapScale);
vec4 orientation = quat(vec3(0., 1., 0.), -flap.horizontalAngle);
vec4 flapRotation = quat(vec3(1., 0., 0.), flapAngle);
vec3 rotated = rotateVertexByQuat(v.pos - flap.pivot, flapRotation) + flap.pivot + flap.segmentOffset;
rotated = rotateVertexByQuat(rotated - .5, orientation) + flap.instancePos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, flapRotation), orientation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = flap.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:belt: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Belt {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec4 rotation;
vec2 sourceTexture;
vec4 scrollTexture;
float scrollMult;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Belt instance) {
vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(v.normal, instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y;
float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult;
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll);
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in float a_i_speed;
in float a_i_offset;
in vec4 a_i_rotation;
in vec2 a_i_sourceTexture;
in vec4 a_i_scrollTexture;
in float a_i_scrollMult;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Belt i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.speed = a_i_speed;
i.offset = a_i_offset;
i.rotation = a_i_rotation;
i.sourceTexture = a_i_sourceTexture;
i.scrollTexture = a_i_scrollTexture;
i.scrollMult = a_i_scrollMult;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:belt: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Belt {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec4 rotation;
vec2 sourceTexture;
vec4 scrollTexture;
float scrollMult;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Belt instance) {
vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(v.normal, instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y;
float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult;
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll);
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:belt: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_RAINBOW
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Belt {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec4 rotation;
vec2 sourceTexture;
vec4 scrollTexture;
float scrollMult;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Belt instance) {
vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(v.normal, instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y;
float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult;
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll);
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in float a_i_speed;
in float a_i_offset;
in vec4 a_i_rotation;
in vec2 a_i_sourceTexture;
in vec4 a_i_scrollTexture;
in float a_i_scrollMult;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Belt i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.speed = a_i_speed;
i.offset = a_i_offset;
i.rotation = a_i_rotation;
i.sourceTexture = a_i_sourceTexture;
i.scrollTexture = a_i_scrollTexture;
i.scrollMult = a_i_scrollMult;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:belt: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_RAINBOW
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Belt {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec4 rotation;
vec2 sourceTexture;
vec4 scrollTexture;
float scrollMult;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Belt instance) {
vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(v.normal, instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y;
float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult;
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll);
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:belt: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Belt {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec4 rotation;
vec2 sourceTexture;
vec4 scrollTexture;
float scrollMult;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Belt instance) {
vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(v.normal, instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y;
float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult;
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll);
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in float a_i_speed;
in float a_i_offset;
in vec4 a_i_rotation;
in vec2 a_i_sourceTexture;
in vec4 a_i_scrollTexture;
in float a_i_scrollMult;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Belt i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.speed = a_i_speed;
i.offset = a_i_offset;
i.rotation = a_i_rotation;
i.sourceTexture = a_i_sourceTexture;
i.scrollTexture = a_i_scrollTexture;
i.scrollMult = a_i_scrollMult;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:belt: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform sampler2D uCrumbling;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
#if defined(USE_FOG)
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
#endif
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
vec4 cr = texture(uCrumbling, texCoords * uTextureScale);
float diffuseAlpha = texture(uBlockAtlas, texCoords).a;
cr.a = cr.a * diffuseAlpha;
return cr;
}
void FLWFinalizeColor(vec4 color) {
#if defined(USE_FOG)
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#endif
if (color.a < 0.1) {
discard;
}
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return vec4(1.);
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Belt {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec4 rotation;
vec2 sourceTexture;
vec4 scrollTexture;
float scrollMult;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Belt instance) {
vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(v.normal, instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y;
float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult;
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll);
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/INFO]: Loading context 'flywheel:context/world'
[17:17:49] [Render thread/ERROR]: Shader compilation log for flywheel:model: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Instance {
vec2 light;
vec4 color;
mat4 transform;
mat3 normalMat;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Instance i) {
vec4 worldPos = i.transform * vec4(v.pos, 1.);
vec3 norm = i.normalMat * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
norm = normalize(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = i.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = i.color;
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in mat4 a_i_transform;
in mat3 a_i_normalMat;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Instance i;
i.light = a_i_light;
i.color = a_i_color;
i.transform = a_i_transform;
i.normalMat = a_i_normalMat;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for flywheel:model: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Instance {
vec2 light;
vec4 color;
mat4 transform;
mat3 normalMat;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Instance i) {
vec4 worldPos = i.transform * vec4(v.pos, 1.);
vec3 norm = i.normalMat * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
norm = normalize(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = i.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = i.color;
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for flywheel:model: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Instance {
vec2 light;
vec4 color;
mat4 transform;
mat3 normalMat;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Instance i) {
vec4 worldPos = i.transform * vec4(v.pos, 1.);
vec3 norm = i.normalMat * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
norm = normalize(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = i.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = i.color;
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in mat4 a_i_transform;
in mat3 a_i_normalMat;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Instance i;
i.light = a_i_light;
i.color = a_i_color;
i.transform = a_i_transform;
i.normalMat = a_i_normalMat;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for flywheel:model: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Instance {
vec2 light;
vec4 color;
mat4 transform;
mat3 normalMat;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Instance i) {
vec4 worldPos = i.transform * vec4(v.pos, 1.);
vec3 norm = i.normalMat * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
norm = normalize(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = i.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = i.color;
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for flywheel:oriented: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Oriented {
vec2 light;
vec4 color;
vec3 pos;
vec3 pivot;
vec4 rotation;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Oriented o) {
vec4 worldPos = vec4(rotateVertexByQuat(v.pos - o.pivot, o.rotation) + o.pivot + o.pos, 1.);
vec3 norm = rotateVertexByQuat(v.normal, o.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = o.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = o.color;
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in vec3 a_i_pivot;
in vec4 a_i_rotation;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Oriented i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.pivot = a_i_pivot;
i.rotation = a_i_rotation;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for flywheel:oriented: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Oriented {
vec2 light;
vec4 color;
vec3 pos;
vec3 pivot;
vec4 rotation;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Oriented o) {
vec4 worldPos = vec4(rotateVertexByQuat(v.pos - o.pivot, o.rotation) + o.pivot + o.pos, 1.);
vec3 norm = rotateVertexByQuat(v.normal, o.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = o.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = o.color;
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for flywheel:oriented: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Oriented {
vec2 light;
vec4 color;
vec3 pos;
vec3 pivot;
vec4 rotation;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Oriented o) {
vec4 worldPos = vec4(rotateVertexByQuat(v.pos - o.pivot, o.rotation) + o.pivot + o.pos, 1.);
vec3 norm = rotateVertexByQuat(v.normal, o.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = o.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = o.color;
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in vec3 a_i_pivot;
in vec4 a_i_rotation;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Oriented i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.pivot = a_i_pivot;
i.rotation = a_i_rotation;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for flywheel:oriented: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Oriented {
vec2 light;
vec4 color;
vec3 pos;
vec3 pivot;
vec4 rotation;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Oriented o) {
vec4 worldPos = vec4(rotateVertexByQuat(v.pos - o.pivot, o.rotation) + o.pivot + o.pos, 1.);
vec3 norm = rotateVertexByQuat(v.normal, o.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = o.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = o.color;
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:rotating: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Rotating {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec3 axis;
};
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
float angle = fract(degrees / 360.) * PI * 2.;
return rotate(axis, angle);
}
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Rotating instance) {
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
vec4 worldPos = spin * vec4(v.pos - .5, 1.);
worldPos += vec4(instance.pos + .5, 0.);
vec3 norm = modelToNormal(spin) * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in float a_i_speed;
in float a_i_offset;
in vec3 a_i_axis;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Rotating i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.speed = a_i_speed;
i.offset = a_i_offset;
i.axis = a_i_axis;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:rotating: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Rotating {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec3 axis;
};
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
float angle = fract(degrees / 360.) * PI * 2.;
return rotate(axis, angle);
}
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Rotating instance) {
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
vec4 worldPos = spin * vec4(v.pos - .5, 1.);
worldPos += vec4(instance.pos + .5, 0.);
vec3 norm = modelToNormal(spin) * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:rotating: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_RAINBOW
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Rotating {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec3 axis;
};
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
float angle = fract(degrees / 360.) * PI * 2.;
return rotate(axis, angle);
}
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Rotating instance) {
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
vec4 worldPos = spin * vec4(v.pos - .5, 1.);
worldPos += vec4(instance.pos + .5, 0.);
vec3 norm = modelToNormal(spin) * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in float a_i_speed;
in float a_i_offset;
in vec3 a_i_axis;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Rotating i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.speed = a_i_speed;
i.offset = a_i_offset;
i.axis = a_i_axis;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:rotating: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_RAINBOW
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Rotating {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec3 axis;
};
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
float angle = fract(degrees / 360.) * PI * 2.;
return rotate(axis, angle);
}
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Rotating instance) {
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
vec4 worldPos = spin * vec4(v.pos - .5, 1.);
worldPos += vec4(instance.pos + .5, 0.);
vec3 norm = modelToNormal(spin) * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:rotating: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Rotating {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec3 axis;
};
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
float angle = fract(degrees / 360.) * PI * 2.;
return rotate(axis, angle);
}
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Rotating instance) {
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
vec4 worldPos = spin * vec4(v.pos - .5, 1.);
worldPos += vec4(instance.pos + .5, 0.);
vec3 norm = modelToNormal(spin) * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in float a_i_speed;
in float a_i_offset;
in vec3 a_i_axis;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Rotating i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.speed = a_i_speed;
i.offset = a_i_offset;
i.axis = a_i_axis;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:rotating: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Rotating {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec3 axis;
};
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
float angle = fract(degrees / 360.) * PI * 2.;
return rotate(axis, angle);
}
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Rotating instance) {
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
vec4 worldPos = spin * vec4(v.pos - .5, 1.);
worldPos += vec4(instance.pos + .5, 0.);
vec3 norm = modelToNormal(spin) * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:contraption_actor: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Actor {
vec3 pos;
vec2 light;
float offset;
vec3 axis;
vec4 rotation;
vec3 rotationCenter;
float speed;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Actor instance) {
float degrees = instance.offset + uTime * instance.speed / 20.;
//float angle = fract(degrees / 360.) * PI * 2.;
vec4 kineticRot = quat(instance.axis, degrees);
vec3 rotated = rotateVertexByQuat(v.pos - instance.rotationCenter, kineticRot) + instance.rotationCenter;
vec4 worldPos = vec4(rotateVertexByQuat(rotated - .5, instance.rotation) + instance.pos + .5, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, kineticRot), instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec3 a_i_pos;
in vec2 a_i_light;
in float a_i_offset;
in vec3 a_i_axis;
in vec4 a_i_rotation;
in vec3 a_i_rotationCenter;
in float a_i_speed;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Actor i;
i.pos = a_i_pos;
i.light = a_i_light;
i.offset = a_i_offset;
i.axis = a_i_axis;
i.rotation = a_i_rotation;
i.rotationCenter = a_i_rotationCenter;
i.speed = a_i_speed;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:contraption_actor: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Actor {
vec3 pos;
vec2 light;
float offset;
vec3 axis;
vec4 rotation;
vec3 rotationCenter;
float speed;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Actor instance) {
float degrees = instance.offset + uTime * instance.speed / 20.;
//float angle = fract(degrees / 360.) * PI * 2.;
vec4 kineticRot = quat(instance.axis, degrees);
vec3 rotated = rotateVertexByQuat(v.pos - instance.rotationCenter, kineticRot) + instance.rotationCenter;
vec4 worldPos = vec4(rotateVertexByQuat(rotated - .5, instance.rotation) + instance.pos + .5, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, kineticRot), instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:contraption_actor: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Actor {
vec3 pos;
vec2 light;
float offset;
vec3 axis;
vec4 rotation;
vec3 rotationCenter;
float speed;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Actor instance) {
float degrees = instance.offset + uTime * instance.speed / 20.;
//float angle = fract(degrees / 360.) * PI * 2.;
vec4 kineticRot = quat(instance.axis, degrees);
vec3 rotated = rotateVertexByQuat(v.pos - instance.rotationCenter, kineticRot) + instance.rotationCenter;
vec4 worldPos = vec4(rotateVertexByQuat(rotated - .5, instance.rotation) + instance.pos + .5, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, kineticRot), instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec3 a_i_pos;
in vec2 a_i_light;
in float a_i_offset;
in vec3 a_i_axis;
in vec4 a_i_rotation;
in vec3 a_i_rotationCenter;
in float a_i_speed;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Actor i;
i.pos = a_i_pos;
i.light = a_i_light;
i.offset = a_i_offset;
i.axis = a_i_axis;
i.rotation = a_i_rotation;
i.rotationCenter = a_i_rotationCenter;
i.speed = a_i_speed;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:contraption_actor: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Actor {
vec3 pos;
vec2 light;
float offset;
vec3 axis;
vec4 rotation;
vec3 rotationCenter;
float speed;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Actor instance) {
float degrees = instance.offset + uTime * instance.speed / 20.;
//float angle = fract(degrees / 360.) * PI * 2.;
vec4 kineticRot = quat(instance.axis, degrees);
vec3 rotated = rotateVertexByQuat(v.pos - instance.rotationCenter, kineticRot) + instance.rotationCenter;
vec4 worldPos = vec4(rotateVertexByQuat(rotated - .5, instance.rotation) + instance.pos + .5, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, kineticRot), instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:flap: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Flap {
vec3 instancePos;
vec2 light;
vec3 segmentOffset;
vec3 pivot;
float horizontalAngle;
float intensity;
float flapScale;
float flapness;
};
#if defined(VERTEX_SHADER)
float toRad(float degrees) {
return fract(degrees / 360.) * PI * 2.;
}
float getFlapAngle(float flapness, float intensity, float scale) {
float absFlap = abs(flapness);
float angle = sin((1. - absFlap) * PI * intensity) * 30. * flapness * scale;
float halfAngle = angle * 0.5;
float which = step(0., flapness); // 0 if negative, 1 if positive
float degrees = which * halfAngle + (1. - which) * angle; // branchless conditional multiply
return degrees;
}
BlockFrag vertex(Vertex v, Flap flap) {
float flapAngle = getFlapAngle(flap.flapness, flap.intensity, flap.flapScale);
vec4 orientation = quat(vec3(0., 1., 0.), -flap.horizontalAngle);
vec4 flapRotation = quat(vec3(1., 0., 0.), flapAngle);
vec3 rotated = rotateVertexByQuat(v.pos - flap.pivot, flapRotation) + flap.pivot + flap.segmentOffset;
rotated = rotateVertexByQuat(rotated - .5, orientation) + flap.instancePos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, flapRotation), orientation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = flap.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec3 a_i_instancePos;
in vec2 a_i_light;
in vec3 a_i_segmentOffset;
in vec3 a_i_pivot;
in float a_i_horizontalAngle;
in float a_i_intensity;
in float a_i_flapScale;
in float a_i_flapness;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Flap i;
i.instancePos = a_i_instancePos;
i.light = a_i_light;
i.segmentOffset = a_i_segmentOffset;
i.pivot = a_i_pivot;
i.horizontalAngle = a_i_horizontalAngle;
i.intensity = a_i_intensity;
i.flapScale = a_i_flapScale;
i.flapness = a_i_flapness;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:flap: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Flap {
vec3 instancePos;
vec2 light;
vec3 segmentOffset;
vec3 pivot;
float horizontalAngle;
float intensity;
float flapScale;
float flapness;
};
#if defined(VERTEX_SHADER)
float toRad(float degrees) {
return fract(degrees / 360.) * PI * 2.;
}
float getFlapAngle(float flapness, float intensity, float scale) {
float absFlap = abs(flapness);
float angle = sin((1. - absFlap) * PI * intensity) * 30. * flapness * scale;
float halfAngle = angle * 0.5;
float which = step(0., flapness); // 0 if negative, 1 if positive
float degrees = which * halfAngle + (1. - which) * angle; // branchless conditional multiply
return degrees;
}
BlockFrag vertex(Vertex v, Flap flap) {
float flapAngle = getFlapAngle(flap.flapness, flap.intensity, flap.flapScale);
vec4 orientation = quat(vec3(0., 1., 0.), -flap.horizontalAngle);
vec4 flapRotation = quat(vec3(1., 0., 0.), flapAngle);
vec3 rotated = rotateVertexByQuat(v.pos - flap.pivot, flapRotation) + flap.pivot + flap.segmentOffset;
rotated = rotateVertexByQuat(rotated - .5, orientation) + flap.instancePos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, flapRotation), orientation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = flap.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:flap: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Flap {
vec3 instancePos;
vec2 light;
vec3 segmentOffset;
vec3 pivot;
float horizontalAngle;
float intensity;
float flapScale;
float flapness;
};
#if defined(VERTEX_SHADER)
float toRad(float degrees) {
return fract(degrees / 360.) * PI * 2.;
}
float getFlapAngle(float flapness, float intensity, float scale) {
float absFlap = abs(flapness);
float angle = sin((1. - absFlap) * PI * intensity) * 30. * flapness * scale;
float halfAngle = angle * 0.5;
float which = step(0., flapness); // 0 if negative, 1 if positive
float degrees = which * halfAngle + (1. - which) * angle; // branchless conditional multiply
return degrees;
}
BlockFrag vertex(Vertex v, Flap flap) {
float flapAngle = getFlapAngle(flap.flapness, flap.intensity, flap.flapScale);
vec4 orientation = quat(vec3(0., 1., 0.), -flap.horizontalAngle);
vec4 flapRotation = quat(vec3(1., 0., 0.), flapAngle);
vec3 rotated = rotateVertexByQuat(v.pos - flap.pivot, flapRotation) + flap.pivot + flap.segmentOffset;
rotated = rotateVertexByQuat(rotated - .5, orientation) + flap.instancePos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, flapRotation), orientation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = flap.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec3 a_i_instancePos;
in vec2 a_i_light;
in vec3 a_i_segmentOffset;
in vec3 a_i_pivot;
in float a_i_horizontalAngle;
in float a_i_intensity;
in float a_i_flapScale;
in float a_i_flapness;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Flap i;
i.instancePos = a_i_instancePos;
i.light = a_i_light;
i.segmentOffset = a_i_segmentOffset;
i.pivot = a_i_pivot;
i.horizontalAngle = a_i_horizontalAngle;
i.intensity = a_i_intensity;
i.flapScale = a_i_flapScale;
i.flapness = a_i_flapness;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:flap: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Flap {
vec3 instancePos;
vec2 light;
vec3 segmentOffset;
vec3 pivot;
float horizontalAngle;
float intensity;
float flapScale;
float flapness;
};
#if defined(VERTEX_SHADER)
float toRad(float degrees) {
return fract(degrees / 360.) * PI * 2.;
}
float getFlapAngle(float flapness, float intensity, float scale) {
float absFlap = abs(flapness);
float angle = sin((1. - absFlap) * PI * intensity) * 30. * flapness * scale;
float halfAngle = angle * 0.5;
float which = step(0., flapness); // 0 if negative, 1 if positive
float degrees = which * halfAngle + (1. - which) * angle; // branchless conditional multiply
return degrees;
}
BlockFrag vertex(Vertex v, Flap flap) {
float flapAngle = getFlapAngle(flap.flapness, flap.intensity, flap.flapScale);
vec4 orientation = quat(vec3(0., 1., 0.), -flap.horizontalAngle);
vec4 flapRotation = quat(vec3(1., 0., 0.), flapAngle);
vec3 rotated = rotateVertexByQuat(v.pos - flap.pivot, flapRotation) + flap.pivot + flap.segmentOffset;
rotated = rotateVertexByQuat(rotated - .5, orientation) + flap.instancePos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, flapRotation), orientation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = flap.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:belt: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Belt {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec4 rotation;
vec2 sourceTexture;
vec4 scrollTexture;
float scrollMult;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Belt instance) {
vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(v.normal, instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y;
float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult;
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll);
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in float a_i_speed;
in float a_i_offset;
in vec4 a_i_rotation;
in vec2 a_i_sourceTexture;
in vec4 a_i_scrollTexture;
in float a_i_scrollMult;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Belt i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.speed = a_i_speed;
i.offset = a_i_offset;
i.rotation = a_i_rotation;
i.sourceTexture = a_i_sourceTexture;
i.scrollTexture = a_i_scrollTexture;
i.scrollMult = a_i_scrollMult;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:belt: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Belt {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec4 rotation;
vec2 sourceTexture;
vec4 scrollTexture;
float scrollMult;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Belt instance) {
vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(v.normal, instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y;
float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult;
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll);
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:belt: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_RAINBOW
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Belt {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec4 rotation;
vec2 sourceTexture;
vec4 scrollTexture;
float scrollMult;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Belt instance) {
vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(v.normal, instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y;
float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult;
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll);
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in float a_i_speed;
in float a_i_offset;
in vec4 a_i_rotation;
in vec2 a_i_sourceTexture;
in vec4 a_i_scrollTexture;
in float a_i_scrollMult;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Belt i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.speed = a_i_speed;
i.offset = a_i_offset;
i.rotation = a_i_rotation;
i.sourceTexture = a_i_sourceTexture;
i.scrollTexture = a_i_scrollTexture;
i.scrollMult = a_i_scrollMult;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:belt: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_RAINBOW
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Belt {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec4 rotation;
vec2 sourceTexture;
vec4 scrollTexture;
float scrollMult;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Belt instance) {
vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(v.normal, instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y;
float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult;
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll);
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:belt: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Belt {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec4 rotation;
vec2 sourceTexture;
vec4 scrollTexture;
float scrollMult;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Belt instance) {
vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(v.normal, instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y;
float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult;
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll);
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in float a_i_speed;
in float a_i_offset;
in vec4 a_i_rotation;
in vec2 a_i_sourceTexture;
in vec4 a_i_scrollTexture;
in float a_i_scrollMult;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Belt i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.speed = a_i_speed;
i.offset = a_i_offset;
i.rotation = a_i_rotation;
i.sourceTexture = a_i_sourceTexture;
i.scrollTexture = a_i_scrollTexture;
i.scrollMult = a_i_scrollMult;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:belt: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
uniform vec2 uTextureScale;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec2 uWindowSize;
void FLWFinalizeNormal(inout vec3 normal) {
// noop
}
#if defined(VERTEX_SHADER)
void FLWFinalizeWorldPos(inout vec4 worldPos) {
FragDistance = cylindrical_distance(worldPos.xyz, uCameraPos);
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
out vec4 fragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
fragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Belt {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec4 rotation;
vec2 sourceTexture;
vec4 scrollTexture;
float scrollMult;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Belt instance) {
vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(v.normal, instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y;
float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult;
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll);
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/INFO]: Loading context 'create:context/contraption'
[17:17:49] [Render thread/ERROR]: Shader compilation log for flywheel:model: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Instance {
vec2 light;
vec4 color;
mat4 transform;
mat3 normalMat;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Instance i) {
vec4 worldPos = i.transform * vec4(v.pos, 1.);
vec3 norm = i.normalMat * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
norm = normalize(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = i.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = i.color;
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in mat4 a_i_transform;
in mat3 a_i_normalMat;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Instance i;
i.light = a_i_light;
i.color = a_i_color;
i.transform = a_i_transform;
i.normalMat = a_i_normalMat;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for flywheel:model: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Instance {
vec2 light;
vec4 color;
mat4 transform;
mat3 normalMat;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Instance i) {
vec4 worldPos = i.transform * vec4(v.pos, 1.);
vec3 norm = i.normalMat * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
norm = normalize(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = i.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = i.color;
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for flywheel:model: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Instance {
vec2 light;
vec4 color;
mat4 transform;
mat3 normalMat;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Instance i) {
vec4 worldPos = i.transform * vec4(v.pos, 1.);
vec3 norm = i.normalMat * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
norm = normalize(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = i.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = i.color;
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in mat4 a_i_transform;
in mat3 a_i_normalMat;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Instance i;
i.light = a_i_light;
i.color = a_i_color;
i.transform = a_i_transform;
i.normalMat = a_i_normalMat;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for flywheel:model: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Instance {
vec2 light;
vec4 color;
mat4 transform;
mat3 normalMat;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Instance i) {
vec4 worldPos = i.transform * vec4(v.pos, 1.);
vec3 norm = i.normalMat * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
norm = normalize(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = i.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = i.color;
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for flywheel:oriented: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Oriented {
vec2 light;
vec4 color;
vec3 pos;
vec3 pivot;
vec4 rotation;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Oriented o) {
vec4 worldPos = vec4(rotateVertexByQuat(v.pos - o.pivot, o.rotation) + o.pivot + o.pos, 1.);
vec3 norm = rotateVertexByQuat(v.normal, o.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = o.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = o.color;
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in vec3 a_i_pivot;
in vec4 a_i_rotation;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Oriented i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.pivot = a_i_pivot;
i.rotation = a_i_rotation;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for flywheel:oriented: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Oriented {
vec2 light;
vec4 color;
vec3 pos;
vec3 pivot;
vec4 rotation;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Oriented o) {
vec4 worldPos = vec4(rotateVertexByQuat(v.pos - o.pivot, o.rotation) + o.pivot + o.pos, 1.);
vec3 norm = rotateVertexByQuat(v.normal, o.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = o.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = o.color;
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for flywheel:oriented: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Oriented {
vec2 light;
vec4 color;
vec3 pos;
vec3 pivot;
vec4 rotation;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Oriented o) {
vec4 worldPos = vec4(rotateVertexByQuat(v.pos - o.pivot, o.rotation) + o.pivot + o.pos, 1.);
vec3 norm = rotateVertexByQuat(v.normal, o.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = o.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = o.color;
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in vec3 a_i_pivot;
in vec4 a_i_rotation;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Oriented i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.pivot = a_i_pivot;
i.rotation = a_i_rotation;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for flywheel:oriented: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
struct Oriented {
vec2 light;
vec4 color;
vec3 pos;
vec3 pivot;
vec4 rotation;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Oriented o) {
vec4 worldPos = vec4(rotateVertexByQuat(v.pos - o.pivot, o.rotation) + o.pivot + o.pos, 1.);
vec3 norm = rotateVertexByQuat(v.normal, o.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = o.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = o.color;
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:rotating: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Rotating {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec3 axis;
};
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
float angle = fract(degrees / 360.) * PI * 2.;
return rotate(axis, angle);
}
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Rotating instance) {
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
vec4 worldPos = spin * vec4(v.pos - .5, 1.);
worldPos += vec4(instance.pos + .5, 0.);
vec3 norm = modelToNormal(spin) * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in float a_i_speed;
in float a_i_offset;
in vec3 a_i_axis;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Rotating i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.speed = a_i_speed;
i.offset = a_i_offset;
i.axis = a_i_axis;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:rotating: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Rotating {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec3 axis;
};
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
float angle = fract(degrees / 360.) * PI * 2.;
return rotate(axis, angle);
}
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Rotating instance) {
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
vec4 worldPos = spin * vec4(v.pos - .5, 1.);
worldPos += vec4(instance.pos + .5, 0.);
vec3 norm = modelToNormal(spin) * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:rotating: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_RAINBOW
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Rotating {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec3 axis;
};
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
float angle = fract(degrees / 360.) * PI * 2.;
return rotate(axis, angle);
}
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Rotating instance) {
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
vec4 worldPos = spin * vec4(v.pos - .5, 1.);
worldPos += vec4(instance.pos + .5, 0.);
vec3 norm = modelToNormal(spin) * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in float a_i_speed;
in float a_i_offset;
in vec3 a_i_axis;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Rotating i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.speed = a_i_speed;
i.offset = a_i_offset;
i.axis = a_i_axis;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:rotating: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_RAINBOW
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Rotating {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec3 axis;
};
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
float angle = fract(degrees / 360.) * PI * 2.;
return rotate(axis, angle);
}
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Rotating instance) {
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
vec4 worldPos = spin * vec4(v.pos - .5, 1.);
worldPos += vec4(instance.pos + .5, 0.);
vec3 norm = modelToNormal(spin) * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:rotating: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Rotating {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec3 axis;
};
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
float angle = fract(degrees / 360.) * PI * 2.;
return rotate(axis, angle);
}
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Rotating instance) {
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
vec4 worldPos = spin * vec4(v.pos - .5, 1.);
worldPos += vec4(instance.pos + .5, 0.);
vec3 norm = modelToNormal(spin) * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in float a_i_speed;
in float a_i_offset;
in vec3 a_i_axis;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Rotating i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.speed = a_i_speed;
i.offset = a_i_offset;
i.axis = a_i_axis;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:rotating: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Rotating {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec3 axis;
};
mat4 kineticRotation(float offset, float speed, vec3 axis) {
float degrees = offset + uTime * speed * 3./10.;
float angle = fract(degrees / 360.) * PI * 2.;
return rotate(axis, angle);
}
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Rotating instance) {
mat4 spin = kineticRotation(instance.offset, instance.speed, instance.axis);
vec4 worldPos = spin * vec4(v.pos - .5, 1.);
worldPos += vec4(instance.pos + .5, 0.);
vec3 norm = modelToNormal(spin) * v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:contraption_actor: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Actor {
vec3 pos;
vec2 light;
float offset;
vec3 axis;
vec4 rotation;
vec3 rotationCenter;
float speed;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Actor instance) {
float degrees = instance.offset + uTime * instance.speed / 20.;
//float angle = fract(degrees / 360.) * PI * 2.;
vec4 kineticRot = quat(instance.axis, degrees);
vec3 rotated = rotateVertexByQuat(v.pos - instance.rotationCenter, kineticRot) + instance.rotationCenter;
vec4 worldPos = vec4(rotateVertexByQuat(rotated - .5, instance.rotation) + instance.pos + .5, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, kineticRot), instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec3 a_i_pos;
in vec2 a_i_light;
in float a_i_offset;
in vec3 a_i_axis;
in vec4 a_i_rotation;
in vec3 a_i_rotationCenter;
in float a_i_speed;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Actor i;
i.pos = a_i_pos;
i.light = a_i_light;
i.offset = a_i_offset;
i.axis = a_i_axis;
i.rotation = a_i_rotation;
i.rotationCenter = a_i_rotationCenter;
i.speed = a_i_speed;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:contraption_actor: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Actor {
vec3 pos;
vec2 light;
float offset;
vec3 axis;
vec4 rotation;
vec3 rotationCenter;
float speed;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Actor instance) {
float degrees = instance.offset + uTime * instance.speed / 20.;
//float angle = fract(degrees / 360.) * PI * 2.;
vec4 kineticRot = quat(instance.axis, degrees);
vec3 rotated = rotateVertexByQuat(v.pos - instance.rotationCenter, kineticRot) + instance.rotationCenter;
vec4 worldPos = vec4(rotateVertexByQuat(rotated - .5, instance.rotation) + instance.pos + .5, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, kineticRot), instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:contraption_actor: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Actor {
vec3 pos;
vec2 light;
float offset;
vec3 axis;
vec4 rotation;
vec3 rotationCenter;
float speed;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Actor instance) {
float degrees = instance.offset + uTime * instance.speed / 20.;
//float angle = fract(degrees / 360.) * PI * 2.;
vec4 kineticRot = quat(instance.axis, degrees);
vec3 rotated = rotateVertexByQuat(v.pos - instance.rotationCenter, kineticRot) + instance.rotationCenter;
vec4 worldPos = vec4(rotateVertexByQuat(rotated - .5, instance.rotation) + instance.pos + .5, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, kineticRot), instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec3 a_i_pos;
in vec2 a_i_light;
in float a_i_offset;
in vec3 a_i_axis;
in vec4 a_i_rotation;
in vec3 a_i_rotationCenter;
in float a_i_speed;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Actor i;
i.pos = a_i_pos;
i.light = a_i_light;
i.offset = a_i_offset;
i.axis = a_i_axis;
i.rotation = a_i_rotation;
i.rotationCenter = a_i_rotationCenter;
i.speed = a_i_speed;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:contraption_actor: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Actor {
vec3 pos;
vec2 light;
float offset;
vec3 axis;
vec4 rotation;
vec3 rotationCenter;
float speed;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Actor instance) {
float degrees = instance.offset + uTime * instance.speed / 20.;
//float angle = fract(degrees / 360.) * PI * 2.;
vec4 kineticRot = quat(instance.axis, degrees);
vec3 rotated = rotateVertexByQuat(v.pos - instance.rotationCenter, kineticRot) + instance.rotationCenter;
vec4 worldPos = vec4(rotateVertexByQuat(rotated - .5, instance.rotation) + instance.pos + .5, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, kineticRot), instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = instance.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:flap: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Flap {
vec3 instancePos;
vec2 light;
vec3 segmentOffset;
vec3 pivot;
float horizontalAngle;
float intensity;
float flapScale;
float flapness;
};
#if defined(VERTEX_SHADER)
float toRad(float degrees) {
return fract(degrees / 360.) * PI * 2.;
}
float getFlapAngle(float flapness, float intensity, float scale) {
float absFlap = abs(flapness);
float angle = sin((1. - absFlap) * PI * intensity) * 30. * flapness * scale;
float halfAngle = angle * 0.5;
float which = step(0., flapness); // 0 if negative, 1 if positive
float degrees = which * halfAngle + (1. - which) * angle; // branchless conditional multiply
return degrees;
}
BlockFrag vertex(Vertex v, Flap flap) {
float flapAngle = getFlapAngle(flap.flapness, flap.intensity, flap.flapScale);
vec4 orientation = quat(vec3(0., 1., 0.), -flap.horizontalAngle);
vec4 flapRotation = quat(vec3(1., 0., 0.), flapAngle);
vec3 rotated = rotateVertexByQuat(v.pos - flap.pivot, flapRotation) + flap.pivot + flap.segmentOffset;
rotated = rotateVertexByQuat(rotated - .5, orientation) + flap.instancePos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, flapRotation), orientation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = flap.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec3 a_i_instancePos;
in vec2 a_i_light;
in vec3 a_i_segmentOffset;
in vec3 a_i_pivot;
in float a_i_horizontalAngle;
in float a_i_intensity;
in float a_i_flapScale;
in float a_i_flapness;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Flap i;
i.instancePos = a_i_instancePos;
i.light = a_i_light;
i.segmentOffset = a_i_segmentOffset;
i.pivot = a_i_pivot;
i.horizontalAngle = a_i_horizontalAngle;
i.intensity = a_i_intensity;
i.flapScale = a_i_flapScale;
i.flapness = a_i_flapness;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:flap: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Flap {
vec3 instancePos;
vec2 light;
vec3 segmentOffset;
vec3 pivot;
float horizontalAngle;
float intensity;
float flapScale;
float flapness;
};
#if defined(VERTEX_SHADER)
float toRad(float degrees) {
return fract(degrees / 360.) * PI * 2.;
}
float getFlapAngle(float flapness, float intensity, float scale) {
float absFlap = abs(flapness);
float angle = sin((1. - absFlap) * PI * intensity) * 30. * flapness * scale;
float halfAngle = angle * 0.5;
float which = step(0., flapness); // 0 if negative, 1 if positive
float degrees = which * halfAngle + (1. - which) * angle; // branchless conditional multiply
return degrees;
}
BlockFrag vertex(Vertex v, Flap flap) {
float flapAngle = getFlapAngle(flap.flapness, flap.intensity, flap.flapScale);
vec4 orientation = quat(vec3(0., 1., 0.), -flap.horizontalAngle);
vec4 flapRotation = quat(vec3(1., 0., 0.), flapAngle);
vec3 rotated = rotateVertexByQuat(v.pos - flap.pivot, flapRotation) + flap.pivot + flap.segmentOffset;
rotated = rotateVertexByQuat(rotated - .5, orientation) + flap.instancePos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, flapRotation), orientation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = flap.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:flap: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Flap {
vec3 instancePos;
vec2 light;
vec3 segmentOffset;
vec3 pivot;
float horizontalAngle;
float intensity;
float flapScale;
float flapness;
};
#if defined(VERTEX_SHADER)
float toRad(float degrees) {
return fract(degrees / 360.) * PI * 2.;
}
float getFlapAngle(float flapness, float intensity, float scale) {
float absFlap = abs(flapness);
float angle = sin((1. - absFlap) * PI * intensity) * 30. * flapness * scale;
float halfAngle = angle * 0.5;
float which = step(0., flapness); // 0 if negative, 1 if positive
float degrees = which * halfAngle + (1. - which) * angle; // branchless conditional multiply
return degrees;
}
BlockFrag vertex(Vertex v, Flap flap) {
float flapAngle = getFlapAngle(flap.flapness, flap.intensity, flap.flapScale);
vec4 orientation = quat(vec3(0., 1., 0.), -flap.horizontalAngle);
vec4 flapRotation = quat(vec3(1., 0., 0.), flapAngle);
vec3 rotated = rotateVertexByQuat(v.pos - flap.pivot, flapRotation) + flap.pivot + flap.segmentOffset;
rotated = rotateVertexByQuat(rotated - .5, orientation) + flap.instancePos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, flapRotation), orientation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = flap.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec3 a_i_instancePos;
in vec2 a_i_light;
in vec3 a_i_segmentOffset;
in vec3 a_i_pivot;
in float a_i_horizontalAngle;
in float a_i_intensity;
in float a_i_flapScale;
in float a_i_flapness;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Flap i;
i.instancePos = a_i_instancePos;
i.light = a_i_light;
i.segmentOffset = a_i_segmentOffset;
i.pivot = a_i_pivot;
i.horizontalAngle = a_i_horizontalAngle;
i.intensity = a_i_intensity;
i.flapScale = a_i_flapScale;
i.flapness = a_i_flapness;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:flap: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Flap {
vec3 instancePos;
vec2 light;
vec3 segmentOffset;
vec3 pivot;
float horizontalAngle;
float intensity;
float flapScale;
float flapness;
};
#if defined(VERTEX_SHADER)
float toRad(float degrees) {
return fract(degrees / 360.) * PI * 2.;
}
float getFlapAngle(float flapness, float intensity, float scale) {
float absFlap = abs(flapness);
float angle = sin((1. - absFlap) * PI * intensity) * 30. * flapness * scale;
float halfAngle = angle * 0.5;
float which = step(0., flapness); // 0 if negative, 1 if positive
float degrees = which * halfAngle + (1. - which) * angle; // branchless conditional multiply
return degrees;
}
BlockFrag vertex(Vertex v, Flap flap) {
float flapAngle = getFlapAngle(flap.flapness, flap.intensity, flap.flapScale);
vec4 orientation = quat(vec3(0., 1., 0.), -flap.horizontalAngle);
vec4 flapRotation = quat(vec3(1., 0., 0.), flapAngle);
vec3 rotated = rotateVertexByQuat(v.pos - flap.pivot, flapRotation) + flap.pivot + flap.segmentOffset;
rotated = rotateVertexByQuat(rotated - .5, orientation) + flap.instancePos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(rotateVertexByQuat(v.normal, flapRotation), orientation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = flap.light;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:belt: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Belt {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec4 rotation;
vec2 sourceTexture;
vec4 scrollTexture;
float scrollMult;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Belt instance) {
vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(v.normal, instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y;
float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult;
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll);
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in float a_i_speed;
in float a_i_offset;
in vec4 a_i_rotation;
in vec2 a_i_sourceTexture;
in vec4 a_i_scrollTexture;
in float a_i_scrollMult;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Belt i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.speed = a_i_speed;
i.offset = a_i_offset;
i.rotation = a_i_rotation;
i.sourceTexture = a_i_sourceTexture;
i.scrollTexture = a_i_scrollTexture;
i.scrollMult = a_i_scrollMult;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:belt: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Belt {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec4 rotation;
vec2 sourceTexture;
vec4 scrollTexture;
float scrollMult;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Belt instance) {
vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(v.normal, instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y;
float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult;
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll);
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:belt: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_RAINBOW
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Belt {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec4 rotation;
vec2 sourceTexture;
vec4 scrollTexture;
float scrollMult;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Belt instance) {
vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(v.normal, instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y;
float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult;
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll);
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in float a_i_speed;
in float a_i_offset;
in vec4 a_i_rotation;
in vec2 a_i_sourceTexture;
in vec4 a_i_scrollTexture;
in float a_i_scrollMult;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Belt i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.speed = a_i_speed;
i.offset = a_i_offset;
i.rotation = a_i_rotation;
i.sourceTexture = a_i_sourceTexture;
i.scrollTexture = a_i_scrollTexture;
i.scrollMult = a_i_scrollMult;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:belt: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_RAINBOW
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Belt {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec4 rotation;
vec2 sourceTexture;
vec4 scrollTexture;
float scrollMult;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Belt instance) {
vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(v.normal, instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y;
float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult;
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll);
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:belt: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Belt {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec4 rotation;
vec2 sourceTexture;
vec4 scrollTexture;
float scrollMult;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Belt instance) {
vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(v.normal, instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y;
float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult;
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll);
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec2 a_v_texCoords;
in vec3 a_v_normal;
in vec2 a_i_light;
in vec4 a_i_color;
in vec3 a_i_pos;
in float a_i_speed;
in float a_i_offset;
in vec4 a_i_rotation;
in vec2 a_i_sourceTexture;
in vec4 a_i_scrollTexture;
in float a_i_scrollMult;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.texCoords = a_v_texCoords;
v.normal = a_v_normal;
Belt i;
i.light = a_i_light;
i.color = a_i_color;
i.pos = a_i_pos;
i.speed = a_i_speed;
i.offset = a_i_offset;
i.rotation = a_i_rotation;
i.sourceTexture = a_i_sourceTexture;
i.scrollTexture = a_i_scrollTexture;
i.scrollMult = a_i_scrollMult;
BlockFrag o = vertex(v, i);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:belt: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
#define PIOVER2 1.5707963268
vec4 quat(vec3 axis, float angle) {
float halfAngle = angle * PIOVER2 / 180.0;
vec2 cs = sin(vec2(PIOVER2 - halfAngle, halfAngle)); // compute sin and cos in one instruction
return vec4(axis.xyz * cs.y, cs.x);
}
vec4 quatMult(vec4 q1, vec4 q2) {
// disgustingly vectorized quaternion multiplication
vec4 a = q1.w * q2.xyzw;
vec4 b = q1.x * q2.wzxy * vec4(1., -1., 1., -1.);
vec4 c = q1.y * q2.zwxy * vec4(1., 1., -1., -1.);
vec4 d = q1.z * q2.yxwz * vec4(-1., 1., 1., -1.);
return a + b + c + d;
}
vec3 rotateVertexByQuat(vec3 v, vec4 q) {
vec3 i = q.xyz;
return v + 2.0 * cross(i, cross(i, v) + q.w * v);
}
vec3 rotateAbout(vec3 v, vec3 axis, float angle) {
return rotateVertexByQuat(v, quat(axis, angle));
}
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct Vertex {
vec3 pos;
vec2 texCoords;
vec3 normal;
};
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Belt {
vec2 light;
vec4 color;
vec3 pos;
float speed;
float offset;
vec4 rotation;
vec2 sourceTexture;
vec4 scrollTexture;
float scrollMult;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v, Belt instance) {
vec3 rotated = rotateVertexByQuat(v.pos - .5, instance.rotation) + instance.pos + .5;
vec4 worldPos = vec4(rotated, 1.);
vec3 norm = rotateVertexByQuat(v.normal, instance.rotation);
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
float scrollSize = instance.scrollTexture.w - instance.scrollTexture.y;
float scroll = fract(instance.speed * uTime / (31.5 * 16.) + instance.offset) * scrollSize * instance.scrollMult;
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords - instance.sourceTexture + instance.scrollTexture.xy + vec2(0, scroll);
b.light = instance.light;
#if defined(DEBUG_RAINBOW)
b.color = instance.color;
#elif defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = vec4(1.);
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/INFO]: Loading context 'create:context/contraption'
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:contraption_structure: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Vertex {
vec3 pos;
vec4 color;
vec2 texCoords;
vec2 modelLight;
vec3 normal;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v) {
vec4 worldPos = vec4(v.pos, 1.);
vec3 norm = v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = v.modelLight;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = v.color;
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec4 a_v_color;
in vec2 a_v_texCoords;
in vec2 a_v_modelLight;
in vec3 a_v_normal;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.color = a_v_color;
v.texCoords = a_v_texCoords;
v.modelLight = a_v_modelLight;
v.normal = a_v_normal;
BlockFrag o = vertex(v);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:contraption_structure: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Vertex {
vec3 pos;
vec4 color;
vec2 texCoords;
vec2 modelLight;
vec3 normal;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v) {
vec4 worldPos = vec4(v.pos, 1.);
vec3 norm = v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = v.modelLight;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = v.color;
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:contraption_structure: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define VERTEX_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Vertex {
vec3 pos;
vec4 color;
vec2 texCoords;
vec2 modelLight;
vec3 normal;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v) {
vec4 worldPos = vec4(v.pos, 1.);
vec3 norm = v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = v.modelLight;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = v.color;
#endif
return b;
}
#endif
in vec3 a_v_pos;
in vec4 a_v_color;
in vec2 a_v_texCoords;
in vec2 a_v_modelLight;
in vec3 a_v_normal;
out vec2 v2f_texCoords;
out vec4 v2f_color;
out float v2f_diffuse;
out vec2 v2f_light;
void main() {
Vertex v;
v.pos = a_v_pos;
v.color = a_v_color;
v.texCoords = a_v_texCoords;
v.modelLight = a_v_modelLight;
v.normal = a_v_normal;
BlockFrag o = vertex(v);
v2f_texCoords = o.texCoords;
v2f_color = o.color;
v2f_diffuse = o.diffuse;
v2f_light = o.light;
}
[17:17:49] [Render thread/ERROR]: Shader compilation log for create:contraption_structure: WARNING: 0:2: warning(#62) enable/warn/disable extension is not found. Extension "GL_ARB_conservative_depth" is not supported
[17:17:49] [Render thread/ERROR]: #version 150
#extension GL_ARB_conservative_depth : enable
#define FRAGMENT_SHADER
#define DEBUG_NORMAL
#if defined(VERTEX_SHADER)
out float FragDistance;
#elif defined(FRAGMENT_SHADER)
in float FragDistance;
#endif
uniform vec4 uFogColor;
uniform vec2 uFogRange;
float cylindrical_distance(vec3 worldPos, vec3 cameraPos) {
float distXZ = length(worldPos.xz - cameraPos.xz);
float distY = abs(worldPos.y - cameraPos.y);
return max(distXZ, distY);
}
float cylindrical_distance(vec3 worldPos) {
float distXZ = length(worldPos.xz);
float distY = abs(worldPos.y);
return max(distXZ, distY);
}
float FLWFogFactor() {
return (uFogRange.y - FragDistance) / (uFogRange.y - uFogRange.x);
}
// Adjust the [0,1] normalized lightmap value based on the texture matrix from LightTexture#enableLightmap
vec2 shiftLight(vec2 lm) {
return lm * 0.99609375 + 0.03125;// * 255/256 + 1/32
}
uniform sampler3D uLightVolume;
uniform sampler2D uBlockAtlas;
uniform sampler2D uLightMap;
uniform vec3 uLightBoxSize;
uniform vec3 uLightBoxMin;
uniform mat4 uModel;
uniform float uTime;
uniform mat4 uViewProjection;
uniform vec3 uCameraPos;
void FLWFinalizeNormal(inout vec3 normal) {
mat3 m;
m[0] = uModel[0].xyz;
m[1] = uModel[1].xyz;
m[2] = uModel[2].xyz;
normal = m * normal;
}
#if defined(VERTEX_SHADER)
out vec3 BoxCoord;
void FLWFinalizeWorldPos(inout vec4 worldPos) {
worldPos = uModel * worldPos;
BoxCoord = (worldPos.xyz - uLightBoxMin) / uLightBoxSize;
FragDistance = max(length(worldPos.xz), abs(worldPos.y)); // cylindrical fog
gl_Position = uViewProjection * worldPos;
}
#elif defined(FRAGMENT_SHADER)
#define ALPHA_DISCARD 0.1
// optimize discard usage
#if defined(ALPHA_DISCARD)
#if defined(GL_ARB_conservative_depth)
layout (depth_greater) out float gl_FragDepth;
#endif
#endif
in vec3 BoxCoord;
out vec4 FragColor;
vec4 FLWBlockTexture(vec2 texCoords) {
return texture(uBlockAtlas, texCoords);
}
void FLWFinalizeColor(vec4 color) {
float a = color.a;
float fog = clamp(FLWFogFactor(), 0., 1.);
color = mix(uFogColor, color, fog);
color.a = a;
#if defined(ALPHA_DISCARD)
if (color.a < ALPHA_DISCARD) {
discard;
}
#endif
FragColor = color;
}
vec4 FLWLight(vec2 lightCoords) {
lightCoords = max(lightCoords, texture(uLightVolume, BoxCoord).rg);
return texture(uLightMap, shiftLight(lightCoords));
}
#endif
mat4 rotate(vec3 axis, float angle) {
float s = sin(angle);
float c = cos(angle);
float oc = 1. - c;
vec3 sa = axis * s;
mat4 mr = mat4(1.);
mr[0].xyz = oc * axis.xxz * axis.xyx + vec3(c, sa.z, -sa.y);
mr[1].xyz = oc * axis.xyy * axis.yyz + vec3(-sa.z, c, sa.x);
mr[2].xyz = oc * axis.zyz * axis.xzz + vec3(sa.y, -sa.x, c);
return mr;
}
mat4 rotation(vec3 rot) {
return rotate(vec3(0., 1., 0.), rot.y) * rotate(vec3(0., 0., 1.), rot.z) * rotate(vec3(1., 0., 0.), rot.x);
}
mat3 modelToNormal(mat4 mat) {
// Discard the edges. This won't be accurate for scaled or skewed matrices,
// but we don't have to work with those often.
mat3 m;
m[0] = mat[0].xyz;
m[1] = mat[1].xyz;
m[2] = mat[2].xyz;
return m;
}
float diffuse(vec3 normal) {
vec3 n2 = normal * normal * vec3(.6, .25, .8);
return min(n2.x + n2.y * (3. + normal.y) + n2.z, 1.);
}
struct BlockFrag {
vec2 texCoords;
vec4 color;
float diffuse;
vec2 light;
};
#if defined(FRAGMENT_SHADER)
void fragment(BlockFrag r) {
vec4 tex = FLWBlockTexture(r.texCoords);
vec4 color = vec4(tex.rgb * FLWLight(r.light).rgb * r.diffuse, tex.a) * r.color;
FLWFinalizeColor(color);
}
#endif
#define PI 3.1415926538
struct Vertex {
vec3 pos;
vec4 color;
vec2 texCoords;
vec2 modelLight;
vec3 normal;
};
#if defined(VERTEX_SHADER)
BlockFrag vertex(Vertex v) {
vec4 worldPos = vec4(v.pos, 1.);
vec3 norm = v.normal;
FLWFinalizeWorldPos(worldPos);
FLWFinalizeNormal(norm);
BlockFrag b;
b.diffuse = diffuse(norm);
b.texCoords = v.texCoords;
b.light = v.modelLight;
#if defined(DEBUG_NORMAL)
b.color = vec4(norm, 1.);
#else
b.color = v.color;
#endif
return b;
}
#endif
in vec2 v2f_texCoords;
in vec4 v2f_color;
in float v2f_diffuse;
in vec2 v2f_light;
void main() {
BlockFrag o;
o.texCoords = v2f_texCoords;
o.color = v2f_color;
o.diffuse = v2f_diffuse;
o.light = v2f_light;
fragment(o);
}
[17:17:49] [Render thread/INFO]: Loaded all shader programs.
[17:17:52] [Render thread/INFO]: OpenAL initialized on device OpenAL Soft on Headset Earphone (HyperX Virtual Surround Sound)
[17:17:52] [Render thread/INFO]: Sound engine started
[17:17:52] [Render thread/INFO]: Created: 2048x1024x4 minecraft:textures/atlas/blocks.png-atlas
[17:17:53] [Render thread/INFO]: [OptiFine] Animated sprites: 56
[17:17:53] [Render thread/INFO]: Created: 256x128x4 minecraft:textures/atlas/signs.png-atlas
[17:17:53] [Render thread/INFO]: [OptiFine] Animated sprites: 0
[17:17:53] [Render thread/INFO]: Created: 512x512x4 minecraft:textures/atlas/banner_patterns.png-atlas
[17:17:53] [Render thread/INFO]: [OptiFine] Animated sprites: 0
[17:17:53] [Render thread/INFO]: Created: 512x512x4 minecraft:textures/atlas/shield_patterns.png-atlas
[17:17:53] [Render thread/INFO]: [OptiFine] Animated sprites: 0
[17:17:53] [Render thread/INFO]: Created: 256x256x4 minecraft:textures/atlas/chest.png-atlas
[17:17:53] [Render thread/INFO]: [OptiFine] Animated sprites: 0
[17:17:53] [Render thread/INFO]: Created: 512x256x4 minecraft:textures/atlas/beds.png-atlas
[17:17:53] [Render thread/INFO]: [OptiFine] Animated sprites: 0
[17:17:53] [Render thread/INFO]: Created: 512x256x4 minecraft:textures/atlas/shulker_boxes.png-atlas
[17:17:53] [Render thread/INFO]: [OptiFine] Animated sprites: 0
[17:17:55] [Render thread/INFO]: Created: 256x256x0 minecraft:textures/atlas/particles.png-atlas
[17:17:56] [Render thread/INFO]: [OptiFine] Animated sprites: 1
[17:17:56] [Render thread/INFO]: Created: 256x256x0 minecraft:textures/atlas/paintings.png-atlas
[17:17:56] [Render thread/INFO]: [OptiFine] Animated sprites: 0
[17:17:56] [Render thread/INFO]: Created: 128x128x0 minecraft:textures/atlas/mob_effects.png-atlas
[17:17:56] [Render thread/INFO]: [OptiFine] Animated sprites: 0
[17:17:56] [Render thread/INFO]: Created: 128x256x0 jei:textures/atlas/gui.png-atlas
[17:17:56] [Render thread/INFO]: [OptiFine] Animated sprites: 0
[17:17:56] [Render thread/WARN]: [OptiFine] Invalid grid V: 16, icon: jei:gui/icons/config_button
[17:17:56] [Render thread/WARN]: [OptiFine] Invalid grid V: 16, icon: jei:gui/icons/config_button
[17:17:56] [Render thread/WARN]: [OptiFine] Invalid grid V: 16, icon: jei:gui/icons/config_button_cheat
[17:17:56] [Render thread/WARN]: [OptiFine] Invalid grid V: 16, icon: jei:gui/icons/config_button_cheat
[17:17:56] [Render thread/WARN]: [OptiFine] Invalid grid V: 16, icon: jei:gui/icons/arrow_previous
[17:17:56] [Render thread/WARN]: [OptiFine] Invalid grid V: 16, icon: jei:gui/icons/arrow_previous
[17:17:56] [Render thread/WARN]: [OptiFine] Invalid grid V: 16, icon: jei:gui/icons/arrow_next
[17:17:56] [Render thread/WARN]: [OptiFine] Invalid grid V: 16, icon: jei:gui/icons/arrow_next
[17:17:56] [Render thread/WARN]: [OptiFine] Invalid grid V: 16, icon: minecraft:missingno
[17:17:56] [Render thread/WARN]: [OptiFine] Invalid grid V: 16, icon: minecraft:missingno
[17:17:56] [Render thread/WARN]: [OptiFine] Invalid grid V: 16, icon: jei:gui/icons/info
[17:17:56] [Render thread/WARN]: [OptiFine] Invalid grid V: 16, icon: jei:gui/icons/info
[17:17:56] [Render thread/WARN]: [OptiFine] Invalid grid V: 16, icon: jei:gui/icons/recipe_transfer
[17:17:56] [Render thread/WARN]: [OptiFine] Invalid grid V: 16, icon: jei:gui/icons/recipe_transfer
[17:17:56] [Render thread/INFO]: [OptiFine] *** Reloading custom textures ***
[17:17:56] [Render thread/WARN]: [OptiFine] Unknown resource pack file: mod_resources
[17:17:56] [Render thread/WARN]: [OptiFine] Unknown resource pack file: mod_resources
[17:17:56] [Render thread/WARN]: [OptiFine] Unknown resource pack file: mod_resources
[17:18:06] [Render thread/WARN]: [OptiFine] Unknown resource pack file: mod_resources
[17:18:06] [Render thread/WARN]: [OptiFine] Model renderer not found, model: creeper, name: armor
[17:18:06] [Render thread/WARN]: [OptiFine] Model renderer not found, model: minecart, name: dirt
[17:18:06] [Render thread/WARN]: [OptiFine] Model renderer not found, model: chest_minecart, name: dirt
[17:18:06] [Render thread/WARN]: [OptiFine] Model renderer not found, model: command_block_minecart, name: dirt
[17:18:06] [Render thread/WARN]: [OptiFine] Model renderer not found, model: furnace_minecart, name: dirt
[17:18:06] [Render thread/WARN]: [OptiFine] Model renderer not found, model: hopper_minecart, name: dirt
[17:18:06] [Render thread/WARN]: [OptiFine] Model renderer not found, model: tnt_minecart, name: dirt
[17:18:06] [Render thread/WARN]: [OptiFine] Model renderer not found, model: spawner_minecart, name: dirt
[17:18:07] [Render thread/WARN]: [OptiFine] Unknown resource pack file: mod_resources
[17:18:07] [Render thread/WARN]: [OptiFine] Unknown resource pack file: mod_resources
[17:18:07] [Render thread/INFO]: [OptiFine] Disable Forge light pipeline
[17:18:07] [Render thread/INFO]: [OptiFine] Set ForgeConfig.CLIENT.experimentalForgeLightPipelineEnabled=false
[17:18:14] [Render thread/INFO]: Connecting to Femboiihooters.aternos.me, 25565
[17:18:14] [Netty Client IO #2/INFO]: Connected to a vanilla server. Catching up missing behaviour.
[11Jan2022 17:18:15.585] [Render thread/INFO] [com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService/]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD'
[17:19:01] [Render thread/INFO]: Stopping!