45 lines
1.5 KiB
GLSL
45 lines
1.5 KiB
GLSL
#version 460
|
|
#extension GL_EXT_nonuniform_qualifier : require
|
|
#extension GL_EXT_scalar_block_layout : require
|
|
#extension GL_EXT_shader_16bit_storage : 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) flat uint instance;
|
|
layout(location = 1) vec3 positionVS;
|
|
layout(location = 2) vec2 texCoord;
|
|
layout(location = 3) vec3 normalVS;
|
|
layout(location = 4) vec3 tangentVS;
|
|
layout(location = 5) vec3 bitangentVS;
|
|
} var;
|
|
|
|
#include "includes/main_common.glsl"
|
|
|
|
#define OBJECT _Object[gl_InstanceIndex]
|
|
|
|
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.instance = gl_InstanceIndex;
|
|
var.positionVS = positionVS;
|
|
var.texCoord = texCoord;
|
|
var.normalVS = normalVS;
|
|
var.tangentVS = tangentVS;
|
|
var.bitangentVS = bitangentVS;
|
|
}
|