Voxelers / mcthings

A Python framework for creating 3D scenes in Minecraft and Minetest
Apache License 2.0
58 stars 11 forks source link

Research textures and shaders #101

Closed acs closed 4 years ago

acs commented 4 years ago

And example with MagicaVoxel:

https://github.com/lachlanmcdonald/magicavoxel-shaders/wiki

acs commented 4 years ago

Samples of texture packs in Minecraft: https://www.pcgamesn.com/minecraft/15-best-minecraft-texture-packs Samples of shaders in MC: https://www.pcgamesn.com/minecraft/minecraft-shaders-best-graphics-mods

The guide to read on howto create texture packs: https://minecraft.gamepedia.com/Tutorials/Creating_a_resource_pack

acs commented 4 years ago

Resource packs includes also animations. Here is a tutorial about it: https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/resource-packs/resource-pack-discussion/1256350-animation-in-resource-packs-a-minecraft-1-6

And in the official guide, you have info about animations also: https://minecraft.gamepedia.com/Resource_Pack#Animation

acs commented 4 years ago

Howto create a shader in MV: https://thebitcave.gitbook.io/magicavoxel-resources/tutorials/writing-your-first-shader

How MV produces textures when exporting to polys:

Howto use textures in MV: https://magicavoxel.fandom.com/wiki/Importing_an_image_as_a_texture

What's the difference between material and texture?

acs commented 4 years ago

Textures repository: https://www.texturex.com/

acs commented 4 years ago

https://twitter.com/voxelers/status/1281464649037357058

Next step is to start trying shaders in MV. It is pretty easy!

acs commented 4 years ago

But, what about shaders in Minecraft? Are they supported?

texture packs don't seem to include shaders: https://minecraft.gamepedia.com/Tutorials/Creating_a_resource_pack

So probably we need mods to add shaders.

https://www.planetminecraft.com/blog/textureresource-pack-creation---an-indepth-tutorial/ «Although using renders or shaders for the images to let the pack look better, it is recommended to use also default Minecraft (thus unmodded) screenshots as images as not everyone uses these modifications.»

It seems that you can download shaders and modify the GLSL included: https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/mods-discussion/2465939-how-to-make-a-glsl-shader-pack

So probably, at some point someone shows howto load GLSL code in Minecraft shaders, and then it is just a matter of implementing in GLSL the shaders logic you want.

https://gamedevelopment.tutsplus.com/tutorials/a-beginners-guide-to-coding-graphics-shaders--cms-23313

GLSL Tutorial: http://www.lighthouse3d.com/tutorials/glsl-tutorial/

Howto write shaders in Minecraft: https://www.reddit.com/r/Minecraft/comments/7hwaxk/where_can_i_get_started_coding_shaders_in/dquf582/

It seems that using https://optifine.net/home and writing GLSL shaders is the way to go.

There are shaders in MC for the Spectator Mode: https://minecraft.gamepedia.com/Shaders

And inside the minecraft jar you can find:

[1.16.1]$ jar tvf 1.16.1.jar | grep shader
   701 Wed Jun 24 10:31:12 CEST 2020 assets/minecraft/shaders/program/notch.fsh
  1217 Wed Jun 24 10:31:12 CEST 2020 assets/minecraft/shaders/program/spider.json
   640 Wed Jun 24 10:31:12 CEST 2020 assets/minecraft/shaders/program/blit.json
   614 Wed Jun 24 10:31:12 CEST 2020 assets/minecraft/shaders/program/outline.json
...

and you can see it is using GLSL shaders:

[mc]$ cat assets/minecraft/shaders/program/antialias.fsh
#version 110

uniform sampler2D DiffuseSampler;

varying vec2 texCoord;
varying vec2 oneTexel;

void main(){
    vec4 c  = texture2D (DiffuseSampler, texCoord);
    vec4 u1 = texture2D (DiffuseSampler, texCoord + vec2 (              0.0, -oneTexel.y      ));
...
    vec4 color = mix (v5, v6, 0.5);
    gl_FragColor = vec4(color.rgb, 1.0);
}
acs commented 4 years ago

The renderer in MagicaVoxel it is based on ray tracing: interactive path tracing renderer. https://medium.com/@junyingw/future-of-gaming-rasterization-vs-ray-tracing-vs-path-tracing-32b334510f1f

acs commented 4 years ago

Textures

The idea is simple: in order to increase the resolution of the surface in the polys, a 2D texture is mapped over them. The key is to define which (u,v) of the texture use in each coordinate (x, y, z) of the poly. The pixels in a texture are called texels, and to distinct the coordinates with the polys (x, y) are called (u, v) (for example Blender does that). OpenGL uses (s,t). The values for values for a texel coordinate goes from 0 to 1 (they are normalized).

m(x,y,z)->c(u,v)->(r,g,b,a)

acs commented 4 years ago

Let's focus in creating a texturepack for Minecraft:

I have a first experience creating a skin for my player, that it is creating a texture for my player.

acs commented 4 years ago

Creating a Resource Pack in Minecraft

https://minecraft.gamepedia.com/Tutorials/Creating_a_resource_pack Resource packs can modify textures, models, animations, music, sounds, user interfaces, and languages.

Ok, creeper edition completed:

creeper

Screenshot from 2020-07-16 07-17-46

Screenshot from 2020-07-16 07-17-07

It is a bit tricky to understand the texture 2D map: the idea is to imaging you are wrapping the cubes.

Screenshot from 2020-07-16 07-20-44

The creeper has:

Screenshot from 2020-07-16 07-32-53

acs commented 4 years ago

Changing textures in MC is interesting because the idea is the same than in other 3D tools. Let's do something similar in Blender.

acs commented 4 years ago

I am going to stop the texture research for a while.

acs commented 4 years ago

In Ray Tracing textures are also used: http://bentonian.com/Lectures/AdvGraph1314/3.%20Ray%20tracing%20-%20color%20and%20texture.pdf

acs commented 4 years ago

Ok, #133 and #134 will be where the research will continue.

And also with #135 and #136 for Blender.

acs commented 4 years ago

Ok, time to close this generic issue now that the more create ones have been created.