main: color attribute
This commit is contained in:
parent
0a423f850d
commit
50b784e6ab
26
main.lua
26
main.lua
@ -3,13 +3,13 @@ local mesh
|
|||||||
local pixelcode = [[
|
local pixelcode = [[
|
||||||
#pragma language glsl3
|
#pragma language glsl3
|
||||||
|
|
||||||
varying vec4 vpos;
|
varying vec4 PixelColor;
|
||||||
|
|
||||||
out vec4 outData;
|
out vec4 outData;
|
||||||
|
|
||||||
void pixelmain()
|
void pixelmain()
|
||||||
{
|
{
|
||||||
outData = vpos;
|
outData = PixelColor;
|
||||||
}
|
}
|
||||||
]]
|
]]
|
||||||
|
|
||||||
@ -17,12 +17,13 @@ local vertexcode = [[
|
|||||||
#pragma language glsl3
|
#pragma language glsl3
|
||||||
|
|
||||||
layout (location = 0) in vec4 VertexPosition;
|
layout (location = 0) in vec4 VertexPosition;
|
||||||
|
layout (location = 1) in vec4 VertexColor;
|
||||||
|
|
||||||
varying vec4 vpos;
|
varying vec4 PixelColor;
|
||||||
|
|
||||||
void vertexmain()
|
void vertexmain()
|
||||||
{
|
{
|
||||||
vpos = VertexPosition;
|
PixelColor = VertexColor;
|
||||||
love_Position = TransformProjectionMatrix * VertexPosition;
|
love_Position = TransformProjectionMatrix * VertexPosition;
|
||||||
}
|
}
|
||||||
]]
|
]]
|
||||||
@ -31,13 +32,14 @@ shader = love.graphics.newShader(pixelcode, vertexcode)
|
|||||||
|
|
||||||
local vertexformat = {
|
local vertexformat = {
|
||||||
{ name = 'VertexPosition', format = 'floatvec3', location = 0 },
|
{ name = 'VertexPosition', format = 'floatvec3', location = 0 },
|
||||||
|
{ name = 'VertexColor', format = 'floatvec3', location = 1 },
|
||||||
}
|
}
|
||||||
|
|
||||||
local vertexdata = {
|
local vertexdata = {
|
||||||
{-0.5, -0.5, -0.5}, -- tl \|
|
{-0.5, -0.5, -0.5, 1, 0, 0}, -- tl \|
|
||||||
{ 0.5, -0.5, -0.5}, -- tr
|
{ 0.5, -0.5, -0.5, 0, 1, 0}, -- tr
|
||||||
{ 0.5, 0.5, -0.5}, -- br
|
{ 0.5, 0.5, -0.5, 0, 0, 1}, -- br
|
||||||
{ -0.5, 0.5, -0.5}, -- bl |\
|
{ -0.5, 0.5, -0.5, 1, 1, 1}, -- bl |\
|
||||||
}
|
}
|
||||||
|
|
||||||
function love.load(args)
|
function love.load(args)
|
||||||
@ -52,6 +54,14 @@ function love.load(args)
|
|||||||
step = "pervertex", -- vertex attribute step ("pervertex" or "perinstance"), defaults to "pervertex".
|
step = "pervertex", -- vertex attribute step ("pervertex" or "perinstance"), defaults to "pervertex".
|
||||||
startindex = 1, -- 1-based array index within the given vertex buffer where the attribute data will start being pulled from during rendering. Defaults to 1.
|
startindex = 1, -- 1-based array index within the given vertex buffer where the attribute data will start being pulled from during rendering. Defaults to 1.
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
buffer = vertexbuffer,
|
||||||
|
location = 1,
|
||||||
|
name = "VertexColor", -- the name this vertex attribute will use in a shader
|
||||||
|
nameinbuffer = nil, -- the name of the attribute in the vertex buffer. Defaults to the name field.
|
||||||
|
step = "pervertex", -- vertex attribute step ("pervertex" or "perinstance"), defaults to "pervertex".
|
||||||
|
startindex = 1, -- 1-based array index within the given vertex buffer where the attribute data will start being pulled from during rendering. Defaults to 1.
|
||||||
|
},
|
||||||
}
|
}
|
||||||
drawmode = "triangles"
|
drawmode = "triangles"
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user