diff options
author | Antti Määttä <antti.maatta@qt.io> | 2017-02-06 15:46:49 +0200 |
---|---|---|
committer | Antti Määttä <antti.maatta@qt.io> | 2017-02-28 07:05:32 +0000 |
commit | 0bb720013d93c34d589c352a53405d8110fa57fe (patch) | |
tree | b5d3496f27e7828850f308901c490f9f3cc35439 /examples/qt3d/simplecustommaterial/shaders | |
parent | 63d417d4ee7611d6453289db62b82da9ac0a39a5 (diff) |
Add simple custom material example
Change-Id: Ia1a706888ca3bb1eedcac34903afe7da0c168462
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'examples/qt3d/simplecustommaterial/shaders')
4 files changed, 51 insertions, 0 deletions
diff --git a/examples/qt3d/simplecustommaterial/shaders/es2/simpleColor.frag b/examples/qt3d/simplecustommaterial/shaders/es2/simpleColor.frag new file mode 100644 index 000000000..d18c01699 --- /dev/null +++ b/examples/qt3d/simplecustommaterial/shaders/es2/simpleColor.frag @@ -0,0 +1,10 @@ +#define FP highp + +uniform FP vec3 maincolor; + +void main() +{ + //output color from material + gl_FragColor = vec4(maincolor,1.0); +} + diff --git a/examples/qt3d/simplecustommaterial/shaders/es2/simpleColor.vert b/examples/qt3d/simplecustommaterial/shaders/es2/simpleColor.vert new file mode 100644 index 000000000..24934948c --- /dev/null +++ b/examples/qt3d/simplecustommaterial/shaders/es2/simpleColor.vert @@ -0,0 +1,15 @@ +#define FP highp + +attribute FP vec3 vertexPosition; +varying FP vec3 worldPosition; +uniform FP mat4 modelMatrix; +uniform FP mat4 mvp; + +void main() +{ + // Transform position, normal, and tangent to world coords + worldPosition = vec3(modelMatrix * vec4(vertexPosition, 1.0)); + + // Calculate vertex position in clip coordinates + gl_Position = mvp * vec4(worldPosition, 1.0); +} diff --git a/examples/qt3d/simplecustommaterial/shaders/gl3/simpleColor.frag b/examples/qt3d/simplecustommaterial/shaders/gl3/simpleColor.frag new file mode 100644 index 000000000..c899052d9 --- /dev/null +++ b/examples/qt3d/simplecustommaterial/shaders/gl3/simpleColor.frag @@ -0,0 +1,11 @@ +#version 150 core + +uniform vec3 maincolor; +out vec4 fragColor; + +void main() +{ + //output color from material + fragColor = vec4(maincolor,1.0); +} + diff --git a/examples/qt3d/simplecustommaterial/shaders/gl3/simpleColor.vert b/examples/qt3d/simplecustommaterial/shaders/gl3/simpleColor.vert new file mode 100644 index 000000000..b29c69d7d --- /dev/null +++ b/examples/qt3d/simplecustommaterial/shaders/gl3/simpleColor.vert @@ -0,0 +1,15 @@ +#version 150 core + +in vec3 vertexPosition; +out vec3 worldPosition; +uniform mat4 modelMatrix; +uniform mat4 mvp; + +void main() +{ + // Transform position, normal, and tangent to world coords + worldPosition = vec3(modelMatrix * vec4(vertexPosition, 1.0)); + + // Calculate vertex position in clip coordinates + gl_Position = mvp * vec4(worldPosition, 1.0); +} |