Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Mesh is black for some reason

AnatolyAnatoly Mod
edited November 2018 in Questions Posts: 893
-- Use this function to perform your initial setup

function setup()
    k = {}
    g = {}
    for x = 1, 20 do
        k[x] = mesh()
        k[x].texture = "Blocks:Stone"
        k[x].color = vec3(1, 2, 1)
        k[x].shader = shader("Project:Colorise")

        g[x] = k[x]:addRect(0, 0, 0, 0)

    --[[m = mesh()
    m.texture = readImage("Blocks:Stone")
    m.shader = shader("Effects:Ripple")

    rIdx = m:addRect(0, 0, 0, 0)]]
    --m:setRectColor(i, 255,0,0)

-- This function gets called once every frame
function draw()
    -- This sets a dark background color
    background(40, 40, 50)

    -- This sets the line thickness

    for x = 1, 20 do
        k[x]:setRect(g[x], 20*x, 30, 25, 25)

    -- Here we set up the rect texture and size
    --[[m:setRect(rIdx, WIDTH/2, HEIGHT/2, 180, 180)

    -- Configure out custom uniforms for the ripple shader
    m.shader.time = ElapsedTime
    m.shader.freq = 2

    -- Draw the mesh

The only change I’ve made in the shader is the fragment:

// A basic fragment shader

//Default precision qualifier
precision highp float;

//This represents the current texture on the mesh
uniform lowp sampler2D texture;

//The interpolated vertex color for this fragment
varying lowp vec4 vColor;

uniform vec3 color;

//The interpolated texture coordinate for this fragment
varying highp vec2 vTexCoord;

void main()
    //Sample the texture at the interpolated coordinate
    lowp vec4 col = texture2D( texture, vTexCoord ) * vColor;

    //Set the output color to the texture color
    gl_FragColor = vec4(col.r * color.x, col.g * color.y, col.b * color.z, 1);


  • dave1707dave1707 Mod
    Posts: 9,616

    @TokOut Did you try removing color.x, color.y, and color.z to see if that works. If it does, then you can figure out what problem you have with color.

Sign In or Register to comment.