-#version 120\r
-\r
uniform sampler2D baseTexture;\r
uniform sampler2D normalTexture;\r
uniform sampler2D useNormalmap;\r
\r
-uniform float enableBumpmapping;\r
-uniform float enableParallaxOcclusion;\r
-uniform float parallaxOcclusionScale;\r
-uniform float parallaxOcclusionBias;\r
-\r
-\r
uniform vec4 skyBgColor;\r
uniform float fogDistance;\r
+uniform vec3 eyePosition;\r
\r
varying vec3 vPosition;\r
-varying vec3 tsEyeVec;\r
varying vec3 eyeVec;\r
\r
+#ifdef ENABLE_PARALLAX_OCCLUSION\r
+varying vec3 tsEyeVec;\r
+#endif\r
+\r
const float e = 2.718281828459;\r
\r
void main (void)\r
{\r
vec3 color;\r
vec2 uv = gl_TexCoord[0].st;\r
- \r
-#ifdef NORMALS\r
+\r
+#ifdef USE_NORMALMAPS\r
+ float use_normalmap = texture2D(useNormalmap,vec2(1.0,1.0)).r;\r
+#endif\r
+\r
+#ifdef ENABLE_PARALLAX_OCCLUSION\r
float height;\r
vec2 tsEye = vec2(tsEyeVec.x,-tsEyeVec.y);\r
- \r
- float use_normalmap = texture2D(useNormalmap,vec2(1.0,1.0)).r;\r
- float enable_bumpmapping = enableBumpmapping;\r
- \r
- if ((enableParallaxOcclusion == 1.0) && (use_normalmap > 0.0)) {\r
+\r
+ if (use_normalmap > 0.0) {\r
float map_height = texture2D(normalTexture, uv).a;\r
if (map_height < 1.0){\r
- float height = parallaxOcclusionScale * map_height - parallaxOcclusionBias;\r
+ float height = PARALLAX_OCCLUSION_SCALE * map_height - PARALLAX_OCCLUSION_BIAS;\r
uv = uv + height * tsEye;\r
}\r
}\r
+#endif\r
\r
- if ((enable_bumpmapping == 1.0) && (use_normalmap > 0.0)) {\r
+#ifdef ENABLE_BUMPMAPPING\r
+ if (use_normalmap > 0.0) {\r
vec3 base = texture2D(baseTexture, uv).rgb;\r
vec3 vVec = normalize(eyeVec);\r
vec3 bump = normalize(texture2D(normalTexture, uv).xyz * 2.0 - 1.0);\r
float d = max(0.0, min(vPosition.z / fogDistance * 1.5 - 0.6, 1.0));\r
col = mix(col, skyBgColor, d);\r
}\r
- gl_FragColor = vec4(col.r, col.g, col.b, alpha); \r
+ gl_FragColor = vec4(col.r, col.g, col.b, alpha);\r
}\r
-#version 120\r
-\r
uniform mat4 mWorldViewProj;\r
uniform mat4 mInvWorld;\r
uniform mat4 mTransWorld;\r
\r
varying vec3 vPosition;\r
varying vec3 eyeVec;\r
+\r
+#ifdef ENABLE_PARALLAX_OCCLUSION\r
varying vec3 tsEyeVec;\r
+#endif\r
\r
void main(void)\r
{\r
gl_Position = mWorldViewProj * gl_Vertex;\r
vPosition = (mWorldViewProj * gl_Vertex).xyz;\r
+ eyeVec = (gl_ModelViewMatrix * gl_Vertex).xyz;\r
\r
- vec3 normal,tangent,binormal; \r
+#ifdef ENABLE_PARALLAX_OCCLUSION\r
+ vec3 normal,tangent,binormal;\r
normal = normalize(gl_NormalMatrix * gl_Normal);\r
\r
if (gl_Normal.x > 0.5) {\r
tangent = normalize(gl_NormalMatrix * vec3(-1.0, 0.0, 0.0));\r
binormal = normalize(gl_NormalMatrix * vec3( 0.0, -1.0, 0.0));\r
}\r
- \r
- mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,\r
- tangent.y, binormal.y, normal.y,\r
- tangent.z, binormal.z, normal.z);\r
\r
- eyeVec = (gl_ModelViewMatrix * gl_Vertex).xyz;\r
+ mat3 tbnMatrix = mat3( tangent.x, binormal.x, normal.x,\r
+ tangent.y, binormal.y, normal.y,\r
+ tangent.z, binormal.z, normal.z);\r
+\r
tsEyeVec = normalize(eyeVec * tbnMatrix);\r
- \r
+#endif\r
+\r
vec4 color;\r
//color = vec4(1.0, 1.0, 1.0, 1.0);\r
\r
-#version 120\r
-\r
uniform sampler2D baseTexture;\r
uniform sampler2D normalTexture;\r
uniform sampler2D useNormalmap;\r
\r
-uniform float enableBumpmapping;\r
-\r
uniform vec4 skyBgColor;\r
uniform float fogDistance;\r
uniform vec3 eyePosition;\r
\r
varying vec3 vPosition;\r
varying vec3 eyeVec;\r
-varying vec4 vColor;\r
\r
const float e = 2.718281828459;\r
\r
vec3 color;\r
vec2 uv = gl_TexCoord[0].st;\r
\r
-#ifdef NORMALS\r
+#ifdef USE_NORMALMAPS\r
float use_normalmap = texture2D(useNormalmap,vec2(1.0,1.0)).r;\r
- float enable_bumpmapping = enableBumpmapping;\r
+#endif\r
\r
- if ((enable_bumpmapping == 1.0) && (use_normalmap > 0.0)) {\r
+#ifdef ENABLE_BUMPMAPPING\r
+ if (use_normalmap > 0.0) {\r
vec3 base = texture2D(baseTexture, uv).rgb;\r
vec3 vVec = normalize(eyeVec);\r
vec3 bump = normalize(texture2D(normalTexture, uv).xyz * 2.0 - 1.0);\r
float d = max(0.0, min(vPosition.z / fogDistance * 1.5 - 0.6, 1.0));\r
col = mix(col, skyBgColor, d);\r
}\r
- gl_FragColor = vec4(col.r, col.g, col.b, alpha); \r
+ gl_FragColor = vec4(col.r, col.g, col.b, alpha);\r
}\r
-#version 120\r
-\r
uniform mat4 mWorldViewProj;\r
uniform mat4 mInvWorld;\r
uniform mat4 mTransWorld;\r
uniform float dayNightRatio;\r
uniform float animationTimer;\r
\r
-uniform float enableWavingLeaves;\r
uniform vec3 eyePosition;\r
\r
varying vec3 vPosition;\r
varying vec3 eyeVec;\r
\r
-float smoothCurve( float x ) { \r
- return x * x *( 3.0 - 2.0 * x ); \r
-} \r
-float triangleWave( float x ) { \r
- return abs( fract( x + 0.5 ) * 2.0 - 1.0 ); \r
-} \r
-float smoothTriangleWave( float x ) { \r
- return smoothCurve( triangleWave( x ) ) * 2.0 - 1.0; \r
-} \r
+#ifdef ENABLE_WAVING_LEAVES\r
+float smoothCurve( float x ) {\r
+ return x * x *( 3.0 - 2.0 * x );\r
+}\r
+float triangleWave( float x ) {\r
+ return abs( fract( x + 0.5 ) * 2.0 - 1.0 );\r
+}\r
+float smoothTriangleWave( float x ) {\r
+ return smoothCurve( triangleWave( x ) ) * 2.0 - 1.0;\r
+}\r
+#endif\r
\r
void main(void)\r
{\r
gl_TexCoord[0] = gl_MultiTexCoord0;\r
- if (enableWavingLeaves == 1.0){ \r
- vec4 pos = gl_Vertex;\r
- vec4 pos2 = mTransWorld*gl_Vertex;\r
- pos.x += (smoothTriangleWave(animationTimer*10.0 + pos2.x * 0.01 + pos2.z * 0.01) * 2.0 - 1.0) * 0.4;\r
- pos.y += (smoothTriangleWave(animationTimer*15.0 + pos2.x * -0.01 + pos2.z * -0.01) * 2.0 - 1.0) * 0.2;\r
- pos.z += (smoothTriangleWave(animationTimer*10.0 + pos2.x * -0.01 + pos2.z * -0.01) * 2.0 - 1.0) * 0.4;\r
- gl_Position = mWorldViewProj * pos;\r
- }\r
- else \r
- gl_Position = mWorldViewProj * gl_Vertex;\r
+\r
+#ifdef ENABLE_WAVING_LEAVES\r
+ vec4 pos = gl_Vertex;\r
+ vec4 pos2 = mTransWorld*gl_Vertex;\r
+ pos.x += (smoothTriangleWave(animationTimer*10.0 + pos2.x * 0.01 + pos2.z * 0.01) * 2.0 - 1.0) * 0.4;\r
+ pos.y += (smoothTriangleWave(animationTimer*15.0 + pos2.x * -0.01 + pos2.z * -0.01) * 2.0 - 1.0) * 0.2;\r
+ pos.z += (smoothTriangleWave(animationTimer*10.0 + pos2.x * -0.01 + pos2.z * -0.01) * 2.0 - 1.0) * 0.4;\r
+ gl_Position = mWorldViewProj * pos;\r
+#else\r
+ gl_Position = mWorldViewProj * gl_Vertex;\r
+#endif\r
\r
vPosition = (mWorldViewProj * gl_Vertex).xyz;\r
\r
-#version 120\r
-\r
uniform sampler2D baseTexture;\r
uniform sampler2D normalTexture;\r
uniform sampler2D useNormalmap;\r
\r
-uniform float enableBumpmapping;\r
-\r
uniform vec4 skyBgColor;\r
uniform float fogDistance;\r
uniform vec3 eyePosition;\r
{\r
vec3 color;\r
vec2 uv = gl_TexCoord[0].st;\r
- \r
-#ifdef NORMALS\r
+\r
+#ifdef USE_NORMALMAPS\r
float use_normalmap = texture2D(useNormalmap,vec2(1.0,1.0)).r;\r
- float enable_bumpmapping = enableBumpmapping;\r
+#endif\r
\r
- if ((enable_bumpmapping == 1.0) && (use_normalmap > 0.0)) {\r
+#ifdef ENABLE_BUMPMAPPING\r
+ if (use_normalmap > 0.0) {\r
vec3 base = texture2D(baseTexture, uv).rgb;\r
vec3 vVec = normalize(eyeVec);\r
vec3 bump = normalize(texture2D(normalTexture, uv).xyz * 2.0 - 1.0);\r
float d = max(0.0, min(vPosition.z / fogDistance * 1.5 - 0.6, 1.0));\r
alpha = mix(alpha, 0.0, d);\r
}\r
- gl_FragColor = vec4(col.r, col.g, col.b, alpha); \r
+ gl_FragColor = vec4(col.r, col.g, col.b, alpha);\r
}\r
-#version 120\r
-\r
uniform mat4 mWorldViewProj;\r
uniform mat4 mInvWorld;\r
uniform mat4 mTransWorld;\r
uniform float dayNightRatio;\r
uniform float animationTimer;\r
\r
-uniform float enableWavingWater;\r
-uniform float waterWaveLength;\r
-uniform float waterWaveHeight;\r
-uniform float waterWaveSpeed;\r
-\r
uniform vec3 eyePosition;\r
\r
varying vec3 vPosition;\r
\r
void main(void)\r
{\r
- if (enableWavingWater == 1.0){\r
- vec4 pos2 = gl_Vertex;\r
- pos2.y -= 2.0;\r
- pos2.y -= sin (pos2.z/waterWaveLength + animationTimer * waterWaveSpeed * waterWaveLength) * waterWaveHeight\r
- + sin ((pos2.z/waterWaveLength + animationTimer * waterWaveSpeed * waterWaveLength) / 7.0) * waterWaveHeight;\r
- gl_Position = mWorldViewProj * pos2;\r
- } else\r
- gl_Position = mWorldViewProj * gl_Vertex;\r
+#ifdef ENABLE_WAVING_WATER\r
+ vec4 pos2 = gl_Vertex;\r
+ pos2.y -= 2.0;\r
+ pos2.y -= sin (pos2.z/WATER_WAVE_LENGTH + animationTimer * WATER_WAVE_SPEED * WATER_WAVE_LENGTH) * WATER_WAVE_HEIGHT\r
+ + sin ((pos2.z/WATER_WAVE_LENGTH + animationTimer * WATER_WAVE_SPEED * WATER_WAVE_LENGTH) / 7.0) * WATER_WAVE_HEIGHT;\r
+ gl_Position = mWorldViewProj * pos2;\r
+#else\r
+ gl_Position = mWorldViewProj * gl_Vertex;\r
+#endif\r
\r
eyeVec = (gl_ModelViewMatrix * gl_Vertex).xyz;\r
vPosition = (mWorldViewProj * gl_Vertex).xyz;\r
-#version 120\r
-\r
uniform sampler2D baseTexture;\r
uniform sampler2D normalTexture;\r
uniform sampler2D useNormalmap;\r
\r
-uniform float enableBumpmapping;\r
-\r
uniform vec4 skyBgColor;\r
uniform float fogDistance;\r
uniform vec3 eyePosition;\r
{\r
vec3 color;\r
vec2 uv = gl_TexCoord[0].st;\r
- \r
-#ifdef NORMALS\r
+\r
+#ifdef USE_NORMALMAPS\r
float use_normalmap = texture2D(useNormalmap,vec2(1.0,1.0)).r;\r
- float enable_bumpmapping = enableBumpmapping;\r
+#endif\r
\r
- if ((enable_bumpmapping == 1.0) && (use_normalmap > 0.0)) {\r
+#ifdef ENABLE_BUMPMAPPING\r
+ if (use_normalmap > 0.0) {\r
vec3 base = texture2D(baseTexture, uv).rgb;\r
vec3 vVec = normalize(eyeVec);\r
vec3 bump = normalize(texture2D(normalTexture, uv).xyz * 2.0 - 1.0);\r
float d = max(0.0, min(vPosition.z / fogDistance * 1.5 - 0.6, 1.0));\r
col = mix(col, skyBgColor, d);\r
}\r
- gl_FragColor = vec4(col.r, col.g, col.b, alpha); \r
+ gl_FragColor = vec4(col.r, col.g, col.b, alpha);\r
}\r
-#version 120\r
-\r
uniform mat4 mWorldViewProj;\r
uniform mat4 mInvWorld;\r
uniform mat4 mTransWorld;\r
uniform float dayNightRatio;\r
uniform float animationTimer;\r
\r
-uniform float enableWavingPlants;\r
-\r
uniform vec3 eyePosition;\r
\r
varying vec3 vPosition;\r
varying vec3 eyeVec;\r
\r
-float smoothCurve( float x ) { \r
- return x * x *( 3.0 - 2.0 * x ); \r
-} \r
-float triangleWave( float x ) { \r
- return abs( fract( x + 0.5 ) * 2.0 - 1.0 ); \r
-} \r
-float smoothTriangleWave( float x ) { \r
- return smoothCurve( triangleWave( x ) ) * 2.0 - 1.0; \r
-} \r
+#ifdef ENABLE_WAVING_PLANTS\r
+float smoothCurve( float x ) {\r
+ return x * x *( 3.0 - 2.0 * x );\r
+}\r
+float triangleWave( float x ) {\r
+ return abs( fract( x + 0.5 ) * 2.0 - 1.0 );\r
+}\r
+float smoothTriangleWave( float x ) {\r
+ return smoothCurve( triangleWave( x ) ) * 2.0 - 1.0;\r
+}\r
+#endif\r
\r
void main(void)\r
{\r
\r
gl_TexCoord[0] = gl_MultiTexCoord0;\r
- if (enableWavingPlants == 1.0){\r
- vec4 pos = gl_Vertex;\r
- vec4 pos2 = mTransWorld * gl_Vertex;\r
- if (gl_TexCoord[0].y < 0.05) {\r
- pos.x += (smoothTriangleWave(animationTimer * 20.0 + pos2.x * 0.1 + pos2.z * 0.1) * 2.0 - 1.0) * 0.8;\r
- pos.y -= (smoothTriangleWave(animationTimer * 10.0 + pos2.x * -0.5 + pos2.z * -0.5) * 2.0 - 1.0) * 0.4; \r
- }\r
- gl_Position = mWorldViewProj * pos;\r
+\r
+#ifdef ENABLE_WAVING_PLANTS\r
+ vec4 pos = gl_Vertex;\r
+ vec4 pos2 = mTransWorld * gl_Vertex;\r
+ if (gl_TexCoord[0].y < 0.05) {\r
+ pos.x += (smoothTriangleWave(animationTimer * 20.0 + pos2.x * 0.1 + pos2.z * 0.1) * 2.0 - 1.0) * 0.8;\r
+ pos.y -= (smoothTriangleWave(animationTimer * 10.0 + pos2.x * -0.5 + pos2.z * -0.5) * 2.0 - 1.0) * 0.4;\r
}\r
- else \r
- gl_Position = mWorldViewProj * gl_Vertex;\r
+ gl_Position = mWorldViewProj * pos;\r
+#else\r
+ gl_Position = mWorldViewProj * gl_Vertex;\r
+#endif\r
\r
vPosition = (mWorldViewProj * gl_Vertex).xyz;\r
eyeVec = (gl_ModelViewMatrix * gl_Vertex).xyz;\r
-#version 120\r
-\r
uniform sampler2D baseTexture;\r
uniform sampler2D normalTexture;\r
uniform sampler2D useNormalmap;\r
\r
-uniform float enableBumpmapping;\r
-uniform float enableParallaxOcclusion;\r
-uniform float parallaxOcclusionScale;\r
-uniform float parallaxOcclusionBias;\r
-\r
-\r
uniform vec4 skyBgColor;\r
uniform float fogDistance;\r
uniform vec3 eyePosition;\r
\r
varying vec3 vPosition;\r
-varying vec3 tsEyeVec;\r
varying vec3 eyeVec;\r
-varying vec4 vColor;\r
+\r
+#ifdef ENABLE_PARALLAX_OCCLUSION\r
+varying vec3 tsEyeVec;\r
+#endif\r
\r
const float e = 2.718281828459;\r
\r
{\r
vec3 color;\r
vec2 uv = gl_TexCoord[0].st;\r
- \r
-#ifdef NORMALS\r
+\r
+#ifdef USE_NORMALMAPS\r
+ float use_normalmap = texture2D(useNormalmap,vec2(1.0,1.0)).r;\r
+#endif\r
+\r
+#ifdef ENABLE_PARALLAX_OCCLUSION\r
float height;\r
vec2 tsEye = vec2(tsEyeVec.x,-tsEyeVec.y);\r
- \r
- float use_normalmap = texture2D(useNormalmap,vec2(1.0,1.0)).r;\r
- float enable_bumpmapping = enableBumpmapping;\r
- \r
- if ((enableParallaxOcclusion == 1.0) && (use_normalmap > 0.0)) {\r
+\r
+ if (use_normalmap > 0.0) {\r
float map_height = texture2D(normalTexture, uv).a;\r
if (map_height < 1.0){\r
- float height = parallaxOcclusionScale * map_height - parallaxOcclusionBias;\r
+ float height = PARALLAX_OCCLUSION_SCALE * map_height - PARALLAX_OCCLUSION_BIAS;\r
uv = uv + height * tsEye;\r
}\r
}\r
+#endif\r
+\r
/* Steep parallax code, for future use\r
if ((parallaxMappingMode == 2.0) && (use_normalmap > 0.0)) {\r
const float numSteps = 40.0;\r
}\r
*/\r
\r
- if ((enable_bumpmapping == 1.0) && (use_normalmap > 0.0)) {\r
+#ifdef ENABLE_BUMPMAPPING\r
+ if (use_normalmap > 0.0) {\r
vec3 base = texture2D(baseTexture, uv).rgb;\r
vec3 vVec = normalize(eyeVec);\r
vec3 bump = normalize(texture2D(normalTexture, uv).xyz * 2.0 - 1.0);\r
float d = max(0.0, min(vPosition.z / fogDistance * 1.5 - 0.6, 1.0));\r
col = mix(col, skyBgColor, d);\r
}\r
- gl_FragColor = vec4(col.r, col.g, col.b, alpha); \r
+ gl_FragColor = vec4(col.r, col.g, col.b, alpha);\r
}\r
-#version 120\r
-\r
uniform mat4 mWorldViewProj;\r
uniform mat4 mInvWorld;\r
uniform mat4 mTransWorld;\r
\r
varying vec3 vPosition;\r
varying vec3 eyeVec;\r
+\r
+#ifdef ENABLE_PARALLAX_OCCLUSION\r
varying vec3 tsEyeVec;\r
+#endif\r
\r
void main(void)\r
{\r
gl_Position = mWorldViewProj * gl_Vertex;\r
vPosition = (mWorldViewProj * gl_Vertex).xyz;\r
+ eyeVec = (gl_ModelViewMatrix * gl_Vertex).xyz;\r
\r
- vec3 normal,tangent,binormal; \r
+#ifdef ENABLE_PARALLAX_OCCLUSION\r
+ vec3 normal,tangent,binormal;\r
normal = normalize(gl_NormalMatrix * gl_Normal);\r
\r
if (gl_Normal.x > 0.5) {\r
tangent = normalize(gl_NormalMatrix * vec3(-1.0, 0.0, 0.0));\r
binormal = normalize(gl_NormalMatrix * vec3( 0.0, -1.0, 0.0));\r
}\r
- \r
- mat3 tbnMatrix = mat3(tangent.x, binormal.x, normal.x,\r
- tangent.y, binormal.y, normal.y,\r
- tangent.z, binormal.z, normal.z);\r
\r
- eyeVec = (gl_ModelViewMatrix * gl_Vertex).xyz;\r
+ mat3 tbnMatrix = mat3( tangent.x, binormal.x, normal.x,\r
+ tangent.y, binormal.y, normal.y,\r
+ tangent.z, binormal.z, normal.z);\r
+\r
tsEyeVec = normalize(eyeVec * tbnMatrix);\r
- \r
+#endif\r
+\r
vec4 color;\r
//color = vec4(1.0, 1.0, 1.0, 1.0);\r
\r
services->setPixelShaderConstant("eyePosition", (irr::f32*)&eye_position, 3);
services->setVertexShaderConstant("eyePosition", (irr::f32*)&eye_position, 3);
- float enable_bumpmapping = 0;
- if (g_settings->getBool("enable_bumpmapping"))
- enable_bumpmapping = 1;
- services->setPixelShaderConstant("enableBumpmapping", &enable_bumpmapping, 1);
-
- float enable_parallax_occlusion = 0;
- if (g_settings->getBool("enable_parallax_occlusion")) {
- enable_parallax_occlusion = 1;
- float parallax_occlusion_scale = g_settings->getFloat("parallax_occlusion_scale");
- services->setPixelShaderConstant("parallaxOcclusionScale", ¶llax_occlusion_scale, 1);
- float parallax_occlusion_bias = g_settings->getFloat("parallax_occlusion_bias");
- services->setPixelShaderConstant("parallaxOcclusionBias", ¶llax_occlusion_bias, 1);
- }
- services->setPixelShaderConstant("enableParallaxOcclusion", &enable_parallax_occlusion, 1);
-
- float enable_waving_water = 0;
- if (g_settings->getBool("enable_waving_water")){
- enable_waving_water = 1;
- float water_wave_height_f = g_settings->getFloat("water_wave_height");
- services->setVertexShaderConstant("waterWaveHeight", &water_wave_height_f, 1);
- float water_wave_length_f = g_settings->getFloat("water_wave_length");
- services->setVertexShaderConstant("waterWaveLength", &water_wave_length_f, 1);
- float water_wave_speed_f = g_settings->getFloat("water_wave_speed");
- services->setVertexShaderConstant("waterWaveSpeed", &water_wave_speed_f, 1);
- }
- services->setVertexShaderConstant("enableWavingWater", &enable_waving_water, 1);
-
- float enable_waving_leaves = 0;
- if (g_settings->getBool("enable_waving_leaves"))
- enable_waving_leaves = 1;
- services->setVertexShaderConstant("enableWavingLeaves", &enable_waving_leaves, 1);
-
- float enable_waving_plants = 0;
- if (g_settings->getBool("enable_waving_plants"))
- enable_waving_plants = 1;
- services->setVertexShaderConstant("enableWavingPlants", &enable_waving_plants, 1);
-
-
// Normal map texture layer
int layer1 = 1;
int layer2 = 2;
*/
bool enable_shaders = g_settings->getBool("enable_shaders");
bool enable_bumpmapping = g_settings->getBool("enable_bumpmapping");
+ bool enable_parallax_occlusion = g_settings->getBool("enable_parallax_occlusion");
video::E_MATERIAL_TYPE shadermat1, shadermat2, shadermat3,
shadermat4, shadermat5;
if (enable_shaders) {
ITextureSource *tsrc = data->m_gamedef->tsrc();
material.setTexture(2, tsrc->getTexture("disable_img.png"));
- if (enable_bumpmapping) {
+ if (enable_bumpmapping || enable_parallax_occlusion) {
std::string fname_base = tsrc->getTextureName(p.tile.texture_id);
std::string normal_ext = "_normal.png";
size_t pos = fname_base.find(".");
{
bool enable_shaders = g_settings->getBool("enable_shaders");
bool enable_bumpmapping = g_settings->getBool("enable_bumpmapping");
-
+ bool enable_parallax_occlusion = g_settings->getBool("enable_parallax_occlusion");
+
if(!m_has_animation)
{
m_animation_force_timer = 100000;
// Set the texture
buf->getMaterial().setTexture(0, tsrc->getTexture(os.str()));
buf->getMaterial().setTexture(2, tsrc->getTexture("disable_img.png"));
- if (enable_shaders && enable_bumpmapping)
+ if (enable_shaders && (enable_bumpmapping || enable_parallax_occlusion))
{
std::string fname_base,fname_normal;
fname_base = tsrc->getTextureName(tile.texture_id);
if(vertex_program == "" && pixel_program == "" && geometry_program == "")
return shaderinfo;
- if (g_settings->getBool("enable_bumpmapping") || g_settings->getBool("enable_parallax_occlusion")) {
- if(vertex_program != "")
- vertex_program = "#define NORMALS\n" + vertex_program;
- if(pixel_program != "")
- pixel_program = "#define NORMALS\n" + pixel_program;
- if(geometry_program != "")
- geometry_program = "#define NORMALS\n" + geometry_program;
- }
+ // Create shaders header
+ std::string shaders_header = "#version 120\n";
+ if (g_settings->getBool("enable_bumpmapping"))
+ shaders_header += "#define ENABLE_BUMPMAPPING\n";
+
+ if (g_settings->getBool("enable_parallax_occlusion")){
+ shaders_header += "#define ENABLE_PARALLAX_OCCLUSION\n";
+ shaders_header += "#define PARALLAX_OCCLUSION_SCALE ";
+ shaders_header += ftos(g_settings->getFloat("parallax_occlusion_scale"));
+ shaders_header += "\n";
+ shaders_header += "#define PARALLAX_OCCLUSION_BIAS ";
+ shaders_header += ftos(g_settings->getFloat("parallax_occlusion_bias"));
+ shaders_header += "\n";
+ }
+
+ if (g_settings->getBool("enable_bumpmapping") || g_settings->getBool("enable_parallax_occlusion"))
+ shaders_header += "#define USE_NORMALMAPS\n";
+
+ if (g_settings->getBool("enable_waving_water")){
+ shaders_header += "#define ENABLE_WAVING_WATER\n";
+ shaders_header += "#define WATER_WAVE_HEIGHT ";
+ shaders_header += ftos(g_settings->getFloat("water_wave_height"));
+ shaders_header += "\n";
+ shaders_header += "#define WATER_WAVE_LENGTH ";
+ shaders_header += ftos(g_settings->getFloat("water_wave_length"));
+ shaders_header += "\n";
+ shaders_header += "#define WATER_WAVE_SPEED ";
+ shaders_header += ftos(g_settings->getFloat("water_wave_speed"));
+ shaders_header += "\n";
+ }
+
+ if (g_settings->getBool("enable_waving_leaves"))
+ shaders_header += "#define ENABLE_WAVING_LEAVES\n";
+
+ if (g_settings->getBool("enable_waving_plants"))
+ shaders_header += "#define ENABLE_WAVING_PLANTS\n";
+
+ if(pixel_program != "")
+ pixel_program = shaders_header + pixel_program;
+ if(vertex_program != "")
+ vertex_program = shaders_header + vertex_program;
+ if(geometry_program != "")
+ geometry_program = shaders_header + geometry_program;
+
// Call addHighLevelShaderMaterial() or addShaderMaterial()
const c8* vertex_program_ptr = 0;
const c8* pixel_program_ptr = 0;