diff options
Diffstat (limited to 'assets')
| -rw-r--r-- | assets/models/cube.bin | bin | 840 -> 1224 bytes | |||
| -rw-r--r-- | assets/models/cube.gltf | 69 | ||||
| -rw-r--r-- | assets/models/cube.png | bin | 0 -> 182802 bytes | |||
| -rw-r--r-- | assets/shaders/texture.frag | 16 | ||||
| -rw-r--r-- | assets/shaders/vert.vert | 32 |
5 files changed, 97 insertions, 20 deletions
diff --git a/assets/models/cube.bin b/assets/models/cube.bin Binary files differindex c59221c..6223cf0 100644 --- a/assets/models/cube.bin +++ b/assets/models/cube.bin diff --git a/assets/models/cube.gltf b/assets/models/cube.gltf index 5077394..9bc8a22 100644 --- a/assets/models/cube.gltf +++ b/assets/models/cube.gltf @@ -21,14 +21,11 @@ "materials":[ { "doubleSided":true, - "name":"Material", + "name":"Material.001", "pbrMetallicRoughness":{ - "baseColorFactor":[ - 0.800000011920929, - 0.800000011920929, - 0.800000011920929, - 1 - ], + "baseColorTexture":{ + "index":0 + }, "metallicFactor":0, "roughnessFactor":0.5 } @@ -36,25 +33,45 @@ ], "meshes":[ { - "name":"Cube", + "name":"Cube.001", "primitives":[ { "attributes":{ - "POSITION":0, - "NORMAL":1, - "TEXCOORD_0":2 + "COLOR_0":0, + "POSITION":1, + "NORMAL":2, + "TEXCOORD_0":3 }, - "indices":3, + "indices":4, "material":0 } ] } ], + "textures":[ + { + "sampler":0, + "source":0 + } + ], + "images":[ + { + "mimeType":"image/png", + "name":"cube", + "uri":"cube.png" + } + ], "accessors":[ { "bufferView":0, "componentType":5126, "count":24, + "type":"VEC4" + }, + { + "bufferView":1, + "componentType":5126, + "count":24, "max":[ 1, 1, @@ -68,19 +85,19 @@ "type":"VEC3" }, { - "bufferView":1, + "bufferView":2, "componentType":5126, "count":24, "type":"VEC3" }, { - "bufferView":2, + "bufferView":3, "componentType":5126, "count":24, "type":"VEC2" }, { - "bufferView":3, + "bufferView":4, "componentType":5123, "count":36, "type":"SCALAR" @@ -89,32 +106,44 @@ "bufferViews":[ { "buffer":0, - "byteLength":288, + "byteLength":384, "byteOffset":0, "target":34962 }, { "buffer":0, "byteLength":288, - "byteOffset":288, + "byteOffset":384, + "target":34962 + }, + { + "buffer":0, + "byteLength":288, + "byteOffset":672, "target":34962 }, { "buffer":0, "byteLength":192, - "byteOffset":576, + "byteOffset":960, "target":34962 }, { "buffer":0, "byteLength":72, - "byteOffset":768, + "byteOffset":1152, "target":34963 } ], + "samplers":[ + { + "magFilter":9729, + "minFilter":9987 + } + ], "buffers":[ { - "byteLength":840, + "byteLength":1224, "uri":"cube.bin" } ] diff --git a/assets/models/cube.png b/assets/models/cube.png Binary files differnew file mode 100644 index 0000000..74a7e29 --- /dev/null +++ b/assets/models/cube.png diff --git a/assets/shaders/texture.frag b/assets/shaders/texture.frag new file mode 100644 index 0000000..e63995f --- /dev/null +++ b/assets/shaders/texture.frag @@ -0,0 +1,16 @@ +# version 450 + +layout(location = 0) in vec3 fragColor; +layout(location = 1) in vec3 fragTexCoord; + +layout(location = 0) out vec4 outColor; + +layout(binding = 1) uniform sampler2D texSampler; + +void main() { + vec4 color = texture(texSampler, fragTexCoord.xy); + if (color.w == 0) { + discard; + } + outColor = color; +} diff --git a/assets/shaders/vert.vert b/assets/shaders/vert.vert new file mode 100644 index 0000000..f3e7cf2 --- /dev/null +++ b/assets/shaders/vert.vert @@ -0,0 +1,32 @@ +#version 450 + +layout(binding = 0) uniform UniformBufferObject { + mat4 model; + mat4 view; + mat4 proj; +} ubo; + +// vertex +layout(location = 0) in vec4 inColor; +layout(location = 1) in vec3 inPosition; +layout(location = 2) in vec3 inNorm; +layout(location = 3) in vec2 inTexCoord; + +// instance +layout(location = 4) in mat4 instPosRotScale; +layout(location = 8) in float textureIndex; + +// output +layout(location = 0) out vec3 fragColor; +layout(location = 1) out vec3 fragTexCoord; + +void main() { + gl_Position = + ubo.proj * + ubo.view * + ubo.model * + instPosRotScale * + vec4(inPosition, 1.0); + fragColor = inColor; + fragTexCoord = vec3(inTexCoord, textureIndex); +} |
