├── .github └── workflows │ └── build.yml ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src └── main ├── java └── net │ └── vulkanmod │ ├── Initializer.java │ ├── config │ ├── Config.java │ ├── CyclingOption.java │ ├── Option.java │ ├── OptionList2.java │ ├── OptionScreenV.java │ ├── Options.java │ ├── OptionsList.java │ ├── RangeOption.java │ ├── SliderWidgetImpl.java │ ├── SwitchOption.java │ ├── VideoResolution.java │ ├── VideoSettingsScreen.java │ └── widget │ │ ├── CustomButtonWidget.java │ │ ├── CyclingOptionWidget.java │ │ ├── OptionWidget.java │ │ ├── RangeOptionWidget.java │ │ └── SwitchOptionWidget.java │ ├── gl │ ├── TextureMap.java │ └── Util.java │ ├── interfaces │ ├── ExtendedVertexBuilder.java │ ├── FrustumMixed.java │ ├── ModelPartCubeMixed.java │ ├── ShaderMixed.java │ ├── VAbstractTextureI.java │ ├── VertexFormatMixed.java │ └── math │ │ └── Vec3Extended.java │ ├── mixin │ ├── ClientLevelM.java │ ├── MixinPlugin.java │ ├── WindowMixin.java │ ├── chunk │ │ ├── DirectionMixin.java │ │ ├── FrustumMixin.java │ │ ├── LevelRendererMixin.java │ │ └── VisibilitySetMixin.java │ ├── compatibility │ │ ├── EffectInstanceM.java │ │ └── UniformM.java │ ├── debug │ │ ├── ChunkBorderRendererM.java │ │ ├── DebugHudM.java │ │ ├── GlDebugInfoM.java │ │ └── KeyboardHandlerM.java │ ├── gui │ │ ├── ChatHudM.java │ │ ├── DebugHudM.java │ │ └── InGameHudM.java │ ├── math │ │ ├── Matrix4fM.java │ │ └── internal │ │ │ ├── Matrix4f.java │ │ │ └── Vertex3fM.java │ ├── model │ │ ├── ModelPartCubeM.java │ │ └── ModelPartM.java │ ├── render │ │ ├── BakedQuadFactoryM.java │ │ ├── BufferBuilderM.java │ │ ├── BufferRendererM.java │ │ ├── FramebufferMixin.java │ │ ├── GameRendererMixin.java │ │ ├── GlProgramManagerMixin.java │ │ ├── GlStateManagerM.java │ │ ├── IndexTypeMixin.java │ │ ├── LevelRendererMixin.java │ │ ├── MinecraftMixin.java │ │ ├── RenderSystemMixin.java │ │ ├── ShaderMixin.java │ │ ├── VertexBufferM.java │ │ ├── VertexConsumerM.java │ │ ├── VertexFormatMixin.java │ │ └── WindowFramebufferMixin.java │ ├── screen │ │ └── OptionsScreenM.java │ ├── texture │ │ ├── MAbstractTexture.java │ │ ├── MDynamicTexture.java │ │ ├── MFontTexture.java │ │ ├── MLightMap.java │ │ ├── MNativeImage.java │ │ ├── MOverlayTexture.java │ │ ├── MPlayerSkinTexture.java │ │ ├── MSimpleTexture.java │ │ ├── MSpriteAtlasTexture.java │ │ ├── MTextureManager.java │ │ └── MTextureUtil.java │ ├── util │ │ └── ScreenshotRecorderM.java │ └── vertex │ │ ├── SpriteCoordinateExpanderM.java │ │ └── VertexConsumersM.java │ ├── model │ └── CubeModel.java │ ├── render │ ├── Profiler.java │ ├── VBO.java │ ├── chunk │ │ ├── ChunkArea.java │ │ ├── ChunkAreaManager.java │ │ ├── ChunkGrid.java │ │ ├── ChunkRenderer.java │ │ ├── ChunkTask.java │ │ ├── RenderSection.java │ │ ├── TaskDispatcher.java │ │ ├── VFrustum.java │ │ ├── WorldRenderer.java │ │ └── util │ │ │ ├── ChunkQueue.java │ │ │ ├── CircularIntList.java │ │ │ └── Util.java │ ├── gui │ │ └── GuiBatchRenderer.java │ └── vertex │ │ └── VertexUtil.java │ └── vulkan │ ├── DeviceInfo.java │ ├── Drawer.java │ ├── ShaderSPIRVUtils.java │ ├── Synchronization.java │ ├── TransferQueue.java │ ├── VRenderSystem.java │ ├── Vulkan.java │ ├── memory │ ├── AutoIndexBuffer.java │ ├── Buffer.java │ ├── IndexBuffer.java │ ├── MemoryManager.java │ ├── MemoryType.java │ ├── MemoryTypes.java │ ├── StagingBuffer.java │ ├── UniformBuffers.java │ └── VertexBuffer.java │ ├── shader │ ├── Pipeline.java │ ├── PipelineState.java │ ├── layout │ │ ├── AlignedStruct.java │ │ ├── Field.java │ │ ├── Mat4f.java │ │ ├── PushConstants.java │ │ ├── UBO.java │ │ ├── Vec1f.java │ │ ├── Vec1i.java │ │ ├── Vec2f.java │ │ ├── Vec3f.java │ │ └── Vec4f.java │ └── parser │ │ ├── GlslConverter.java │ │ ├── InputOutputParser.java │ │ └── UniformParser.java │ ├── texture │ ├── VTextureSelector.java │ └── VulkanImage.java │ └── util │ ├── MappedBuffer.java │ ├── Pair.java │ └── VUtil.java └── resources ├── assets └── vulkanmod │ ├── Vlogo.png │ └── shaders │ └── core │ ├── blit_screen.fsh │ ├── blit_screen.json │ ├── blit_screen.vsh │ ├── particle.fsh │ ├── particle.json │ ├── particle.vsh │ ├── position.fsh │ ├── position.json │ ├── position.vsh │ ├── position_color.fsh │ ├── position_color.json │ ├── position_color.vsh │ ├── position_color_lightmap.fsh │ ├── position_color_lightmap.json │ ├── position_color_lightmap.vsh │ ├── position_color_normal.fsh │ ├── position_color_normal.json │ ├── position_color_normal.vsh │ ├── position_color_tex.fsh │ ├── position_color_tex.json │ ├── position_color_tex.vsh │ ├── position_color_tex_lightmap.fsh │ ├── position_color_tex_lightmap.json │ ├── position_color_tex_lightmap.vsh │ ├── position_tex.fsh │ ├── position_tex.json │ ├── position_tex.vsh │ ├── position_tex_color.fsh │ ├── position_tex_color.json │ ├── position_tex_color.vsh │ ├── position_tex_color_normal.fsh │ ├── position_tex_color_normal.json │ ├── position_tex_color_normal.vsh │ ├── rendertype_armor_cutout_no_cull.fsh │ ├── rendertype_armor_cutout_no_cull.json │ ├── rendertype_armor_cutout_no_cull.vsh │ ├── rendertype_armor_entity_glint.fsh │ ├── rendertype_armor_entity_glint.json │ ├── rendertype_armor_entity_glint.vsh │ ├── rendertype_armor_glint.fsh │ ├── rendertype_armor_glint.json │ ├── rendertype_armor_glint.vsh │ ├── rendertype_beacon_beam.fsh │ ├── rendertype_beacon_beam.json │ ├── rendertype_beacon_beam.vsh │ ├── rendertype_crumbling.fsh │ ├── rendertype_crumbling.json │ ├── rendertype_crumbling.vsh │ ├── rendertype_cutout.fsh │ ├── rendertype_cutout.json │ ├── rendertype_cutout.vsh │ ├── rendertype_cutout_mipped.fsh │ ├── rendertype_cutout_mipped.json │ ├── rendertype_cutout_mipped.vsh │ ├── rendertype_end_portal.fsh │ ├── rendertype_end_portal.json │ ├── rendertype_end_portal.vsh │ ├── rendertype_energy_swirl.fsh │ ├── rendertype_energy_swirl.json │ ├── rendertype_energy_swirl.vsh │ ├── rendertype_entity_alpha.fsh │ ├── rendertype_entity_alpha.json │ ├── rendertype_entity_alpha.vsh │ ├── rendertype_entity_cutout.fsh │ ├── rendertype_entity_cutout.json │ ├── rendertype_entity_cutout.vsh │ ├── rendertype_entity_cutout_no_cull.fsh │ ├── rendertype_entity_cutout_no_cull.json │ ├── rendertype_entity_cutout_no_cull.vsh │ ├── rendertype_entity_cutout_no_cull_z_offset.fsh │ ├── rendertype_entity_cutout_no_cull_z_offset.json │ ├── rendertype_entity_cutout_no_cull_z_offset.vsh │ ├── rendertype_entity_decal.fsh │ ├── rendertype_entity_decal.json │ ├── rendertype_entity_decal.vsh │ ├── rendertype_entity_glint.fsh │ ├── rendertype_entity_glint.json │ ├── rendertype_entity_glint.vsh │ ├── rendertype_entity_glint_direct.fsh │ ├── rendertype_entity_glint_direct.json │ ├── rendertype_entity_glint_direct.vsh │ ├── rendertype_entity_no_outline.fsh │ ├── rendertype_entity_no_outline.json │ ├── rendertype_entity_no_outline.vsh │ ├── rendertype_entity_shadow.fsh │ ├── rendertype_entity_shadow.json │ ├── rendertype_entity_shadow.vsh │ ├── rendertype_entity_smooth_cutout.fsh │ ├── rendertype_entity_smooth_cutout.json │ ├── rendertype_entity_smooth_cutout.vsh │ ├── rendertype_entity_solid.fsh │ ├── rendertype_entity_solid.json │ ├── rendertype_entity_solid.vsh │ ├── rendertype_entity_translucent.fsh │ ├── rendertype_entity_translucent.json │ ├── rendertype_entity_translucent.vsh │ ├── rendertype_entity_translucent_cull.fsh │ ├── rendertype_entity_translucent_cull.json │ ├── rendertype_entity_translucent_cull.vsh │ ├── rendertype_entity_translucent_emissive.fsh │ ├── rendertype_entity_translucent_emissive.json │ ├── rendertype_entity_translucent_emissive.vsh │ ├── rendertype_eyes.fsh │ ├── rendertype_eyes.json │ ├── rendertype_eyes.vsh │ ├── rendertype_glint.fsh │ ├── rendertype_glint.json │ ├── rendertype_glint.vsh │ ├── rendertype_glint_direct.fsh │ ├── rendertype_glint_direct.json │ ├── rendertype_glint_direct.vsh │ ├── rendertype_glint_translucent.fsh │ ├── rendertype_glint_translucent.json │ ├── rendertype_glint_translucent.vsh │ ├── rendertype_item_entity_translucent_cull.fsh │ ├── rendertype_item_entity_translucent_cull.json │ ├── rendertype_item_entity_translucent_cull.vsh │ ├── rendertype_leash.fsh │ ├── rendertype_leash.json │ ├── rendertype_leash.vsh │ ├── rendertype_lightning.fsh │ ├── rendertype_lightning.json │ ├── rendertype_lightning.vsh │ ├── rendertype_lines.fsh │ ├── rendertype_lines.json │ ├── rendertype_lines.vsh │ ├── rendertype_outline.fsh │ ├── rendertype_outline.json │ ├── rendertype_outline.vsh │ ├── rendertype_solid.fsh │ ├── rendertype_solid.json │ ├── rendertype_solid.vsh │ ├── rendertype_text.fsh │ ├── rendertype_text.json │ ├── rendertype_text.vsh │ ├── rendertype_text_see_through.fsh │ ├── rendertype_text_see_through.json │ ├── rendertype_text_see_through.vsh │ ├── rendertype_translucent.fsh │ ├── rendertype_translucent.json │ ├── rendertype_translucent.vsh │ ├── rendertype_translucent_moving_block.fsh │ ├── rendertype_translucent_moving_block.json │ ├── rendertype_translucent_moving_block.vsh │ ├── rendertype_translucent_no_crumbling.fsh │ ├── rendertype_translucent_no_crumbling.json │ ├── rendertype_translucent_no_crumbling.vsh │ ├── rendertype_tripwire.fsh │ ├── rendertype_tripwire.json │ ├── rendertype_tripwire.vsh │ ├── rendertype_water_mask.fsh │ ├── rendertype_water_mask.json │ └── rendertype_water_mask.vsh ├── fabric.mod.json ├── vulkanmod.accesswidener └── vulkanmod.mixins.json /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # Automatically build the project and run any configured tests for every push 2 | # and submitted pull request. This can help catch issues that only occur on 3 | # certain platforms or Java versions, and provides a first line of defence 4 | # against bad commits. 5 | 6 | name: build 7 | on: [pull_request, push, workflow_dispatch] 8 | 9 | jobs: 10 | build: 11 | strategy: 12 | matrix: 13 | # Use these Java versions 14 | java: [ 15 | 17, # Current Java LTS & minimum supported by Minecraft 16 | ] 17 | # and run on both Linux and Windows 18 | os: [ubuntu-20.04] #, windows-2022] 19 | runs-on: ${{ matrix.os }} 20 | steps: 21 | - name: checkout repository 22 | uses: actions/checkout@v2 23 | - name: validate gradle wrapper 24 | uses: gradle/wrapper-validation-action@v1 25 | - name: setup jdk ${{ matrix.java }} 26 | uses: actions/setup-java@v1 27 | with: 28 | java-version: ${{ matrix.java }} 29 | - name: make gradle wrapper executable 30 | if: ${{ runner.os != 'Windows' }} 31 | run: chmod +x ./gradlew 32 | - name: build 33 | run: | 34 | ./gradlew build 35 | # patch to make LWJGL 3.3.1 as optional 36 | jar xf build/libs/*.jar fabric.mod.json 37 | echo "$(jq '.jars=[{"file":"META-INF/jars/joml-1.10.4.jar"}]' fabric.mod.json)" > fabric.mod.json 38 | find build/libs -name '*.jar' -exec jar uf {} fabric.mod.json \; 39 | - name: capture build artifacts 40 | if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS 41 | uses: actions/upload-artifact@v2 42 | with: 43 | name: Artifacts 44 | path: build/libs/ 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # gradle 2 | 3 | .gradle/ 4 | build/ 5 | out/ 6 | classes/ 7 | 8 | # eclipse 9 | 10 | *.launch 11 | 12 | # idea 13 | 14 | .idea/ 15 | *.iml 16 | *.ipr 17 | *.iws 18 | 19 | # vscode 20 | 21 | .settings/ 22 | .vscode/ 23 | bin/ 24 | .classpath 25 | .project 26 | 27 | # macos 28 | 29 | *.DS_Store 30 | 31 | # fabric 32 | 33 | run/ 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | [![Logo](https://media.discordapp.net/attachments/963349566839738369/969920960373334076/Vlogo.png?width=300&height=300)](#) 4 | 5 | # VulkanMod 6 | 7 | This is a fabric mod that rewrites Minecraft OpenGL renderer to use Vulkan API. 8 | 9 | Demostration Video: 10 | 11 | [![Demostration Video](http://img.youtube.com/vi/sbr7UxcAmOE/0.jpg)](https://youtu.be/sbr7UxcAmOE) 12 | 13 | ![Download](https://img.shields.io/github/downloads/xCollateral/VulkanMod/total?color=red&logo=github&style=for-the-badge) 14 | 15 | [![Discord](https://img.shields.io/badge/Discord-7289DA?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/FVXg7AYR2Q) 16 | 17 | [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/V7V7CHHJV) 18 | 19 | ## Installation 20 | 21 | ### Download 22 | 23 | [![Modrinth](https://modrinth-utils.vercel.app/api/badge/downloads?id=vulkanmod&logo=true&style=for-the-badge)](https://modrinth.com/mod/vulkanmod) 24 | 25 | [![CurseForge](https://cf.way2muchnoise.eu/title/635429_Get_Mod.svg?badge_style=flat)](https://www.curseforge.com/minecraft/mc-mods/vulkanmod) 26 | 27 | [![CurseForge](https://cf.way2muchnoise.eu/full_635429_downloads.svg?badge_style=flat)](https://www.curseforge.com/minecraft/mc-mods/vulkanmod) 28 | 29 | - Fabric mod loader is needed. 30 | - Move `VulkanMod.jar` to `mods` folder of your Minecraft Instance. 31 | 32 | ## Known Issues 33 | 34 | - Linux and macOS may not work. 35 | 36 | ## Notes 37 | This is still a pre-alpha mod. Bugs are to be expected. 38 | 39 |
-------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Done to increase the memory available to gradle. 2 | org.gradle.jvmargs=-Xmx1G 3 | 4 | # Fabric Properties 5 | # check these on https://fabricmc.net/develop 6 | minecraft_version=1.19.2 7 | yarn_mappings=1.19.2+build.1 8 | loader_version=0.14.10 9 | 10 | # Mod Properties 11 | mod_version = 0.2.4 12 | maven_group = net.vulkanmod 13 | archives_base_name = VulkanMod_1.19.2 14 | 15 | # Dependencies 16 | fabric_version=0.66.0+1.19.2 17 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PojavLauncherTeam/VulkanMod/3f2b48e514f4e3335fe9d0d8a5a3f78f6c4eea72/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PojavLauncherTeam/VulkanMod/3f2b48e514f4e3335fe9d0d8a5a3f78f6c4eea72/gradlew -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { 4 | name = 'Fabric' 5 | url = 'https://maven.fabricmc.net/' 6 | } 7 | mavenCentral() 8 | gradlePluginPortal() 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/Initializer.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod; 2 | 3 | import net.fabricmc.api.ModInitializer; 4 | import net.fabricmc.loader.api.FabricLoader; 5 | import net.vulkanmod.config.Config; 6 | import net.vulkanmod.config.VideoResolution; 7 | import org.apache.logging.log4j.LogManager; 8 | import org.apache.logging.log4j.Logger; 9 | 10 | import java.nio.file.Path; 11 | 12 | public class Initializer implements ModInitializer { 13 | public static final Logger LOGGER = LogManager.getLogger("VulkanMod"); 14 | 15 | private static String VERSION; 16 | public static Config CONFIG; 17 | 18 | @Override 19 | public void onInitialize() { 20 | 21 | VERSION = FabricLoader.getInstance() 22 | .getModContainer("vulkanmod") 23 | .get() 24 | .getMetadata() 25 | .getVersion().getFriendlyString(); 26 | 27 | LOGGER.info("== VulkanMod =="); 28 | 29 | VideoResolution.init(); 30 | 31 | var configPath = FabricLoader.getInstance() 32 | .getConfigDir() 33 | .resolve("vulkanmod_settings.json"); 34 | 35 | CONFIG = loadConfig(configPath); 36 | 37 | } 38 | 39 | private static Config loadConfig(Path path) { 40 | Config config = Config.load(path); 41 | if(config == null) { 42 | config = new Config(); 43 | config.write(); 44 | } 45 | return config; 46 | } 47 | 48 | public static String getVersion() { 49 | return VERSION; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/config/Config.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.config; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.GsonBuilder; 5 | 6 | import java.io.FileReader; 7 | import java.io.IOException; 8 | import java.lang.reflect.Modifier; 9 | import java.nio.file.Files; 10 | import java.nio.file.Path; 11 | import java.util.Collections; 12 | 13 | public class Config { 14 | 15 | public int frameQueueSize = 2; 16 | public VideoResolution resolution = VideoResolution.getFirstAvailable(); 17 | public boolean windowedFullscreen = false; 18 | public boolean guiOptimizations = false; 19 | public int advCulling = 2; 20 | 21 | private static Path path; 22 | 23 | private static final Gson GSON = new GsonBuilder() 24 | .setPrettyPrinting() 25 | .excludeFieldsWithModifiers(Modifier.PRIVATE) 26 | .create(); 27 | 28 | public static Config load(Path path) { 29 | Config config; 30 | Config.path = path; 31 | 32 | if (Files.exists(path)) { 33 | try (FileReader fileReader = new FileReader(path.toFile())) { 34 | config = GSON.fromJson(fileReader, Config.class); 35 | } 36 | catch (IOException exception) { 37 | throw new RuntimeException(exception.getMessage()); 38 | } 39 | } 40 | else { 41 | config = null; 42 | } 43 | 44 | return config; 45 | } 46 | 47 | public void write() { 48 | 49 | if(!Files.exists(path.getParent())) { 50 | try { 51 | Files.createDirectories(path); 52 | } catch (IOException e) { 53 | e.printStackTrace(); 54 | } 55 | } 56 | 57 | try { 58 | Files.write(path, Collections.singleton(GSON.toJson(this))); 59 | } catch (IOException e) { 60 | e.printStackTrace(); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/config/Option.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.config; 2 | 3 | import net.minecraft.client.gui.components.AbstractWidget; 4 | import net.minecraft.network.chat.Component; 5 | import net.vulkanmod.config.widget.OptionWidget; 6 | 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | public abstract class Option { 11 | protected final Component name; 12 | protected Component tooltip; 13 | 14 | protected Consumer setter; 15 | protected Supplier getter; 16 | 17 | protected T value; 18 | protected T newValue; 19 | 20 | public Option(String name, Consumer setter, Supplier getter) { 21 | this.name = Component.literal(name); 22 | 23 | this.setter = setter; 24 | this.getter = getter; 25 | 26 | this.newValue = this.value = this.getter.get(); 27 | } 28 | 29 | public abstract AbstractWidget createWidget(int x, int y, int width, int height); 30 | 31 | public abstract OptionWidget createOptionWidget(int x, int y, int width, int height); 32 | 33 | public abstract void setValue(T t); 34 | 35 | public Component getName() { 36 | return this.name; 37 | } 38 | 39 | public boolean isModified() { 40 | return !this.newValue.equals(this.value); 41 | } 42 | 43 | protected void apply() { 44 | if(!isModified()) return; 45 | setter.accept(this.newValue); 46 | this.value = this.newValue; 47 | } 48 | 49 | public T getValue() { 50 | return this.newValue; 51 | } 52 | 53 | public Option setTooltip(Component text) { 54 | this.tooltip = text; 55 | return this; 56 | } 57 | 58 | public Component getTooltip() { 59 | return this.tooltip; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/config/SliderWidgetImpl.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.config; 2 | 3 | import net.minecraft.client.gui.components.AbstractSliderButton; 4 | import net.minecraft.network.chat.Component; 5 | 6 | public class SliderWidgetImpl extends AbstractSliderButton { 7 | private RangeOption option; 8 | 9 | public SliderWidgetImpl(RangeOption option, int x, int y, int width, int height, Component text, double value) { 10 | super(x, y, width, height, text, value); 11 | this.option = option; 12 | } 13 | 14 | @Override 15 | protected void updateMessage() { 16 | this.setMessage(option.getName()); 17 | } 18 | 19 | @Override 20 | protected void applyValue() { 21 | option.setValue((float) this.value); 22 | this.value = option.getScaledValue(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/config/SwitchOption.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.config; 2 | 3 | import net.minecraft.client.gui.components.AbstractWidget; 4 | import net.vulkanmod.config.widget.OptionWidget; 5 | import net.vulkanmod.config.widget.SwitchOptionWidget; 6 | 7 | import java.util.function.Consumer; 8 | import java.util.function.Supplier; 9 | 10 | public class SwitchOption extends Option { 11 | public SwitchOption(String name, Consumer setter, Supplier getter) { 12 | super(name, setter, getter); 13 | } 14 | 15 | @Override 16 | public AbstractWidget createWidget(int x, int y, int width, int height) { 17 | return null; 18 | } 19 | 20 | @Override 21 | public OptionWidget createOptionWidget(int x, int y, int width, int height) { 22 | return new SwitchOptionWidget(this, x, y, width, height, this.name); 23 | } 24 | 25 | @Override 26 | public void setValue(Boolean aBoolean) { 27 | this.newValue = aBoolean; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/config/widget/SwitchOptionWidget.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.config.widget; 2 | 3 | import net.minecraft.network.chat.Component; 4 | import net.vulkanmod.config.SwitchOption; 5 | 6 | public class SwitchOptionWidget extends OptionWidget { 7 | SwitchOption option; 8 | 9 | public SwitchOptionWidget(SwitchOption option, int x, int y, int width, int height, Component name) { 10 | super(x, y, width, height, name); 11 | this.option = option; 12 | updateDisplayedValue(); 13 | } 14 | 15 | public void onClick(double mouseX, double mouseY) { 16 | this.option.setValue(!this.option.getValue()); 17 | updateDisplayedValue(); 18 | } 19 | 20 | private void updateDisplayedValue() { 21 | this.displayedValue = option.getValue() ? Component.nullToEmpty("On") : Component.nullToEmpty("Off"); 22 | } 23 | 24 | public Component getTooltip() { 25 | return this.option.getTooltip(); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/gl/TextureMap.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.gl; 2 | 3 | import it.unimi.dsi.fastutil.ints.Int2ReferenceOpenHashMap; 4 | import net.vulkanmod.vulkan.texture.VulkanImage; 5 | 6 | public class TextureMap { 7 | 8 | static Int2ReferenceOpenHashMap textures = new Int2ReferenceOpenHashMap<>(); 9 | 10 | public static void addTexture(VulkanImage vulkanImage) { 11 | textures.put(getId(vulkanImage), vulkanImage); 12 | } 13 | 14 | public static VulkanImage getTexture(int id) { 15 | return textures.get(id); 16 | } 17 | 18 | public static boolean removeTexture(int id) { return textures.remove(id) != null; } 19 | 20 | public static int getId(VulkanImage vulkanImage) { 21 | return (int) vulkanImage.getId(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/gl/Util.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.gl; 2 | 3 | import net.vulkanmod.vulkan.ShaderSPIRVUtils; 4 | 5 | public class Util { 6 | 7 | public static ShaderSPIRVUtils.ShaderKind extToShaderKind(String in) { 8 | return switch (in) { 9 | case ".vsh" -> ShaderSPIRVUtils.ShaderKind.VERTEX_SHADER; 10 | case ".fsh" -> ShaderSPIRVUtils.ShaderKind.FRAGMENT_SHADER; 11 | default -> throw new RuntimeException("unknown shader type: " + in); 12 | }; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/interfaces/ExtendedVertexBuilder.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.interfaces; 2 | 3 | import net.vulkanmod.render.vertex.VertexUtil; 4 | 5 | public interface ExtendedVertexBuilder { 6 | 7 | void vertex(float x, float y, float z, int packedColor, float u, float v, int overlay, int light, int packedNormal); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/interfaces/FrustumMixed.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.interfaces; 2 | 3 | import net.vulkanmod.render.chunk.VFrustum; 4 | 5 | public interface FrustumMixed { 6 | 7 | VFrustum customFrustum(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/interfaces/ModelPartCubeMixed.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.interfaces; 2 | 3 | import net.vulkanmod.model.CubeModel; 4 | 5 | public interface ModelPartCubeMixed { 6 | 7 | CubeModel getCubeModel(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/interfaces/ShaderMixed.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.interfaces; 2 | 3 | import net.vulkanmod.vulkan.shader.Pipeline; 4 | 5 | public interface ShaderMixed { 6 | 7 | Pipeline getPipeline(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/interfaces/VAbstractTextureI.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.interfaces; 2 | 3 | import net.vulkanmod.vulkan.texture.VulkanImage; 4 | 5 | public interface VAbstractTextureI { 6 | 7 | public void bindTexture(); 8 | 9 | void setId(int i); 10 | 11 | public VulkanImage getVulkanImage(); 12 | 13 | public void setVulkanImage(VulkanImage image); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/interfaces/VertexFormatMixed.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.interfaces; 2 | 3 | import com.mojang.blaze3d.vertex.VertexFormatElement; 4 | 5 | import java.util.List; 6 | 7 | public interface VertexFormatMixed { 8 | 9 | int getOffset(int i); 10 | 11 | List getFastList(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/interfaces/math/Vec3Extended.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.interfaces.math; 2 | 3 | import com.mojang.math.Vector3f; 4 | import org.joml.Matrix4fc; 5 | 6 | public interface Vec3Extended { 7 | 8 | Vector3f mulPosition(Matrix4fc mat, Vector3f dest); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/ClientLevelM.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin; 2 | 3 | import net.minecraft.client.multiplayer.ClientLevel; 4 | import net.vulkanmod.render.chunk.RenderSection; 5 | import net.vulkanmod.render.chunk.WorldRenderer; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Inject; 9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 10 | 11 | @Mixin(ClientLevel.class) 12 | public class ClientLevelM { 13 | 14 | @Inject(method = "setLightReady", at = @At("RETURN")) 15 | private void setLightReady(int i, int j, CallbackInfo ci) { 16 | WorldRenderer.getInstance().setSectionsLightReady(i, j); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/MixinPlugin.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin; 2 | 3 | import net.vulkanmod.config.Config; 4 | import net.vulkanmod.config.VideoResolution; 5 | import org.objectweb.asm.tree.ClassNode; 6 | import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; 7 | import org.spongepowered.asm.mixin.extensibility.IMixinInfo; 8 | 9 | import java.io.File; 10 | import java.util.HashSet; 11 | import java.util.List; 12 | import java.util.Set; 13 | 14 | public class MixinPlugin implements IMixinConfigPlugin { 15 | 16 | private static Config config; 17 | @Override 18 | public void onLoad(String mixinPackage) { 19 | config = Config.load(new File("./config/vulkanmod_settings.json").toPath().toAbsolutePath()); 20 | if(config == null) config = new Config(); 21 | } 22 | 23 | @Override 24 | public String getRefMapperConfig() { 25 | return null; 26 | } 27 | 28 | @Override 29 | public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { 30 | 31 | if(mixinClassName.startsWith("net.vulkanmod.mixin.gui") && !config.guiOptimizations) { 32 | return false; 33 | } 34 | 35 | return true; 36 | } 37 | 38 | @Override 39 | public void acceptTargets(Set myTargets, Set otherTargets) { 40 | 41 | } 42 | 43 | @Override 44 | public List getMixins() { 45 | return null; 46 | } 47 | 48 | @Override 49 | public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { 50 | } 51 | 52 | @Override 53 | public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/chunk/DirectionMixin.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.chunk; 2 | 3 | import net.minecraft.core.Direction; 4 | import org.spongepowered.asm.mixin.Final; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.Overwrite; 7 | import org.spongepowered.asm.mixin.Shadow; 8 | 9 | @Mixin(Direction.class) 10 | public class DirectionMixin { 11 | 12 | @Shadow @Final private static Direction[] BY_3D_DATA; 13 | 14 | @Shadow @Final private int oppositeIndex; 15 | 16 | /** 17 | * @author 18 | * @reason 19 | */ 20 | @Overwrite 21 | public Direction getOpposite() { 22 | return BY_3D_DATA[this.oppositeIndex]; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/chunk/FrustumMixin.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.chunk; 2 | 3 | import com.mojang.math.Matrix4f; 4 | import net.minecraft.client.renderer.culling.Frustum; 5 | import net.vulkanmod.interfaces.FrustumMixed; 6 | import net.vulkanmod.render.chunk.VFrustum; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Shadow; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 12 | 13 | @Mixin(Frustum.class) 14 | public class FrustumMixin implements FrustumMixed { 15 | 16 | @Shadow private double camX; 17 | @Shadow private double camY; 18 | @Shadow private double camZ; 19 | private VFrustum vFrustum; 20 | 21 | @Inject(method = "calculateFrustum", at = @At("RETURN")) 22 | private void calculateFrustum(Matrix4f modelView, Matrix4f projection, CallbackInfo ci) { 23 | this.vFrustum = new VFrustum(modelView, projection); 24 | } 25 | 26 | @Inject(method = "prepare", at = @At("RETURN")) 27 | public void prepare(double d, double e, double f, CallbackInfo ci) { 28 | this.vFrustum.prepare(this.camX, this.camY, this.camZ); 29 | } 30 | 31 | @Override 32 | public VFrustum customFrustum() { 33 | return vFrustum; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/chunk/VisibilitySetMixin.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.chunk; 2 | 3 | import net.minecraft.client.renderer.chunk.VisibilitySet; 4 | import net.minecraft.core.Direction; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.Overwrite; 7 | 8 | @Mixin(VisibilitySet.class) 9 | public class VisibilitySetMixin { 10 | 11 | // private int vis = 0; 12 | private long vis = 0; 13 | 14 | /** 15 | * @author 16 | * @reason 17 | */ 18 | @Overwrite 19 | public void set(Direction dir1, Direction dir2, boolean p_112989_) { 20 | // this.vis |= 1 << (dir1.ordinal() * 5 + dir2.ordinal()) | 1 << (dir2.ordinal() * 5 + dir1.ordinal()); 21 | this.vis |= 1L << ((dir1.ordinal() << 3) + dir2.ordinal()) | 1L << ((dir2.ordinal() << 3) + dir1.ordinal()); 22 | } 23 | 24 | /** 25 | * @author 26 | * @reason 27 | */ 28 | @Overwrite 29 | public void setAll(boolean bl) { 30 | if(bl) this.vis = 0xFFFFFFFFFFFFFFFFL; 31 | } 32 | 33 | /** 34 | * @author 35 | * @reason 36 | */ 37 | @Overwrite 38 | public boolean visibilityBetween(Direction dir1, Direction dir2) { 39 | // return (this.vis & (1 << (dir1.ordinal() * 5 + dir2.ordinal()))) != 0; 40 | return (this.vis & (1L << ((dir1.ordinal() << 3) + dir2.ordinal()))) != 0; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/compatibility/UniformM.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.compatibility; 2 | 3 | import com.mojang.blaze3d.shaders.Uniform; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.Overwrite; 6 | import org.spongepowered.asm.mixin.injection.At; 7 | import org.spongepowered.asm.mixin.injection.Inject; 8 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 9 | 10 | @Mixin(Uniform.class) 11 | public class UniformM { 12 | 13 | /** 14 | * @author 15 | * @reason 16 | */ 17 | @Overwrite 18 | public static int glGetUniformLocation(int i, CharSequence charSequence) { 19 | //TODO 20 | return 1; 21 | } 22 | 23 | /** 24 | * @author 25 | * @reason 26 | */ 27 | @Overwrite 28 | public static int glGetAttribLocation(int i, CharSequence charSequence) { 29 | return 0; 30 | } 31 | 32 | @Inject(method = "upload", at = @At("HEAD"), cancellable = true) 33 | public void cancelUpload(CallbackInfo ci) { 34 | ci.cancel(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/debug/GlDebugInfoM.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.debug; 2 | 3 | import com.mojang.blaze3d.platform.GlUtil; 4 | import net.vulkanmod.vulkan.DeviceInfo; 5 | import net.vulkanmod.vulkan.Vulkan; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.Overwrite; 8 | 9 | @Mixin(GlUtil.class) 10 | public class GlDebugInfoM { 11 | 12 | /** 13 | * @author 14 | */ 15 | @Overwrite 16 | public static String getVendor() { 17 | return Vulkan.getDeviceInfo() != null ? Vulkan.getDeviceInfo().vendorId : "n/a"; 18 | } 19 | 20 | /** 21 | * @author 22 | */ 23 | @Overwrite 24 | public static String getRenderer() { 25 | return Vulkan.getDeviceInfo() != null ? Vulkan.getDeviceInfo().deviceName : "n/a"; 26 | } 27 | 28 | /** 29 | * @author 30 | */ 31 | @Overwrite 32 | public static String getOpenGLVersion() { 33 | return Vulkan.getDeviceInfo() != null ? Vulkan.getDeviceInfo().driverVersion : "n/a"; 34 | } 35 | 36 | /** 37 | * @author 38 | */ 39 | @Overwrite 40 | public static String getCpuInfo() { 41 | return DeviceInfo.cpuInfo; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/debug/KeyboardHandlerM.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.debug; 2 | 3 | import com.mojang.blaze3d.platform.InputConstants; 4 | import net.minecraft.client.KeyboardHandler; 5 | import net.minecraft.client.Minecraft; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.Shadow; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Inject; 10 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 11 | 12 | @Mixin(KeyboardHandler.class) 13 | public abstract class KeyboardHandlerM { 14 | 15 | @Shadow protected abstract boolean handleChunkDebugKeys(int i); 16 | 17 | @Shadow private boolean handledDebugKey; 18 | 19 | @Inject(method = "keyPress", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/InputConstants;isKeyDown(JI)Z", ordinal = 5, shift = At.Shift.AFTER)) 20 | private void chunkDebug(long l, int i, int j, int k, int m, CallbackInfo ci) { 21 | this.handledDebugKey |= InputConstants.isKeyDown(Minecraft.getInstance().getWindow().getWindow(), 296) && this.handleChunkDebugKeys(i); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/math/Matrix4fM.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.math; 2 | 3 | import org.joml.Matrix4f; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.Overwrite; 6 | 7 | @Mixin(Matrix4f.class) 8 | public class Matrix4fM { 9 | 10 | /** 11 | * @author 12 | * @reason 13 | */ 14 | @Overwrite(remap = false) 15 | public Matrix4f setOrtho(float left, float right, float bottom, float top, float zNear, float zFar) { 16 | return new Matrix4f().setOrtho(left, right, bottom, top, zNear, zFar, true); 17 | } 18 | 19 | /** 20 | * @author 21 | * @reason 22 | */ 23 | @Overwrite(remap = false) 24 | public Matrix4f ortho(float left, float right, float bottom, float top, float zNear, float zFar) { 25 | return new Matrix4f().ortho(left, right, bottom, top, zNear, zFar, true); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/math/internal/Vertex3fM.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.math.internal; 2 | 3 | import com.mojang.math.Vector3f; 4 | import net.vulkanmod.interfaces.math.Vec3Extended; 5 | import org.joml.Math; 6 | import org.joml.Matrix4fc; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Shadow; 9 | 10 | @Mixin(Vector3f.class) 11 | public class Vertex3fM implements Vec3Extended { 12 | 13 | @Shadow private float x; 14 | 15 | @Shadow private float y; 16 | 17 | @Shadow private float z; 18 | 19 | public Vector3f mulPosition(Matrix4fc mat, Vector3f dest) { 20 | float x = this.x, y = this.y, z = this.z; 21 | float xd = Math.fma(mat.m00(), x, Math.fma(mat.m10(), y, Math.fma(mat.m20(), z, mat.m30()))); 22 | float yd = Math.fma(mat.m01(), x, Math.fma(mat.m11(), y, Math.fma(mat.m21(), z, mat.m31()))); 23 | float zd = Math.fma(mat.m02(), x, Math.fma(mat.m12(), y, Math.fma(mat.m22(), z, mat.m32()))); 24 | dest.set(xd, yd, zd); 25 | return dest; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/model/ModelPartCubeM.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.model; 2 | 3 | import net.minecraft.client.model.geom.ModelPart; 4 | import net.vulkanmod.interfaces.ModelPartCubeMixed; 5 | import net.vulkanmod.model.CubeModel; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.At; 8 | import org.spongepowered.asm.mixin.injection.Inject; 9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 10 | 11 | @Mixin(ModelPart.Cube.class) 12 | public class ModelPartCubeM implements ModelPartCubeMixed { 13 | 14 | CubeModel cube; 15 | 16 | @Inject(method = "", at = @At(value = "FIELD", 17 | target = "Lnet/minecraft/client/model/geom/ModelPart$Cube;polygons:[Lnet/minecraft/client/model/geom/ModelPart$Polygon;", 18 | ordinal = 0, shift = At.Shift.AFTER)) 19 | private void getVertices(int i, int j, float f, float g, float h, float k, float l, float m, float n, float o, float p, boolean bl, float q, float r, CallbackInfo ci) { 20 | CubeModel cube = new CubeModel(); 21 | cube.setVertices(i, j, f, g, h, k, l, m, n, o, p, bl, q, r); 22 | this.cube = cube; 23 | } 24 | 25 | 26 | @Override 27 | public CubeModel getCubeModel() { 28 | return this.cube; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/render/BufferRendererM.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.render; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import com.mojang.blaze3d.vertex.BufferBuilder; 5 | import com.mojang.blaze3d.vertex.BufferUploader; 6 | import net.vulkanmod.vulkan.Drawer; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Overwrite; 9 | 10 | @Mixin(BufferUploader.class) 11 | public class BufferRendererM { 12 | 13 | /** 14 | * @author 15 | */ 16 | @Overwrite 17 | public static void reset() {} 18 | 19 | /** 20 | * @author 21 | */ 22 | @Overwrite 23 | public static void drawWithShader(BufferBuilder.RenderedBuffer buffer) { 24 | RenderSystem.assertOnRenderThread(); 25 | buffer.release(); 26 | 27 | BufferBuilder.DrawState parameters = buffer.drawState(); 28 | 29 | int glMode; 30 | switch (parameters.mode()) { 31 | case QUADS: 32 | case LINES: 33 | glMode = 7; 34 | break; 35 | case TRIANGLE_FAN: 36 | glMode = 6; 37 | break; 38 | case TRIANGLE_STRIP: 39 | case LINE_STRIP: 40 | glMode = 5; 41 | break; 42 | default: 43 | glMode = 4; 44 | } 45 | 46 | // Drawer.setModelViewMatrix(RenderSystem.getModelViewMatrix()); 47 | // Drawer.setProjectionMatrix(RenderSystem.getProjectionMatrix()); 48 | 49 | Drawer drawer = Drawer.getInstance(); 50 | drawer.draw(buffer.vertexBuffer(), glMode, parameters.format(), parameters.vertexCount()); 51 | } 52 | 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/render/FramebufferMixin.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.render; 2 | 3 | import com.mojang.blaze3d.pipeline.RenderTarget; 4 | import com.mojang.blaze3d.platform.GlStateManager; 5 | import com.mojang.blaze3d.systems.RenderSystem; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.Overwrite; 8 | import org.spongepowered.asm.mixin.Shadow; 9 | 10 | @Mixin(RenderTarget.class) 11 | public class FramebufferMixin { 12 | 13 | @Shadow public int viewWidth; 14 | 15 | @Shadow public int viewHeight; 16 | 17 | @Shadow public int width; 18 | 19 | @Shadow public int height; 20 | 21 | /** 22 | * @author 23 | */ 24 | @Overwrite 25 | public void clear(boolean getError) {} 26 | 27 | /** 28 | * @author 29 | */ 30 | @Overwrite 31 | private void _resize(int i, int j, boolean bl) { 32 | this.viewWidth = i; 33 | this.viewHeight = j; 34 | this.width = i; 35 | this.height = j; 36 | } 37 | 38 | /** 39 | * @author 40 | */ 41 | @Overwrite 42 | private void _bindWrite(boolean updateViewport) {} 43 | 44 | /** 45 | * @author 46 | */ 47 | @Overwrite 48 | public void unbindWrite() {} 49 | 50 | /** 51 | * @author 52 | */ 53 | @Overwrite 54 | private void _blitToScreen(int width, int height, boolean disableBlend) {} 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/render/GlProgramManagerMixin.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.render; 2 | 3 | import com.mojang.blaze3d.shaders.ProgramManager; 4 | import com.mojang.blaze3d.shaders.Shader; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.At; 7 | import org.spongepowered.asm.mixin.injection.Inject; 8 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 10 | 11 | import java.io.IOException; 12 | 13 | @Mixin(ProgramManager.class) 14 | public class GlProgramManagerMixin { 15 | 16 | @Inject(method = "createProgram", at = @At("HEAD"), cancellable = true) 17 | private static void createProgram(CallbackInfoReturnable cir) throws IOException { 18 | cir.setReturnValue(-1); 19 | } 20 | 21 | @Inject(method = "linkShader", at = @At("HEAD"), cancellable = true) 22 | private static void linkProgram(Shader shader, CallbackInfo ci) throws IOException { 23 | ci.cancel(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/render/IndexTypeMixin.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.render; 2 | 3 | import com.mojang.blaze3d.vertex.VertexFormat; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.Overwrite; 6 | 7 | @Mixin(VertexFormat.IndexType.class) 8 | public class IndexTypeMixin { 9 | 10 | /** 11 | * @author 12 | */ 13 | @Overwrite 14 | public static VertexFormat.IndexType least(int number) { 15 | return VertexFormat.IndexType.SHORT; 16 | } 17 | } -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/render/LevelRendererMixin.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.render; 2 | 3 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 4 | import net.minecraft.client.Minecraft; 5 | import net.minecraft.client.renderer.LevelRenderer; 6 | import net.minecraft.client.renderer.PostChain; 7 | import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher; 8 | import org.jetbrains.annotations.Nullable; 9 | import org.spongepowered.asm.mixin.Final; 10 | import org.spongepowered.asm.mixin.Mixin; 11 | import org.spongepowered.asm.mixin.Overwrite; 12 | import org.spongepowered.asm.mixin.Shadow; 13 | 14 | @Mixin(LevelRenderer.class) 15 | public abstract class LevelRendererMixin { 16 | 17 | @Shadow private @Nullable PostChain entityEffect; 18 | 19 | /** 20 | * @author 21 | */ 22 | @Overwrite 23 | public void initOutline() { 24 | if (this.entityEffect != null) { 25 | this.entityEffect.close(); 26 | } 27 | // Identifier identifier = new Identifier("shaders/post/entity_outline.json"); 28 | // try { 29 | // this.entityOutlineShader = new ShaderEffect(this.minecraft.getTextureManager(), this.minecraft.getResourceManager(), this.minecraft.getFramebuffer(), identifier); 30 | // this.entityOutlineShader.setupDimensions(this.minecraft.getWindow().getFramebufferWidth(), this.minecraft.getWindow().getFramebufferHeight()); 31 | // this.entityOutlinesFramebuffer = this.entityOutlineShader.getSecondaryTarget("final"); 32 | // } 33 | // catch (IOException iOException) { 34 | // LOGGER.warn("Failed to load shader: {}", (Object)identifier, (Object)iOException); 35 | // this.entityOutlineShader = null; 36 | // this.entityOutlinesFramebuffer = null; 37 | // } 38 | // catch (JsonSyntaxException iOException) { 39 | // LOGGER.warn("Failed to parse shader: {}", (Object)identifier, (Object)iOException); 40 | // this.entityOutlineShader = null; 41 | // this.entityOutlinesFramebuffer = null; 42 | // } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/render/VertexFormatMixin.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.render; 2 | 3 | import com.google.common.collect.ImmutableMap; 4 | import com.mojang.blaze3d.vertex.VertexFormat; 5 | import com.mojang.blaze3d.vertex.VertexFormatElement; 6 | import it.unimi.dsi.fastutil.ints.IntList; 7 | import it.unimi.dsi.fastutil.objects.ObjectArrayList; 8 | import net.vulkanmod.interfaces.VertexFormatMixed; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.Shadow; 11 | import org.spongepowered.asm.mixin.injection.At; 12 | import org.spongepowered.asm.mixin.injection.Inject; 13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 14 | 15 | import java.util.List; 16 | 17 | @Mixin(VertexFormat.class) 18 | public class VertexFormatMixin implements VertexFormatMixed { 19 | @Shadow private IntList offsets; 20 | 21 | private ObjectArrayList fastList; 22 | 23 | public int getOffset(int i) { 24 | return offsets.getInt(i); 25 | } 26 | 27 | public VertexFormatElement getElement(int i) { 28 | return this.fastList.get(i); 29 | } 30 | 31 | public List getFastList() { 32 | return this.fastList; 33 | } 34 | 35 | @Inject(method = "", at = @At("RETURN")) 36 | private void injectList(ImmutableMap immutableMap, CallbackInfo ci) { 37 | ObjectArrayList list = new ObjectArrayList<>(); 38 | list.addAll(immutableMap.values()); 39 | 40 | this.fastList = list; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/render/WindowFramebufferMixin.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.render; 2 | 3 | import com.mojang.blaze3d.pipeline.MainTarget; 4 | import com.mojang.blaze3d.pipeline.RenderTarget; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.Overwrite; 7 | 8 | @Mixin(MainTarget.class) 9 | public class WindowFramebufferMixin extends RenderTarget { 10 | 11 | public WindowFramebufferMixin(boolean useDepth) { 12 | super(useDepth); 13 | } 14 | 15 | /** 16 | * @author 17 | */ 18 | @Overwrite 19 | private void createFrameBuffer(int width, int height) { 20 | 21 | this.viewWidth = width; 22 | this.viewHeight = height; 23 | this.width = width; 24 | this.height = height; 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/screen/OptionsScreenM.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.screen; 2 | 3 | import net.minecraft.client.Options; 4 | import net.minecraft.client.gui.components.Button; 5 | import net.minecraft.client.gui.screens.OptionsScreen; 6 | import net.minecraft.client.gui.screens.Screen; 7 | import net.minecraft.network.chat.Component; 8 | import net.vulkanmod.config.OptionScreenV; 9 | import net.vulkanmod.config.VideoSettingsScreen; 10 | import org.spongepowered.asm.mixin.Final; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.Shadow; 13 | import org.spongepowered.asm.mixin.injection.At; 14 | import org.spongepowered.asm.mixin.injection.Inject; 15 | import org.spongepowered.asm.mixin.injection.Redirect; 16 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 17 | 18 | @Mixin(OptionsScreen.class) 19 | public class OptionsScreenM extends Screen { 20 | 21 | @Shadow @Final private Screen lastScreen; 22 | 23 | @Shadow @Final private Options options; 24 | 25 | protected OptionsScreenM(Component title) { 26 | super(title); 27 | } 28 | 29 | @Inject(method = "method_19828", at = @At("HEAD"), cancellable = true) 30 | private void injectVideoOptionScreen(Button button, CallbackInfo ci) { 31 | // this.minecraft.setScreen(new VideoSettingsScreen(this, this.options)); 32 | this.minecraft.setScreen(new OptionScreenV(Component.literal("Video Setting"), this)); 33 | ci.cancel(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/texture/MFontTexture.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.texture; 2 | 3 | import com.mojang.blaze3d.platform.NativeImage; 4 | import net.minecraft.client.gui.font.FontTexture; 5 | import net.vulkanmod.interfaces.VAbstractTextureI; 6 | import net.vulkanmod.vulkan.texture.VulkanImage; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Redirect; 10 | 11 | @Mixin(FontTexture.class) 12 | public class MFontTexture { 13 | 14 | @Redirect(method = "", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/TextureUtil;prepareImage(Lcom/mojang/blaze3d/platform/NativeImage$InternalGlFormat;III)V")) 15 | private void redirect(NativeImage.InternalGlFormat internalFormat, int id, int width, int height) { 16 | //this.vulkanImage = new VulkanImage(1, 256, 256, 4, false, false); 17 | ((VAbstractTextureI)(this)).setVulkanImage(new VulkanImage(1, 256, 256, 4, false, false)); 18 | //((VAbstractTextureI)(this)).bind(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/texture/MLightMap.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.texture; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import net.minecraft.client.renderer.LightTexture; 5 | import net.minecraft.client.renderer.texture.DynamicTexture; 6 | import net.vulkanmod.interfaces.VAbstractTextureI; 7 | import net.vulkanmod.vulkan.texture.VTextureSelector; 8 | import org.spongepowered.asm.mixin.Final; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.Overwrite; 11 | import org.spongepowered.asm.mixin.Shadow; 12 | 13 | @Mixin(LightTexture.class) 14 | public class MLightMap { 15 | 16 | @Shadow @Final private DynamicTexture lightTexture; 17 | 18 | /** 19 | * @author 20 | */ 21 | @Overwrite 22 | public void turnOnLightLayer() { 23 | // RenderSystem.setShaderTexture(2, this.textureIdentifier); 24 | // this.client.getTextureManager().bindTexture(this.textureIdentifier); 25 | // RenderSystem.texParameter(3553, 10241, 9729); 26 | // RenderSystem.texParameter(3553, 10240, 9729); 27 | VTextureSelector.setLightTexture(((VAbstractTextureI)this.lightTexture).getVulkanImage()); 28 | RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/texture/MOverlayTexture.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.texture; 2 | 3 | import net.minecraft.client.renderer.texture.DynamicTexture; 4 | import net.minecraft.client.renderer.texture.OverlayTexture; 5 | import net.vulkanmod.interfaces.VAbstractTextureI; 6 | import net.vulkanmod.vulkan.texture.VTextureSelector; 7 | import org.spongepowered.asm.mixin.Final; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Shadow; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.Redirect; 13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 14 | 15 | @Mixin(OverlayTexture.class) 16 | public class MOverlayTexture { 17 | 18 | @Shadow @Final private DynamicTexture texture; 19 | 20 | @Redirect(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/texture/DynamicTexture;bind()V")) 21 | private void overlay(DynamicTexture instance) { 22 | VTextureSelector.setOverlayTexture(((VAbstractTextureI)this.texture).getVulkanImage()); 23 | VTextureSelector.setActiveTexture(2); 24 | } 25 | 26 | @Inject(method = "", at = @At(value = "RETURN", target = "Lnet/minecraft/client/texture/NativeImageBackedTexture;bindTexture()V")) 27 | private void overlay(CallbackInfo ci) { 28 | VTextureSelector.setActiveTexture(0); 29 | } 30 | 31 | @Inject(method = "setupOverlayColor", at = @At(value = "HEAD"), cancellable = true) 32 | private void setupOverlay(CallbackInfo ci) { 33 | VTextureSelector.setOverlayTexture(((VAbstractTextureI)this.texture).getVulkanImage()); 34 | ci.cancel(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/texture/MPlayerSkinTexture.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.texture; 2 | 3 | import com.mojang.blaze3d.platform.NativeImage; 4 | import net.minecraft.client.renderer.texture.HttpTexture; 5 | import net.vulkanmod.interfaces.VAbstractTextureI; 6 | import net.vulkanmod.vulkan.texture.VulkanImage; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Overwrite; 9 | 10 | @Mixin(HttpTexture.class) 11 | public class MPlayerSkinTexture { 12 | 13 | /** 14 | * @author 15 | */ 16 | @Overwrite 17 | private void upload(NativeImage image) { 18 | ((VAbstractTextureI)this).setVulkanImage(new VulkanImage(image.getWidth(), image.getHeight())); 19 | ((VAbstractTextureI)this).bindTexture(); 20 | image.upload(0, 0, 0, true); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/texture/MSimpleTexture.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.texture; 2 | 3 | import com.mojang.blaze3d.platform.NativeImage; 4 | import net.minecraft.client.renderer.texture.SimpleTexture; 5 | import net.vulkanmod.interfaces.VAbstractTextureI; 6 | import net.vulkanmod.vulkan.texture.VulkanImage; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Overwrite; 9 | 10 | @Mixin(SimpleTexture.class) 11 | public class MSimpleTexture { 12 | 13 | 14 | 15 | /** 16 | * @author 17 | */ 18 | @Overwrite 19 | private void doLoad(NativeImage nativeImage, boolean blur, boolean clamp) { 20 | ((VAbstractTextureI)this).setVulkanImage(new VulkanImage(1, nativeImage.getWidth(), nativeImage.getHeight(), nativeImage.format().components(), blur, clamp)); 21 | ((VAbstractTextureI)this).bindTexture(); 22 | nativeImage.upload(0, 0, 0, 0, 0, nativeImage.getWidth(), nativeImage.getHeight(), blur, clamp, false, true); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/texture/MSpriteAtlasTexture.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.texture; 2 | 3 | import net.minecraft.client.renderer.texture.TextureAtlas; 4 | import net.vulkanmod.interfaces.VAbstractTextureI; 5 | import net.vulkanmod.vulkan.texture.VulkanImage; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.Overwrite; 8 | import org.spongepowered.asm.mixin.injection.At; 9 | import org.spongepowered.asm.mixin.injection.Redirect; 10 | 11 | @Mixin(TextureAtlas.class) 12 | public class MSpriteAtlasTexture { 13 | 14 | private VulkanImage vulkanImage; 15 | 16 | @Redirect(method = "reload", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/TextureUtil;prepareImage(IIII)V")) 17 | private void redirect(int id, int maxLevel, int width, int height) { 18 | //this.vulkanImage = new VulkanImage(1, 256, 256, 4, false, false); 19 | ((VAbstractTextureI)(this)).setVulkanImage(new VulkanImage(maxLevel + 1, width, height)); 20 | ((VAbstractTextureI)(this)).bindTexture(); 21 | } 22 | 23 | /** 24 | * @author 25 | */ 26 | @Overwrite 27 | public void updateFilter(TextureAtlas.Preparations data) { 28 | //this.setFilter(false, data.maxLevel > 0); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/texture/MTextureManager.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.texture; 2 | 3 | import net.minecraft.client.renderer.texture.AbstractTexture; 4 | import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite; 5 | import net.minecraft.client.renderer.texture.TextureManager; 6 | import net.minecraft.client.renderer.texture.Tickable; 7 | import net.minecraft.resources.ResourceLocation; 8 | import net.vulkanmod.vulkan.Drawer; 9 | import net.vulkanmod.vulkan.TransferQueue; 10 | import org.spongepowered.asm.mixin.Final; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.Overwrite; 13 | import org.spongepowered.asm.mixin.Shadow; 14 | 15 | import java.util.Set; 16 | 17 | @Mixin(TextureManager.class) 18 | public abstract class MTextureManager { 19 | 20 | 21 | @Shadow @Final private Set tickableTextures; 22 | 23 | 24 | @Shadow public abstract AbstractTexture getTexture(ResourceLocation resourceLocation, AbstractTexture abstractTexture); 25 | 26 | /** 27 | * @author 28 | */ 29 | @Overwrite 30 | public void tick() { 31 | if(Drawer.skipRendering) return; 32 | TransferQueue.startRecording(); 33 | for (Tickable tickable : this.tickableTextures) { 34 | tickable.tick(); 35 | } 36 | TransferQueue.endRecording(); 37 | } 38 | 39 | /** 40 | * @author 41 | */ 42 | @Overwrite 43 | public void release(ResourceLocation id) { 44 | AbstractTexture abstractTexture = this.getTexture(id, MissingTextureAtlasSprite.getTexture()); 45 | if (abstractTexture != MissingTextureAtlasSprite.getTexture()) { 46 | //TODO: delete 47 | abstractTexture.releaseId(); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/texture/MTextureUtil.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.texture; 2 | 3 | import com.mojang.blaze3d.platform.GlStateManager; 4 | import com.mojang.blaze3d.platform.TextureUtil; 5 | import com.mojang.blaze3d.systems.RenderSystem; 6 | import net.minecraft.SharedConstants; 7 | import org.spongepowered.asm.mixin.Mixin; 8 | import org.spongepowered.asm.mixin.Overwrite; 9 | 10 | import java.nio.IntBuffer; 11 | import java.util.concurrent.ThreadLocalRandom; 12 | 13 | @Mixin(TextureUtil.class) 14 | public class MTextureUtil { 15 | 16 | /** 17 | * @author 18 | */ 19 | @Overwrite(remap = false) 20 | public static void initTexture(IntBuffer imageData, int width, int height) {} 21 | 22 | /** 23 | * @author 24 | */ 25 | @Overwrite(remap = false) 26 | public static int generateTextureId() { return -1; } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/util/ScreenshotRecorderM.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.util; 2 | 3 | import com.mojang.blaze3d.pipeline.RenderTarget; 4 | import com.mojang.blaze3d.platform.NativeImage; 5 | import net.minecraft.client.Screenshot; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.Overwrite; 8 | 9 | @Mixin(Screenshot.class) 10 | public class ScreenshotRecorderM { 11 | 12 | /** 13 | * @author 14 | */ 15 | @Overwrite 16 | public static NativeImage takeScreenshot(RenderTarget framebuffer) { 17 | int i = framebuffer.width; 18 | int j = framebuffer.height; 19 | 20 | NativeImage nativeimage = new NativeImage(i, j, false); 21 | //RenderSystem.bindTexture(p_92282_.getColorTextureId()); 22 | nativeimage.downloadTexture(0, true); 23 | //nativeimage.flipY(); 24 | return nativeimage; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/mixin/vertex/SpriteCoordinateExpanderM.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.mixin.vertex; 2 | 3 | import com.mojang.blaze3d.vertex.VertexConsumer; 4 | import net.minecraft.client.renderer.SpriteCoordinateExpander; 5 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; 6 | import net.vulkanmod.interfaces.ExtendedVertexBuilder; 7 | import org.spongepowered.asm.mixin.Final; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.Shadow; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | 14 | //TODO move 15 | @Mixin(SpriteCoordinateExpander.class) 16 | public class SpriteCoordinateExpanderM implements ExtendedVertexBuilder { 17 | 18 | @Shadow @Final private VertexConsumer delegate; 19 | 20 | @Shadow @Final private TextureAtlasSprite sprite; 21 | private ExtendedVertexBuilder extDelegate; 22 | 23 | @Inject(method = "", at = @At("RETURN")) 24 | private void getExtBuilder(VertexConsumer vertexConsumer, TextureAtlasSprite textureAtlasSprite, CallbackInfo ci) { 25 | this.extDelegate = (ExtendedVertexBuilder) vertexConsumer; 26 | } 27 | 28 | @Override 29 | public void vertex(float x, float y, float z, int packedColor, float u, float v, int overlay, int light, int packedNormal) { 30 | this.extDelegate.vertex(x, y, z, packedColor, this.sprite.getU(u * 16.0F), this.sprite.getV(v * 16.0F), overlay, light, packedNormal); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/render/chunk/ChunkRenderer.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.render.chunk; 2 | 3 | import net.minecraft.client.renderer.ChunkBufferBuilderPack; 4 | import net.minecraft.client.renderer.chunk.RenderRegionCache; 5 | 6 | import java.util.Queue; 7 | import java.util.concurrent.ConcurrentLinkedQueue; 8 | 9 | public class ChunkRenderer { 10 | 11 | private final static int threadCount = 4; 12 | private Thread[] threads; 13 | private Queue tasks = new ConcurrentLinkedQueue<>(); 14 | 15 | 16 | 17 | static class BuilderThread extends Thread { 18 | 19 | ChunkBufferBuilderPack buffers = new ChunkBufferBuilderPack(); 20 | RenderRegionCache cache = new RenderRegionCache(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/render/chunk/util/ChunkQueue.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.render.chunk.util; 2 | 3 | import net.vulkanmod.render.chunk.WorldRenderer; 4 | 5 | public class ChunkQueue { 6 | WorldRenderer.QueueChunkInfo[] queue; 7 | int position = 0; 8 | int limit = 0; 9 | int capacity; 10 | 11 | public ChunkQueue() { 12 | this.capacity = 1024; 13 | 14 | this.queue = new WorldRenderer.QueueChunkInfo[this.capacity]; 15 | } 16 | 17 | public boolean hasNext() { 18 | return this.position < this.limit; 19 | } 20 | 21 | public WorldRenderer.QueueChunkInfo poll() { 22 | WorldRenderer.QueueChunkInfo chunk = this.queue[position]; 23 | this.position++; 24 | 25 | return chunk; 26 | } 27 | 28 | public void add(WorldRenderer.QueueChunkInfo chunk) { 29 | if(chunk == null) 30 | return; 31 | 32 | if(limit == capacity) resize(); 33 | this.queue[limit] = chunk; 34 | 35 | this.limit++; 36 | } 37 | 38 | private void resize() { 39 | this.capacity *= 2; 40 | 41 | WorldRenderer.QueueChunkInfo[] oldQueue = this.queue; 42 | this.queue = new WorldRenderer.QueueChunkInfo[this.capacity]; 43 | 44 | System.arraycopy(oldQueue, 0, this.queue, 0, oldQueue.length); 45 | } 46 | 47 | public void clear() { 48 | this.position = 0; 49 | this.limit = 0; 50 | } 51 | 52 | //debug 53 | public void resetPosition() { 54 | this.position = 0; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/render/chunk/util/Util.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.render.chunk.util; 2 | 3 | import net.minecraft.core.Direction; 4 | import org.joml.Matrix3f; 5 | import org.joml.Matrix4f; 6 | import org.lwjgl.system.MemoryStack; 7 | 8 | import java.nio.FloatBuffer; 9 | 10 | public class Util { 11 | 12 | public static final Direction[] DIRECTIONS = Direction.values(); 13 | public static final Direction[] XZ_DIRECTIONS = getXzDirections(); 14 | 15 | private static Direction[] getXzDirections() { 16 | Direction[] directions = new Direction[4]; 17 | 18 | int i = 0; 19 | for(Direction direction : Direction.values()) { 20 | if(direction.getAxis() == Direction.Axis.X || direction.getAxis() == Direction.Axis.Z) { 21 | directions[i] = direction; 22 | ++i; 23 | } 24 | } 25 | return directions; 26 | } 27 | 28 | public static Matrix4f convertMatrix(com.mojang.math.Matrix4f in) { 29 | Matrix4f out; 30 | 31 | try(MemoryStack stack = MemoryStack.stackPush()) { 32 | FloatBuffer fb = stack.mallocFloat(16); 33 | in.store(fb); 34 | out = new Matrix4f(fb); 35 | } 36 | return out; 37 | } 38 | 39 | public static Matrix3f convertMatrix(com.mojang.math.Matrix3f in) { 40 | Matrix3f out; 41 | 42 | try(MemoryStack stack = MemoryStack.stackPush()) { 43 | FloatBuffer fb = stack.mallocFloat(9); 44 | in.store(fb); 45 | out = new Matrix3f(fb); 46 | } 47 | return out; 48 | } 49 | 50 | public static long posLongHash(int x, int y, int z) { 51 | return (long)x & 0x00000000FFFFL | ((long) z << 16) & 0x0000FFFF0000L | ((long) y << 32) & 0xFFFF00000000L; 52 | } 53 | 54 | public static int flooredLog(int v) { 55 | assert v > 0; 56 | int log = 30; 57 | int t = 0x40000000; 58 | 59 | while((v & t) == 0) { 60 | t >>= 1; 61 | log--; 62 | } 63 | 64 | return log; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/render/vertex/VertexUtil.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.render.vertex; 2 | 3 | public class VertexUtil { 4 | 5 | private static final float NORM_INV = 1.0f / 127.0f; 6 | 7 | public static int packColor(float r, float g, float b, float a) { 8 | r *= 255.0f; 9 | g *= 255.0f; 10 | b *= 255.0f; 11 | a *= 255.0f; 12 | 13 | return ((int)r & 0xFF) | ((int)g & 0xFF) << 8 | ((int)b & 0xFF) << 16 | ((int)a & 0xFF) << 24; 14 | } 15 | 16 | public static int packNormal(float x, float y, float z) { 17 | x *= 127.0f; 18 | y *= 127.0f; 19 | z *= 127.0f; 20 | 21 | return ((int)x & 0xFF) | ((int)y & 0xFF) << 8| ((int)z & 0xFF) << 16; 22 | } 23 | 24 | public static float unpackN1(int i) { 25 | return (byte)(i & 0xFF) * NORM_INV; 26 | } 27 | 28 | public static float unpackN2(int i) { 29 | return (byte)((i >> 8) & 0xFF) * NORM_INV; 30 | } 31 | 32 | public static float unpackN3(int i) { 33 | return (byte)((i >> 16) & 0xFF) * NORM_INV; 34 | } 35 | 36 | public record GenericVertex(float x, float y, float z, int packedColor, float u, float v, int overlay, int light, int packedNormal){} 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/vulkan/Synchronization.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.vulkan; 2 | 3 | import net.vulkanmod.vulkan.util.VUtil; 4 | import org.lwjgl.PointerBuffer; 5 | import org.lwjgl.system.MemoryUtil; 6 | import org.lwjgl.vulkan.VkDevice; 7 | 8 | import java.nio.LongBuffer; 9 | 10 | import static org.lwjgl.vulkan.VK10.*; 11 | 12 | public class Synchronization { 13 | private static final int allocSize = 20000; 14 | private static final LongBuffer fences = MemoryUtil.memAllocLong(allocSize); 15 | private static int idx = 0; 16 | 17 | public synchronized static void addFence(long fence) { 18 | fences.put(idx, fence); 19 | idx++; 20 | } 21 | 22 | public synchronized static void waitFences() { 23 | // TransferQueue.resetCurrent(); 24 | 25 | if(idx == 0) return; 26 | 27 | VkDevice device = Vulkan.getDevice(); 28 | 29 | fences.limit(idx); 30 | 31 | int count = 50; 32 | long[] longs = new long[count]; 33 | int i; 34 | for (i = 0; i + count - 1 < idx; i += count) { 35 | fences.position(i); 36 | fences.get(longs, 0, count); 37 | vkWaitForFences(device, longs, true, VUtil.UINT64_MAX); 38 | } 39 | if(idx - i > 0) { 40 | longs = new long[idx - i]; 41 | fences.position(i); 42 | fences.get(longs, 0, idx - i); 43 | vkWaitForFences(device, longs, true, VUtil.UINT64_MAX); 44 | } 45 | 46 | // Profiler profiler = new Profiler("sync"); 47 | // profiler.start(); 48 | // vkWaitForFences(device, fences, true, VUtil.UINT64_MAX); 49 | // profiler.push("wait"); 50 | // vkResetCommandPool(device, commandPool, 0); 51 | // profiler.push("free"); 52 | 53 | // profiler.push("end"); 54 | // profiler.end(); 55 | 56 | TransferQueue.resetCurrent(); 57 | 58 | fences.limit(allocSize); 59 | idx = 0; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/vulkan/memory/Buffer.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.vulkan.memory; 2 | 3 | import org.lwjgl.PointerBuffer; 4 | 5 | public abstract class Buffer { 6 | protected long id; 7 | protected long allocation; 8 | 9 | protected int bufferSize; 10 | protected int usedBytes; 11 | protected int offset; 12 | 13 | protected MemoryType type; 14 | protected int usage; 15 | protected PointerBuffer data; 16 | 17 | protected Buffer(int usage, MemoryType type) { 18 | //TODO: check usage 19 | this.usage = usage; 20 | this.type = type; 21 | 22 | } 23 | 24 | protected void createBuffer(int bufferSize) { 25 | this.type.createBuffer(this, bufferSize); 26 | 27 | if(this.type.mappable()) { 28 | this.data = MemoryManager.getInstance().Map(this.allocation); 29 | } 30 | } 31 | 32 | public void freeBuffer() { 33 | MemoryManager.getInstance().addToFreeable(this); 34 | } 35 | 36 | public void reset() { usedBytes = 0; } 37 | 38 | public long getAllocation() { return allocation; } 39 | 40 | public long getUsedBytes() { return usedBytes; } 41 | 42 | public long getId() {return id; } 43 | 44 | protected void setBufferSize(int size) { this.bufferSize = size; } 45 | 46 | protected void setId(long id) { this.id = id; } 47 | 48 | protected void setAllocation(long allocation) {this.allocation = allocation; } 49 | 50 | public BufferInfo getBufferInfo() { return new BufferInfo(this.id, this.allocation, this.bufferSize, this.type.getType()); } 51 | 52 | public record BufferInfo(long id, long allocation, long bufferSize, MemoryType.Type type) { 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/vulkan/memory/MemoryType.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.vulkan.memory; 2 | 3 | import java.nio.ByteBuffer; 4 | 5 | public abstract class MemoryType { 6 | protected Type type; 7 | 8 | abstract void createBuffer(Buffer buffer, int size); 9 | abstract void copyToBuffer(Buffer buffer, long bufferSize, ByteBuffer byteBuffer); 10 | abstract void copyFromBuffer(Buffer buffer, long bufferSize, ByteBuffer byteBuffer); 11 | 12 | /** 13 | * Replace data from byte 0 14 | */ 15 | abstract void uploadBuffer(Buffer buffer, ByteBuffer byteBuffer); 16 | 17 | abstract boolean mappable(); 18 | 19 | public Type getType() { 20 | return this.type; 21 | } 22 | 23 | public enum Type { 24 | DEVICE_LOCAL, 25 | HOST_LOCAL 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/vulkan/memory/StagingBuffer.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.vulkan.memory; 2 | 3 | import net.vulkanmod.vulkan.util.VUtil; 4 | 5 | import java.nio.ByteBuffer; 6 | 7 | import static org.lwjgl.vulkan.VK10.*; 8 | 9 | public class StagingBuffer extends Buffer { 10 | 11 | public StagingBuffer(int bufferSize) { 12 | super(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, MemoryTypes.HOST_MEM); 13 | this.usedBytes = 0; 14 | this.offset = 0; 15 | 16 | this.createBuffer(bufferSize); 17 | } 18 | 19 | public void copyBuffer(int size, ByteBuffer byteBuffer) { 20 | 21 | if(size > this.bufferSize - this.usedBytes) { 22 | resizeBuffer((this.bufferSize + size) * 2); 23 | } 24 | 25 | VUtil.memcpy(this.data.getByteBuffer(0, this.bufferSize), byteBuffer, this.usedBytes); 26 | 27 | offset = usedBytes; 28 | usedBytes += size; 29 | 30 | //createVertexBuffer(vertexSize, vertexCount, byteBuffer); 31 | } 32 | 33 | private void resizeBuffer(int newSize) { 34 | MemoryManager.getInstance().addToFreeable(this); 35 | this.createBuffer(newSize); 36 | 37 | System.out.println("resized staging buffer to: " + newSize); 38 | } 39 | 40 | public void reset() { 41 | usedBytes = 0; 42 | } 43 | 44 | public long getOffset() { 45 | return offset; 46 | } 47 | 48 | public long getBufferId() { 49 | return id; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/vulkan/shader/layout/Mat4f.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.vulkan.shader.layout; 2 | 3 | import net.vulkanmod.vulkan.VRenderSystem; 4 | import net.vulkanmod.vulkan.util.MappedBuffer; 5 | import org.lwjgl.system.MemoryUtil; 6 | 7 | import java.nio.ByteBuffer; 8 | 9 | public class Mat4f extends Field { 10 | public Mat4f(FieldInfo info, long ptr) { 11 | super(info, ptr); 12 | } 13 | 14 | protected void setSupplier() { 15 | switch (this.fieldInfo.name) { 16 | case "ModelViewMat" -> this.values = VRenderSystem::getModelViewMatrix; 17 | case "ProjMat" -> this.values = VRenderSystem::getProjectionMatrix; 18 | case "MVP" -> this.values = VRenderSystem::getMVP; 19 | case "TextureMat" -> this.values = VRenderSystem::getTextureMatrix; 20 | } 21 | } 22 | 23 | void update() { 24 | MappedBuffer src = values.get(); 25 | 26 | // float[] floats = new float[16]; 27 | // src.asFloatBuffer().get(floats); 28 | 29 | MemoryUtil.memCopy(src.buffer, MemoryUtil.memByteBuffer(this.basePtr, 64)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/vulkan/shader/layout/PushConstants.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.vulkan.shader.layout; 2 | 3 | import java.util.List; 4 | 5 | public class PushConstants extends AlignedStruct { 6 | 7 | protected PushConstants(List infoList, int size) { 8 | super(infoList, size); 9 | } 10 | 11 | public long getAddress() { 12 | return buffer.ptr; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/vulkan/shader/layout/UBO.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.vulkan.shader.layout; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.util.List; 5 | 6 | public class UBO extends AlignedStruct { 7 | private final int binding; 8 | private final int flags; 9 | 10 | protected UBO(int binding, int type, int size, List infoList) { 11 | super(infoList, size); 12 | this.binding = binding; 13 | this.flags = type; 14 | } 15 | 16 | public int getBinding() { 17 | return binding; 18 | } 19 | 20 | public int getFlags() { 21 | return flags; 22 | } 23 | 24 | public ByteBuffer getBuffer() { 25 | return buffer.buffer; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/vulkan/shader/layout/Vec1f.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.vulkan.shader.layout; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import org.lwjgl.system.MemoryUtil; 5 | 6 | import java.util.function.Supplier; 7 | 8 | public class Vec1f extends Field { 9 | private Supplier floatSupplier; 10 | 11 | public Vec1f(FieldInfo fieldInfo, long ptr) { 12 | super(fieldInfo, ptr); 13 | } 14 | 15 | void setSupplier() { 16 | switch (this.fieldInfo.name) { 17 | case "FogStart" -> this.floatSupplier = RenderSystem::getShaderFogStart; 18 | case "FogEnd" -> this.floatSupplier = RenderSystem::getShaderFogEnd; 19 | case "LineWidth" -> this.floatSupplier = RenderSystem::getShaderLineWidth; 20 | case "GameTime" -> this.floatSupplier = RenderSystem::getShaderGameTime; 21 | } 22 | } 23 | 24 | void update() { 25 | float f = this.floatSupplier.get(); 26 | MemoryUtil.memPutFloat(this.basePtr, f); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/vulkan/shader/layout/Vec1i.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.vulkan.shader.layout; 2 | 3 | import org.lwjgl.system.MemoryUtil; 4 | 5 | import java.util.function.Supplier; 6 | 7 | public class Vec1i extends Field { 8 | private Supplier intSupplier; 9 | 10 | public Vec1i(FieldInfo fieldInfo, long ptr) { 11 | super(fieldInfo, ptr); 12 | } 13 | 14 | void setSupplier() { 15 | if (this.fieldInfo.name.equals("EndPortalLayers")) this.intSupplier = () -> 15; 16 | } 17 | 18 | void update() { 19 | int i = this.intSupplier.get(); 20 | MemoryUtil.memPutInt(this.basePtr, i); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/vulkan/shader/layout/Vec2f.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.vulkan.shader.layout; 2 | 3 | import net.vulkanmod.vulkan.VRenderSystem; 4 | import net.vulkanmod.vulkan.util.MappedBuffer; 5 | import org.joml.Vector2f; 6 | import org.lwjgl.system.MemoryUtil; 7 | 8 | public class Vec2f extends Field { 9 | 10 | public Vec2f(FieldInfo fieldInfo, long ptr) { 11 | super(fieldInfo, ptr); 12 | } 13 | 14 | void setSupplier() { 15 | if (this.fieldInfo.name.equals("ScreenSize")) this.values = VRenderSystem::getScreenSize; 16 | } 17 | 18 | void update() { 19 | MappedBuffer buffer = this.values.get(); 20 | 21 | MemoryUtil.memPutFloat(this.basePtr, buffer.getFloat(0)); 22 | MemoryUtil.memPutFloat(this.basePtr + 4, buffer.getFloat(4)); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/vulkan/shader/layout/Vec3f.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.vulkan.shader.layout; 2 | 3 | import net.vulkanmod.vulkan.VRenderSystem; 4 | import net.vulkanmod.vulkan.util.MappedBuffer; 5 | import net.vulkanmod.vulkan.util.VUtil; 6 | 7 | public class Vec3f extends Field { 8 | 9 | public Vec3f(FieldInfo fieldInfo, long ptr) { 10 | super(fieldInfo, ptr); 11 | } 12 | 13 | void setSupplier() { 14 | switch (this.fieldInfo.name) { 15 | case "Light0_Direction" -> this.values = () -> VRenderSystem.lightDirection0; 16 | case "Light1_Direction" -> this.values = () -> VRenderSystem.lightDirection1; 17 | case "ChunkOffset" -> this.values = () -> VRenderSystem.ChunkOffset; 18 | } 19 | } 20 | 21 | void update() { 22 | MappedBuffer src = this.values.get(); 23 | 24 | VUtil.UNSAFE.putFloat(this.basePtr, VUtil.UNSAFE.getFloat(src.ptr)); 25 | VUtil.UNSAFE.putFloat(this.basePtr + 4, VUtil.UNSAFE.getFloat(src.ptr + 4)); 26 | VUtil.UNSAFE.putFloat(this.basePtr + 8, VUtil.UNSAFE.getFloat(src.ptr + 8)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/vulkan/shader/layout/Vec4f.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.vulkan.shader.layout; 2 | 3 | import com.mojang.blaze3d.systems.RenderSystem; 4 | import net.vulkanmod.vulkan.VRenderSystem; 5 | import net.vulkanmod.vulkan.util.MappedBuffer; 6 | import org.lwjgl.system.MemoryUtil; 7 | 8 | public class Vec4f extends Field { 9 | 10 | public Vec4f(FieldInfo fieldInfo, long ptr) { 11 | super(fieldInfo, ptr); 12 | } 13 | 14 | void setSupplier() { 15 | 16 | if (this.fieldInfo.name.equals("ColorModulator")) this.values = VRenderSystem::getShaderColor; 17 | else if (this.fieldInfo.name.equals("FogColor")) this.values = VRenderSystem::getShaderFogColor; 18 | } 19 | 20 | void update() { 21 | MappedBuffer buffer = this.values.get(); 22 | 23 | MemoryUtil.memPutFloat(this.basePtr, buffer.getFloat(0)); 24 | MemoryUtil.memPutFloat(this.basePtr + 4, buffer.getFloat(4)); 25 | MemoryUtil.memPutFloat(this.basePtr + 8, buffer.getFloat(8)); 26 | MemoryUtil.memPutFloat(this.basePtr + 12, buffer.getFloat(12)); 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/vulkan/util/MappedBuffer.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.vulkan.util; 2 | 3 | import org.lwjgl.system.MemoryUtil; 4 | 5 | import java.nio.ByteBuffer; 6 | 7 | public class MappedBuffer { 8 | 9 | public final ByteBuffer buffer; 10 | public final long ptr; 11 | 12 | public static MappedBuffer createFromBuffer(ByteBuffer buffer) { 13 | return new MappedBuffer(buffer, MemoryUtil.memAddress0(buffer)); 14 | } 15 | MappedBuffer(ByteBuffer buffer, long ptr) { 16 | this.buffer = buffer; 17 | this.ptr = ptr; 18 | } 19 | 20 | public MappedBuffer(int size) { 21 | this.buffer = MemoryUtil.memAlloc(size); 22 | this.ptr = MemoryUtil.memAddress0(this.buffer); 23 | } 24 | 25 | public void putFloat(int idx, float f) { 26 | VUtil.UNSAFE.putFloat(ptr + idx, f); 27 | } 28 | 29 | public void putInt(int idx, int f) { 30 | VUtil.UNSAFE.putInt(ptr + idx, f); 31 | } 32 | 33 | public float getFloat(int idx) { 34 | return VUtil.UNSAFE.getFloat(ptr + idx); 35 | } 36 | 37 | public int getInt(int idx) { 38 | return VUtil.UNSAFE.getInt(ptr + idx); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/net/vulkanmod/vulkan/util/Pair.java: -------------------------------------------------------------------------------- 1 | package net.vulkanmod.vulkan.util; 2 | 3 | public class Pair { 4 | public A first; 5 | public B second; 6 | 7 | public Pair(A a, B b) { 8 | this.first = a; 9 | this.second = b; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/Vlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PojavLauncherTeam/VulkanMod/3f2b48e514f4e3335fe9d0d8a5a3f78f6c4eea72/src/main/resources/assets/vulkanmod/Vlogo.png -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/blit_screen.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(binding = 2) uniform sampler2D DiffuseSampler; 4 | 5 | layout(binding = 1) uniform UBO{ 6 | vec4 ColorModulator; 7 | }; 8 | 9 | layout(location = 0) in vec2 texCoord; 10 | layout(location = 1) in vec4 vertexColor; 11 | 12 | layout(location = 0) out vec4 fragColor; 13 | 14 | void main() { 15 | vec4 color = texture(DiffuseSampler, texCoord) * vertexColor; 16 | 17 | // blit final output of compositor into displayed back buffer 18 | fragColor = color * ColorModulator; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/blit_screen.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "blit_screen", 8 | "fragment": "blit_screen", 9 | "attributes": [ 10 | "Position", 11 | "UV", 12 | "Color" 13 | ], 14 | "samplers": [ 15 | { "name": "DiffuseSampler" } 16 | ], 17 | "uniforms": [ 18 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 19 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 20 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 21 | ], 22 | "UBOs": [ 23 | { "type": "vertex", "binding": 0, "fields": [ 24 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 25 | ] }, 26 | { "type": "fragment", "binding": 1, "fields": [ 27 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 28 | ] } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/blit_screen.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec2 UV; 5 | layout(location = 2) in vec4 Color; 6 | 7 | layout(binding = 0) uniform UniformBufferObject { 8 | mat4 MVP; 9 | }; 10 | 11 | layout(location = 0) out vec2 texCoord; 12 | layout(location = 1) out vec4 vertexColor; 13 | 14 | void main() { 15 | gl_Position = MVP * vec4(Position, 1.0); 16 | 17 | texCoord = UV; 18 | vertexColor = Color; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/particle.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 2) uniform sampler2D Sampler0; 13 | 14 | layout(binding = 1) uniform UBO{ 15 | vec4 ColorModulator; 16 | vec4 FogColor; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in vec4 vertexColor; 22 | layout(location = 1) in vec2 texCoord0; 23 | layout(location = 2) in float vertexDistance; 24 | 25 | layout(location = 0) out vec4 fragColor; 26 | 27 | void main() { 28 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 29 | if (color.a < 0.1) { 30 | discard; 31 | } 32 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 33 | } 34 | 35 | /* 36 | #version 150 37 | 38 | #moj_import 39 | 40 | uniform sampler2D Sampler0; 41 | 42 | uniform vec4 ColorModulator; 43 | uniform float FogStart; 44 | uniform float FogEnd; 45 | uniform vec4 FogColor; 46 | 47 | in float vertexDistance; 48 | in vec2 texCoord0; 49 | in vec4 vertexColor; 50 | 51 | out vec4 fragColor; 52 | 53 | void main() { 54 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 55 | if (color.a < 0.1) { 56 | discard; 57 | } 58 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 59 | } 60 | */ 61 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/particle.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "particle", 8 | "fragment": "particle", 9 | "attributes": [ 10 | "Position", 11 | "UV0", 12 | "Color", 13 | "UV2" 14 | ], 15 | "samplers": [ 16 | { "name": "Sampler0" }, 17 | { "name": "Sampler2" } 18 | ], 19 | "uniforms": [ 20 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 21 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 22 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 23 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 24 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] }, 25 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] } 26 | ], 27 | "UBOs": [ 28 | { "type": "vertex", "binding": 0, "fields": [ 29 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 30 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 31 | ] }, 32 | { "type": "fragment", "binding": 1, "fields": [ 33 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 34 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] }, 35 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 36 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] } 37 | ] } 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/particle.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec2 UV0; 5 | layout(location = 2) in vec4 Color; 6 | layout(location = 3) in ivec2 UV2; 7 | 8 | layout(binding = 0) uniform UniformBufferObject { 9 | mat4 MVP; 10 | mat4 ModelViewMat; 11 | }; 12 | 13 | layout(binding = 3) uniform sampler2D Sampler2; 14 | 15 | layout(location = 0) out vec4 vertexColor; 16 | layout(location = 1) out vec2 texCoord0; 17 | layout(location = 2) out float vertexDistance; 18 | 19 | void main() { 20 | gl_Position = MVP * vec4(Position, 1.0); 21 | 22 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 23 | texCoord0 = UV0; 24 | vertexColor = Color * texelFetch(Sampler2, UV2 / 16, 0); 25 | } 26 | 27 | /* 28 | #version 150 29 | 30 | in vec3 Position; 31 | in vec2 UV0; 32 | in vec4 Color; 33 | in ivec2 UV2; 34 | 35 | uniform sampler2D Sampler2; 36 | 37 | uniform mat4 ModelViewMat; 38 | uniform mat4 ProjMat; 39 | 40 | out float vertexDistance; 41 | out vec2 texCoord0; 42 | out vec4 vertexColor; 43 | */ 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 1) uniform UBO{ 13 | vec4 ColorModulator; 14 | vec4 FogColor; 15 | float FogStart; 16 | float FogEnd; 17 | }; 18 | 19 | layout(location = 0) in float vertexDistance; 20 | 21 | layout(location = 0) out vec4 fragColor; 22 | 23 | void main() { 24 | fragColor = linear_fog(ColorModulator, vertexDistance, FogStart, FogEnd, FogColor); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "position", 8 | "fragment": "position", 9 | "attributes": [ 10 | ], 11 | "samplers": [ 12 | ], 13 | "uniforms": [ 14 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 15 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 16 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 17 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 18 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] }, 19 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] } 20 | ], 21 | "UBOs": [ 22 | { "type": "vertex", "binding": 0, "fields": [ 23 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 24 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 25 | ] }, 26 | { "type": "fragment", "binding": 1, "fields": [ 27 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 28 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] }, 29 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 30 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] } 31 | ] } 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | 5 | layout(binding = 0) uniform UniformBufferObject { 6 | mat4 MVP; 7 | mat4 ModelViewMat; 8 | }; 9 | 10 | layout(location = 0) out float vertexDistance; 11 | 12 | void main() { 13 | gl_Position = MVP * vec4(Position, 1.0); 14 | 15 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_color.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec4 vertexColor; 4 | 5 | layout(binding = 1) uniform UBO{ 6 | vec4 ColorModulator; 7 | }; 8 | 9 | layout(location = 0) out vec4 fragColor; 10 | 11 | void main() { 12 | vec4 color = vertexColor; 13 | if (color.a == 0.0) { 14 | discard; 15 | } 16 | fragColor = color * ColorModulator; 17 | fragColor = color; 18 | } 19 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_color.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "position_color", 8 | "fragment": "position_color", 9 | "attributes": [ 10 | "Color" 11 | ], 12 | "samplers": [ 13 | ], 14 | "uniforms": [ 15 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 16 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 17 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 18 | ], 19 | "UBOs": [ 20 | { "type": "vertex", "binding": 0, "fields": [ 21 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 22 | ] }, 23 | { "type": "fragment", "binding": 1, "fields": [ 24 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 25 | ] } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_color.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec4 Color; 5 | 6 | layout(binding = 0) uniform UniformBufferObject { 7 | mat4 MVP; 8 | }; 9 | 10 | layout(location = 0) out vec4 vertexColor; 11 | 12 | void main() { 13 | gl_Position = MVP * vec4(Position, 1.0); 14 | 15 | vertexColor = Color; 16 | } 17 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_color_lightmap.fsh: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D Sampler2; 4 | 5 | uniform vec4 ColorModulator; 6 | 7 | in vec4 vertexColor; 8 | in vec2 texCoord2; 9 | 10 | out vec4 fragColor; 11 | 12 | void main() { 13 | vec4 color = texture(Sampler2, texCoord2) * vertexColor; 14 | fragColor = color * ColorModulator; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_color_lightmap.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "position_color_lightmap", 8 | "fragment": "position_color_lightmap", 9 | "attributes": [ 10 | "Position", 11 | "Color", 12 | "UV2" 13 | ], 14 | "samplers": [ 15 | { "name": "Sampler2" } 16 | ], 17 | "uniforms": [ 18 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 19 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 20 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 21 | ], 22 | "UBOs": [ 23 | { "type": "vertex", "binding": 0, "fields": [ 24 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 25 | ] }, 26 | { "type": "fragment", "binding": 1, "fields": [ 27 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 28 | ] } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_color_lightmap.vsh: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec3 Position; 4 | in vec4 Color; 5 | in vec2 UV2; 6 | 7 | uniform mat4 ModelViewMat; 8 | uniform mat4 ProjMat; 9 | 10 | out vec4 vertexColor; 11 | out vec2 texCoord2; 12 | 13 | void main() { 14 | gl_Position = MVP * vec4(Position, 1.0); 15 | 16 | vertexColor = Color; 17 | texCoord2 = UV2; 18 | } 19 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_color_normal.fsh: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | #moj_import 4 | 5 | uniform vec4 ColorModulator; 6 | uniform float FogStart; 7 | uniform float FogEnd; 8 | uniform vec4 FogColor; 9 | 10 | in float vertexDistance; 11 | in vec4 vertexColor; 12 | in vec4 normal; 13 | 14 | out vec4 fragColor; 15 | 16 | void main() { 17 | vec4 color = vertexColor * ColorModulator; 18 | if (color.a < 0.1) { 19 | discard; 20 | } 21 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_color_normal.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "position_color_normal", 8 | "fragment": "position_color_normal", 9 | "attributes": [ 10 | "Position", 11 | "Color", 12 | "Normal" 13 | ], 14 | "samplers": [ 15 | ], 16 | "uniforms": [ 17 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 18 | { "name": "ModelViewProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 19 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 20 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 21 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] }, 22 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_color_normal.vsh: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec3 Position; 4 | in vec4 Color; 5 | in vec3 Normal; 6 | 7 | uniform mat4 ModelViewMat; 8 | uniform mat4 ModelViewProjMat; 9 | 10 | out float vertexDistance; 11 | out vec4 vertexColor; 12 | out vec4 normal; 13 | 14 | void main() { 15 | gl_Position = ModelViewProjMat * vec4(Position, 1.0); 16 | 17 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 18 | vertexColor = Color; 19 | normal = ModelViewProjMat * vec4(Normal, 0.0); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_color_tex.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(binding = 2) uniform sampler2D Sampler0; 4 | 5 | layout(binding = 1) uniform UBO{ 6 | vec4 ColorModulator; 7 | }; 8 | 9 | layout(location = 0) in vec4 vertexColor; 10 | layout(location = 1) in vec2 texCoord0; 11 | 12 | layout(location = 0) out vec4 fragColor; 13 | 14 | void main() { 15 | vec4 color = texture(Sampler0, texCoord0) * vertexColor; 16 | if (color.a < 0.1) { 17 | discard; 18 | } 19 | fragColor = color * ColorModulator; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_color_tex.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "position_color_tex", 8 | "fragment": "position_color_tex", 9 | "attributes": [ 10 | "Position", 11 | "Color", 12 | "UV0" 13 | ], 14 | "samplers": [ 15 | { "name": "Sampler0" } 16 | ], 17 | "uniforms": [ 18 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 19 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 20 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 21 | ], 22 | "UBOs": [ 23 | { "type": "vertex", "binding": 0, "fields": [ 24 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 25 | ] }, 26 | { "type": "fragment", "binding": 1, "fields": [ 27 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 28 | ] } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_color_tex.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec4 Color; 5 | layout(location = 2) in vec2 UV0; 6 | 7 | layout(binding = 0) uniform UniformBufferObject { 8 | mat4 MVP; 9 | }; 10 | 11 | layout(location = 0) out vec4 vertexColor; 12 | layout(location = 1) out vec2 texCoord0; 13 | 14 | void main() { 15 | gl_Position = MVP * vec4(Position, 1.0); 16 | 17 | vertexColor = Color; 18 | texCoord0 = UV0; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_color_tex_lightmap.fsh: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | uniform sampler2D Sampler0; 4 | 5 | uniform vec4 ColorModulator; 6 | 7 | in vec4 vertexColor; 8 | in vec2 texCoord0; 9 | in vec2 texCoord2; 10 | 11 | out vec4 fragColor; 12 | 13 | void main() { 14 | vec4 color = texture(Sampler0, texCoord0) * vertexColor; 15 | if (color.a < 0.1) { 16 | discard; 17 | } 18 | fragColor = color * ColorModulator; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_color_tex_lightmap.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "position_color_tex_lightmap", 8 | "fragment": "position_color_tex_lightmap", 9 | "attributes": [ 10 | "Position", 11 | "Color", 12 | "UV0", 13 | "UV2" 14 | ], 15 | "samplers": [ 16 | { "name": "Sampler0" } 17 | ], 18 | "uniforms": [ 19 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 20 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 21 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_color_tex_lightmap.vsh: -------------------------------------------------------------------------------- 1 | #version 150 2 | 3 | in vec3 Position; 4 | in vec4 Color; 5 | in vec2 UV0; 6 | in vec2 UV2; 7 | 8 | uniform mat4 ModelViewMat; 9 | uniform mat4 ProjMat; 10 | 11 | out vec4 vertexColor; 12 | out vec2 texCoord0; 13 | out vec2 texCoord2; 14 | 15 | void main() { 16 | gl_Position = MVP * vec4(Position, 1.0); 17 | 18 | vertexColor = Color; 19 | texCoord0 = UV0; 20 | texCoord2 = UV2; 21 | } 22 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_tex.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(binding = 2) uniform sampler2D Sampler0; 4 | 5 | layout(binding = 1) uniform UBO{ 6 | vec4 ColorModulator; 7 | }; 8 | 9 | layout(location = 0) in vec2 texCoord0; 10 | 11 | layout(location = 0) out vec4 fragColor; 12 | 13 | void main() { 14 | vec4 color = texture(Sampler0, texCoord0); 15 | if (color.a == 0.0) { 16 | discard; 17 | } 18 | fragColor = color * ColorModulator; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_tex.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "position_tex", 8 | "fragment": "position_tex", 9 | "attributes": [ 10 | "Position", 11 | "UV0" 12 | ], 13 | "samplers": [ 14 | { "name": "Sampler0" } 15 | ], 16 | "uniforms": [ 17 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 18 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 19 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 20 | ], 21 | "UBOs": [ 22 | { "type": "vertex", "binding": 0, "fields": [ 23 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 24 | ] }, 25 | { "type": "fragment", "binding": 1, "fields": [ 26 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 27 | ] } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_tex.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec2 UV0; 5 | 6 | layout(binding = 0) uniform UniformBufferObject { 7 | mat4 MVP; 8 | }; 9 | 10 | layout(location = 0) out vec2 texCoord0; 11 | 12 | void main() { 13 | gl_Position = MVP * vec4(Position, 1.0); 14 | 15 | texCoord0 = UV0; 16 | } 17 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_tex_color.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(binding = 2) uniform sampler2D Sampler0; 4 | 5 | layout(binding = 1) uniform UBO{ 6 | vec4 ColorModulator; 7 | }; 8 | 9 | layout(location = 0) in vec4 vertexColor; 10 | layout(location = 1) in vec2 texCoord0; 11 | 12 | layout(location = 0) out vec4 fragColor; 13 | 14 | void main() { 15 | vec4 color = texture(Sampler0, texCoord0) * vertexColor; 16 | if (color.a < 0.1) { 17 | discard; 18 | } 19 | fragColor = color * ColorModulator; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_tex_color.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "position_tex_color", 8 | "fragment": "position_tex_color", 9 | "attributes": [ 10 | "Position", 11 | "UV0", 12 | "Color" 13 | ], 14 | "samplers": [ 15 | { "name": "Sampler0" } 16 | ], 17 | "uniforms": [ 18 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 19 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 20 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 21 | ], 22 | "UBOs": [ 23 | { "type": "vertex", "binding": 0, "fields": [ 24 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 25 | ] }, 26 | { "type": "fragment", "binding": 1, "fields": [ 27 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 28 | ] } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_tex_color.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 2) in vec4 Color; 5 | layout(location = 1) in vec2 UV0; 6 | 7 | layout(binding = 0) uniform UniformBufferObject { 8 | mat4 MVP; 9 | }; 10 | 11 | layout(location = 0) out vec4 vertexColor; 12 | layout(location = 1) out vec2 texCoord0; 13 | 14 | void main() { 15 | gl_Position = MVP * vec4(Position, 1.0); 16 | 17 | vertexColor = Color; 18 | texCoord0 = UV0; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_tex_color_normal.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 2) uniform sampler2D Sampler0; 13 | 14 | layout(binding = 1) uniform UBO{ 15 | vec4 ColorModulator; 16 | vec4 FogColor; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in vec4 vertexColor; 22 | layout(location = 1) in vec2 texCoord0; 23 | layout(location = 2) in float vertexDistance; 24 | layout(location = 3) in vec3 normal; 25 | 26 | layout(location = 0) out vec4 fragColor; 27 | 28 | void main() { 29 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 30 | if (color.a < 0.1) { 31 | discard; 32 | } 33 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 34 | } 35 | 36 | /* 37 | #version 150 38 | 39 | #moj_import 40 | 41 | uniform sampler2D Sampler0; 42 | 43 | uniform vec4 ColorModulator; 44 | uniform float FogStart; 45 | uniform float FogEnd; 46 | uniform vec4 FogColor; 47 | 48 | in vec2 texCoord0; 49 | in float vertexDistance; 50 | in vec4 vertexColor; 51 | in vec4 normal; 52 | 53 | out vec4 fragColor; 54 | */ 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_tex_color_normal.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "position_tex_color_normal", 8 | "fragment": "position_tex_color_normal", 9 | "attributes": [ 10 | "Position", 11 | "UV0", 12 | "Color", 13 | "Normal" 14 | ], 15 | "samplers": [ 16 | { "name": "Sampler0" } 17 | ], 18 | "uniforms": [ 19 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 20 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 21 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 22 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 23 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] }, 24 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] } 25 | ], 26 | "UBOs": [ 27 | { "type": "vertex", "binding": 0, "fields": [ 28 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 29 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 30 | ] }, 31 | { "type": "fragment", "binding": 1, "fields": [ 32 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 33 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] }, 34 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 35 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] } 36 | ] } 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/position_tex_color_normal.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec2 UV0; 5 | layout(location = 2) in vec4 Color; 6 | layout(location = 3) in vec3 Normal; 7 | 8 | layout(binding = 0) uniform UniformBufferObject { 9 | mat4 MVP; 10 | mat4 ModelViewMat; 11 | }; 12 | 13 | layout(location = 0) out vec4 vertexColor; 14 | layout(location = 1) out vec2 texCoord0; 15 | layout(location = 2) out float vertexDistance; 16 | layout(location = 3) out vec4 normal; 17 | 18 | void main() { 19 | gl_Position = MVP * vec4(Position, 1.0); 20 | 21 | texCoord0 = UV0; 22 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 23 | vertexColor = Color; 24 | normal = MVP * vec4(Normal, 0.0); 25 | } 26 | 27 | /* 28 | #version 150 29 | 30 | in vec3 Position; 31 | in vec2 UV0; 32 | in vec4 Color; 33 | in vec3 Normal; 34 | 35 | uniform mat4 ModelViewMat; 36 | uniform mat4 ProjMat; 37 | 38 | out vec2 texCoord0; 39 | out float vertexDistance; 40 | out vec4 vertexColor; 41 | out vec4 normal; 42 | */ 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_armor_cutout_no_cull.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 2) uniform sampler2D Sampler0; 13 | 14 | layout(binding = 1) uniform UBO{ 15 | vec4 ColorModulator; 16 | vec4 FogColor; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in vec4 vertexColor; 22 | layout(location = 1) in vec2 texCoord0; 23 | layout(location = 2) in vec2 texCoord1; 24 | layout(location = 3) in vec4 normal; 25 | layout(location = 4) in float vertexDistance; 26 | 27 | layout(location = 0) out vec4 fragColor; 28 | 29 | void main() { 30 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 31 | if (color.a < 0.1) { 32 | discard; 33 | } 34 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 35 | } 36 | 37 | /* 38 | #version 150 39 | 40 | #moj_import 41 | 42 | uniform sampler2D Sampler0; 43 | 44 | uniform vec4 ColorModulator; 45 | uniform float FogStart; 46 | uniform float FogEnd; 47 | uniform vec4 FogColor; 48 | 49 | in float vertexDistance; 50 | in vec4 vertexColor; 51 | in vec2 texCoord0; 52 | in vec2 texCoord1; 53 | in vec4 normal; 54 | 55 | out vec4 fragColor; 56 | */ 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_armor_entity_glint.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | float linear_fog_fade(float vertexDistance, float fogStart, float fogEnd) { 4 | if (vertexDistance <= fogStart) { 5 | return 1.0; 6 | } else if (vertexDistance >= fogEnd) { 7 | return 0.0; 8 | } 9 | 10 | return smoothstep(fogEnd, fogStart, vertexDistance); 11 | } 12 | 13 | layout(binding = 2) uniform sampler2D Sampler0; 14 | 15 | layout(binding = 1) uniform UBO{ 16 | vec4 ColorModulator; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in float vertexDistance; 22 | layout(location = 1) in vec2 texCoord0; 23 | 24 | layout(location = 0) out vec4 fragColor; 25 | 26 | void main() { 27 | vec4 color = texture(Sampler0, texCoord0) * ColorModulator; 28 | if (color.a < 0.1) { 29 | discard; 30 | } 31 | float fade = linear_fog_fade(vertexDistance, FogStart, FogEnd); 32 | fragColor = vec4(color.rgb * fade, color.a); 33 | } 34 | 35 | /* 36 | #version 150 37 | 38 | #moj_import 39 | 40 | uniform sampler2D Sampler0; 41 | 42 | uniform vec4 ColorModulator; 43 | uniform float FogStart; 44 | uniform float FogEnd; 45 | 46 | in float vertexDistance; 47 | in vec2 texCoord0; 48 | 49 | out vec4 fragColor; 50 | */ 51 | 52 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_armor_entity_glint.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec2 UV0; 5 | 6 | layout(binding = 0) uniform UniformBufferObject { 7 | mat4 MVP; 8 | mat4 ModelViewMat; 9 | mat4 TextureMat; 10 | }; 11 | 12 | layout(location = 0) out float vertexDistance; 13 | layout(location = 1) out vec2 texCoord0; 14 | 15 | void main() { 16 | gl_Position = MVP * vec4(Position, 1.0); 17 | 18 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 19 | texCoord0 = (TextureMat * vec4(UV0, 0.0, 1.0)).xy; 20 | } 21 | 22 | /* 23 | #version 150 24 | 25 | in vec3 Position; 26 | in vec2 UV0; 27 | 28 | uniform mat4 ModelViewMat; 29 | uniform mat4 ProjMat; 30 | uniform mat4 TextureMat; 31 | 32 | out float vertexDistance; 33 | out vec2 texCoord0; 34 | 35 | void main() { 36 | gl_Position = MVP * vec4(Position, 1.0); 37 | 38 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 39 | texCoord0 = (TextureMat * vec4(UV0, 0.0, 1.0)).xy; 40 | } 41 | */ 42 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_armor_glint.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | float linear_fog_fade(float vertexDistance, float fogStart, float fogEnd) { 4 | if (vertexDistance <= fogStart) { 5 | return 1.0; 6 | } else if (vertexDistance >= fogEnd) { 7 | return 0.0; 8 | } 9 | 10 | return smoothstep(fogEnd, fogStart, vertexDistance); 11 | } 12 | 13 | layout(binding = 2) uniform sampler2D Sampler0; 14 | 15 | layout(binding = 1) uniform UBO{ 16 | vec4 ColorModulator; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in float vertexDistance; 22 | layout(location = 1) in vec2 texCoord0; 23 | 24 | layout(location = 0) out vec4 fragColor; 25 | 26 | void main() { 27 | vec4 color = texture(Sampler0, texCoord0) * ColorModulator; 28 | if (color.a < 0.1) { 29 | discard; 30 | } 31 | float fade = linear_fog_fade(vertexDistance, FogStart, FogEnd); 32 | fragColor = vec4(color.rgb * fade, color.a); 33 | } 34 | 35 | /* 36 | #version 150 37 | 38 | #moj_import 39 | 40 | uniform sampler2D Sampler0; 41 | 42 | uniform vec4 ColorModulator; 43 | uniform float FogStart; 44 | uniform float FogEnd; 45 | 46 | in float vertexDistance; 47 | in vec2 texCoord0; 48 | 49 | out vec4 fragColor; 50 | 51 | 52 | */ 53 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_armor_glint.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec2 UV0; 5 | 6 | layout(binding = 0) uniform UniformBufferObject { 7 | mat4 MVP; 8 | mat4 ModelViewMat; 9 | mat4 TextureMat; 10 | }; 11 | 12 | layout(location = 0) out float vertexDistance; 13 | layout(location = 1) out vec2 texCoord0; 14 | 15 | void main() { 16 | gl_Position = MVP * vec4(Position, 1.0); 17 | 18 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 19 | texCoord0 = (TextureMat * vec4(UV0, 0.0, 1.0)).xy; 20 | } 21 | 22 | /* 23 | #version 150 24 | 25 | in vec3 Position; 26 | in vec2 UV0; 27 | 28 | uniform mat4 ModelViewMat; 29 | uniform mat4 ProjMat; 30 | uniform mat4 TextureMat; 31 | 32 | out float vertexDistance; 33 | out vec2 texCoord0; 34 | 35 | void main() { 36 | gl_Position = MVP * vec4(Position, 1.0); 37 | 38 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 39 | texCoord0 = (TextureMat * vec4(UV0, 0.0, 1.0)).xy; 40 | } 41 | */ 42 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_beacon_beam.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 0) uniform UniformBufferObject { 13 | mat4 MVP; 14 | mat4 ProjMat; 15 | }; 16 | 17 | layout(binding = 1) uniform UBO{ 18 | vec4 ColorModulator; 19 | vec4 FogColor; 20 | float FogStart; 21 | float FogEnd; 22 | }; 23 | 24 | layout(binding = 2) uniform sampler2D Sampler0; 25 | 26 | layout(location = 0) in vec4 vertexColor; 27 | layout(location = 1) in vec2 texCoord0; 28 | 29 | layout(location = 0) out vec4 fragColor; 30 | 31 | void main() { 32 | vec4 color = texture(Sampler0, texCoord0); 33 | color *= vertexColor * ColorModulator; 34 | float fragmentDistance = -ProjMat[3].z / ((gl_FragCoord.z) * -2.0 + 1.0 - ProjMat[2].z); 35 | fragColor = linear_fog(color, fragmentDistance, FogStart, FogEnd, FogColor); 36 | } 37 | 38 | /* 39 | #version 150 40 | 41 | #moj_import 42 | 43 | uniform sampler2D Sampler0; 44 | 45 | uniform mat4 ProjMat; 46 | uniform vec4 ColorModulator; 47 | uniform float FogStart; 48 | uniform float FogEnd; 49 | uniform vec4 FogColor; 50 | 51 | in vec4 vertexColor; 52 | in vec2 texCoord0; 53 | 54 | out vec4 fragColor; 55 | */ 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_beacon_beam.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "rendertype_beacon_beam", 8 | "fragment": "rendertype_beacon_beam", 9 | "attributes": [ 10 | "Position", 11 | "Color", 12 | "UV0" 13 | ], 14 | "samplers": [ 15 | { "name": "Sampler0" } 16 | ], 17 | "uniforms": [ 18 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 19 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 20 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 21 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 22 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] }, 23 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] } 24 | ], 25 | "UBOs": [ 26 | { "type": "all", "binding": 0, "fields": [ 27 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 28 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 29 | ] }, 30 | { "type": "fragment", "binding": 1, "fields": [ 31 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 32 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] }, 33 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 34 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] } 35 | ] } 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_beacon_beam.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec4 Color; 5 | layout(location = 2) in vec2 UV0; 6 | 7 | layout(binding = 0) uniform UniformBufferObject { 8 | mat4 MVP; 9 | mat4 ProjMat; 10 | }; 11 | 12 | layout(location = 0) out vec4 vertexColor; 13 | layout(location = 1) out vec2 texCoord0; 14 | 15 | void main() { 16 | gl_Position = MVP * vec4(Position, 1.0); 17 | 18 | vertexColor = Color; 19 | texCoord0 = UV0; 20 | } 21 | 22 | /* 23 | #version 150 24 | 25 | in vec3 Position; 26 | in vec4 Color; 27 | in vec2 UV0; 28 | 29 | uniform mat4 ModelViewMat; 30 | uniform mat4 ProjMat; 31 | 32 | out vec4 vertexColor; 33 | out vec2 texCoord0; 34 | */ 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_crumbling.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(binding = 2) uniform sampler2D Sampler0; 4 | 5 | layout(binding = 1) uniform UBO{ 6 | vec4 ColorModulator; 7 | }; 8 | 9 | layout(location = 0) in vec4 vertexColor; 10 | layout(location = 1) in vec2 texCoord0; 11 | layout(location = 2) in vec2 texCoord2; 12 | layout(location = 3) in vec3 normal; 13 | 14 | layout(location = 0) out vec4 fragColor; 15 | 16 | void main() { 17 | vec4 color = texture(Sampler0, texCoord0) * vertexColor; 18 | if (color.a < 0.1) { 19 | discard; 20 | } 21 | fragColor = color * ColorModulator; 22 | } 23 | 24 | /* 25 | #version 150 26 | 27 | uniform sampler2D Sampler0; 28 | 29 | uniform vec4 ColorModulator; 30 | 31 | in vec4 vertexColor; 32 | in vec2 texCoord0; 33 | in vec2 texCoord2; 34 | in vec4 normal; 35 | 36 | out vec4 fragColor; 37 | 38 | void main() { 39 | vec4 color = texture(Sampler0, texCoord0) * vertexColor; 40 | if (color.a < 0.1) { 41 | discard; 42 | } 43 | fragColor = color * ColorModulator; 44 | } 45 | */ 46 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_crumbling.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "rendertype_crumbling", 8 | "fragment": "rendertype_crumbling", 9 | "attributes": [ 10 | "Position", 11 | "Color", 12 | "UV0", 13 | "UV2", 14 | "Normal" 15 | ], 16 | "samplers": [ 17 | { "name": "Sampler0" } 18 | ], 19 | "uniforms": [ 20 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 21 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 22 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 23 | ], 24 | "UBOs": [ 25 | { "type": "vertex", "binding": 0, "fields": [ 26 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 27 | ] }, 28 | { "type": "fragment", "binding": 1, "fields": [ 29 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 30 | ] } 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_crumbling.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec4 Color; 5 | layout(location = 2) in vec2 UV0; 6 | layout(location = 3) in ivec2 UV2; 7 | layout(location = 4) in vec3 Normal; 8 | 9 | layout(binding = 0) uniform UniformBufferObject { 10 | mat4 MVP; 11 | }; 12 | 13 | layout(location = 0) out vec4 vertexColor; 14 | layout(location = 1) out vec2 texCoord0; 15 | layout(location = 2) out vec2 texCoord2; 16 | layout(location = 3) out vec4 normal; 17 | 18 | void main() { 19 | gl_Position = MVP * vec4(Position, 1.0); 20 | 21 | vertexColor = Color; 22 | texCoord0 = UV0; 23 | //texCoord2 = UV2; 24 | normal = MVP * vec4(Normal, 0.0); 25 | } 26 | 27 | /* 28 | #version 150 29 | 30 | in vec3 Position; 31 | in vec4 Color; 32 | in vec2 UV0; 33 | in vec2 UV2; 34 | in vec3 Normal; 35 | 36 | uniform mat4 ModelViewMat; 37 | uniform mat4 ProjMat; 38 | 39 | out vec4 vertexColor; 40 | out vec2 texCoord0; 41 | out vec2 texCoord2; 42 | out vec4 normal; 43 | 44 | 45 | */ 46 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_cutout.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 2) uniform sampler2D Sampler0; 13 | 14 | layout(binding = 1) uniform UBO{ 15 | vec4 ColorModulator; 16 | vec4 FogColor; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in float vertexDistance; 22 | layout(location = 1) in vec4 vertexColor; 23 | layout(location = 2) in vec4 normal; 24 | layout(location = 3) in vec2 texCoord0; 25 | 26 | layout(location = 0) out vec4 fragColor; 27 | 28 | void main() { 29 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 30 | if (color.a < 0.1) { 31 | discard; 32 | } 33 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 34 | } 35 | 36 | /* 37 | #version 150 38 | 39 | #moj_import 40 | 41 | uniform sampler2D Sampler0; 42 | 43 | uniform vec4 ColorModulator; 44 | uniform float FogStart; 45 | uniform float FogEnd; 46 | uniform vec4 FogColor; 47 | 48 | in float vertexDistance; 49 | in vec4 vertexColor; 50 | in vec2 texCoord0; 51 | in vec4 normal; 52 | 53 | out vec4 fragColor; 54 | 55 | void main() { 56 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 57 | if (color.a < 0.1) { 58 | discard; 59 | } 60 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 61 | } 62 | */ 63 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_cutout_mipped.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 2) uniform sampler2D Sampler0; 13 | 14 | layout(binding = 1) uniform UBO{ 15 | vec4 ColorModulator; 16 | vec4 FogColor; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in float vertexDistance; 22 | layout(location = 1) in vec4 vertexColor; 23 | layout(location = 2) in vec4 normal; 24 | layout(location = 3) in vec2 texCoord0; 25 | 26 | layout(location = 0) out vec4 fragColor; 27 | 28 | void main() { 29 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 30 | if (color.a < 0.5) { 31 | discard; 32 | } 33 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 34 | } 35 | 36 | /* 37 | #version 150 38 | 39 | #moj_import 40 | 41 | uniform sampler2D Sampler0; 42 | 43 | uniform vec4 ColorModulator; 44 | uniform float FogStart; 45 | uniform float FogEnd; 46 | uniform vec4 FogColor; 47 | 48 | in float vertexDistance; 49 | in vec4 vertexColor; 50 | in vec2 texCoord0; 51 | in vec4 normal; 52 | 53 | out vec4 fragColor; 54 | 55 | void main() { 56 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 57 | if (color.a < 0.5) { 58 | discard; 59 | } 60 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 61 | } 62 | */ 63 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_end_portal.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "rendertype_end_portal", 8 | "fragment": "rendertype_end_portal", 9 | "attributes": [], 10 | "samplers": [ 11 | { "name": "Sampler0" }, 12 | { "name": "Sampler1" } 13 | ], 14 | "uniforms": [ 15 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 16 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 17 | { "name": "GameTime", "type": "float", "count": 1, "values": [ 0.0 ] }, 18 | { "name": "EndPortalLayers", "type": "int", "count": 1, "values": [ 15 ] } 19 | ], 20 | "UBOs": [ 21 | { "type": "vertex", "binding": 0, "fields": [ 22 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 23 | ] }, 24 | { "type": "fragment", "binding": 1, "fields": [ 25 | { "name": "GameTime", "type": "float", "count": 1, "values": [ 0.0 ] }, 26 | { "name": "EndPortalLayers", "type": "int", "count": 1, "values": [ 15 ] } 27 | ] } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_end_portal.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | //projection.glsl 4 | vec4 projection_from_position(vec4 position) { 5 | vec4 projection = position * 0.5; 6 | projection.xy = vec2(projection.x + projection.w, projection.y + projection.w); 7 | projection.zw = position.zw; 8 | return projection; 9 | } 10 | 11 | layout(location = 0) in vec3 Position; 12 | 13 | layout(binding = 0) uniform UniformBufferObject { 14 | mat4 MVP; 15 | }; 16 | 17 | layout(location = 0) out vec4 texProj0; 18 | 19 | void main() { 20 | gl_Position = MVP * vec4(Position, 1.0); 21 | 22 | texProj0 = projection_from_position(gl_Position); 23 | } 24 | 25 | /* 26 | #version 150 27 | 28 | #moj_import 29 | 30 | in vec3 Position; 31 | 32 | uniform mat4 ModelViewMat; 33 | uniform mat4 ProjMat; 34 | 35 | out vec4 texProj0; 36 | */ 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_energy_swirl.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | float linear_fog_fade(float vertexDistance, float fogStart, float fogEnd) { 4 | if (vertexDistance <= fogStart) { 5 | return 1.0; 6 | } else if (vertexDistance >= fogEnd) { 7 | return 0.0; 8 | } 9 | 10 | return smoothstep(fogEnd, fogStart, vertexDistance); 11 | } 12 | 13 | layout(binding = 2) uniform sampler2D Sampler0; 14 | 15 | layout(binding = 1) uniform UBO{ 16 | vec4 ColorModulator; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in float vertexDistance; 22 | layout(location = 1) in vec4 vertexColor; 23 | layout(location = 2) in vec2 texCoord0; 24 | 25 | layout(location = 0) out vec4 fragColor; 26 | 27 | void main() { 28 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 29 | if (color.a < 0.1) { 30 | discard; 31 | } 32 | fragColor = color * linear_fog_fade(vertexDistance, FogStart, FogEnd); 33 | } 34 | 35 | /* 36 | #version 150 37 | 38 | #moj_import 39 | 40 | uniform sampler2D Sampler0; 41 | 42 | uniform vec4 ColorModulator; 43 | uniform float FogStart; 44 | uniform float FogEnd; 45 | 46 | in float vertexDistance; 47 | in vec4 vertexColor; 48 | in vec2 texCoord0; 49 | 50 | out vec4 fragColor; 51 | */ 52 | 53 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_energy_swirl.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec4 Color; 5 | layout(location = 2) in vec2 UV0; 6 | 7 | layout(binding = 0) uniform UniformBufferObject { 8 | mat4 MVP; 9 | mat4 ModelViewMat; 10 | mat4 TextureMat; 11 | }; 12 | 13 | layout(location = 0) out float vertexDistance; 14 | layout(location = 1) out vec4 vertexColor; 15 | layout(location = 2) out vec2 texCoord0; 16 | 17 | void main() { 18 | gl_Position = MVP * vec4(Position, 1.0); 19 | 20 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 21 | vertexColor = Color; 22 | texCoord0 = (TextureMat * vec4(UV0, 0.0, 1.0)).xy; 23 | } 24 | 25 | /* 26 | #version 150 27 | 28 | in vec3 Position; 29 | in vec4 Color; 30 | in vec2 UV0; 31 | 32 | uniform mat4 ModelViewMat; 33 | uniform mat4 ProjMat; 34 | uniform mat4 TextureMat; 35 | 36 | out float vertexDistance; 37 | out vec4 vertexColor; 38 | out vec2 texCoord0; 39 | */ 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_entity_alpha.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(binding = 1) uniform sampler2D Sampler0; 4 | 5 | layout(location = 0) in vec4 vertexColor; 6 | layout(location = 1) in vec2 texCoord0; 7 | layout(location = 2) in vec2 texCoord1; 8 | layout(location = 3) in vec2 texCoord2; 9 | layout(location = 4) in vec4 normal; 10 | 11 | layout(location = 0) out vec4 fragColor; 12 | 13 | void main() { 14 | vec4 color = texture(Sampler0, texCoord0); 15 | if (color.a < vertexColor.a) { 16 | discard; 17 | } 18 | fragColor = color; 19 | } 20 | 21 | /* 22 | #version 150 23 | 24 | uniform sampler2D Sampler0; 25 | 26 | in vec4 vertexColor; 27 | in vec2 texCoord0; 28 | in vec2 texCoord1; 29 | in vec2 texCoord2; 30 | in vec4 normal; 31 | 32 | out vec4 fragColor; 33 | */ 34 | 35 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_entity_alpha.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "rendertype_entity_alpha", 8 | "fragment": "rendertype_entity_alpha", 9 | "attributes": [ 10 | "Position", 11 | "Color", 12 | "UV0", 13 | "UV1", 14 | "UV2", 15 | "Normal" 16 | ], 17 | "samplers": [ 18 | { "name": "Sampler0" } 19 | ], 20 | "uniforms": [ 21 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 22 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 23 | ], 24 | "UBOs": [ 25 | { "type": "vertex", "binding": 0, "fields": [ 26 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 27 | ] } 28 | 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_entity_alpha.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec4 Color; 5 | layout(location = 2) in vec2 UV0; 6 | layout(location = 3) in ivec2 UV1; 7 | layout(location = 4) in ivec2 UV2; 8 | layout(location = 5) in vec3 Normal; 9 | 10 | layout(binding = 0) uniform UniformBufferObject { 11 | mat4 MVP; 12 | }; 13 | 14 | layout(location = 0) out vec4 vertexColor; 15 | layout(location = 1) out vec2 texCoord0; 16 | layout(location = 2) out vec2 texCoord1; 17 | layout(location = 3) out vec2 texCoord2; 18 | layout(location = 4) out vec4 normal; 19 | 20 | void main() { 21 | gl_Position = MVP * vec4(Position, 1.0); 22 | 23 | vertexColor = Color; 24 | texCoord0 = UV0; 25 | texCoord1 = UV1; 26 | texCoord2 = UV2; 27 | normal = MVP * vec4(Normal, 0.0); 28 | } 29 | 30 | /* 31 | #version 150 32 | 33 | in vec3 Position; 34 | in vec4 Color; 35 | in vec2 UV0; 36 | in vec2 UV1; 37 | in vec2 UV2; 38 | in vec3 Normal; 39 | 40 | uniform mat4 ModelViewMat; 41 | uniform mat4 ProjMat; 42 | 43 | out vec4 vertexColor; 44 | out vec2 texCoord0; 45 | out vec2 texCoord1; 46 | out vec2 texCoord2; 47 | out vec4 normal; 48 | */ 49 | 50 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_entity_cutout.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 2) uniform sampler2D Sampler0; 13 | 14 | layout(binding = 1) uniform UBO{ 15 | vec4 ColorModulator; 16 | vec4 FogColor; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in vec4 vertexColor; 22 | layout(location = 1) in vec4 lightMapColor; 23 | layout(location = 2) in vec4 overlayColor; 24 | layout(location = 3) in vec2 texCoord0; 25 | layout(location = 4) in vec2 normal; 26 | layout(location = 5) in float vertexDistance; 27 | 28 | layout(location = 0) out vec4 fragColor; 29 | 30 | void main() { 31 | vec4 color = texture(Sampler0, texCoord0); 32 | if (color.a < 0.1) { 33 | discard; 34 | } 35 | color *= vertexColor * ColorModulator; 36 | color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a); 37 | color *= lightMapColor; 38 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 39 | } 40 | 41 | /* 42 | #version 150 43 | 44 | #moj_import 45 | 46 | uniform sampler2D Sampler0; 47 | 48 | uniform vec4 ColorModulator; 49 | uniform float FogStart; 50 | uniform float FogEnd; 51 | uniform vec4 FogColor; 52 | 53 | in float vertexDistance; 54 | in vec4 vertexColor; 55 | in vec4 lightMapColor; 56 | in vec4 overlayColor; 57 | in vec2 texCoord0; 58 | in vec4 normal; 59 | 60 | out vec4 fragColor; 61 | 62 | void main() { 63 | vec4 color = texture(Sampler0, texCoord0); 64 | if (color.a < 0.1) { 65 | discard; 66 | } 67 | color *= vertexColor * ColorModulator; 68 | color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a); 69 | color *= lightMapColor; 70 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 71 | } 72 | */ 73 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_entity_cutout_no_cull.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 2) uniform sampler2D Sampler0; 13 | 14 | layout(binding = 1) uniform UBO{ 15 | vec4 ColorModulator; 16 | vec4 FogColor; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in vec4 vertexColor; 22 | layout(location = 1) in vec4 lightMapColor; 23 | layout(location = 2) in vec4 overlayColor; 24 | layout(location = 3) in vec2 texCoord0; 25 | layout(location = 4) in vec2 normal; 26 | layout(location = 5) in float vertexDistance; 27 | 28 | layout(location = 0) out vec4 fragColor; 29 | 30 | void main() { 31 | vec4 color = texture(Sampler0, texCoord0); 32 | if (color.a < 0.1) { 33 | discard; 34 | } 35 | color *= vertexColor * ColorModulator; 36 | color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a); 37 | color *= lightMapColor; 38 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 39 | } 40 | 41 | /* 42 | #version 150 43 | 44 | #moj_import 45 | 46 | uniform sampler2D Sampler0; 47 | 48 | uniform vec4 ColorModulator; 49 | uniform float FogStart; 50 | uniform float FogEnd; 51 | uniform vec4 FogColor; 52 | 53 | in float vertexDistance; 54 | in vec4 vertexColor; 55 | in vec4 lightMapColor; 56 | in vec4 overlayColor; 57 | in vec2 texCoord0; 58 | in vec4 normal; 59 | 60 | out vec4 fragColor; 61 | */ 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_entity_cutout_no_cull_z_offset.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "rendertype_entity_cutout_no_cull_z_offset", 8 | "fragment": "rendertype_entity_cutout_no_cull_z_offset", 9 | "attributes": [ 10 | "Position", 11 | "Color", 12 | "UV0", 13 | "UV1", 14 | "UV2", 15 | "Normal" 16 | ], 17 | "samplers": [ 18 | { "name": "Sampler0" }, 19 | { "name": "Sampler1" }, 20 | { "name": "Sampler2" } 21 | ], 22 | "uniforms": [ 23 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 24 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 25 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 26 | { "name": "Light0_Direction", "type": "float", "count": 3, "values": [0.0, 0.0, 0.0] }, 27 | { "name": "Light1_Direction", "type": "float", "count": 3, "values": [0.0, 0.0, 0.0] }, 28 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 29 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] }, 30 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] } 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_entity_decal.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 2) uniform sampler2D Sampler0; 13 | 14 | layout(binding = 1) uniform UBO{ 15 | vec4 ColorModulator; 16 | vec4 FogColor; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in vec4 vertexColor; 22 | layout(location = 1) in vec4 overlayColor; 23 | layout(location = 2) in vec2 texCoord0; 24 | layout(location = 3) in vec2 normal; 25 | layout(location = 4) in float vertexDistance; 26 | 27 | layout(location = 0) out vec4 fragColor; 28 | 29 | void main() { 30 | vec4 color = texture(Sampler0, texCoord0); 31 | if (color.a < 0.1) { 32 | discard; 33 | } 34 | color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a); 35 | color *= vertexColor * ColorModulator; 36 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 37 | } 38 | 39 | /* 40 | #version 150 41 | 42 | #moj_import 43 | 44 | uniform sampler2D Sampler0; 45 | 46 | uniform vec4 ColorModulator; 47 | uniform float FogStart; 48 | uniform float FogEnd; 49 | uniform vec4 FogColor; 50 | 51 | in float vertexDistance; 52 | in vec4 vertexColor; 53 | in vec4 overlayColor; 54 | in vec2 texCoord0; 55 | in vec4 normal; 56 | 57 | out vec4 fragColor; 58 | 59 | void main() { 60 | vec4 color = texture(Sampler0, texCoord0); 61 | if (color.a < 0.1) { 62 | discard; 63 | } 64 | color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a); 65 | color *= vertexColor * ColorModulator; 66 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 67 | } 68 | */ 69 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_entity_glint.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | float linear_fog_fade(float vertexDistance, float fogStart, float fogEnd) { 4 | if (vertexDistance <= fogStart) { 5 | return 1.0; 6 | } else if (vertexDistance >= fogEnd) { 7 | return 0.0; 8 | } 9 | 10 | return smoothstep(fogEnd, fogStart, vertexDistance); 11 | } 12 | 13 | layout(binding = 2) uniform sampler2D Sampler0; 14 | 15 | layout(binding = 1) uniform UBO{ 16 | vec4 ColorModulator; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in float vertexDistance; 22 | layout(location = 1) in vec2 texCoord0; 23 | 24 | layout(location = 0) out vec4 fragColor; 25 | 26 | void main() { 27 | vec4 color = texture(Sampler0, texCoord0) * ColorModulator; 28 | if (color.a < 0.1) { 29 | discard; 30 | } 31 | float fade = linear_fog_fade(vertexDistance, FogStart, FogEnd); 32 | fragColor = vec4(color.rgb * fade, color.a); 33 | } 34 | 35 | /* 36 | #version 150 37 | 38 | #moj_import 39 | 40 | uniform sampler2D Sampler0; 41 | 42 | uniform vec4 ColorModulator; 43 | uniform float FogStart; 44 | uniform float FogEnd; 45 | 46 | in float vertexDistance; 47 | in vec2 texCoord0; 48 | 49 | out vec4 fragColor; 50 | 51 | void main() { 52 | vec4 color = texture(Sampler0, texCoord0) * ColorModulator; 53 | if (color.a < 0.1) { 54 | discard; 55 | } 56 | float fade = linear_fog_fade(vertexDistance, FogStart, FogEnd); 57 | fragColor = vec4(color.rgb * fade, color.a); 58 | } 59 | */ 60 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_entity_glint.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec2 UV0; 5 | 6 | layout(binding = 0) uniform UniformBufferObject { 7 | mat4 MVP; 8 | mat4 ModelViewMat; 9 | mat4 TextureMat; 10 | }; 11 | 12 | layout(location = 0) out float vertexDistance; 13 | layout(location = 1) out vec2 texCoord0; 14 | 15 | void main() { 16 | gl_Position = MVP * vec4(Position, 1.0); 17 | 18 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 19 | texCoord0 = (TextureMat * vec4(UV0, 0.0, 1.0)).xy; 20 | } 21 | 22 | /* 23 | #version 150 24 | 25 | in vec3 Position; 26 | in vec2 UV0; 27 | 28 | uniform mat4 ModelViewMat; 29 | uniform mat4 ProjMat; 30 | uniform mat4 TextureMat; 31 | 32 | out float vertexDistance; 33 | out vec2 texCoord0; 34 | 35 | void main() { 36 | gl_Position = MVP * vec4(Position, 1.0); 37 | 38 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 39 | texCoord0 = (TextureMat * vec4(UV0, 0.0, 1.0)).xy; 40 | } 41 | */ 42 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_entity_glint_direct.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | float linear_fog_fade(float vertexDistance, float fogStart, float fogEnd) { 4 | if (vertexDistance <= fogStart) { 5 | return 1.0; 6 | } else if (vertexDistance >= fogEnd) { 7 | return 0.0; 8 | } 9 | 10 | return smoothstep(fogEnd, fogStart, vertexDistance); 11 | } 12 | 13 | layout(binding = 2) uniform sampler2D Sampler0; 14 | 15 | layout(binding = 1) uniform UBO{ 16 | vec4 ColorModulator; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in float vertexDistance; 22 | layout(location = 1) in vec2 texCoord0; 23 | 24 | layout(location = 0) out vec4 fragColor; 25 | 26 | void main() { 27 | vec4 color = texture(Sampler0, texCoord0) * ColorModulator; 28 | if (color.a < 0.1) { 29 | discard; 30 | } 31 | float fade = linear_fog_fade(vertexDistance, FogStart, FogEnd); 32 | fragColor = vec4(color.rgb * fade, color.a); 33 | } 34 | 35 | /* 36 | #version 150 37 | 38 | #moj_import 39 | 40 | uniform sampler2D Sampler0; 41 | 42 | uniform vec4 ColorModulator; 43 | uniform float FogStart; 44 | uniform float FogEnd; 45 | 46 | in float vertexDistance; 47 | in vec2 texCoord0; 48 | 49 | out vec4 fragColor; 50 | 51 | void main() { 52 | vec4 color = texture(Sampler0, texCoord0) * ColorModulator; 53 | if (color.a < 0.1) { 54 | discard; 55 | } 56 | float fade = linear_fog_fade(vertexDistance, FogStart, FogEnd); 57 | fragColor = vec4(color.rgb * fade, color.a); 58 | } 59 | */ 60 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_entity_glint_direct.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec2 UV0; 5 | 6 | layout(binding = 0) uniform UniformBufferObject { 7 | mat4 MVP; 8 | mat4 ModelViewMat; 9 | mat4 TextureMat; 10 | }; 11 | 12 | layout(location = 0) out float vertexDistance; 13 | layout(location = 1) out vec2 texCoord0; 14 | 15 | void main() { 16 | gl_Position = MVP * vec4(Position, 1.0); 17 | 18 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 19 | texCoord0 = (TextureMat * vec4(UV0, 0.0, 1.0)).xy; 20 | } 21 | 22 | /* 23 | #version 150 24 | 25 | in vec3 Position; 26 | in vec2 UV0; 27 | 28 | uniform mat4 ModelViewMat; 29 | uniform mat4 ProjMat; 30 | uniform mat4 TextureMat; 31 | 32 | out float vertexDistance; 33 | out vec2 texCoord0; 34 | 35 | void main() { 36 | gl_Position = MVP * vec4(Position, 1.0); 37 | 38 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 39 | texCoord0 = (TextureMat * vec4(UV0, 0.0, 1.0)).xy; 40 | } 41 | */ 42 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_entity_no_outline.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 2) uniform sampler2D Sampler0; 13 | 14 | layout(binding = 1) uniform UBO{ 15 | vec4 ColorModulator; 16 | vec4 FogColor; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in vec4 vertexColor; 22 | layout(location = 1) in vec2 texCoord0; 23 | layout(location = 2) in vec2 normal; 24 | layout(location = 3) in float vertexDistance; 25 | 26 | layout(location = 0) out vec4 fragColor; 27 | 28 | void main() { 29 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 30 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 31 | } 32 | 33 | /* 34 | #version 150 35 | 36 | #moj_import 37 | 38 | uniform sampler2D Sampler0; 39 | 40 | uniform vec4 ColorModulator; 41 | uniform float FogStart; 42 | uniform float FogEnd; 43 | uniform vec4 FogColor; 44 | 45 | in float vertexDistance; 46 | in vec4 vertexColor; 47 | in vec2 texCoord0; 48 | in vec4 normal; 49 | 50 | out vec4 fragColor; 51 | */ 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_entity_shadow.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 2) uniform sampler2D Sampler0; 13 | 14 | layout(binding = 1) uniform UBO{ 15 | vec4 ColorModulator; 16 | vec4 FogColor; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in vec4 vertexColor; 22 | layout(location = 1) in vec2 texCoord0; 23 | layout(location = 2) in float vertexDistance; 24 | 25 | layout(location = 0) out vec4 fragColor; 26 | 27 | void main() { 28 | vec4 color = texture(Sampler0, clamp(texCoord0, 0.0, 1.0)); 29 | color *= vertexColor * ColorModulator; 30 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 31 | } 32 | 33 | /* 34 | #version 150 35 | 36 | #moj_import 37 | 38 | uniform sampler2D Sampler0; 39 | 40 | uniform vec4 ColorModulator; 41 | uniform float FogStart; 42 | uniform float FogEnd; 43 | uniform vec4 FogColor; 44 | 45 | in float vertexDistance; 46 | in vec4 vertexColor; 47 | in vec2 texCoord0; 48 | 49 | out vec4 fragColor; 50 | */ 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_entity_shadow.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "rendertype_entity_shadow", 8 | "fragment": "rendertype_entity_shadow", 9 | "attributes": [ 10 | "Position", 11 | "Color", 12 | "UV0" 13 | ], 14 | "samplers": [ 15 | { "name": "Sampler0" } 16 | ], 17 | "uniforms": [ 18 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 19 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 20 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 21 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 22 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] }, 23 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] } 24 | ], 25 | "UBOs": [ 26 | { "type": "vertex", "binding": 0, "fields": [ 27 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 28 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 29 | ] }, 30 | { "type": "fragment", "binding": 1, "fields": [ 31 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 32 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] }, 33 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 34 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] } 35 | ] } 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_entity_shadow.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec4 Color; 5 | layout(location = 2) in vec2 UV0; 6 | 7 | layout(binding = 0) uniform UniformBufferObject { 8 | mat4 MVP; 9 | mat4 ModelViewMat; 10 | }; 11 | 12 | layout(location = 0) out vec4 vertexColor; 13 | layout(location = 1) out vec2 texCoord0; 14 | layout(location = 2) out float vertexDistance; 15 | 16 | void main() { 17 | gl_Position = MVP * vec4(Position, 1.0); 18 | 19 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 20 | vertexColor = Color; 21 | texCoord0 = UV0; 22 | } 23 | 24 | /* 25 | #version 150 26 | 27 | in vec3 Position; 28 | in vec4 Color; 29 | in vec2 UV0; 30 | 31 | uniform mat4 ModelViewMat; 32 | uniform mat4 ProjMat; 33 | 34 | out float vertexDistance; 35 | out vec4 vertexColor; 36 | out vec2 texCoord0; 37 | */ 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_entity_solid.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 2) uniform sampler2D Sampler0; 13 | 14 | layout(binding = 1) uniform UBO{ 15 | vec4 ColorModulator; 16 | vec4 FogColor; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in vec4 vertexColor; 22 | layout(location = 1) in vec4 lightMapColor; 23 | layout(location = 2) in vec4 overlayColor; 24 | layout(location = 3) in vec2 texCoord0; 25 | layout(location = 4) in vec2 normal; 26 | layout(location = 5) in float vertexDistance; 27 | 28 | layout(location = 0) out vec4 fragColor; 29 | 30 | void main() { 31 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 32 | color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a); 33 | color *= lightMapColor; 34 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 35 | } 36 | 37 | /* 38 | #version 150 39 | 40 | #moj_import 41 | 42 | uniform sampler2D Sampler0; 43 | 44 | uniform vec4 ColorModulator; 45 | uniform float FogStart; 46 | uniform float FogEnd; 47 | uniform vec4 FogColor; 48 | 49 | in float vertexDistance; 50 | in vec4 vertexColor; 51 | in vec4 lightMapColor; 52 | in vec4 overlayColor; 53 | in vec2 texCoord0; 54 | in vec4 normal; 55 | 56 | out vec4 fragColor; 57 | 58 | void main() { 59 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 60 | color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a); 61 | color *= lightMapColor; 62 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 63 | } 64 | */ -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_entity_translucent.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 2) uniform sampler2D Sampler0; 13 | 14 | layout(binding = 1) uniform UBO{ 15 | vec4 ColorModulator; 16 | vec4 FogColor; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in vec4 vertexColor; 22 | layout(location = 1) in vec4 lightMapColor; 23 | layout(location = 2) in vec4 overlayColor; 24 | layout(location = 3) in vec2 texCoord0; 25 | layout(location = 4) in vec2 normal; 26 | layout(location = 5) in float vertexDistance; 27 | 28 | layout(location = 0) out vec4 fragColor; 29 | 30 | void main() { 31 | vec4 color = texture(Sampler0, texCoord0); 32 | if (color.a < 0.1) { 33 | discard; 34 | } 35 | color *= vertexColor * ColorModulator; 36 | color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a); 37 | color *= lightMapColor; 38 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 39 | } 40 | 41 | /* 42 | #version 150 43 | 44 | #moj_import 45 | 46 | uniform sampler2D Sampler0; 47 | 48 | uniform vec4 ColorModulator; 49 | uniform float FogStart; 50 | uniform float FogEnd; 51 | uniform vec4 FogColor; 52 | 53 | in float vertexDistance; 54 | in vec4 vertexColor; 55 | in vec4 lightMapColor; 56 | in vec4 overlayColor; 57 | in vec2 texCoord0; 58 | in vec4 normal; 59 | 60 | out vec4 fragColor; 61 | */ 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_entity_translucent_cull.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 2) uniform sampler2D Sampler0; 13 | 14 | layout(binding = 1) uniform UBO{ 15 | vec4 ColorModulator; 16 | vec4 FogColor; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in vec4 vertexColor; 22 | layout(location = 1) in vec2 texCoord0; 23 | layout(location = 2) in vec2 texCoord1; 24 | layout(location = 3) in vec2 normal; 25 | layout(location = 4) in float vertexDistance; 26 | 27 | layout(location = 0) out vec4 fragColor; 28 | 29 | void main() { 30 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 31 | if (color.a < 0.1) { 32 | discard; 33 | } 34 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 35 | } 36 | 37 | /* 38 | #version 150 39 | 40 | #moj_import 41 | 42 | uniform sampler2D Sampler0; 43 | 44 | uniform vec4 ColorModulator; 45 | uniform float FogStart; 46 | uniform float FogEnd; 47 | uniform vec4 FogColor; 48 | 49 | in float vertexDistance; 50 | in vec4 vertexColor; 51 | in vec2 texCoord0; 52 | in vec2 texCoord1; 53 | in vec4 normal; 54 | 55 | out vec4 fragColor; 56 | */ 57 | 58 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_entity_translucent_emissive.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | float linear_fog_fade(float vertexDistance, float fogStart, float fogEnd) { 4 | if (vertexDistance <= fogStart) { 5 | return 1.0; 6 | } else if (vertexDistance >= fogEnd) { 7 | return 0.0; 8 | } 9 | 10 | return smoothstep(fogEnd, fogStart, vertexDistance); 11 | } 12 | 13 | layout(binding = 2) uniform sampler2D Sampler0; 14 | 15 | layout(binding = 1) uniform UBO{ 16 | vec4 ColorModulator; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in vec4 vertexColor; 22 | layout(location = 1) in vec4 overlayColor; 23 | layout(location = 2) in vec2 texCoord0; 24 | layout(location = 3) in vec2 normal; 25 | layout(location = 4) in float vertexDistance; 26 | 27 | layout(location = 0) out vec4 fragColor; 28 | 29 | void main() { 30 | vec4 color = texture(Sampler0, texCoord0); 31 | if (color.a < 0.1) { 32 | discard; 33 | } 34 | color *= vertexColor * ColorModulator; 35 | color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a); 36 | fragColor = color * linear_fog_fade(vertexDistance, FogStart, FogEnd); 37 | } 38 | 39 | /* 40 | #version 150 41 | 42 | #moj_import 43 | 44 | uniform sampler2D Sampler0; 45 | 46 | uniform vec4 ColorModulator; 47 | uniform float FogStart; 48 | uniform float FogEnd; 49 | 50 | in float vertexDistance; 51 | in vec4 vertexColor; 52 | in vec4 overlayColor; 53 | in vec2 texCoord0; 54 | in vec4 normal; 55 | 56 | out vec4 fragColor; 57 | */ 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_eyes.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | float linear_fog_fade(float vertexDistance, float fogStart, float fogEnd) { 13 | if (vertexDistance <= fogStart) { 14 | return 1.0; 15 | } else if (vertexDistance >= fogEnd) { 16 | return 0.0; 17 | } 18 | 19 | return smoothstep(fogEnd, fogStart, vertexDistance); 20 | } 21 | 22 | layout(binding = 2) uniform sampler2D Sampler0; 23 | 24 | layout(binding = 1) uniform UBO{ 25 | vec4 ColorModulator; 26 | float FogStart; 27 | float FogEnd; 28 | }; 29 | 30 | layout(location = 0) in vec4 vertexColor; 31 | layout(location = 1) in vec2 texCoord0; 32 | layout(location = 2) in float vertexDistance; 33 | 34 | layout(location = 0) out vec4 fragColor; 35 | 36 | void main() { 37 | vec4 color = texture(Sampler0, texCoord0) * vertexColor; 38 | fragColor = color * ColorModulator * linear_fog_fade(vertexDistance, FogStart, FogEnd); 39 | } 40 | 41 | /* 42 | #version 150 43 | 44 | #moj_import 45 | 46 | uniform sampler2D Sampler0; 47 | 48 | uniform vec4 ColorModulator; 49 | uniform float FogStart; 50 | uniform float FogEnd; 51 | 52 | in float vertexDistance; 53 | in vec4 vertexColor; 54 | in vec2 texCoord0; 55 | 56 | out vec4 fragColor; 57 | */ 58 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_eyes.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "rendertype_eyes", 8 | "fragment": "rendertype_eyes", 9 | "attributes": [ 10 | "Position", 11 | "Color", 12 | "UV0", 13 | "UV1", 14 | "UV2", 15 | "Normal" 16 | ], 17 | "samplers": [ 18 | { "name": "Sampler0" } 19 | ], 20 | "uniforms": [ 21 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 22 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 23 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 24 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 25 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] } 26 | ], 27 | "UBOs": [ 28 | { "type": "vertex", "binding": 0, "fields": [ 29 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 30 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 31 | ] }, 32 | { "type": "fragment", "binding": 1, "fields": [ 33 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 34 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 35 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] } 36 | ] } 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_eyes.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec4 Color; 5 | layout(location = 2) in vec2 UV0; 6 | 7 | layout(binding = 0) uniform UniformBufferObject { 8 | mat4 MVP; 9 | mat4 ModelViewMat; 10 | }; 11 | 12 | layout(location = 0) out vec4 vertexColor; 13 | layout(location = 1) out vec2 texCoord0; 14 | layout(location = 2) out float vertexDistance; 15 | 16 | void main() { 17 | gl_Position = MVP * vec4(Position, 1.0); 18 | 19 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 20 | vertexColor = Color; 21 | texCoord0 = UV0; 22 | } 23 | 24 | /* 25 | #version 150 26 | 27 | in vec3 Position; 28 | in vec4 Color; 29 | in vec2 UV0; 30 | 31 | uniform mat4 ModelViewMat; 32 | uniform mat4 ProjMat; 33 | 34 | out float vertexDistance; 35 | out vec4 vertexColor; 36 | out vec2 texCoord0; 37 | 38 | void main() { 39 | gl_Position = MVP * vec4(Position, 1.0); 40 | 41 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 42 | vertexColor = Color; 43 | texCoord0 = UV0; 44 | } 45 | */ 46 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_glint.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | float linear_fog_fade(float vertexDistance, float fogStart, float fogEnd) { 4 | if (vertexDistance <= fogStart) { 5 | return 1.0; 6 | } else if (vertexDistance >= fogEnd) { 7 | return 0.0; 8 | } 9 | 10 | return smoothstep(fogEnd, fogStart, vertexDistance); 11 | } 12 | 13 | layout(binding = 2) uniform sampler2D Sampler0; 14 | 15 | layout(binding = 1) uniform UBO{ 16 | vec4 ColorModulator; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in float vertexDistance; 22 | layout(location = 1) in vec2 texCoord0; 23 | 24 | layout(location = 0) out vec4 fragColor; 25 | 26 | void main() { 27 | vec4 color = texture(Sampler0, texCoord0) * ColorModulator; 28 | if (color.a < 0.1) { 29 | discard; 30 | } 31 | float fade = linear_fog_fade(vertexDistance, FogStart, FogEnd); 32 | fragColor = vec4(color.rgb * fade, color.a); 33 | } 34 | 35 | /* 36 | #version 150 37 | 38 | #moj_import 39 | 40 | uniform sampler2D Sampler0; 41 | 42 | uniform vec4 ColorModulator; 43 | uniform float FogStart; 44 | uniform float FogEnd; 45 | 46 | in float vertexDistance; 47 | in vec2 texCoord0; 48 | 49 | out vec4 fragColor; 50 | */ 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_glint.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec2 UV0; 5 | 6 | layout(binding = 0) uniform UniformBufferObject { 7 | mat4 MVP; 8 | mat4 ModelViewMat; 9 | mat4 TextureMat; 10 | }; 11 | 12 | layout(location = 0) out float vertexDistance; 13 | layout(location = 1) out vec2 texCoord0; 14 | 15 | void main() { 16 | gl_Position = MVP * vec4(Position, 1.0); 17 | 18 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 19 | texCoord0 = (TextureMat * vec4(UV0, 0.0, 1.0)).xy; 20 | } 21 | 22 | /* 23 | #version 150 24 | 25 | in vec3 Position; 26 | in vec2 UV0; 27 | 28 | uniform mat4 ModelViewMat; 29 | uniform mat4 ProjMat; 30 | uniform mat4 TextureMat; 31 | 32 | out float vertexDistance; 33 | out vec2 texCoord0; 34 | */ 35 | 36 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_glint_direct.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | float linear_fog_fade(float vertexDistance, float fogStart, float fogEnd) { 4 | if (vertexDistance <= fogStart) { 5 | return 1.0; 6 | } else if (vertexDistance >= fogEnd) { 7 | return 0.0; 8 | } 9 | 10 | return smoothstep(fogEnd, fogStart, vertexDistance); 11 | } 12 | 13 | layout(binding = 2) uniform sampler2D Sampler0; 14 | 15 | layout(binding = 1) uniform UBO{ 16 | vec4 ColorModulator; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in float vertexDistance; 22 | layout(location = 1) in vec2 texCoord0; 23 | 24 | layout(location = 0) out vec4 fragColor; 25 | 26 | void main() { 27 | vec4 color = texture(Sampler0, texCoord0) * ColorModulator; 28 | if (color.a < 0.1) { 29 | discard; 30 | } 31 | float fade = linear_fog_fade(vertexDistance, FogStart, FogEnd); 32 | fragColor = vec4(color.rgb * fade, color.a); 33 | } 34 | 35 | /* 36 | #version 150 37 | 38 | #moj_import 39 | 40 | uniform sampler2D Sampler0; 41 | 42 | uniform vec4 ColorModulator; 43 | uniform float FogStart; 44 | uniform float FogEnd; 45 | 46 | in float vertexDistance; 47 | in vec2 texCoord0; 48 | 49 | out vec4 fragColor; 50 | 51 | void main() { 52 | vec4 color = texture(Sampler0, texCoord0) * ColorModulator; 53 | if (color.a < 0.1) { 54 | discard; 55 | } 56 | float fade = linear_fog_fade(vertexDistance, FogStart, FogEnd); 57 | fragColor = vec4(color.rgb * fade, color.a); 58 | } 59 | */ 60 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_glint_direct.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec2 UV0; 5 | 6 | layout(binding = 0) uniform UniformBufferObject { 7 | mat4 MVP; 8 | mat4 ModelViewMat; 9 | mat4 TextureMat; 10 | }; 11 | 12 | layout(location = 0) out float vertexDistance; 13 | layout(location = 1) out vec2 texCoord0; 14 | 15 | void main() { 16 | gl_Position = MVP * vec4(Position, 1.0); 17 | 18 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 19 | texCoord0 = (TextureMat * vec4(UV0, 0.0, 1.0)).xy; 20 | } 21 | 22 | /* 23 | #version 150 24 | 25 | in vec3 Position; 26 | in vec2 UV0; 27 | 28 | uniform mat4 ModelViewMat; 29 | uniform mat4 ProjMat; 30 | uniform mat4 TextureMat; 31 | 32 | out float vertexDistance; 33 | out vec2 texCoord0; 34 | 35 | void main() { 36 | gl_Position = MVP * vec4(Position, 1.0); 37 | 38 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 39 | texCoord0 = (TextureMat * vec4(UV0, 0.0, 1.0)).xy; 40 | } 41 | */ 42 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_glint_translucent.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | float linear_fog_fade(float vertexDistance, float fogStart, float fogEnd) { 4 | if (vertexDistance <= fogStart) { 5 | return 1.0; 6 | } else if (vertexDistance >= fogEnd) { 7 | return 0.0; 8 | } 9 | 10 | return smoothstep(fogEnd, fogStart, vertexDistance); 11 | } 12 | 13 | layout(binding = 2) uniform sampler2D Sampler0; 14 | 15 | layout(binding = 1) uniform UBO{ 16 | vec4 ColorModulator; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in float vertexDistance; 22 | layout(location = 1) in vec2 texCoord0; 23 | 24 | layout(location = 0) out vec4 fragColor; 25 | 26 | void main() { 27 | vec4 color = texture(Sampler0, texCoord0) * ColorModulator; 28 | if (color.a < 0.1) { 29 | discard; 30 | } 31 | float fade = linear_fog_fade(vertexDistance, FogStart, FogEnd); 32 | fragColor = vec4(color.rgb * fade, color.a); 33 | } 34 | 35 | /* 36 | #version 150 37 | 38 | #moj_import 39 | 40 | uniform sampler2D Sampler0; 41 | 42 | uniform vec4 ColorModulator; 43 | uniform float FogStart; 44 | uniform float FogEnd; 45 | 46 | in float vertexDistance; 47 | in vec2 texCoord0; 48 | 49 | out vec4 fragColor; 50 | 51 | void main() { 52 | vec4 color = texture(Sampler0, texCoord0) * ColorModulator; 53 | if (color.a < 0.1) { 54 | discard; 55 | } 56 | float fade = linear_fog_fade(vertexDistance, FogStart, FogEnd); 57 | fragColor = vec4(color.rgb * fade, color.a); 58 | } 59 | */ 60 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_glint_translucent.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec2 UV0; 5 | 6 | layout(binding = 0) uniform UniformBufferObject { 7 | mat4 MVP; 8 | mat4 ModelViewMat; 9 | mat4 TextureMat; 10 | }; 11 | 12 | layout(location = 0) out float vertexDistance; 13 | layout(location = 1) out vec2 texCoord0; 14 | 15 | void main() { 16 | gl_Position = MVP * vec4(Position, 1.0); 17 | 18 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 19 | texCoord0 = (TextureMat * vec4(UV0, 0.0, 1.0)).xy; 20 | } 21 | 22 | /* 23 | #version 150 24 | 25 | in vec3 Position; 26 | in vec2 UV0; 27 | 28 | uniform mat4 ModelViewMat; 29 | uniform mat4 ProjMat; 30 | uniform mat4 TextureMat; 31 | 32 | out float vertexDistance; 33 | out vec2 texCoord0; 34 | 35 | void main() { 36 | gl_Position = MVP * vec4(Position, 1.0); 37 | 38 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 39 | texCoord0 = (TextureMat * vec4(UV0, 0.0, 1.0)).xy; 40 | } 41 | */ 42 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_item_entity_translucent_cull.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 2) uniform sampler2D Sampler0; 13 | 14 | layout(binding = 1) uniform UBO{ 15 | vec4 ColorModulator; 16 | vec4 FogColor; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in vec4 vertexColor; 22 | layout(location = 1) in vec2 texCoord0; 23 | layout(location = 2) in vec2 texCoord1; 24 | layout(location = 3) in vec2 normal; 25 | layout(location = 4) in float vertexDistance; 26 | 27 | layout(location = 0) out vec4 fragColor; 28 | 29 | void main() { 30 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 31 | if (color.a < 0.1) { 32 | discard; 33 | } 34 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 35 | } 36 | 37 | /* 38 | #version 150 39 | 40 | #moj_import 41 | 42 | uniform sampler2D Sampler0; 43 | 44 | uniform vec4 ColorModulator; 45 | uniform float FogStart; 46 | uniform float FogEnd; 47 | uniform vec4 FogColor; 48 | 49 | in float vertexDistance; 50 | in vec4 vertexColor; 51 | in vec2 texCoord0; 52 | in vec2 texCoord1; 53 | in vec4 normal; 54 | 55 | out vec4 fragColor; 56 | */ 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_leash.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 1) uniform UBO{ 13 | vec4 FogColor; 14 | float FogStart; 15 | float FogEnd; 16 | }; 17 | 18 | layout(location = 0) in vec4 vertexColor; 19 | layout(location = 1) in float vertexDistance; 20 | 21 | layout(location = 0) out vec4 fragColor; 22 | 23 | void main() { 24 | fragColor = linear_fog(vertexColor, vertexDistance, FogStart, FogEnd, FogColor); 25 | } 26 | 27 | /* 28 | #version 150 29 | 30 | #moj_import 31 | 32 | uniform float FogStart; 33 | uniform float FogEnd; 34 | uniform vec4 FogColor; 35 | 36 | in float vertexDistance; 37 | flat in vec4 vertexColor; 38 | 39 | out vec4 fragColor; 40 | 41 | void main() { 42 | fragColor = linear_fog(vertexColor, vertexDistance, FogStart, FogEnd, FogColor); 43 | } 44 | */ 45 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_leash.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "rendertype_leash", 8 | "fragment": "rendertype_leash", 9 | "attributes": [ 10 | "Position", 11 | "Color", 12 | "UV2" 13 | ], 14 | "samplers": [ 15 | { "name": "Sampler2" } 16 | ], 17 | "uniforms": [ 18 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 19 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 20 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 21 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 22 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] }, 23 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] } 24 | ], 25 | "UBOs": [ 26 | { "type": "vertex", "binding": 0, "fields": [ 27 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 28 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 29 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 30 | ] }, 31 | { "type": "fragment", "binding": 1, "fields": [ 32 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] }, 33 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 34 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] } 35 | ] } 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_leash.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec4 Color; 5 | layout(location = 2) in ivec2 UV2; 6 | 7 | layout(binding = 0) uniform UniformBufferObject { 8 | mat4 MVP; 9 | mat4 ModelViewMat; 10 | vec4 ColorModulator; 11 | }; 12 | 13 | layout(binding = 2) uniform sampler2D Sampler2; 14 | 15 | layout(location = 0) out vec4 vertexColor; 16 | layout(location = 1) out float vertexDistance; 17 | 18 | void main() { 19 | gl_Position = MVP * vec4(Position, 1.0); 20 | 21 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 22 | vertexColor = Color * ColorModulator * texelFetch(Sampler2, UV2 / 16, 0); 23 | } 24 | 25 | /* 26 | #version 150 27 | 28 | in vec3 Position; 29 | in vec4 Color; 30 | in ivec2 UV2; 31 | 32 | uniform sampler2D Sampler2; 33 | 34 | uniform mat4 ModelViewMat; 35 | uniform mat4 ProjMat; 36 | uniform vec4 ColorModulator; 37 | 38 | out float vertexDistance; 39 | flat out vec4 vertexColor; 40 | */ 41 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_lightning.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | float linear_fog_fade(float vertexDistance, float fogStart, float fogEnd) { 4 | if (vertexDistance <= fogStart) { 5 | return 1.0; 6 | } else if (vertexDistance >= fogEnd) { 7 | return 0.0; 8 | } 9 | 10 | return smoothstep(fogEnd, fogStart, vertexDistance); 11 | } 12 | 13 | layout(binding = 1) uniform UBO{ 14 | vec4 ColorModulator; 15 | float FogStart; 16 | float FogEnd; 17 | }; 18 | 19 | layout(location = 0) in vec4 vertexColor; 20 | layout(location = 1) in float vertexDistance; 21 | 22 | layout(location = 0) out vec4 fragColor; 23 | 24 | void main() { 25 | fragColor = vertexColor * ColorModulator * linear_fog_fade(vertexDistance, FogStart, FogEnd); 26 | } 27 | 28 | /* 29 | #version 150 30 | 31 | #moj_import 32 | 33 | uniform vec4 ColorModulator; 34 | uniform float FogStart; 35 | uniform float FogEnd; 36 | 37 | in float vertexDistance; 38 | in vec4 vertexColor; 39 | 40 | out vec4 fragColor; 41 | 42 | 43 | */ 44 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_lightning.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "rendertype_lightning", 8 | "fragment": "rendertype_lightning", 9 | "attributes": [ 10 | "Color" 11 | ], 12 | "samplers": [ 13 | ], 14 | "uniforms": [ 15 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 16 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 17 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 18 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 19 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] } 20 | ], 21 | "UBOs": [ 22 | { "type": "vertex", "binding": 0, "fields": [ 23 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 24 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 25 | ] }, 26 | { "type": "fragment", "binding": 1, "fields": [ 27 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 28 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 29 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] } 30 | ] } 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_lightning.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec4 Color; 5 | 6 | layout(binding = 0) uniform UniformBufferObject { 7 | mat4 MVP; 8 | mat4 ModelViewMat; 9 | }; 10 | 11 | layout(location = 0) out vec4 vertexColor; 12 | layout(location = 1) out float vertexDistance; 13 | 14 | void main() { 15 | gl_Position = MVP * vec4(Position, 1.0); 16 | 17 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 18 | vertexColor = Color; 19 | } 20 | 21 | /* 22 | #version 150 23 | 24 | in vec3 Position; 25 | in vec4 Color; 26 | 27 | uniform mat4 ModelViewMat; 28 | uniform mat4 ProjMat; 29 | 30 | out float vertexDistance; 31 | out vec4 vertexColor; 32 | 33 | void main() { 34 | gl_Position = MVP * vec4(Position, 1.0); 35 | 36 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 37 | vertexColor = Color; 38 | } 39 | */ 40 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_lines.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 1) uniform UBO{ 13 | vec4 ColorModulator; 14 | vec4 FogColor; 15 | float FogStart; 16 | float FogEnd; 17 | }; 18 | 19 | layout(location = 0) in vec4 vertexColor; 20 | layout(location = 1) in float vertexDistance; 21 | 22 | layout(location = 0) out vec4 fragColor; 23 | 24 | void main() { 25 | vec4 color = vertexColor * ColorModulator; 26 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 27 | } 28 | 29 | /* 30 | #version 150 31 | 32 | #moj_import 33 | 34 | uniform vec4 ColorModulator; 35 | uniform float FogStart; 36 | uniform float FogEnd; 37 | uniform vec4 FogColor; 38 | 39 | in float vertexDistance; 40 | in vec4 vertexColor; 41 | 42 | out vec4 fragColor; 43 | */ 44 | 45 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_lines.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec4 Color; 5 | layout(location = 2) in vec3 Normal; 6 | 7 | layout(binding = 0) uniform UniformBufferObject { 8 | mat4 ModelViewMat; 9 | mat4 ProjMat; 10 | vec2 ScreenSize; 11 | float LineWidth; 12 | }; 13 | 14 | layout(location = 1) out float vertexDistance; 15 | layout(location = 0) out vec4 vertexColor; 16 | 17 | const float VIEW_SHRINK = 1.0 - (1.0 / 256.0); 18 | const mat4 VIEW_SCALE = mat4( 19 | VIEW_SHRINK, 0.0, 0.0, 0.0, 20 | 0.0, VIEW_SHRINK, 0.0, 0.0, 21 | 0.0, 0.0, VIEW_SHRINK, 0.0, 22 | 0.0, 0.0, 0.0, 1.0 23 | ); 24 | 25 | void main() { 26 | vec4 linePosStart = ProjMat * VIEW_SCALE * ModelViewMat * vec4(Position, 1.0); 27 | vec4 linePosEnd = ProjMat * VIEW_SCALE * ModelViewMat * vec4(Position + Normal, 1.0); 28 | 29 | vec3 ndc1 = linePosStart.xyz / linePosStart.w; 30 | vec3 ndc2 = linePosEnd.xyz / linePosEnd.w; 31 | 32 | vec2 lineScreenDirection = normalize((ndc2.xy - ndc1.xy) * ScreenSize); 33 | vec2 lineOffset = vec2(-lineScreenDirection.y, lineScreenDirection.x) * LineWidth / ScreenSize; 34 | 35 | if (lineOffset.x < 0.0) { 36 | lineOffset *= -1.0; 37 | } 38 | 39 | int div = (gl_VertexIndex / 2); 40 | if (gl_VertexIndex - div * 2 == 0) { 41 | gl_Position = vec4((ndc1 + vec3(lineOffset, 0.0)) * linePosStart.w, linePosStart.w); 42 | } else { 43 | gl_Position = vec4((ndc1 - vec3(lineOffset, 0.0)) * linePosStart.w, linePosStart.w); 44 | } 45 | 46 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 47 | vertexColor = Color; 48 | } 49 | 50 | // #version 150 51 | // 52 | // in vec3 Position; 53 | // in vec4 Color; 54 | // in vec3 Normal; 55 | // 56 | // uniform mat4 ModelViewMat; 57 | // uniform mat4 ProjMat; 58 | // uniform float LineWidth; 59 | // uniform vec2 ScreenSize; 60 | // 61 | // out float vertexDistance; 62 | // out vec4 vertexColor; 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_outline.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(binding = 2) uniform sampler2D Sampler0; 4 | 5 | layout(binding = 1) uniform UBO{ 6 | vec4 ColorModulator; 7 | }; 8 | 9 | layout(location = 0) in vec4 vertexColor; 10 | layout(location = 1) in vec2 texCoord0; 11 | 12 | layout(location = 0) out vec4 fragColor; 13 | 14 | void main() { 15 | vec4 color = texture(Sampler0, texCoord0); 16 | if (color.a == 0.0) { 17 | discard; 18 | } 19 | fragColor = vec4(ColorModulator.rgb * vertexColor.rgb, ColorModulator.a); 20 | } 21 | 22 | /* 23 | #version 150 24 | 25 | uniform sampler2D Sampler0; 26 | 27 | uniform vec4 ColorModulator; 28 | 29 | in vec4 vertexColor; 30 | in vec2 texCoord0; 31 | 32 | out vec4 fragColor; 33 | */ 34 | 35 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_outline.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "rendertype_outline", 8 | "fragment": "rendertype_outline", 9 | "attributes": [ 10 | "Position", 11 | "Color", 12 | "UV0" 13 | ], 14 | "samplers": [ 15 | { "name": "Sampler0" } 16 | ], 17 | "uniforms": [ 18 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 19 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 20 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 21 | ], 22 | "UBOs": [ 23 | { "type": "vertex", "binding": 0, "fields": [ 24 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 25 | ] }, 26 | { "type": "fragment", "binding": 1, "fields": [ 27 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 28 | ] } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_outline.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec4 Color; 5 | layout(location = 2) in vec2 UV0; 6 | 7 | layout(binding = 0) uniform UniformBufferObject { 8 | mat4 MVP; 9 | }; 10 | 11 | layout(location = 0) out vec4 vertexColor; 12 | layout(location = 1) out vec2 texCoord0; 13 | 14 | void main() { 15 | gl_Position = MVP * vec4(Position, 1.0); 16 | 17 | vertexColor = Color; 18 | texCoord0 = UV0; 19 | } 20 | 21 | /* 22 | #version 150 23 | 24 | in vec3 Position; 25 | in vec4 Color; 26 | in vec2 UV0; 27 | 28 | uniform mat4 ModelViewMat; 29 | uniform mat4 ProjMat; 30 | 31 | out vec4 vertexColor; 32 | out vec2 texCoord0; 33 | */ 34 | 35 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_solid.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 2) uniform sampler2D Sampler0; 13 | 14 | layout(binding = 1) uniform UBO{ 15 | vec4 ColorModulator; 16 | vec4 FogColor; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in float vertexDistance; 22 | layout(location = 1) in vec4 vertexColor; 23 | layout(location = 2) in vec4 normal; 24 | layout(location = 3) in vec2 texCoord0; 25 | 26 | layout(location = 0) out vec4 fragColor; 27 | 28 | void main() { 29 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 30 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 31 | } 32 | 33 | /* 34 | #version 150 35 | 36 | #moj_import 37 | 38 | uniform sampler2D Sampler0; 39 | 40 | uniform vec4 ColorModulator; 41 | uniform float FogStart; 42 | uniform float FogEnd; 43 | uniform vec4 FogColor; 44 | 45 | in float vertexDistance; 46 | in vec4 vertexColor; 47 | in vec2 texCoord0; 48 | in vec4 normal; 49 | 50 | out vec4 fragColor; 51 | 52 | void main() { 53 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 54 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 55 | } 56 | */ 57 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_text.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 2) uniform sampler2D Sampler0; 13 | 14 | layout(binding = 1) uniform UBO{ 15 | vec4 ColorModulator; 16 | vec4 FogColor; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in vec4 vertexColor; 22 | layout(location = 1) in vec2 texCoord0; 23 | layout(location = 2) in float vertexDistance; 24 | 25 | layout(location = 0) out vec4 fragColor; 26 | 27 | void main() { 28 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 29 | if (color.a < 0.1) { 30 | discard; 31 | } 32 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 33 | //fragColor = vec4(color.r, color.g, color.b, 1.0f); 34 | } 35 | 36 | /* 37 | #version 150 38 | 39 | //#moj_import 40 | 41 | uniform sampler2D Sampler0; 42 | 43 | uniform vec4 ColorModulator; 44 | uniform float FogStart; 45 | uniform float FogEnd; 46 | uniform vec4 FogColor; 47 | 48 | in float vertexDistance; 49 | in vec4 vertexColor; 50 | in vec2 texCoord0; 51 | 52 | out vec4 fragColor; 53 | 54 | void main() { 55 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 56 | if (color.a < 0.1) { 57 | discard; 58 | } 59 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 60 | } 61 | */ 62 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_text.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "rendertype_text", 8 | "fragment": "rendertype_text", 9 | "attributes": [ 10 | "Position", 11 | "Color", 12 | "UV0", 13 | "UV2" 14 | ], 15 | "samplers": [ 16 | { "name": "Sampler0" }, 17 | { "name": "Sampler2" } 18 | ], 19 | "uniforms": [ 20 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 21 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 22 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 23 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 24 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] }, 25 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] } 26 | ], 27 | "UBOs": [ 28 | { "type": "vertex", "binding": 0, "fields": [ 29 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 30 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 31 | ] }, 32 | { "type": "fragment", "binding": 1, "fields": [ 33 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] }, 34 | { "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] }, 35 | { "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] }, 36 | { "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] } 37 | ] } 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_text.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec4 Color; 5 | layout(location = 2) in vec2 UV0; 6 | layout(location = 3) in ivec2 UV2; 7 | 8 | layout(binding = 0) uniform UniformBufferObject { 9 | mat4 MVP; 10 | mat4 ModelViewMat; 11 | }; 12 | 13 | layout(binding = 3) uniform sampler2D Sampler2; 14 | 15 | layout(location = 0) out vec4 vertexColor; 16 | layout(location = 1) out vec2 texCoord0; 17 | layout(location = 2) out float vertexDistance; 18 | 19 | void main() { 20 | gl_Position = MVP * vec4(Position, 1.0); 21 | 22 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 23 | vertexColor = Color * texelFetch(Sampler2, UV2 / 16, 0); 24 | vertexColor = Color; 25 | texCoord0 = UV0; 26 | } 27 | /* 28 | #version 150 29 | 30 | in vec3 Position; 31 | in vec4 Color; 32 | in vec2 UV0; 33 | in ivec2 UV2; 34 | 35 | uniform sampler2D Sampler2; 36 | 37 | uniform mat4 ModelViewMat; 38 | uniform mat4 ProjMat; 39 | 40 | out float vertexDistance; 41 | out vec4 vertexColor; 42 | out vec2 texCoord0; 43 | 44 | void main() { 45 | gl_Position = MVP * vec4(Position, 1.0); 46 | 47 | vertexDistance = length((ModelViewMat * vec4(Position, 1.0)).xyz); 48 | vertexColor = Color * texelFetch(Sampler2, UV2 / 16, 0); 49 | texCoord0 = UV0; 50 | } */ 51 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_text_see_through.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(binding = 2) uniform sampler2D Sampler0; 4 | 5 | layout(binding = 1) uniform UBO{ 6 | vec4 ColorModulator; 7 | }; 8 | 9 | layout(location = 0) in vec4 vertexColor; 10 | layout(location = 1) in vec2 texCoord0; 11 | 12 | layout(location = 0) out vec4 fragColor; 13 | 14 | void main() { 15 | vec4 color = texture(Sampler0, texCoord0) * vertexColor; 16 | if (color.a < 0.1) { 17 | discard; 18 | } 19 | fragColor = color * ColorModulator; 20 | } 21 | 22 | /* 23 | #version 150 24 | 25 | uniform sampler2D Sampler0; 26 | 27 | uniform vec4 ColorModulator; 28 | 29 | in vec4 vertexColor; 30 | in vec2 texCoord0; 31 | 32 | out vec4 fragColor; 33 | */ 34 | 35 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_text_see_through.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "rendertype_text_see_through", 8 | "fragment": "rendertype_text_see_through", 9 | "attributes": [ 10 | "Position", 11 | "Color", 12 | "UV0" 13 | ], 14 | "samplers": [ 15 | { "name": "Sampler0" } 16 | ], 17 | "uniforms": [ 18 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 19 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 20 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 21 | ],"UBOs": [ 22 | { "type": "vertex", "binding": 0, "fields": [ 23 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 24 | ] }, 25 | { "type": "fragment", "binding": 1, "fields": [ 26 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 27 | ] } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_text_see_through.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec4 Color; 5 | layout(location = 2) in vec2 UV0; 6 | 7 | layout(binding = 0) uniform UniformBufferObject { 8 | mat4 MVP; 9 | }; 10 | 11 | layout(location = 0) out vec4 vertexColor; 12 | layout(location = 1) out vec2 texCoord0; 13 | 14 | void main() { 15 | gl_Position = MVP * vec4(Position, 1.0); 16 | 17 | vertexColor = Color; 18 | texCoord0 = UV0; 19 | } 20 | 21 | /* 22 | #version 150 23 | 24 | in vec3 Position; 25 | in vec4 Color; 26 | in vec2 UV0; 27 | 28 | uniform mat4 ModelViewMat; 29 | uniform mat4 ProjMat; 30 | 31 | out vec4 vertexColor; 32 | out vec2 texCoord0; 33 | */ 34 | 35 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_translucent.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 2) uniform sampler2D Sampler0; 13 | 14 | layout(binding = 1) uniform UBO{ 15 | vec4 ColorModulator; 16 | vec4 FogColor; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in vec4 vertexColor; 22 | layout(location = 1) in vec4 normal; 23 | layout(location = 2) in vec2 texCoord0; 24 | layout(location = 3) in float vertexDistance; 25 | 26 | layout(location = 0) out vec4 fragColor; 27 | 28 | void main() { 29 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 30 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 31 | } 32 | 33 | /* 34 | #version 150 35 | 36 | #moj_import 37 | 38 | uniform sampler2D Sampler0; 39 | 40 | uniform vec4 ColorModulator; 41 | uniform float FogStart; 42 | uniform float FogEnd; 43 | uniform vec4 FogColor; 44 | 45 | in float vertexDistance; 46 | in vec4 vertexColor; 47 | in vec2 texCoord0; 48 | in vec4 normal; 49 | 50 | out vec4 fragColor; 51 | */ 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_translucent_moving_block.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(binding = 2) uniform sampler2D Sampler0; 4 | layout(binding = 3) uniform sampler2D Sampler2; 5 | 6 | layout(binding = 1) uniform UBO{ 7 | vec4 ColorModulator; 8 | }; 9 | 10 | layout(location = 0) in vec4 vertexColor; 11 | layout(location = 1) in vec4 normal; 12 | layout(location = 2) in vec2 texCoord0; 13 | 14 | layout(location = 0) out vec4 fragColor; 15 | 16 | void main() { 17 | vec4 color = texture(Sampler0, texCoord0) * vertexColor; 18 | fragColor = color * ColorModulator; 19 | } 20 | 21 | /* 22 | #version 150 23 | 24 | uniform sampler2D Sampler0; 25 | uniform sampler2D Sampler2; 26 | 27 | uniform vec4 ColorModulator; 28 | 29 | in vec4 vertexColor; 30 | in vec2 texCoord0; 31 | in vec4 normal; 32 | 33 | out vec4 fragColor; 34 | */ 35 | 36 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_translucent_moving_block.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "rendertype_translucent_moving_block", 8 | "fragment": "rendertype_translucent_moving_block", 9 | "attributes": [ 10 | "Position", 11 | "Color", 12 | "UV0", 13 | "UV2", 14 | "Normal" 15 | ], 16 | "samplers": [ 17 | { "name": "Sampler0" }, 18 | { "name": "Sampler2" } 19 | ], 20 | "uniforms": [ 21 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 22 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 23 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 24 | ], 25 | "UBOs": [ 26 | { "type": "vertex", "binding": 0, "fields": [ 27 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 28 | ] }, 29 | { "type": "fragment", "binding": 1, "fields": [ 30 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 31 | ] } 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_translucent_moving_block.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec4 Color; 5 | layout(location = 2) in vec2 UV0; 6 | layout(location = 3) in ivec2 UV2; 7 | layout(location = 4) in vec3 Normal; 8 | 9 | layout(binding = 0) uniform UniformBufferObject { 10 | mat4 MVP; 11 | }; 12 | 13 | layout(binding = 3) uniform sampler2D Sampler2; 14 | 15 | layout(location = 0) out vec4 vertexColor; 16 | layout(location = 1) out vec4 normal; 17 | layout(location = 2) out vec2 texCoord0; 18 | 19 | void main() { 20 | gl_Position = MVP * vec4(Position, 1.0); 21 | 22 | vertexColor = Color * texelFetch(Sampler2, UV2 / 16, 0); 23 | texCoord0 = UV0; 24 | normal = MVP * vec4(Normal, 0.0); 25 | } 26 | 27 | /* 28 | #version 150 29 | 30 | in vec3 Position; 31 | in vec4 Color; 32 | in vec2 UV0; 33 | in ivec2 UV2; 34 | in vec3 Normal; 35 | 36 | uniform sampler2D Sampler2; 37 | 38 | uniform mat4 ModelViewMat; 39 | uniform mat4 ProjMat; 40 | 41 | out vec4 vertexColor; 42 | out vec2 texCoord0; 43 | out vec4 normal; 44 | */ 45 | 46 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_translucent_no_crumbling.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(binding = 2) uniform sampler2D Sampler0; 4 | 5 | layout(binding = 1) uniform UBO{ 6 | vec4 ColorModulator; 7 | }; 8 | 9 | layout(location = 0) in vec4 vertexColor; 10 | layout(location = 1) in vec4 normal; 11 | layout(location = 2) in vec2 texCoord0; 12 | 13 | layout(location = 0) out vec4 fragColor; 14 | 15 | void main() { 16 | vec4 color = texture(Sampler0, texCoord0) * vertexColor; 17 | fragColor = color * ColorModulator; 18 | } 19 | 20 | /* 21 | #version 150 22 | 23 | uniform sampler2D Sampler0; 24 | 25 | uniform vec4 ColorModulator; 26 | 27 | in vec4 vertexColor; 28 | in vec2 texCoord0; 29 | in vec2 texCoord2; 30 | in vec4 normal; 31 | 32 | out vec4 fragColor; 33 | */ 34 | 35 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_translucent_no_crumbling.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "rendertype_translucent_no_crumbling", 8 | "fragment": "rendertype_translucent_no_crumbling", 9 | "attributes": [ 10 | "Position", 11 | "Color", 12 | "UV0", 13 | "UV2", 14 | "Normal" 15 | ], 16 | "samplers": [ 17 | { "name": "Sampler0" } 18 | ], 19 | "uniforms": [ 20 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 21 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 22 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 23 | ], 24 | "UBOs": [ 25 | { "type": "vertex", "binding": 0, "fields": [ 26 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 27 | ] }, 28 | { "type": "fragment", "binding": 1, "fields": [ 29 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 30 | ] } 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_translucent_no_crumbling.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | layout(location = 1) in vec4 Color; 5 | layout(location = 2) in vec2 UV0; 6 | layout(location = 3) in ivec2 UV2; 7 | layout(location = 4) in vec3 Normal; 8 | 9 | layout(binding = 0) uniform UniformBufferObject { 10 | mat4 MVP; 11 | }; 12 | 13 | layout(binding = 3) uniform sampler2D Sampler2; 14 | 15 | layout(location = 0) out vec4 vertexColor; 16 | layout(location = 1) out vec4 normal; 17 | layout(location = 2) out vec2 texCoord0; 18 | 19 | void main() { 20 | gl_Position = MVP * vec4(Position, 1.0); 21 | 22 | vertexColor = Color; 23 | texCoord0 = UV0; 24 | //texCoord2 = UV2; 25 | normal = MVP * vec4(Normal, 0.0); 26 | } 27 | 28 | /* 29 | #version 150 30 | 31 | in vec3 Position; 32 | in vec4 Color; 33 | in vec2 UV0; 34 | in vec2 UV2; 35 | in vec3 Normal; 36 | 37 | uniform mat4 ModelViewMat; 38 | uniform mat4 ProjMat; 39 | 40 | out vec4 vertexColor; 41 | out vec2 texCoord0; 42 | out vec2 texCoord2; 43 | out vec4 normal; 44 | 45 | 46 | */ 47 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_tripwire.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | vec4 linear_fog(vec4 inColor, float vertexDistance, float fogStart, float fogEnd, vec4 fogColor) { 4 | if (vertexDistance <= fogStart) { 5 | return inColor; 6 | } 7 | 8 | float fogValue = vertexDistance < fogEnd ? smoothstep(fogStart, fogEnd, vertexDistance) : 1.0; 9 | return vec4(mix(inColor.rgb, fogColor.rgb, fogValue * fogColor.a), inColor.a); 10 | } 11 | 12 | layout(binding = 2) uniform sampler2D Sampler0; 13 | 14 | layout(binding = 1) uniform UBO{ 15 | vec4 ColorModulator; 16 | vec4 FogColor; 17 | float FogStart; 18 | float FogEnd; 19 | }; 20 | 21 | layout(location = 0) in vec4 vertexColor; 22 | layout(location = 1) in vec4 normal; 23 | layout(location = 2) in vec2 texCoord0; 24 | layout(location = 3) in float vertexDistance; 25 | 26 | layout(location = 0) out vec4 fragColor; 27 | 28 | void main() { 29 | vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; 30 | if (color.a < 0.1) { 31 | discard; 32 | } 33 | fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor); 34 | } 35 | 36 | /* 37 | #version 150 38 | 39 | #moj_import 40 | 41 | uniform sampler2D Sampler0; 42 | 43 | uniform vec4 ColorModulator; 44 | uniform float FogStart; 45 | uniform float FogEnd; 46 | uniform vec4 FogColor; 47 | 48 | in float vertexDistance; 49 | in vec4 vertexColor; 50 | in vec2 texCoord0; 51 | in vec4 normal; 52 | 53 | out vec4 fragColor; 54 | */ 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_water_mask.fsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(binding = 1) uniform UniformBufferObject { 4 | vec4 ColorModulator; 5 | }; 6 | 7 | layout(location = 0) out vec4 fragColor; 8 | 9 | void main() { 10 | fragColor = ColorModulator; 11 | } 12 | 13 | /* 14 | #version 150 15 | 16 | uniform vec4 ColorModulator; 17 | 18 | out vec4 fragColor; 19 | */ 20 | 21 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_water_mask.json: -------------------------------------------------------------------------------- 1 | { 2 | "blend": { 3 | "func": "add", 4 | "srcrgb": "srcalpha", 5 | "dstrgb": "1-srcalpha" 6 | }, 7 | "vertex": "rendertype_water_mask", 8 | "fragment": "rendertype_water_mask", 9 | "attributes": [ 10 | ], 11 | "samplers": [ 12 | ], 13 | "uniforms": [ 14 | { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 15 | { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, 16 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 17 | ], 18 | "UBOs": [ 19 | { "type": "vertex", "binding": 0, "fields": [ 20 | { "name": "MVP", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] } 21 | ] }, 22 | { "type": "fragment", "binding": 1, "fields": [ 23 | { "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] } 24 | ] } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /src/main/resources/assets/vulkanmod/shaders/core/rendertype_water_mask.vsh: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 Position; 4 | 5 | layout(binding = 0) uniform UniformBufferObject { 6 | mat4 MVP; 7 | }; 8 | 9 | void main() { 10 | gl_Position = MVP * vec4(Position, 1.0); 11 | } 12 | 13 | /* 14 | #version 150 15 | 16 | in vec3 Position; 17 | 18 | uniform mat4 ModelViewMat; 19 | uniform mat4 ProjMat; 20 | 21 | void main() { 22 | gl_Position = MVP * vec4(Position, 1.0); 23 | } 24 | */ 25 | -------------------------------------------------------------------------------- /src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "vulkanmod", 4 | "version": "0.2.3", 5 | 6 | "name": "VulkanMod", 7 | "description": "Bring Vulkan to Minecraft!", 8 | "authors": [ 9 | "Collateral" 10 | ], 11 | "contact": { 12 | "homepage": "", 13 | "sources": "https://github.com/xCollateral/VulkanMod" 14 | }, 15 | 16 | "icon": "assets/vulkanmod/Vlogo.png", 17 | 18 | "environment": "*", 19 | "entrypoints": { 20 | "main": [ 21 | "net.vulkanmod.Initializer" 22 | ] 23 | }, 24 | "mixins": [ 25 | "vulkanmod.mixins.json" 26 | ], 27 | "accessWidener" : "vulkanmod.accesswidener", 28 | 29 | "depends": { 30 | "fabricloader": ">=0.13.3", 31 | "minecraft": "1.19.2", 32 | "java": ">=17" 33 | }, 34 | "suggests": { 35 | "another-mod": "*" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/resources/vulkanmod.accesswidener: -------------------------------------------------------------------------------- 1 | accessWidener v1 named 2 | 3 | accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo chunk Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk; 4 | 5 | accessible class net/minecraft/client/model/geom/ModelPart$Polygon 6 | accessible class net/minecraft/client/model/geom/ModelPart$Vertex 7 | accessible class net/minecraft/client/gui/Gui$HeartType -------------------------------------------------------------------------------- /src/main/resources/vulkanmod.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "net.vulkanmod.mixin", 5 | "compatibilityLevel": "JAVA_17", 6 | "plugin": "net.vulkanmod.mixin.MixinPlugin", 7 | "mixins": [ 8 | ], 9 | "client": [ 10 | "chunk.DirectionMixin", 11 | "chunk.FrustumMixin", 12 | "chunk.LevelRendererMixin", 13 | "chunk.VisibilitySetMixin", 14 | 15 | "debug.ChunkBorderRendererM", 16 | "debug.DebugHudM", 17 | "debug.GlDebugInfoM", 18 | "debug.KeyboardHandlerM", 19 | 20 | "gui.ChatHudM", 21 | "gui.DebugHudM", 22 | "gui.InGameHudM", 23 | 24 | "math.Matrix4fM", 25 | "math.internal.Matrix4f", 26 | "math.internal.Vertex3fM", 27 | 28 | "render.BakedQuadFactoryM", 29 | "render.BufferBuilderM", 30 | "render.BufferRendererM", 31 | "render.VertexBufferM", 32 | "render.VertexConsumerM", 33 | "render.FramebufferMixin", 34 | "render.GameRendererMixin", 35 | "render.GlProgramManagerMixin", 36 | "render.GlStateManagerM", 37 | "render.IndexTypeMixin", 38 | "render.MinecraftMixin", 39 | "render.RenderSystemMixin", 40 | "render.ShaderMixin", 41 | "render.VertexFormatMixin", 42 | "render.WindowFramebufferMixin", 43 | "render.LevelRendererMixin", 44 | 45 | "screen.OptionsScreenM", 46 | 47 | "texture.MAbstractTexture", 48 | "texture.MDynamicTexture", 49 | "texture.MFontTexture", 50 | "texture.MLightMap", 51 | "texture.MOverlayTexture", 52 | "texture.MPlayerSkinTexture", 53 | "texture.MSimpleTexture", 54 | "texture.MSpriteAtlasTexture", 55 | "texture.MTextureManager", 56 | "texture.MNativeImage", 57 | 58 | "util.ScreenshotRecorderM", 59 | 60 | "model.ModelPartCubeM", 61 | "model.ModelPartM", 62 | 63 | "vertex.SpriteCoordinateExpanderM", 64 | "vertex.VertexConsumersM$DoubleM", 65 | "vertex.VertexConsumersM$SheetDecalM", 66 | 67 | "compatibility.EffectInstanceM", 68 | "compatibility.UniformM", 69 | 70 | "ClientLevelM", 71 | "WindowMixin" 72 | ], 73 | "injectors": { 74 | "defaultRequire": 1 75 | } 76 | } 77 | --------------------------------------------------------------------------------