Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Research textures and shaders #101

Closed
acs opened this issue Jun 17, 2020 · 15 comments
Closed

Research textures and shaders #101

acs opened this issue Jun 17, 2020 · 15 comments
Labels
research Research a Topic

Comments

@acs
Copy link
Contributor

acs commented Jun 17, 2020

And example with MagicaVoxel:

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

@acs acs added the research Research a Topic label Jun 17, 2020
@acs
Copy link
Contributor Author

acs commented Jul 9, 2020

@acs
Copy link
Contributor Author

acs commented Jul 9, 2020

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
Copy link
Contributor Author

acs commented Jul 10, 2020

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

@acs
Copy link
Contributor Author

acs commented Jul 10, 2020

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

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

@acs
Copy link
Contributor Author

acs commented Jul 13, 2020

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
Copy link
Contributor Author

acs commented Jul 13, 2020

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
Copy link
Contributor Author

acs commented Jul 14, 2020

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).

  • Mapping: m(x,y,z) -> (u,v)
  • Sampling/Color: c(u,v) -> (r,g,b,a)

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

@acs
Copy link
Contributor Author

acs commented Jul 15, 2020

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
Copy link
Contributor Author

acs commented Jul 16, 2020

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:

  • Head: A cube for the head with
  • Body: A rectangular prism
  • 4 Feet

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

@acs
Copy link
Contributor Author

acs commented Jul 16, 2020

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
Copy link
Contributor Author

acs commented Jul 30, 2020

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

@acs
Copy link
Contributor Author

acs commented Jul 30, 2020

@acs
Copy link
Contributor Author

acs commented Aug 8, 2020

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

And also with #135 and #136 for Blender.

@acs
Copy link
Contributor Author

acs commented Aug 8, 2020

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

@acs acs closed this as completed Aug 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
research Research a Topic
Projects
None yet
Development

No branches or pull requests

1 participant