ksuprynowiczVulkan cleanup 24ab3c961 year agoHistory
134 lines · 4.8 KB · Text
RawDownload
<@include gpu/Config.slh@><$VERSION_HEADER$>//  <$_SCRIBE_FILENAME$>//  Generated on <$_SCRIBE_DATE$>////  Created by Hifi Engine Team//  Copyright 2019 High Fidelity, Inc.//  Copyright 2024 Overte e.V.////  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@><$declareMultipleTexCoords()$> <@include gpu/Color.slh@><@include render-utils/ShaderConstants.h@><@include gpu/Transform.slh@><$declareStandardTransform()$> <@include graphics/MaterialTextures.slh@><$declareMaterialTexMapArrayBuffer()$> <@if HIFI_USE_DEFORMED or HIFI_USE_DEFORMEDDQ@>    <@include MeshDeformer.slh@>    <@if HIFI_USE_DEFORMEDDQ@>        <@if HIFI_USE_SHADOW@>            <$declareMeshDeformer(_SCRIBE_NULL, _SCRIBE_NULL, 1, 1, 1)$>        <@elif not HIFI_USE_NORMALMAP@>            <$declareMeshDeformer(1, _SCRIBE_NULL, 1, 1, 1)$>        <@elif HIFI_USE_TRIPLANAR@>            <$declareMeshDeformer(1, _SCRIBE_NULL, 1, 1, 1)$>        <@else@>            <$declareMeshDeformer(1, 1, 1, 1, 1)$>        <@endif@>    <@else@>        <@if HIFI_USE_SHADOW@>            <$declareMeshDeformer(_SCRIBE_NULL, _SCRIBE_NULL, 1, _SCRIBE_NULL, 1)$>        <@elif not HIFI_USE_NORMALMAP@>            <$declareMeshDeformer(1, _SCRIBE_NULL, 1, _SCRIBE_NULL, 1)$>        <@elif HIFI_USE_TRIPLANAR@>            <$declareMeshDeformer(1, _SCRIBE_NULL, 1, _SCRIBE_NULL, 1)$>        <@else@>            <$declareMeshDeformer(1, 1, 1, _SCRIBE_NULL, 1)$>        <@endif@>    <@endif@>    <$declareMeshDeformerActivation(1, 1)$><@endif@> OUTPUT(RENDER_UTILS_ATTR_POSITION_WS, vec4, _positionWS);OUTPUT(RENDER_UTILS_ATTR_TEXCOORD01, vec4, _texCoord01[NUM_LAYERS]);<@if not HIFI_USE_SHADOW@>    OUTPUT(RENDER_UTILS_ATTR_POSITION_ES, vec4, _positionES);    OUTPUT(RENDER_UTILS_ATTR_NORMAL_WS, vec3, _normalWS);    <@if not HIFI_USE_MTOON@>        OUTPUT(RENDER_UTILS_ATTR_COLOR, vec4, _color);    <@endif@>    OUTPUT(RENDER_UTILS_ATTR_PREV_POSITION_CS, vec4, _prevPositionCS);    <@if not HIFI_USE_TRIPLANAR@>        <@if HIFI_USE_NORMALMAP@>            OUTPUT(RENDER_UTILS_ATTR_TANGENT_WS, vec3, _tangentWS);        <@endif@>    <@endif@><@endif@><@if HIFI_USE_TRIPLANAR@>    OUTPUT(RENDER_UTILS_ATTR_POSITION_MS, vec3, _positionMS);    OUTPUT(RENDER_UTILS_ATTR_NORMAL_MS, vec3, _normalMS);<@endif@> void main(void) {    vec4 positionMS = inPosition;    vec3 normalMS = inNormal.xyz;<@if not HIFI_USE_TRIPLANAR@>    vec3 tangentMS = inTangent.xyz;<@endif@> <@if HIFI_USE_TRIPLANAR@>        _positionMS = inPosition.xyz;        _normalMS = normalMS.xyz;<@endif@> <@if HIFI_USE_DEFORMED or HIFI_USE_DEFORMEDDQ@>        evalMeshDeformer(inPosition, positionMS,    <@if not HIFI_USE_SHADOW@>                            inNormal.xyz, normalMS,        <@if HIFI_USE_NORMALMAP@>            <@if not HIFI_USE_TRIPLANAR@>                                inTangent.xyz, tangentMS,            <@endif@>        <@endif@>    <@endif@>                         meshDeformer_doSkinning(_inDrawCallInfo.y), inSkinClusterIndex, inSkinClusterWeight,                         meshDeformer_doBlendshape(_inDrawCallInfo.y), gl_VertexID);<@endif@>     TransformCamera cam = getTransformCamera();    TransformObject obj = getTransformObject();<@if not HIFI_USE_SHADOW@>    <@if not HIFI_USE_MTOON@>            _color = color_sRGBAToLinear(inColor);    <@endif@>         <$transformModelToWorldEyeClipPosAndPrevClipPos(cam, obj, positionMS, _positionWS, _positionES, gl_Position, _prevPositionCS)$>        <$transformModelToWorldDir(obj, normalMS, _normalWS)$><@else@>        <$transformModelToClipPos(cam, obj, positionMS, gl_Position)$>        <$transformModelToWorldPos(obj, positionMS, _positionWS)$><@endif@> <@if HIFI_USE_NORMALMAP@>    <@if not HIFI_USE_TRIPLANAR@>        <$transformModelToWorldDir(obj, tangentMS, _tangentWS)$>    <@endif@><@endif@>     for (int layer = 0; layer < NUM_LAYERS; layer++) {        _texCoord01[layer] = vec4(0.0);    <@if HIFI_USE_SHADOW@>            Material mat = getMaterial(layer);            BITFIELD matKey = getMaterialKey(mat);            // If we have an opacity mask than we need the first tex coord            if ((matKey & OPACITY_MASK_MAP_BIT) != 0) {                TexMapArray texMapArray = getTexMapArray(layer);                <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01[layer].xy)$>                <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _positionWS, _texCoord01[layer].zw)$>            }    <@else@>            TexMapArray texMapArray = getTexMapArray(layer);            <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _positionWS, _texCoord01[layer].xy)$>            <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _positionWS, _texCoord01[layer].zw)$>    <@endif@>    }}