diff options
author | Jesse Barker <jesse.barker@linaro.org> | 2012-12-13 16:06:17 -0800 |
---|---|---|
committer | Jesse Barker <jesse.barker@linaro.org> | 2012-12-13 16:06:17 -0800 |
commit | 6f808b75d48e5c8ed98fd103098a677ca9ce2e9b (patch) | |
tree | 20c3d65e8cf9631377b58a51a5d9b80d670801d0 | |
parent | 90c50c723d9ee13bcd4cdc4f0284f2c246945095 (diff) | |
download | glmark2-6f808b75d48e5c8ed98fd103098a677ca9ce2e9b.tar.gz |
SceneRefract: Make the refractive index of the medium a command line option.
The default is 1.2, but could be anything ("believable" effects are probably in
the lower values).
-rw-r--r-- | data/shaders/light-refract.frag | 2 | ||||
-rw-r--r-- | src/scene-refract.cpp | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/data/shaders/light-refract.frag b/data/shaders/light-refract.frag index bcc5096..d1f1397 100644 --- a/data/shaders/light-refract.frag +++ b/data/shaders/light-refract.frag @@ -16,7 +16,7 @@ void main() // compute the transmitted vector through the "front" surface of the object. vec3 eye_direction = normalize(-vertex_position.xyz); vec3 normalized_normal = normalize(vertex_normal); - vec3 front_refraction = refract(eye_direction, normalized_normal, 1.45); + vec3 front_refraction = refract(eye_direction, normalized_normal, RefractiveIndex); // Find our best distance approximation through the object so we can // project the transmitted vector to the back of the object to find // the exit point. diff --git a/src/scene-refract.cpp b/src/scene-refract.cpp index f4188e0..b936362 100644 --- a/src/scene-refract.cpp +++ b/src/scene-refract.cpp @@ -77,6 +77,8 @@ SceneRefract::SceneRefract(Canvas& canvas) : } options_["texture"] = Scene::Option("texture", "nasa1", "Which texture to use", optionValues); + options_["index"] = Scene::Option("index", "1.2", + "Index of refraction of the medium to simulate"); options_["use-vbo"] = Scene::Option("use-vbo", "true", "Whether to use VBOs for rendering", "false,true"); @@ -277,6 +279,8 @@ RefractPrivate::setup(map<string, Scene::Option>& options) frg_source.add_const("LightColor", lightColor); frg_source.add_const("LightSourcePosition", lightPosition); + float refractive_index(Util::fromString<float>(options["index"].value)); + frg_source.add_const("RefractiveIndex", refractive_index); if (!Scene::load_shaders_from_strings(program_, vtx_source.str(), frg_source.str())) { return false; |