-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added missing shaders and temporary test application
- Loading branch information
Showing
16 changed files
with
694 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<RCC> | ||
<qresource prefix="/"> | ||
<file>shaders/instanced.frag</file> | ||
<file>shaders/instanced.vert</file> | ||
<file>shaders/light.inc.frag</file> | ||
</qresource> | ||
</RCC> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#version 150 core | ||
|
||
// copy of phong.frag from qt3d extras | ||
|
||
uniform vec3 ka; // Ambient reflectivity | ||
uniform vec3 kd; // Diffuse reflectivity | ||
uniform vec3 ks; // Specular reflectivity | ||
uniform float shininess; // Specular shininess factor | ||
|
||
uniform vec3 eyePosition; | ||
|
||
in vec3 worldPosition; | ||
in vec3 worldNormal; | ||
|
||
out vec4 fragColor; | ||
|
||
#pragma include light.inc.frag | ||
|
||
void main() | ||
{ | ||
vec3 diffuseColor, specularColor; | ||
adsModel(worldPosition, worldNormal, eyePosition, shininess, diffuseColor, specularColor); | ||
fragColor = vec4( ka + kd * diffuseColor + ks * specularColor, 1.0 ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#version 150 core | ||
|
||
in vec3 vertexPosition; | ||
in vec3 vertexNormal; | ||
in vec3 pos; | ||
|
||
out vec3 worldPosition; | ||
out vec3 worldNormal; | ||
|
||
uniform mat4 modelView; | ||
uniform mat3 modelViewNormal; | ||
uniform mat4 modelViewProjection; | ||
|
||
uniform mat4 inst; // transform of individual object instance | ||
uniform mat4 instNormal; // should be mat3 but Qt3D only supports mat4... | ||
|
||
void main() | ||
{ | ||
// TODO: i think this is not entirely correct: the translation by "pos" works | ||
// like this only because we assume that "inst" matrix only does translation/scale/rotation | ||
// which all keep "w" set to 1. correctly we should use translation matrix... | ||
vec4 offsetPos = inst * vec4(vertexPosition, 1.0) + vec4(pos, 0.0); | ||
|
||
worldNormal = normalize(modelViewNormal * mat3(instNormal) * vertexNormal); | ||
worldPosition = vec3(modelView * offsetPos); | ||
|
||
gl_Position = modelViewProjection * offsetPos; | ||
} |
Oops, something went wrong.