Image Shader

Only use a shader to display an image on your screen~

Редакция NLZONE · 2 мин чтения · 1 просмотр
Image Shader
Скачать Image Shader1.16 – 1.21.8 · с официальной страницы: modrinth.com
Перейти к загрузке

Что это

Only use a shader to display an image on your screen~

  • Тип: шейдеры
  • Загрузчик: iris
  • Версии Minecraft: 1.16 – 1.21.8
  • Скачиваний на Modrinth: 6 717

Подробно

Image Shader Only use a shader to display an image on your screen~ Note: compiling the shader may take some time!

How to prepare a custom image~ First, use ffmpeg (or any tool) to resize your image to 160×160 pixels.

bash Using ffmpeg: ffmpeg -i Input.png -vf scale=160:160 image.png

Then place the resized image in the same directory as the Python script below. Run the script to produce an imagechunks folder, then copy the 16 .glsl files inside into shaders/data/imagechunks (you need to unpack the shader pack first). Enter the game, enable the custom image option in the shader settings, and wait for the shader to finish compiling — Then it's ok~

A Python Script python from PIL import Image import os

def generateglslchunks(imagepath, outputdir="imagechunks"): try: img = Image.open(imagepath).convert('RGBA') except FileNotFoundError: print(f"Error: Image file not found at {imagepath}") return

width, height = img.size if width != 160 or height != 160: print(f"Error: Image must be 160x160 pixels, but it is {width}x{height}.") print(f"You can use:") print(f"ffmpeg -i image.png -vf scale=160:160 output.png") print(f"to adjust the image resolution.") return os.makedirs(outputdir, existok=True) chunksize = 40 numchunksx = width // chunksize numchunksy = height // chunksize

for chunky in range(numchunksy): for chunkx in range(numchunksx): left = chunkx chunksize upper = chunky chunksize right = left + chunksize lower = upper + chunksize subimg = img.crop((left, upper, right, lower)) pixeldata = list(subimg.getdata())

arrayname = f"imagedata{chunky}{chunkx}" outputfilepath = os.path.join(outputdir, f"{arrayname}.glsl")

glslarray = f"vec4 {arrayname}[{chunksize chunksize}] = vec4{chunksize chunksize}: r, g, b, a = pixel glslarray += f" vec4({r/255.0}, {g/255.0}, {b/255.0}, {a/255.0})" if i < len(pixeldata) - 1: glslarray += "," if (i + 1) % 4 == 0: glslarray += "\n" glslarray += ");\n"

with open(outputfilepath, 'w') as f: f.write(glslarray) print(f"Generated file: {outputfilepath}")

--- Config --- imagefile = "image.png" outputdirectory = "imagechunks"

generateglslchunks(imagefile, outputdirectory)

Как установить

Скачайте файл на официальной странице ниже и положите его в папку mods (для модов) или plugins (для плагинов) вашего сервера или клиента. Для модов нужен совместимый загрузчик. Версия должна совпадать с версией Minecraft.

Текст подготовлен автоматически из описания на Modrinth и ждёт проверки редакцией.

Редакция NLZONE

Пишем о серверах, модах и играх, в которые играем сами. Нашли ошибку — напишите нам, исправим.

Комментарии 0

Комментарии к этому материалу отключены.

Читайте также