Using an arbitrary shaders to similate the reflection of a mirror on a model.
Note that the current implementation of arbitraray GLSL shaders does not work well with THE current Mesa3D libraries and this model will simply appear to have a texture applied to the material when it is used. This example however should run on computer with a decent graphics card and this example has only been tested with nvidia graphics card only.
Special thanks to Dr. Hayley Reynolds for providing the human model.
The background picture is taken in front of the Hong Kong Jockey Club, Shatin, Hong Kong. Created April, 2009 by Alan Wu.
#A short example to demonstrate the capability of arbitrary shaders in cmgui. #It uses an arbitrary shaders to simulate the effect of a mirror, the effect will #be much nicer with a cube map. #Read in the model and texture. gfx read node $example/final_all_skin.exnode; gfx read element $example/final_all_skin.exelem; gfx create texture base image $example/background.jpg; #Read in the arbitrary program. CORE::open VPFILE, "<$example/mirror.vert"; @vp = <VPFILE>; CORE::open FPFILE, "<$example/mirror.frag"; @fp = <FPFILE>; #Set the material properties. gfx create material T-1000 ambient 1 1 1 diffuse 0.8 0.8 0.8 emission 0 0 0 specular 0 0 0 alpha 1 shininess 0 texture base; #Set the material to use the shaders. gfx modify material T-1000 vertex_program_string "@vp" fragment_program_string "@fp"; gfx modify material T-1000 uniform_name FresnelPower uniform_value 5.0; gfx modify material T-1000 uniform_name Eta uniform_value 0.66; #Set up the graphical settings. gfx modify g_element final_all_skin surface material T-1000 texture_coordinates xi; gfx modify g_element final_all_skin general clear circle_discretization 6 default_coordinate coordinates element_discretization "5*5*1" native_discretization none; gfx modify g_element final_all_skin lines select_on material default selected_material default_selected invisible; gfx modify g_element final_all_skin surfaces select_on material T-1000 texture_coordinates xi selected_material default_selected render_shaded; #Set up the display windows. gfx cre win 1; gfx mod win 1 layout width 800 height 800; gfx mod win 1 set anti 8; gfx mod win 1 bac texture base; gfx modify window 1 view perspective eye_point -968.304 4214.24 -878.345 interest_point 290.504 186.619 -910.696 up_vector 0.0170221 -0.00271091 0.999851 view_angle 40 near_clipping_plane 42.1987 far_clipping_plane 15080.4 relative_viewport ndc_placement -1 1 2 2 viewport_coordinates 0 0 1 1; #You can adjust the diffuse colour and alpha of material T-1000 to see the effect they have on the model.
Name Modified Size
example_arbitrary_shaders.com 20-Apr-2012 2.0k COPYRIGHT 20-Apr-2012 504 background.jpg 20-Apr-2012 552k final_all_skin.exelem 20-Apr-2012 1.1M final_all_skin.exnode 20-Apr-2012 249k mirror.frag 20-Apr-2012 714 mirror.vert 20-Apr-2012 929
Name Modified Size
examples_a_backup_arbitrary_shaders.tar.gz 12-Aug-2014 2.4M
Status | Tested | Real time (s) | |
i686-linux | |||
cmgui-wx | Success | Sun Mar 6 00:19:41 2016 | 5 |
cmgui-wx-debug | Success | Sun Mar 6 00:19:43 2016 | 5 |
cmgui-wx-debug-memorycheck | Success | Sun Mar 6 00:19:26 2016 | 5 |
cmgui-wx-debug-valgrind | Failure | Sun Mar 6 02:04:17 2016 | 262 |
last break | Sun Mar 6 01:59:00 2016 | 262 | |
last success | Tue Feb 10 02:11:00 2015 | 257 | |
x86_64-linux | |||
cmgui-wx | Failure | Sun Mar 6 00:01:36 2016 | 0 |
last break | Sun Mar 6 00:01:00 2016 | 0 | |
last success | Wed Jun 3 00:06:00 2015 | 2 | |
cmgui-wx-debug | Failure | Sun Mar 6 00:01:36 2016 | 0 |
last break | Sun Mar 6 00:01:00 2016 | 0 | |
last success | Wed Jun 3 00:06:00 2015 | 3 | |
cmgui-wx-debug-memorycheck | Failure | Sun Mar 6 00:01:36 2016 | 0 |
last break | Sun Mar 6 00:01:00 2016 | 0 | |
last success | Wed Jun 3 00:06:00 2015 | 2 | |
cmgui-wx-debug-valgrind | Failure | Sun Mar 6 00:02:34 2016 | 10 |
last break | Sun Mar 6 00:02:00 2016 | 10 | |
last success | Wed Jun 3 01:06:00 2015 | 152 | |
cmgui-wx-gcc-cad-debug-valgrind | Success | Thu Jan 7 00:02:21 2016 | 7 |
x86_64-linux | |||
139 | cmgui-wx: | error exit status 139. | |
139 | cmgui-wx-debug: | error exit status 139. | |
139 | cmgui-wx-debug-memorycheck: | error exit status 139. | |
139 | cmgui-wx-debug-valgrind: | error exit status 139. |
i686-linux | |||
Success | cmgui-wx: | diff test: no differences with generic answer. | |
Success | cmgui-wx-debug: | diff test: no differences with generic answer. | |
Success | cmgui-wx-debug-memorycheck: | diff test: no differences with generic answer. | |
Failure | cmgui-wx-debug-valgrind: | diff test: differences with generic answer; Test output. | |
x86_64-linux | |||
Failure | cmgui-wx: | diff test: differences with generic answer; Test output. | |
Failure | cmgui-wx-debug: | diff test: differences with generic answer; Test output. | |
Failure | cmgui-wx-debug-memorycheck: | diff test: differences with generic answer; Test output. | |
Failure | cmgui-wx-debug-valgrind: | diff test: differences with generic answer; Test output. |
Html last generated: Sun Mar 6 05:50:53 2016
Input last modified: Thu Oct 11 23:52:59 2012