diff --git a/client/shaders/nodes_shader/opengl_vertex.glsl b/client/shaders/nodes_shader/opengl_vertex.glsl index e5644b8b2..42a5f6cbf 100644 --- a/client/shaders/nodes_shader/opengl_vertex.glsl +++ b/client/shaders/nodes_shader/opengl_vertex.glsl @@ -14,36 +14,36 @@ varying vec3 eyeVec; varying vec3 lightVec; varying vec3 tsEyeVec; varying vec3 tsLightVec; -varying float generate_heightmaps; +varying float generate_heightmaps; const float e = 2.718281828459; const float BS = 10.0; -float smoothCurve(float x) -{ - return x * x * (3.0 - 2.0 * x); +float smoothCurve(float x) +{ + return x * x * (3.0 - 2.0 * x); } -float triangleWave(float x) -{ - return abs(fract(x + 0.5) * 2.0 - 1.0); +float triangleWave(float x) +{ + return abs(fract(x + 0.5) * 2.0 - 1.0); } -float smoothTriangleWave(float x) -{ - return smoothCurve(triangleWave(x)) * 2.0 - 1.0; +float smoothTriangleWave(float x) +{ + return smoothCurve(triangleWave(x)) * 2.0 - 1.0; } void main(void) { gl_TexCoord[0] = gl_MultiTexCoord0; - gl_TexCoord[0].y += 0.008; - -#if ((DRAW_TYPE == NDT_NORMAL || DRAW_TYPE == NDT_LIQUID || DRAW_TYPE == NDT_FLOWINGLIQUID) && GENERATE_NORMALMAPS) - generate_heightmaps = 1.0; -#else - generate_heightmaps = 0.0; -#endif - -#if ((MATERIAL_TYPE == TILE_MATERIAL_LIQUID_TRANSPARENT || MATERIAL_TYPE == TILE_MATERIAL_LIQUID_OPAQUE) && ENABLE_WAVING_WATER) + gl_TexCoord[0].y += 0.008; + +#if ((DRAW_TYPE == NDT_NORMAL || DRAW_TYPE == NDT_LIQUID || DRAW_TYPE == NDT_FLOWINGLIQUID) && GENERATE_NORMALMAPS) + generate_heightmaps = 1.0; +#else + generate_heightmaps = 0.0; +#endif + +#if ((MATERIAL_TYPE == TILE_MATERIAL_LIQUID_TRANSPARENT || MATERIAL_TYPE == TILE_MATERIAL_LIQUID_OPAQUE) && ENABLE_WAVING_WATER) vec4 pos = gl_Vertex; pos.y -= 2.0; @@ -87,33 +87,33 @@ void main(void) vPosition = gl_Position.xyz; worldPosition = (mWorld * gl_Vertex).xyz; - - // Don't generate heightmaps when too far from the eye - float dist = distance (worldPosition, eyePosition); - if (dist > 100.00) { - generate_heightmaps = 0.0; - } - + + // Don't generate heightmaps when too far from the eye + float dist = distance (worldPosition, eyePosition); + if (dist > 100.00) { + generate_heightmaps = 0.0; + } + vec3 sunPosition = vec3 (0.0, eyePosition.y * BS + 900.0, 0.0); vec3 normal, tangent, binormal; normal = normalize(gl_NormalMatrix * gl_Normal); - tangent = normalize(gl_NormalMatrix * gl_MultiTexCoord1.xyz); - binormal = normalize(gl_NormalMatrix * -gl_MultiTexCoord2.xyz); - - vec3 v; + tangent = normalize(gl_NormalMatrix * gl_MultiTexCoord1.xyz); + binormal = normalize(gl_NormalMatrix * -gl_MultiTexCoord2.xyz); + + vec3 v; lightVec = sunPosition - worldPosition; - v.x = dot(lightVec, tangent); - v.y = dot(lightVec, binormal); - v.z = dot(lightVec, normal); - tsLightVec = v; - - eyeVec = -(gl_ModelViewMatrix * gl_Vertex).xyz; - v.x = dot(eyeVec, tangent); - v.y = dot(eyeVec, binormal); - v.z = dot(eyeVec, normal); - tsEyeVec = v; + v.x = dot(lightVec, tangent); + v.y = dot(lightVec, binormal); + v.z = dot(lightVec, normal); + tsLightVec = v; + + eyeVec = -(gl_ModelViewMatrix * gl_Vertex).xyz; + v.x = dot(eyeVec, tangent); + v.y = dot(eyeVec, binormal); + v.z = dot(eyeVec, normal); + tsEyeVec = v; vec4 color; float day = gl_Color.r; diff --git a/client/shaders/water_surface_shader/opengl_vertex.glsl b/client/shaders/water_surface_shader/opengl_vertex.glsl index 53678800d..7ae517d8a 100644 --- a/client/shaders/water_surface_shader/opengl_vertex.glsl +++ b/client/shaders/water_surface_shader/opengl_vertex.glsl @@ -18,23 +18,23 @@ varying vec3 tsLightVec; const float e = 2.718281828459; const float BS = 10.0; -float smoothCurve(float x) -{ - return x * x * (3.0 - 2.0 * x); +float smoothCurve(float x) +{ + return x * x * (3.0 - 2.0 * x); } -float triangleWave(float x) -{ - return abs(fract( x + 0.5 ) * 2.0 - 1.0); +float triangleWave(float x) +{ + return abs(fract( x + 0.5 ) * 2.0 - 1.0); } -float smoothTriangleWave(float x) -{ - return smoothCurve(triangleWave( x )) * 2.0 - 1.0; +float smoothTriangleWave(float x) +{ + return smoothCurve(triangleWave( x )) * 2.0 - 1.0; } void main(void) { gl_TexCoord[0] = gl_MultiTexCoord0; - + #if (MATERIAL_TYPE == TILE_MATERIAL_LIQUID_TRANSPARENT || MATERIAL_TYPE == TILE_MATERIAL_LIQUID_OPAQUE) && ENABLE_WAVING_WATER vec4 pos = gl_Vertex; pos.y -= 2.0; diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp index 9c755b102..79e3e81ba 100644 --- a/src/mapblock_mesh.cpp +++ b/src/mapblock_mesh.cpp @@ -1213,7 +1213,7 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset): p.tile.applyMaterialOptions(material); } } - + // Create meshbuffer scene::SMeshBufferTangents *buf = new scene::SMeshBufferTangents(); // Set material diff --git a/src/mesh.cpp b/src/mesh.cpp index 6c7c6d37b..4f70b7fa2 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -106,7 +106,7 @@ void scaleMesh(scene::IMesh *mesh, v3f scale) const u32 stride = getVertexPitchFromType(buf->getVertexType()); u32 vertex_count = buf->getVertexCount(); u8 *vertices = (u8 *)buf->getVertices(); - for (u32 i = 0; i < vertex_count; i++) + for (u32 i = 0; i < vertex_count; i++) ((video::S3DVertex *)(vertices + i * stride))->Pos *= scale; buf->recalculateBoundingBox(); @@ -134,7 +134,7 @@ void translateMesh(scene::IMesh *mesh, v3f vec) const u32 stride = getVertexPitchFromType(buf->getVertexType()); u32 vertex_count = buf->getVertexCount(); u8 *vertices = (u8 *)buf->getVertices(); - for (u32 i = 0; i < vertex_count; i++) + for (u32 i = 0; i < vertex_count; i++) ((video::S3DVertex *)(vertices + i * stride))->Pos += vec; buf->recalculateBoundingBox(); @@ -160,7 +160,7 @@ void setMeshColor(scene::IMesh *mesh, const video::SColor &color) const u32 stride = getVertexPitchFromType(buf->getVertexType()); u32 vertex_count = buf->getVertexCount(); u8 *vertices = (u8 *)buf->getVertices(); - for (u32 i = 0; i < vertex_count; i++) + for (u32 i = 0; i < vertex_count; i++) ((video::S3DVertex *)(vertices + i * stride))->Color = color; } }