I checked out the tutorial on https://love2d.org/wiki/love.graphics.drawInstanced but It seems that it only takes an x and y coordinate when I need to instance in 3d.
Also the shader I am using is using a transformation matrix and stuff so I am not sure how I can instance a mesh inside a shader like that.
Code: Select all
SS3D.Scene.threeShader = love.graphics.newShader[[
uniform mat4 view;
uniform mat4 model_matrix;
uniform mat4 model_matrix_inverse;
uniform float ambientLight;
uniform vec3 ambientVector;
varying mat4 modelView;
varying mat4 modelViewProjection;
varying vec3 normal;
varying vec3 vposition;
#ifdef VERTEX
attribute vec4 VertexNormal;
vec4 position(mat4 transform_projection, vec4 vertex_position) {
modelView = view * model_matrix;
modelViewProjection = view * model_matrix * transform_projection;
normal = vec3(model_matrix_inverse * vec4(VertexNormal));
vposition = vec3(model_matrix * vertex_position);
return view * model_matrix * vertex_position;
}
#endif
#ifdef PIXEL
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) {
vec4 texturecolor = Texel(texture, texture_coords);
// if the alpha here is zero just don't draw anything here
// otherwise alpha values of zero will render as black pixels
if (texturecolor.a == 0.0)
{
discard;
}
float light = max(dot(normalize(ambientVector), normal), 0.0);
texturecolor.rgb *= max(light, ambientLight);
return color*texturecolor;
}
#endif
]]