aboutsummaryrefslogtreecommitdiff
path: root/src/shader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader.cpp')
-rw-r--r--src/shader.cpp65
1 files changed, 38 insertions, 27 deletions
diff --git a/src/shader.cpp b/src/shader.cpp
index a467c2ea9..a6d18e1be 100644
--- a/src/shader.cpp
+++ b/src/shader.cpp
@@ -680,42 +680,54 @@ ShaderInfo generate_shader(std::string name, u8 material_type, u8 drawtype,
shaders_header += itos(drawtype);
shaders_header += "\n";
- if (g_settings->getBool("generate_normalmaps")){
- shaders_header += "#define GENERATE_NORMALMAPS\n";
- shaders_header += "#define NORMALMAPS_STRENGTH ";
- shaders_header += ftos(g_settings->getFloat("normalmaps_strength"));
- shaders_header += "\n";
- float sample_step;
- int smooth = (int)g_settings->getFloat("normalmaps_smooth");
- switch (smooth){
- case 0:
- sample_step = 0.0078125; // 1.0 / 128.0
- break;
- case 1:
- sample_step = 0.00390625; // 1.0 / 256.0
- break;
- case 2:
- sample_step = 0.001953125; // 1.0 / 512.0
- break;
- default:
- sample_step = 0.0078125;
- break;
- }
- shaders_header += "#define SAMPLE_STEP ";
- shaders_header += ftos(sample_step);
- shaders_header += "\n";
+ if (g_settings->getBool("generate_normalmaps")) {
+ shaders_header += "#define GENERATE_NORMALMAPS 1\n";
+ } else {
+ shaders_header += "#define GENERATE_NORMALMAPS 0\n";
+ }
+ shaders_header += "#define NORMALMAPS_STRENGTH ";
+ shaders_header += ftos(g_settings->getFloat("normalmaps_strength"));
+ shaders_header += "\n";
+ float sample_step;
+ int smooth = (int)g_settings->getFloat("normalmaps_smooth");
+ switch (smooth){
+ case 0:
+ sample_step = 0.0078125; // 1.0 / 128.0
+ break;
+ case 1:
+ sample_step = 0.00390625; // 1.0 / 256.0
+ break;
+ case 2:
+ sample_step = 0.001953125; // 1.0 / 512.0
+ break;
+ default:
+ sample_step = 0.0078125;
+ break;
}
+ shaders_header += "#define SAMPLE_STEP ";
+ shaders_header += ftos(sample_step);
+ shaders_header += "\n";
if (g_settings->getBool("enable_bumpmapping"))
shaders_header += "#define ENABLE_BUMPMAPPING\n";
if (g_settings->getBool("enable_parallax_occlusion")){
+ int mode = g_settings->getFloat("parallax_occlusion_mode");
+ float scale = g_settings->getFloat("parallax_occlusion_scale");
+ float bias = g_settings->getFloat("parallax_occlusion_bias");
+ int iterations = g_settings->getFloat("parallax_occlusion_iterations");
shaders_header += "#define ENABLE_PARALLAX_OCCLUSION\n";
+ shaders_header += "#define PARALLAX_OCCLUSION_MODE ";
+ shaders_header += itos(mode);
+ shaders_header += "\n";
shaders_header += "#define PARALLAX_OCCLUSION_SCALE ";
- shaders_header += ftos(g_settings->getFloat("parallax_occlusion_scale"));
+ shaders_header += ftos(scale);
shaders_header += "\n";
shaders_header += "#define PARALLAX_OCCLUSION_BIAS ";
- shaders_header += ftos(g_settings->getFloat("parallax_occlusion_bias"));
+ shaders_header += ftos(bias);
+ shaders_header += "\n";
+ shaders_header += "#define PARALLAX_OCCLUSION_ITERATIONS ";
+ shaders_header += itos(iterations);
shaders_header += "\n";
}
@@ -755,7 +767,6 @@ ShaderInfo generate_shader(std::string name, u8 material_type, u8 drawtype,
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;