Generate some random heights to fill the height map texture and ... it works!

This commit is contained in:
Eryn Wells 2018-11-04 08:25:01 -05:00
parent 18e9d078b0
commit af5e5a6123
2 changed files with 27 additions and 6 deletions

View file

@ -30,7 +30,7 @@ typedef struct
} ColorInOut;
vertex ColorInOut vertexShader(Vertex in [[stage_in]],
texture2d<half> heights [[texture(0)]],
texture2d<float> heights [[texture(0)]],
constant Uniforms & uniforms [[buffer(BufferIndexUniforms)]])
{
constexpr sampler s(coord::pixel, address::clamp_to_zero, filter::linear);
@ -39,9 +39,9 @@ vertex ColorInOut vertexShader(Vertex in [[stage_in]],
// TODO: Concerned about this.
uint2 gridCoord(in.texCoord.x * heights.get_width(), in.texCoord.y * heights.get_height());
half4 height = heights.read(gridCoord).rrrr;
float4 height = heights.read(gridCoord).rrrr;
float4 position(in.position.x, float(height.r), in.position.z, 1.0);
float4 position(in.position.x, height.r, in.position.z, 1.0);
out.position = uniforms.projectionMatrix * uniforms.modelViewMatrix * position;
out.texCoord = in.texCoord;