Example a/multipass_render: Multipass rendering: Modifying vertices with texture values.

Demonstration of using a first render pass to calculate or modify the vertex positions of geometry.

Note that current Mesa3D OpenGL libraries don't have float texture buffers and so the updated vertices are clamped into the 0-1 range. The test is still useful and as float textures are a OpenGL 3.0 core feature I'm sure it will be implemented at some point.

Screenshot of example a/multipass_render

The comfile run by this example is as follows:

# Version: MPL 1.1/GPL 2.0/LGPL 2.1
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
# The Original Code is CMISS Multipass Render Example.
# The Initial Developer of the Original Code is
# Spark Dental Technology Ltd.
# Portions created by the Initial Developer are Copyright (C) 2008
# the Initial Developer. All Rights Reserved.
# Contributor(s):
#    Shane Blackett <shane@blackett.co.nz>
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
# ***** END LICENSE BLOCK *****

gfx read element $example/square.exelem;

gfx create texture waterfall image $example/karekarefalls.jpg decal;

gfx create material waterfall texture waterfall;

gfx define field texture_coordinatesA multiply fields coordinates [0.5];
gfx define field texture_coordinates add fields texture_coordinatesA [0.5];

gfx modify g_element square general clear circle_discretization 6 default_coordinate coordinates element_discretization "4*4*4" native_discretization none;
gfx modify g_element square lines select_on material default selected_material default_selected;

#When we convert surfaces to use vertex buffer objects then we can displace this too,
#for now just lines.
gfx modify g_element square surfaces select_on material waterfall texture_coordinates texture_coordinates selected_material default_selected render_shaded;

#Render some lines displaced by values in the texture.
#This material is for the first pass.  The second texture coordinates are the 
#the required positions for the first pass to correctly write to the vertex buffer
#for the second pass.
gfx read element $example/trace_line.exelem;

CORE::open VPFILE, "<$example/perturb_vertex.txt";
@vp = <VPFILE>;
close VPFILE;
CORE::open FPFILE, "<$example/perturb_fragment.txt";
@fp = <FPFILE>;
close FPFILE;

gfx create material perturb_from_texture vertex_program_string join("",@vp) fragment_program_string join("",@fp) texture waterfall;

gfx modify g_element trace_line general element_discretization 40 default_coordinate coordinates;
#Render the texture on the lines too (now that we can).
gfx modify g_element trace_line line material waterfall secondary_material perturb_from_texture texture_coordinate texture_coordinates;

gfx cre win 1;

   gfx print win 1 file multipass_render.jpg;


Files used by this example are:

Name                  Modified     Size

multipass_render.com 17-Mar-2014 3.4k COPYRIGHT 17-Mar-2014 504 karekarefalls.jpg 17-Mar-2014 202k perturb_fragment.txt 17-Mar-2014 300 perturb_vertex.txt 17-Mar-2014 682 square.exelem 17-Mar-2014 1.9k trace_line.exelem 17-Mar-2014 1.8k

Download the entire example:

Name                                Modified     Size

examples_a_multipass_render.tar.gz 09-Mar-2016 534k

Testing status by version:

StatusTestedReal time (s)
cmgui-wxFailureSun Mar 6 00:10:24 20163
last breakTue Feb 24 03:20:00 20152
cmgui-wx-debugFailureSun Mar 6 00:11:12 20163
last breakTue Feb 24 03:11:00 20152
cmgui-wx-debug-memorycheckFailureSun Mar 6 00:11:13 20162
last breakTue Feb 24 03:11:00 20152
cmgui-wx-debug-valgrindFailureSun Mar 6 00:59:44 201640
last breakSun Mar 6 00:59:00 201640
cmgui-wxFailureSun Mar 6 00:01:31 20160
last breakSun Mar 6 00:01:00 20160
cmgui-wx-debugFailureSun Mar 6 00:01:31 20160
last breakSun Mar 6 00:01:00 20160
cmgui-wx-debug-memorycheckFailureSun Mar 6 00:01:31 20160
last breakSun Mar 6 00:01:00 20160
cmgui-wx-debug-valgrindFailureSun Mar 6 00:02:26 20169
last breakSun Mar 6 00:02:00 20169
cmgui-wx-gcc-cad-debug-valgrindSuccessThu Jan 7 00:02:10 20166

Testing status by file:

Html last generated: Wed Mar 9 16:02:23 2016

Input last modified: Wed Mar 9 15:49:41 2016

CMISS Help / Examples / a / multipass_render