Fix dminer example

This commit is contained in:
Grim Maple 2022-10-22 15:12:32 +03:00
parent 2915bece47
commit 7a585654ee
5 changed files with 76 additions and 76 deletions

View File

@ -197,7 +197,7 @@ struct SmallChunk {
} }
/// return chunk position in world (aligned to chunk origin) /// return chunk position in world (aligned to chunk origin)
@property ref const(Vector3d) position() { @property const(Vector3d) position() {
return _pos; return _pos;
} }

View File

@ -70,27 +70,27 @@ out vec4 _fragColor;
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Varyings // Varyings
#if defined(VERTEX_COLOR) #if defined(VERTEX_COLOR)
varying vec3 v_color; in vec3 v_color;
#endif #endif
#if defined(LIGHTMAP) #if defined(LIGHTMAP)
varying vec2 v_texCoord1; in vec2 v_texCoord1;
#endif #endif
#if defined(LIGHTING) #if defined(LIGHTING)
varying vec3 v_normalVector; in vec3 v_normalVector;
#if (POINT_LIGHT_COUNT > 0) #if (POINT_LIGHT_COUNT > 0)
varying vec3 v_vertexToPointLightDirection[POINT_LIGHT_COUNT]; in vec3 v_vertexToPointLightDirection[POINT_LIGHT_COUNT];
#endif #endif
#if (SPOT_LIGHT_COUNT > 0) #if (SPOT_LIGHT_COUNT > 0)
varying vec3 v_vertexToSpotLightDirection[SPOT_LIGHT_COUNT]; in vec3 v_vertexToSpotLightDirection[SPOT_LIGHT_COUNT];
#endif #endif
#if defined(SPECULAR) #if defined(SPECULAR)
varying vec3 v_cameraDirection; in vec3 v_cameraDirection;
#endif #endif
#include "lighting.frag" #include "lighting.frag"
@ -98,7 +98,7 @@ varying vec3 v_cameraDirection;
#endif #endif
#if defined(CLIP_PLANE) #if defined(CLIP_PLANE)
varying float v_clipDistance; in float v_clipDistance;
#endif #endif
void main() void main()
@ -106,7 +106,7 @@ void main()
#if defined(CLIP_PLANE) #if defined(CLIP_PLANE)
if(v_clipDistance < 0.0) discard; if(v_clipDistance < 0.0) discard;
#endif #endif
#if defined(LIGHTING) #if defined(LIGHTING)
#if defined(VERTEX_COLOR) #if defined(VERTEX_COLOR)
@ -114,19 +114,19 @@ void main()
#else #else
_baseColor = u_diffuseColor; _baseColor = u_diffuseColor;
#endif #endif
_fragColor.a = _baseColor.a; _fragColor.a = _baseColor.a;
_fragColor.rgb = getLitPixel(); _fragColor.rgb = getLitPixel();
#else #else
#if defined(VERTEX_COLOR) #if defined(VERTEX_COLOR)
_fragColor.rgb = v_color; _fragColor.rgb = v_color;
_fragColor.a = 1.0; _fragColor.a = 1.0;
#else #else
_fragColor = u_diffuseColor; _fragColor = u_diffuseColor;
#endif #endif
#endif #endif
#if defined(LIGHTMAP) #if defined(LIGHTMAP)

View File

