40 lines
1.3 KiB
GLSL
40 lines
1.3 KiB
GLSL
#version 460
|
|
#extension GL_EXT_nonuniform_qualifier : require
|
|
#extension GL_EXT_scalar_block_layout : require
|
|
|
|
layout(location = 0) in vec3 positionOS;
|
|
layout(location = 1) in vec2 texCoord;
|
|
layout(location = 2) in vec3 normalOS;
|
|
layout(location = 3) in vec4 tangentOS;
|
|
|
|
out Varyings {
|
|
layout(location = 0) vec3 positionVS;
|
|
layout(location = 1) vec2 texCoord;
|
|
layout(location = 2) vec3 normalVS;
|
|
layout(location = 3) vec3 tangentVS;
|
|
layout(location = 4) vec3 bitangentVS;
|
|
} var;
|
|
|
|
#include "main_common.glsl"
|
|
|
|
void main() {
|
|
vec3 positionWS = (_Object.matrixOStoWS * vec4(positionOS, 1.0)).xyz;
|
|
vec3 positionVS = (_Global.matrixWStoVS * vec4(positionWS, 1.0)).xyz;
|
|
vec4 positionCS = _Global.matrixVStoCS * vec4(positionVS, 1.0);
|
|
|
|
vec3 normalWS = normalize((_Object.matrixOStoWSNormal * vec4(normalOS, 0.0)).xyz);
|
|
vec3 normalVS = normalize((_Global.matrixWStoVS * vec4(normalWS, 0.0)).xyz);
|
|
|
|
vec3 tangentWS = normalize((_Object.matrixOStoWSNormal * vec4(tangentOS.xyz, 0.0)).xyz);
|
|
vec3 tangentVS = normalize((_Global.matrixWStoVS * vec4(tangentWS, 0.0)).xyz);
|
|
|
|
vec3 bitangentVS = tangentOS.w * normalize(cross(normalVS, tangentVS));
|
|
|
|
gl_Position = positionCS;
|
|
var.positionVS = positionVS;
|
|
var.texCoord = texCoord;
|
|
var.normalVS = normalVS;
|
|
var.tangentVS = tangentVS;
|
|
var.bitangentVS = bitangentVS;
|
|
}
|