aboutsummaryrefslogtreecommitdiffstatsci
path: root/samples/Model/shaders/model.vert
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2019-04-01 14:24:57 +0200
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2019-04-01 14:24:57 +0200
commit9af331260bf34cd2f7578e863367dec69b32fa68 (patch)
tree47b91a2e1a71bcc8e86847faeacb35bff53bad19 /samples/Model/shaders/model.vert
parente4ff67fb5f3a492809dcac8b09b8b4b0ba288044 (diff)
model
Diffstat (limited to 'samples/Model/shaders/model.vert')
-rw-r--r--samples/Model/shaders/model.vert19
1 files changed, 17 insertions, 2 deletions
diff --git a/samples/Model/shaders/model.vert b/samples/Model/shaders/model.vert
index b1329ef..37b83d7 100644
--- a/samples/Model/shaders/model.vert
+++ b/samples/Model/shaders/model.vert
@@ -15,15 +15,30 @@ layout (binding = 0) uniform UBO
} ubo;
layout (location = 0) out vec2 outUV;
+layout (location = 1) out vec3 outN;
+layout (location = 2) out vec3 outV;//ViewDir
out gl_PerVertex
{
vec4 gl_Position;
};
+layout(push_constant) uniform PushConsts {
+ mat4 model;
+} pc;
void main()
{
- outUV = inUV;
- gl_Position = ubo.projectionMatrix * ubo.viewMatrix * ubo.modelMatrix * vec4(inPos.xyz, 1.0);
+ outUV = inUV;
+
+ mat4 mod = ubo.modelMatrix * pc.model;
+ vec4 pos = mod * vec4(inPos.xyz, 1.0);
+
+ //outN = normalize(transpose(inverse(mat3(mod))) * inNormal);
+ outN = normalize(mat3(mod)* inNormal);
+
+ mat4 viewInv = inverse(ubo.viewMatrix);
+ outV = -(ubo.viewMatrix * pos).xyz;//normalize(vec3(viewInv * vec4(0.0, 0.0, 0.0, 1.0) - pos));
+
+ gl_Position = ubo.projectionMatrix * ubo.viewMatrix * pos;
}