mirror of
https://github.com/overte-org/overte.git
synced 2025-06-19 20:00:19 +02:00
69 lines
1.9 KiB
Text
69 lines
1.9 KiB
Text
<@include gpu/Config.slh@>
|
|
<$VERSION_HEADER$>
|
|
// Generated on <$_SCRIBE_DATE$>
|
|
//
|
|
// deferred_light_spot.vert
|
|
// vertex shader
|
|
//
|
|
// Created by Sam Gateau on 7/8/15.
|
|
// Copyright 2015 High Fidelity, Inc.
|
|
//
|
|
// Distributed under the Apache License, Version 2.0.
|
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
//
|
|
|
|
<@include gpu/Inputs.slh@>
|
|
|
|
<@include gpu/Transform.slh@>
|
|
|
|
<$declareStandardTransform()$>
|
|
|
|
<@include graphics/Light.slh@>
|
|
<$declareLightBuffer(256)$>
|
|
|
|
uniform lightIndexBuffer {
|
|
int lightIndex[256];
|
|
};
|
|
out vec4 _texCoord0;
|
|
|
|
void main(void) {
|
|
vec4 coneVertex = inPosition;
|
|
int instanceID = lightIndex[gl_InstanceID];
|
|
Light light = getLight(instanceID);
|
|
vec3 lightPos = getLightPosition(light);
|
|
vec4 coneParam = vec4(1.0); // = getLightVolumeGeometry(light);
|
|
|
|
if(coneVertex.z >= 0.0) {
|
|
// Evaluate the true position of the spot volume
|
|
vec2 dir = float(coneVertex.z < 0.5f) * (coneParam.xy
|
|
+ vec2(coneParam.y, -coneParam.x) * coneParam.z * float(coneVertex.z > 0.0f))
|
|
+ float(coneVertex.z > 0.5f) * (vec2(1.0, 0.0)
|
|
+ vec2(0.0, coneParam.z) * float(coneVertex.z < 1.0f));
|
|
|
|
coneVertex.xy *= dir.y;
|
|
coneVertex.z = -dir.x;
|
|
} else {
|
|
coneVertex.z = 0.0;
|
|
}
|
|
|
|
coneVertex.xyz *= coneParam.w;
|
|
|
|
coneVertex.xyz += lightPos;
|
|
|
|
// standard transform
|
|
TransformCamera cam = getTransformCamera();
|
|
<$transformWorldToClipPos(cam, coneVertex, gl_Position)$>;
|
|
|
|
vec4 projected = gl_Position / gl_Position.w;
|
|
projected.xy = (projected.xy + 1.0) * 0.5;
|
|
|
|
#ifdef GPU_TRANSFORM_IS_STEREO
|
|
#ifdef GPU_TRANSFORM_STEREO_SPLIT_SCREEN
|
|
#else
|
|
if (cam_isStereo()) {
|
|
projected.x = 0.5 * (projected.x + cam_getStereoSide());
|
|
}
|
|
#endif
|
|
#endif
|
|
_texCoord0 = vec4(projected.xy, 0.0, 1.0) * gl_Position.w;
|
|
}
|