/* * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved. * * 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. * * SPDX-FileCopyrightText: Copyright (c) 2019-2021 NVIDIA CORPORATION * SPDX-License-Identifier: Apache-2.0 */ #version 460 #extension GL_ARB_separate_shader_objects : enable #extension GL_EXT_scalar_block_layout : enable #extension GL_GOOGLE_include_directive : enable #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require #include "wavefront.glsl" layout(binding = 0, scalar) buffer Vertices_ { Vertex v[]; } vertices; layout(push_constant) uniform shaderInformation { float iTime; } pushc; void main() { Vertex v0 = vertices.v[gl_GlobalInvocationID.x]; // Compute vertex position const float PI = 3.14159265; const float signY = (v0.pos.y >= 0 ? 1 : -1); const float radius = length(v0.pos.xz); const float argument = pushc.iTime * 4 + radius * PI; const float s = sin(argument); v0.pos.y = signY * abs(s) * 0.5; // Compute normal if(radius == 0.0f) { v0.nrm = vec3(0.0f, signY, 0.0f); } else { const float c = cos(argument); const float xzFactor = -PI * s * c; const float yFactor = 2.0f * signY * radius * abs(s); v0.nrm = normalize(vec3(v0.pos.x * xzFactor, yFactor, v0.pos.z * xzFactor)); } vertices.v[gl_GlobalInvocationID.x] = v0; }