@ -13,23 +13,23 @@
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Attributes // Attributes
attribute vec4 a_position; in vec4 a_position;
#if defined(SKINNING) #if defined(SKINNING)
attribute vec4 a_blendWeights; in vec4 a_blendWeights;
attribute vec4 a_blendIndices; in vec4 a_blendIndices;
#endif #endif
#if defined(LIGHTMAP) #if defined(LIGHTMAP)
attribute vec2 a_texCoord1; in vec2 a_texCoord1;
#endif #endif
#if defined(LIGHTING) #if defined(LIGHTING)
attribute vec3 a_normal; in vec3 a_normal;
#endif #endif
#if defined(VERTEX_COLOR) #if defined(VERTEX_COLOR)
attribute vec3 a_color; in vec3 a_color;
#endif #endif
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -51,7 +51,7 @@ uniform mat4 u_worldViewMatrix;
uniform vec3 u_directionalLightDirection[DIRECTIONAL_LIGHT_COUNT]; uniform vec3 u_directionalLightDirection[DIRECTIONAL_LIGHT_COUNT];
#endif #endif
#if (POINT_LIGHT_COUNT > 0) #if (POINT_LIGHT_COUNT > 0)
uniform vec3 u_pointLightPosition[POINT_LIGHT_COUNT]; uniform vec3 u_pointLightPosition[POINT_LIGHT_COUNT];
#endif #endif
@ -74,31 +74,31 @@ uniform vec4 u_clipPlane;
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Varyings // Varyings
#if defined(LIGHTMAP) #if defined(LIGHTMAP)
varying vec2 v_texCoord1; out vec2 v_texCoord1;
#endif #endif
#if defined(VERTEX_COLOR) #if defined(VERTEX_COLOR)
varying vec3 v_color; out vec3 v_color;
#endif #endif
#if defined(LIGHTING) #if defined(LIGHTING)
varying vec3 v_normalVector; out vec3 v_normalVector;
#if (DIRECTIONAL_LIGHT_COUNT > 0) #if (DIRECTIONAL_LIGHT_COUNT > 0)
varying vec3 v_lightDirection[DIRECTIONAL_LIGHT_COUNT]; out vec3 v_lightDirection[DIRECTIONAL_LIGHT_COUNT];
#endif #endif
#if (POINT_LIGHT_COUNT > 0) #if (POINT_LIGHT_COUNT > 0)
varying vec3 v_vertexToPointLightDirection[POINT_LIGHT_COUNT]; out vec3 v_vertexToPointLightDirection[POINT_LIGHT_COUNT];
#endif #endif
#if (SPOT_LIGHT_COUNT > 0) #if (SPOT_LIGHT_COUNT > 0)
varying vec3 v_vertexToSpotLightDirection[SPOT_LIGHT_COUNT]; out vec3 v_vertexToSpotLightDirection[SPOT_LIGHT_COUNT];
#endif #endif
#if defined(SPECULAR) #if defined(SPECULAR)
varying vec3 v_cameraDirection; out vec3 v_cameraDirection;
#endif #endif
#include "lighting.vert" #include "lighting.vert"
@ -108,11 +108,11 @@ varying vec3 v_cameraDirection;
#if defined(SKINNING) #if defined(SKINNING)
#include "skinning.vert" #include "skinning.vert"
#else #else
#include "skinning-none.vert" #include "skinning-none.vert"
#endif #endif
#if defined(CLIP_PLANE) #if defined(CLIP_PLANE)
varying float v_clipDistance; out float v_clipDistance;
#endif #endif
void main() void main()
@ -137,13 +137,13 @@ void main()
#if defined(LIGHTMAP) #if defined(LIGHTMAP)
v_texCoord1 = a_texCoord1; v_texCoord1 = a_texCoord1;
#endif #endif
// Pass the vertex color // Pass the vertex color
#if defined(VERTEX_COLOR) #if defined(VERTEX_COLOR)
v_color = a_color; v_color = a_color;
#endif #endif
#if defined(CLIP_PLANE) #if defined(CLIP_PLANE)
v_clipDistance = dot(u_worldMatrix * position, u_clipPlane); v_clipDistance = dot(u_worldMatrix * position, u_clipPlane);
#endif #endif
} }

View File

