Files
Vulkan-Samples/shaders/gshader_to_mshader/gshader_to_mshader.vert
T
2025-09-04 10:54:47 +08:00

46 lines
1.5 KiB
GLSL

/* Copyright (c) 2023, Mobica Limited
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 the "License";
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#version 450
layout(set = 0, binding = 0) uniform UniformBufferObject {
mat4 model;
mat4 view;
mat4 proj;
} ubo;
layout(location = 0) in vec3 inPosition;
layout(location = 1) in vec3 inNormal;
layout (location = 0) out vec3 outNormal;
layout (location = 1) out vec3 outColor;
layout (location = 2) out vec3 outViewVec;
layout (location = 3) out vec3 outLightVec;
void main()
{
outColor = vec3(0.0f, 1.0f, 1.0f);
gl_Position = ubo.proj * ubo.view * ubo.model * vec4(inPosition, 1.0f);
vec4 FragPos = ubo.model * vec4(inPosition, 1.0f);
vec3 lightPos = vec3(-20.0f, 5.0f, 5.0f);
vec3 lPos = mat3(ubo.model) * lightPos.xyz;
outNormal = mat3(transpose(inverse( ubo.view *ubo.model))) * inNormal;
outLightVec = lPos.xyz - FragPos.xyz;
outViewVec = - (ubo.view * ubo.model * vec4(inPosition, 1.0f)).xyz;
}