Example a_backup/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_backup/multipass_render


The comfile run by this example is as follows:

# ***** BEGIN LICENSE BLOCK *****
# 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;

if($TESTING)
{
   gfx print win 1 file multipass_render.jpg;
}

}

Files used by this example are:

Name                  Modified     Size

multipass_render.com 20-Apr-2012 3.4k COPYRIGHT 20-Apr-2012 504 karekarefalls.jpg 20-Apr-2012 202k perturb_fragment.txt 20-Apr-2012 300 perturb_vertex.txt 20-Apr-2012 682 square.exelem 20-Apr-2012 1.9k trace_line.exelem 20-Apr-2012 1.8k

Download the entire example:

Name                                       Modified     Size

examples_a_backup_multipass_render.tar.gz 12-Aug-2014 534k

Testing status by version:

StatusTestedReal time (s)
i686-linux
cmgui-wxSuccessSun Mar 6 00:10:08 20162
cmgui-wx-debugSuccessSun Mar 6 00:11:50 20163
cmgui-wx-debug-memorycheckSuccessSun Mar 6 00:10:10 20162
cmgui-wx-debug-valgrindFailureSun Mar 6 01:10:03 201639
last breakSun Mar 6 01:09:00 201639
last successTue Feb 10 00:53:00 201545
x86_64-linux
cmgui-wxFailureSun Mar 6 00:01:37 20160
last breakSun Mar 6 00:01:00 20160
last successWed Jun 3 00:05:00 20151
cmgui-wx-debugFailureSun Mar 6 00:01:37 20160
last breakSun Mar 6 00:01:00 20160
last successWed Jun 3 00:05:00 20151
cmgui-wx-debug-memorycheckFailureSun Mar 6 00:01:37 20160
last breakSun Mar 6 00:01:00 20160
last successWed Jun 3 00:05:00 20151
cmgui-wx-debug-valgrindFailureSun Mar 6 00:02:43 20169
last breakSun Mar 6 00:02:00 20169
last successWed Jun 3 00:29:00 201533
cmgui-wx-gcc-cad-debug-valgrindSuccessThu Jan 7 00:02:17 20167

Testing status by file:


Html last generated: Sun Mar 6 05:50:59 2016

Input last modified: Fri Apr 20 16:00:22 2012


CMISS Help / Examples / a_backup / multipass_render