@ -84,35 +84,35 @@ vec4 _baseColor;
out vec4 _fragColor; out vec4 _fragColor;
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Varyings // Varyings
varying vec2 v_texCoord; in vec2 v_texCoord;
#if defined(LIGHTMAP) #if defined(LIGHTMAP)
varying vec2 v_texCoord1; in vec2 v_texCoord1;
#endif #endif
#if defined(LIGHTING) #if defined(LIGHTING)
#if !defined(BUMPED) #if !defined(BUMPED)
varying vec3 v_normalVector; in vec3 v_normalVector;
#endif #endif
#if defined(BUMPED) && (DIRECTIONAL_LIGHT_COUNT > 0) #if defined(BUMPED) && (DIRECTIONAL_LIGHT_COUNT > 0)
varying vec3 v_directionalLightDirection[DIRECTIONAL_LIGHT_COUNT]; in vec3 v_directionalLightDirection[DIRECTIONAL_LIGHT_COUNT];
#endif #endif
#if (POINT_LIGHT_COUNT > 0) #if (POINT_LIGHT_COUNT > 0)
varying vec3 v_vertexToPointLightDirection[POINT_LIGHT_COUNT]; in vec3 v_vertexToPointLightDirection[POINT_LIGHT_COUNT];
#endif #endif
#if (SPOT_LIGHT_COUNT > 0) #if (SPOT_LIGHT_COUNT > 0)
varying vec3 v_vertexToSpotLightDirection[SPOT_LIGHT_COUNT]; in vec3 v_vertexToSpotLightDirection[SPOT_LIGHT_COUNT];
#if defined(BUMPED) #if defined(BUMPED)
varying vec3 v_spotLightDirection[SPOT_LIGHT_COUNT]; in vec3 v_spotLightDirection[SPOT_LIGHT_COUNT];
#endif #endif
#endif #endif
#if defined(SPECULAR) #if defined(SPECULAR)
varying vec3 v_cameraDirection; in vec3 v_cameraDirection;
#endif #endif
#include "lighting.frag" #include "lighting.frag"
@ -120,11 +120,11 @@ varying vec3 v_cameraDirection;
#endif #endif
#if defined(CLIP_PLANE) #if defined(CLIP_PLANE)
varying float v_clipDistance; in float v_clipDistance;
#endif #endif
#if defined(FOG) #if defined(FOG)
varying vec4 viewSpace; in vec4 viewSpace;
#endif #endif
void main() void main()
@ -145,7 +145,7 @@ void main()
fogFactor = clamp( fogFactor, 0.0, 1.0 ); fogFactor = clamp( fogFactor, 0.0, 1.0 );
_baseColor = mix(u_fogColor, _baseColor, fogFactor); _baseColor = mix(u_fogColor, _baseColor, fogFactor);
#endif #endif
_fragColor.a = _baseColor.a; _fragColor.a = _baseColor.a;
#if defined(TEXTURE_DISCARD_ALPHA) #if defined(TEXTURE_DISCARD_ALPHA)

View File

