summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2014-10-02 11:59:25 +0200
committerSean Harmer <sean.harmer@kdab.com>2014-10-03 21:19:02 +0200
commiteb4a451e14e02915675b95a1ea899629d2681e17 (patch)
tree813d2e232baef6be9162c54144220dd0c19b93c1 /examples
parent7e8d0d9e72ee231d45008cce447f342980de9405 (diff)
DeferredRendererQML
Added comments about RGB32F RGB16F not being always supported as a color attachment formats(Mesa/Intel). Set version number of shaders on the first line to avoid complains from the Mesa GLSL parser. Change-Id: Ifb4b9dc9a4171a1f4b0fbef666f7722bfcb10423 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/deferred-renderer-qml/FinalEffect.qml172
-rw-r--r--examples/deferred-renderer-qml/GBuffer.qml4
-rw-r--r--examples/deferred-renderer-qml/SceneEffect.qml12
3 files changed, 92 insertions, 96 deletions
diff --git a/examples/deferred-renderer-qml/FinalEffect.qml b/examples/deferred-renderer-qml/FinalEffect.qml
index 7bc4a3a10..9c5df1199 100644
--- a/examples/deferred-renderer-qml/FinalEffect.qml
+++ b/examples/deferred-renderer-qml/FinalEffect.qml
@@ -52,54 +52,52 @@ Effect {
shaderProgram : ShaderProgram {
id : finalShaderGL3
vertexShaderCode:
- "
- #version 140
+ "#version 140
- in vec4 vertexPosition;
- uniform mat4 modelMatrix;
+ in vec4 vertexPosition;
+ uniform mat4 modelMatrix;
- void main()
- {
- gl_Position = modelMatrix * vertexPosition;
- }
- "
- fragmentShaderCode:
+ void main()
+ {
+ gl_Position = modelMatrix * vertexPosition;
+ }
"
- #version 140
-
- uniform sampler2D color;
- uniform sampler2D position;
- uniform sampler2D normal;
- uniform vec2 winSize;
-
- out vec4 fragColor;
-
- struct PointLight
- {
- vec3 position;
- vec3 direction;
- vec4 color;
- float intensity;
- };
-
- const int lightCount = 3;
- uniform PointLight pointLights[lightCount];
-
- void main()
- {
- vec2 texCoord = gl_FragCoord.xy / winSize;
- vec4 col = texture2D(color, texCoord);
- vec3 pos = texture2D(position, texCoord).xyz;
- vec3 norm = texture2D(normal, texCoord).xyz;
-
- vec4 lightColor;
- for (int i = 0; i < 3; i++) {
- vec3 s = normalize(pointLights[i].position - pos);
- lightColor += pointLights[i].color * (pointLights[i].intensity * max(dot(s, norm), 0.0));
- }
- lightColor /= float(lightCount);
- fragColor = col * lightColor;
- }
+ fragmentShaderCode:
+ "#version 140
+
+ uniform sampler2D color;
+ uniform sampler2D position;
+ uniform sampler2D normal;
+ uniform vec2 winSize;
+
+ out vec4 fragColor;
+
+ struct PointLight
+ {
+ vec3 position;
+ vec3 direction;
+ vec4 color;
+ float intensity;
+ };
+
+ const int lightCount = 3;
+ uniform PointLight pointLights[lightCount];
+
+ void main()
+ {
+ vec2 texCoord = gl_FragCoord.xy / winSize;
+ vec4 col = texture2D(color, texCoord);
+ vec3 pos = texture2D(position, texCoord).xyz;
+ vec3 norm = texture2D(normal, texCoord).xyz;
+
+ vec4 lightColor;
+ for (int i = 0; i < 3; i++) {
+ vec3 s = normalize(pointLights[i].position - pos);
+ lightColor += pointLights[i].color * (pointLights[i].intensity * max(dot(s, norm), 0.0));
+ }
+ lightColor /= float(lightCount);
+ fragColor = col * lightColor;
+ }
"
}
}
@@ -112,53 +110,51 @@ Effect {
shaderProgram : ShaderProgram {
id : finalShaderGL2
vertexShaderCode:
- "
- #version 110
+ "#version 110
- attribute vec4 vertexPosition;
- uniform mat4 modelMatrix;
+ attribute vec4 vertexPosition;
+ uniform mat4 modelMatrix;
- void main()
- {
- gl_Position = modelMatrix * vertexPosition;
- }
+ void main()
+ {
+ gl_Position = modelMatrix * vertexPosition;
+ }
"
fragmentShaderCode:
- "
- #version 110
-
- uniform sampler2D color;
- uniform sampler2D position;
- uniform sampler2D normal;
- uniform vec2 winSize;
-
- struct PointLight
- {
- vec3 position;
- vec3 direction;
- vec4 color;
- float intensity;
- };
-
- const int lightCount = 3;
- uniform PointLight pointLights[lightCount];
-
- void main()
- {
- vec2 texCoord = gl_FragCoord.xy / winSize;
- vec4 col = texture2D(color, texCoord);
- vec3 pos = texture2D(position, texCoord).xyz;
- vec3 norm = texture2D(normal, texCoord).xyz;
-
- vec4 lightColor;
- for (int i = 0; i < 3; i++) {
- vec3 s = normalize(pointLights[i].position - pos);
- lightColor += pointLights[i].color * (pointLights[i].intensity * max(dot(s, norm), 0.0));
- }
- lightColor /= float(lightCount);
- gl_FragColor = col * lightColor;
- }
- "
+ "#version 110
+
+ uniform sampler2D color;
+ uniform sampler2D position;
+ uniform sampler2D normal;
+ uniform vec2 winSize;
+
+ struct PointLight
+ {
+ vec3 position;
+ vec3 direction;
+ vec4 color;
+ float intensity;
+ };
+
+ const int lightCount = 3;
+ uniform PointLight pointLights[lightCount];
+
+ void main()
+ {
+ vec2 texCoord = gl_FragCoord.xy / winSize;
+ vec4 col = texture2D(color, texCoord);
+ vec3 pos = texture2D(position, texCoord).xyz;
+ vec3 norm = texture2D(normal, texCoord).xyz;
+
+ vec4 lightColor;
+ for (int i = 0; i < 3; i++) {
+ vec3 s = normalize(pointLights[i].position - pos);
+ lightColor += pointLights[i].color * (pointLights[i].intensity * max(dot(s, norm), 0.0));
+ }
+ lightColor /= float(lightCount);
+ gl_FragColor = col * lightColor;
+ }
+ "
}
}
}]
diff --git a/examples/deferred-renderer-qml/GBuffer.qml b/examples/deferred-renderer-qml/GBuffer.qml
index b2cab491e..1384485fd 100644
--- a/examples/deferred-renderer-qml/GBuffer.qml
+++ b/examples/deferred-renderer-qml/GBuffer.qml
@@ -74,6 +74,8 @@ RenderTarget {
target : Texture.Target2D
width : 1024
height : 1024
+ // This texture format may not be supported by
+ // some OpenGL vendors when used as a color attachment
format : Texture.RGB32F
generateMipMaps : false
magnificationFilter : Texture.Linear
@@ -89,6 +91,8 @@ RenderTarget {
target : Texture.Target2D
width : 1024
height : 1024
+ // This texture format may not be supported by
+ // some OpenGL vendors when used as a color attachment
format : Texture.RGB16F
generateMipMaps : false
magnificationFilter : Texture.Linear
diff --git a/examples/deferred-renderer-qml/SceneEffect.qml b/examples/deferred-renderer-qml/SceneEffect.qml
index 5aac9ba78..527422dfc 100644
--- a/examples/deferred-renderer-qml/SceneEffect.qml
+++ b/examples/deferred-renderer-qml/SceneEffect.qml
@@ -53,8 +53,7 @@ Effect {
shaderProgram : ShaderProgram {
id : sceneShaderGL3
vertexShaderCode:
- "
- #version 140
+ "#version 140
in vec4 vertexPosition;
in vec3 vertexNormal;
@@ -77,8 +76,7 @@ Effect {
}
"
fragmentShaderCode:
- "
- #version 140
+ "#version 140
in vec4 color0;
in vec3 position0;
@@ -106,8 +104,7 @@ Effect {
shaderProgram : ShaderProgram {
id : sceneShaderGL2
vertexShaderCode:
- "
- #version 110
+ "#version 110
attribute vec4 vertexPosition;
attribute vec3 vertexNormal;
@@ -130,8 +127,7 @@ Effect {
}
"
fragmentShaderCode:
- "
- #version 110
+ "#version 110
varying vec4 color0;
varying vec3 position0;