Update heights of plane geometry in a shader kernel

This commit is contained in:
Eryn Wells 2018-11-11 19:50:43 -05:00
parent e5678f291b
commit 3462fa2458
4 changed files with 80 additions and 10 deletions

View file

@ -34,15 +34,14 @@ vertex ColorInOut vertexShader(Vertex in [[stage_in]],
texture2d<float> heights [[texture(0)]],
constant Uniforms & uniforms [[buffer(BufferIndexUniforms)]])
{
constexpr sampler s(coord::normalized, address::clamp_to_zero, filter::linear);
// constexpr sampler s(coord::normalized, address::clamp_to_zero, filter::linear);
ColorInOut out;
float4 height = heights.sample(s, in.texCoord);
// float4 height = heights.sample(s, in.texCoord);
// Replace the y coordinate with the height we read from the texture.
float4 position(in.position.x, height.r, in.position.z, 1.0);
out.position = uniforms.projectionMatrix * uniforms.modelViewMatrix * position;
out.position = uniforms.projectionMatrix * uniforms.modelViewMatrix * float4(in.position, 1.0);
out.normal = in.normal;
out.texCoord = in.texCoord;