@ -13,25 +13,25 @@
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Atributes // Atributes
attribute vec4 a_position; in vec4 a_position;
#if defined(SKINNING) #if defined(SKINNING)
attribute vec4 a_blendWeights; in vec4 a_blendWeights;
attribute vec4 a_blendIndices; in vec4 a_blendIndices;
#endif #endif
attribute vec2 a_texCoord; in vec2 a_texCoord;
#if defined(LIGHTMAP) #if defined(LIGHTMAP)
attribute vec2 a_texCoord1; in vec2 a_texCoord1;
#endif #endif
#if defined(LIGHTING) #if defined(LIGHTING)
attribute vec3 a_normal; in vec3 a_normal;
#if defined(BUMPED) #if defined(BUMPED)
attribute vec3 a_tangent; in vec3 a_tangent;
attribute vec3 a_binormal; in vec3 a_binormal;
#endif #endif
#endif #endif
@ -58,7 +58,7 @@ uniform vec3 u_directionalLightDirection[DIRECTIONAL_LIGHT_COUNT];
uniform vec3 u_pointLightPosition[POINT_LIGHT_COUNT]; uniform vec3 u_pointLightPosition[POINT_LIGHT_COUNT];
#endif #endif
#if (SPOT_LIGHT_COUNT > 0) #if (SPOT_LIGHT_COUNT > 0)
uniform vec3 u_spotLightPosition[SPOT_LIGHT_COUNT]; uniform vec3 u_spotLightPosition[SPOT_LIGHT_COUNT];
#if defined(BUMPED) #if defined(BUMPED)
uniform vec3 u_spotLightDirection[SPOT_LIGHT_COUNT]; uniform vec3 u_spotLightDirection[SPOT_LIGHT_COUNT];
@ -92,35 +92,35 @@ uniform vec4 u_clipPlane;
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// Varyings // Varyings
varying vec2 v_texCoord; out vec2 v_texCoord;
#if defined(LIGHTMAP) #if defined(LIGHTMAP)
varying vec2 v_texCoord1; out vec2 v_texCoord1;
#endif #endif
#if defined(LIGHTING) #if defined(LIGHTING)
#if !defined(BUMPED) #if !defined(BUMPED)
varying vec3 v_normalVector; out vec3 v_normalVector;
#endif #endif
#if defined(BUMPED) && (DIRECTIONAL_LIGHT_COUNT > 0) #if defined(BUMPED) && (DIRECTIONAL_LIGHT_COUNT > 0)
varying vec3 v_directionalLightDirection[DIRECTIONAL_LIGHT_COUNT]; out vec3 v_directionalLightDirection[DIRECTIONAL_LIGHT_COUNT];
#endif #endif
#if (POINT_LIGHT_COUNT > 0) #if (POINT_LIGHT_COUNT > 0)
varying vec3 v_vertexToPointLightDirection[POINT_LIGHT_COUNT]; out vec3 v_vertexToPointLightDirection[POINT_LIGHT_COUNT];
#endif #endif
#if (SPOT_LIGHT_COUNT > 0) #if (SPOT_LIGHT_COUNT > 0)
varying vec3 v_vertexToSpotLightDirection[SPOT_LIGHT_COUNT]; out vec3 v_vertexToSpotLightDirection[SPOT_LIGHT_COUNT];
#if defined(BUMPED) #if defined(BUMPED)
varying vec3 v_spotLightDirection[SPOT_LIGHT_COUNT]; out vec3 v_spotLightDirection[SPOT_LIGHT_COUNT];
#endif #endif
#endif #endif
#if defined(SPECULAR) #if defined(SPECULAR)
varying vec3 v_cameraDirection; out vec3 v_cameraDirection;
#endif #endif
#include "lighting.vert" #include "lighting.vert"
@ -130,15 +130,15 @@ varying vec3 v_cameraDirection;
#if defined(SKINNING) #if defined(SKINNING)
#include "skinning.vert" #include "skinning.vert"
#else #else
#include "skinning-none.vert" #include "skinning-none.vert"
#endif #endif
#if defined(CLIP_PLANE) #if defined(CLIP_PLANE)
varying float v_clipDistance; out float v_clipDistance;
#endif #endif
#if defined(FOG) #if defined(FOG)
varying vec4 viewSpace; out vec4 viewSpace;
#endif #endif
void main() void main()
@ -154,39 +154,39 @@ void main()
// Transform the normal, tangent and binormals to view space. // Transform the normal, tangent and binormals to view space.
mat3 inverseTransposeWorldViewMatrix = mat3(u_inverseTransposeWorldViewMatrix[0].xyz, u_inverseTransposeWorldViewMatrix[1].xyz, u_inverseTransposeWorldViewMatrix[2].xyz); mat3 inverseTransposeWorldViewMatrix = mat3(u_inverseTransposeWorldViewMatrix[0].xyz, u_inverseTransposeWorldViewMatrix[1].xyz, u_inverseTransposeWorldViewMatrix[2].xyz);
vec3 normalVector = normalize(inverseTransposeWorldViewMatrix * normal); vec3 normalVector = normalize(inverseTransposeWorldViewMatrix * normal);
#if defined(BUMPED) #if defined(BUMPED)
vec3 tangent = getTangent(); vec3 tangent = getTangent();
vec3 binormal = getBinormal(); vec3 binormal = getBinormal();
vec3 tangentVector = normalize(inverseTransposeWorldViewMatrix * tangent); vec3 tangentVector = normalize(inverseTransposeWorldViewMatrix * tangent);
vec3 binormalVector = normalize(inverseTransposeWorldViewMatrix * binormal); vec3 binormalVector = normalize(inverseTransposeWorldViewMatrix * binormal);
mat3 tangentSpaceTransformMatrix = mat3(tangentVector.x, binormalVector.x, normalVector.x, tangentVector.y, binormalVector.y, normalVector.y, tangentVector.z, binormalVector.z, normalVector.z); mat3 tangentSpaceTransformMatrix = mat3(tangentVector.x, binormalVector.x, normalVector.x, tangentVector.y, binormalVector.y, normalVector.y, tangentVector.z, binormalVector.z, normalVector.z);
applyLight(position, tangentSpaceTransformMatrix); applyLight(position, tangentSpaceTransformMatrix);
#else #else
v_normalVector = normalVector; v_normalVector = normalVector;
applyLight(position); applyLight(position);
#endif #endif
#endif #endif
v_texCoord = a_texCoord; v_texCoord = a_texCoord;
#if defined(TEXTURE_REPEAT) #if defined(TEXTURE_REPEAT)
v_texCoord *= u_textureRepeat; v_texCoord *= u_textureRepeat;
#endif #endif
#if defined(TEXTURE_OFFSET) #if defined(TEXTURE_OFFSET)
v_texCoord += u_textureOffset; v_texCoord += u_textureOffset;
#endif #endif
#if defined(LIGHTMAP) #if defined(LIGHTMAP)
v_texCoord1 = a_texCoord1; v_texCoord1 = a_texCoord1;
#endif #endif
#if defined(CLIP_PLANE) #if defined(CLIP_PLANE)
v_clipDistance = dot(u_worldMatrix * position, u_clipPlane); v_clipDistance = dot(u_worldMatrix * position, u_clipPlane);
#endif #endif