summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2015-02-13 17:19:24 +0100
committerPaul Lemire <paul.lemire@kdab.com>2015-02-18 13:13:06 +0000
commit245d0dec44d691d0fceab4d2c1c111f41d7d5a7c (patch)
treebafed21dabcd252dc080d48e433d861d8b3dd4a9 /examples
parent3f9d0a60b678011691c7b19f705fcaeaab1c975e (diff)
playground-qml now properly showing ShaderData/UBO
Change-Id: I939927270786773522ca7a327195cc504dccc412 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/playground-qml/AnimatedDiffuseMaterial.qml43
-rw-r--r--examples/playground-qml/MainView.qml4
2 files changed, 11 insertions, 36 deletions
diff --git a/examples/playground-qml/AnimatedDiffuseMaterial.qml b/examples/playground-qml/AnimatedDiffuseMaterial.qml
index c09f166bd..50605baee 100644
--- a/examples/playground-qml/AnimatedDiffuseMaterial.qml
+++ b/examples/playground-qml/AnimatedDiffuseMaterial.qml
@@ -160,40 +160,10 @@ Material {
fragmentShaderCode: loadSource("qrc:/shaders/diffuse.frag")
}
},
- // TEXTURE PASS
- RenderPass {
- annotations: Annotation {name : "Name"; value : "Texture" }
- bindings: ParameterMapping {parameterName: "texture"; shaderVariableName: "tex"; bindingType: ParameterMapping.Uniform}
- shaderProgram: ShaderProgram {
- vertexShaderCode : "
- #version 140
- in vec4 vertexPosition;
- in vec2 vertexTexCoord;
- out vec2 texCoord;
-
- uniform mat4 mvp;
-
- void main()
- {
- texCoord = vertexTexCoord;
- gl_Position = mvp * vertexPosition;
- }"
-
- fragmentShaderCode: "
- #version 140
- in vec2 texCoord;
- out vec4 fragColor;
- uniform sampler2D tex;
-
- void main()
- {
- fragColor = texture(tex, texCoord);
- }
- "
- }
- },
+ // TEXTURE PASS + UBO
RenderPass {
annotations : [Annotation {name : "Name"; value : "Texture" }]
+ bindings: ParameterMapping {parameterName: "texture"; shaderVariableName: "tex"; bindingType: ParameterMapping.Uniform}
renderStates : [BlendState {srcRGB: BlendState.One; dstRGB : BlendState.One},
BlendEquation {mode: BlendEquation.FuncAdd},
CullFace { mode : CullFace.Back },
@@ -204,9 +174,11 @@ Material {
#version 140
in vec4 vertexPosition;
in vec3 vertexNormal;
+ in vec2 vertexTexCoord;
out vec3 worldPosition;
out vec3 normal;
+ out vec2 texCoord;
uniform mat4 modelViewProjection;
uniform mat4 modelView;
@@ -214,6 +186,7 @@ Material {
void main()
{
+ texCoord = vertexTexCoord;
worldPosition = vec3(modelView * vertexPosition);
normal = normalize(modelViewNormal * vertexNormal);
gl_Position = modelViewProjection * vertexPosition;
@@ -224,6 +197,7 @@ Material {
#version 140
in vec3 worldPosition;
in vec3 normal;
+ in vec2 texCoord;
out vec4 fragColor;
struct subStruct
@@ -254,6 +228,7 @@ Material {
innerStruct u[4];
} lightSource;
+ uniform sampler2D tex;
void main()
{
@@ -281,9 +256,9 @@ Material {
fragColor = vec4(lightSource.intensity, 1.0) * (
lightSource.colorAmbient * lightSource.s.innerV +
lightSource.colorDiffuse * diffuse +
- lightSource.colorSpecular * specular);
+ lightSource.colorSpecular * specular) * 0.2 + texture(tex, texCoord);
else
- fragColor = vec4(1.0, 1.0, 1.0, 1.0) * tmp;
+ fragColor = vec4(1.0, 1.0, 1.0, 1.0);
}"
}
}
diff --git a/examples/playground-qml/MainView.qml b/examples/playground-qml/MainView.qml
index 0ad847e6a..0f115d397 100644
--- a/examples/playground-qml/MainView.qml
+++ b/examples/playground-qml/MainView.qml
@@ -67,7 +67,7 @@ Entity {
AnimatedDiffuseMaterial {
id: animatedMaterial
- texture: Texture2D { source : "assets/gltf/wine/Wood_Cherry_Original_.jpg" }
+ texture: Texture2D { TextureImage { source : "assets/gltf/wine/Wood_Cherry_Original_.jpg" } }
}
// Scene elements
@@ -76,7 +76,7 @@ Entity {
id : sceneEntity
components : SceneLoader {
id: scene
- source: ":/assets/test_scene.dae"
+ source: "qrc:/assets/test_scene.dae"
objectName: "dae_scene"
}
}