forked from mirror/ObjToSchematic
Added support for block textures
This commit is contained in:
parent
e56c5ee61c
commit
ccfe27eae6
@ -49,3 +49,5 @@ You can either download the [latest release](https://github.com/LucasDower/ObjTo
|
||||
* Run `npm install`.
|
||||
* Run `npm start`.
|
||||
|
||||
# Disclaimer
|
||||
This is an non-commercial **unofficial** tool that is neither approved, endorsed, associated, nor connected to Mojang Studios. Block textures used are from Minecraft and usage complies with the [Mojang Studios Brand And Assets Guidelines](https://account.mojang.com/terms#brand).
|
BIN
resources/blocks/stone.png
Normal file
BIN
resources/blocks/stone.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 215 B |
@ -1,6 +1,8 @@
|
||||
precision mediump float;
|
||||
|
||||
varying vec4 v_colour;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
varying float v_lighting;
|
||||
varying vec4 v_occlusion;
|
||||
varying vec2 v_texcoord;
|
||||
|
||||
@ -16,7 +18,10 @@ void main() {
|
||||
|
||||
float g = v*(u*b + (1.0-u)*d) + (1.0-v)*(u*a + (1.0-u)*c);
|
||||
|
||||
gl_FragColor = vec4(v_colour.xyz * g, 1.0);
|
||||
vec3 diffuse = texture2D(u_texture, v_texcoord).rgb;
|
||||
gl_FragColor = vec4(diffuse * (v_lighting * g), 1.0);
|
||||
//gl_FragColor = vec4(vec3(v_lighting * g), 1.0);
|
||||
//gl_FragColor = vec4(v_colour.xyz * g, 1.0);
|
||||
//gl_FragColor = vec4(v_colour.xyz, 1.0);
|
||||
//gl_FragColor = vec4(vec3(g), 1.0);
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
uniform mat4 u_worldViewProjection;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
attribute vec4 position;
|
||||
attribute vec3 normal;
|
||||
attribute vec4 occlusion;
|
||||
attribute vec2 texcoord;
|
||||
|
||||
varying vec4 v_colour;
|
||||
varying float v_lighting;
|
||||
varying vec4 v_occlusion;
|
||||
varying vec2 v_texcoord;
|
||||
|
||||
@ -18,6 +19,6 @@ void main() {
|
||||
//float lighting = dot(light, abs(normal)) * (1.0 - occlusion * 0.2);
|
||||
//float lighting = 0.2 * occlusion;
|
||||
//v_colour = vec4(abs(normal), 1.0);
|
||||
v_colour = vec4(vec3(dot(light, abs(normal))), 1.0);
|
||||
v_lighting = dot(light, abs(normal));
|
||||
gl_Position = u_worldViewProjection * vec4(position.xyz, 1.0);
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ class Renderer {
|
||||
|
||||
this._debug = false;
|
||||
this._compiled = false;
|
||||
|
||||
this._blockTexture = twgl.createTexture(this._gl, { src: "resources/blocks/stone.png", mag: this._gl.NEAREST });
|
||||
}
|
||||
|
||||
|
||||
@ -132,7 +134,8 @@ class Renderer {
|
||||
|
||||
// Draw voxel register
|
||||
this._drawRegister(this._registerVoxels, this._gl.TRIANGLES, shaderManager.aoProgram, {
|
||||
u_worldViewProjection: this._camera.getWorldViewProjection()
|
||||
u_worldViewProjection: this._camera.getWorldViewProjection(),
|
||||
u_texture: this._blockTexture
|
||||
});
|
||||
|
||||
// Draw default register
|
||||
|
Loading…
Reference in New Issue
Block a user