diff options
author | Jere Tuliniemi <jere.tuliniemi@qt.io> | 2018-10-22 14:18:24 +0300 |
---|---|---|
committer | Jere Tuliniemi <jere.tuliniemi@qt.io> | 2019-01-15 12:14:07 +0000 |
commit | 0cf63f1de93635c85fc3120cdfce3410a59edc9b (patch) | |
tree | 30ea4185da967d19e2c33298698fb6deadfec1d4 /tests | |
parent | 7c203cb04362c246c709285d583052ec1358e7de (diff) |
Enable vertex shaders in custom materials
If <VertexShader> tags in custom material contain a main function, use
the shaders provided as is. The shader generator adds } to the end of
the fully custom fragment shaders so I left that also to the vertex
shader generation.
Custom attributes can be provided with a user-generated .mesh file. The
test scene has a sphere with the normal attr_pos and a sphere with an
attr_pos2 instead. "simple-pos.material" expects an attr_pos vertex
attribute and "simple-pos2.material" an attr_pos2.
Task-number: QT3DS-2026
Change-Id: I2c0cd1c079f9c741900f119aefd2e3515d42f36d
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/scenes/customvertex/customvertex.uia | 15 | ||||
-rw-r--r-- | tests/scenes/customvertex/materials/simple-pos.material | 25 | ||||
-rw-r--r-- | tests/scenes/customvertex/materials/simple-pos2.material | 25 | ||||
-rw-r--r-- | tests/scenes/customvertex/models/Sphere-pos.mesh | bin | 0 -> 4356 bytes | |||
-rw-r--r-- | tests/scenes/customvertex/models/Sphere-pos2.mesh | bin | 0 -> 8372 bytes | |||
-rw-r--r-- | tests/scenes/customvertex/presentations/customvertex.uip | 39 |
6 files changed, 104 insertions, 0 deletions
diff --git a/tests/scenes/customvertex/customvertex.uia b/tests/scenes/customvertex/customvertex.uia new file mode 100644 index 0000000..06c0c6a --- /dev/null +++ b/tests/scenes/customvertex/customvertex.uia @@ -0,0 +1,15 @@ +<?xml version='1.0' encoding='utf-8'?> +<application xmlns="http://qt.io/qt3dstudio/uia"> + <assets initial="customvertex"> + <presentation src="presentations/customvertex.uip" id="customvertex"/> + </assets> + <statemachine ref="#logic"> + <visual-states> + <state ref="Initial"> + <enter> + <goto-slide element="main:Scene" rel="next"/> + </enter> + </state> + </visual-states> + </statemachine> +</application> diff --git a/tests/scenes/customvertex/materials/simple-pos.material b/tests/scenes/customvertex/materials/simple-pos.material new file mode 100644 index 0000000..6a76694 --- /dev/null +++ b/tests/scenes/customvertex/materials/simple-pos.material @@ -0,0 +1,25 @@ +<Material name="simple" version="1.0"> + <MetaData> + <Property formalName="Test Vertex" name="test_vertex" type="Float" default="1.000000" stage="vertex" category="Material" /> + <Property formalName="Test Fragment" name="test_fragment" type="Float" default="1.000000" stage="fragment" category="Material" /> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <VertexShader> + attribute vec3 attr_pos; + uniform mat4 modelViewProjection; + + void main() { + gl_Position = modelViewProjection * vec4(attr_pos, test_vertex); + </VertexShader> + <FragmentShader> + void main() { + fragOutput = vec4(1.0, test_fragment, 0.0, 1.0); + </FragmentShader> + </Shader> + </Shaders> +<Passes> + <Pass> + </Pass> +</Passes> +</Material> diff --git a/tests/scenes/customvertex/materials/simple-pos2.material b/tests/scenes/customvertex/materials/simple-pos2.material new file mode 100644 index 0000000..8d14185 --- /dev/null +++ b/tests/scenes/customvertex/materials/simple-pos2.material @@ -0,0 +1,25 @@ +<Material name="simple" version="1.0"> + <MetaData> + <Property formalName="Test Vertex" name="test_vertex" type="Float" default="1.000000" stage="vertex" category="Material" /> + <Property formalName="Test Fragment" name="test_fragment" type="Float" default="1.000000" stage="fragment" category="Material" /> + </MetaData> + <Shaders type="GLSL" version="330"> + <Shader> + <VertexShader> + attribute vec3 attr_pos2; + uniform mat4 modelViewProjection; + + void main() { + gl_Position = modelViewProjection * vec4(attr_pos2, test_vertex); + </VertexShader> + <FragmentShader> + void main() { + fragOutput = vec4(1.0, test_fragment, 0.0, 1.0); + </FragmentShader> + </Shader> + </Shaders> +<Passes> + <Pass> + </Pass> +</Passes> +</Material> diff --git a/tests/scenes/customvertex/models/Sphere-pos.mesh b/tests/scenes/customvertex/models/Sphere-pos.mesh Binary files differnew file mode 100644 index 0000000..5eace9d --- /dev/null +++ b/tests/scenes/customvertex/models/Sphere-pos.mesh diff --git a/tests/scenes/customvertex/models/Sphere-pos2.mesh b/tests/scenes/customvertex/models/Sphere-pos2.mesh Binary files differnew file mode 100644 index 0000000..c54f34f --- /dev/null +++ b/tests/scenes/customvertex/models/Sphere-pos2.mesh diff --git a/tests/scenes/customvertex/presentations/customvertex.uip b/tests/scenes/customvertex/presentations/customvertex.uip new file mode 100644 index 0000000..076b1c6 --- /dev/null +++ b/tests/scenes/customvertex/presentations/customvertex.uip @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<UIP version="5" > + <Project > + <ProjectSettings author="" company="" presentationWidth="1280" presentationHeight="720" maintainAspect="False" preferKtx="False" > + <CustomColors count="16" >#7391ff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff #ffffff</CustomColors> + </ProjectSettings> + <Classes > + <CustomMaterial id="simple-pos" name="simple-pos" sourcepath="../materials/simple-pos.material" /> + <CustomMaterial id="simple-pos2" name="simple-pos2" sourcepath="../materials/simple-pos2.material" /> + </Classes> + <Graph > + <Scene id="Scene" > + <Layer id="Layer" > + <Camera id="Camera" /> + <Light id="Light" /> + <Model id="Sphere-pos" > + <CustomMaterial id="simple-pos_001" class="#simple-pos" /> + </Model> + <Model id="Sphere-pos2" > + <CustomMaterial id="simple-pos2_001" class="#simple-pos2" /> + </Model> + </Layer> + </Scene> + </Graph> + <Logic > + <State name="Master Slide" component="#Scene" > + <Add ref="#Layer" /> + <Add ref="#Camera" /> + <Add ref="#Light" /> + <State id="Scene-Slide1" name="Slide1" > + <Add ref="#Sphere-pos" name="Sphere-pos" position="200 0 0" scale="2 2 2" sourcepath="../models/Sphere-pos.mesh" /> + <Add ref="#simple-pos_001" name="simple-pos" test_fragment="0.5" test_vertex="0.7" /> + <Add ref="#Sphere-pos2" name="Sphere-pos2" position="-200 0 0" scale="2 2 2" sourcepath="../models/Sphere-pos2.mesh" /> + <Add ref="#simple-pos2_001" name="simple-pos2" test_vertex="2" /> + </State> + </State> + </Logic> + </Project> +</UIP> |