melowntech / workshop

Workshop of Melown 3D stack
10 stars 3 forks source link

How do I use a custom shader? #26

Closed TriangularPainter closed 4 years ago

TriangularPainter commented 4 years ago

For learning purposes, I'm going to draw a red triangle using a custom shader. but It doesn't render anything.

  1. the mesh: var mesh = renderer.createMesh({ vertices: [ 0, 0, 0, 0.5, 0.7, 0], vertexSize: 2 })

  2. the shader:

vs:

     attribute vec4 aPosition; 

     void main() {

            gl_Position = aPosition;

     }

fs:

     precision mediump float;

        void main() {

            gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); 
        }
  1. draw call:

      renderer.drawMesh({
    
           mesh: model,
           shader: shader,
           shaderVariables : {
    
        }
    })

demo link

ladislavhorky commented 4 years ago

Hello, are you following any of vts-geospatial tutorials? I would be glad to help if provide some more context (what are you trying to achieve? The VTS Geospatial is a 3D virtual landscape streaming and rendering platform).

Depending on if you are using out C++ or JavaScript clients, you might consider posting issue there.

TriangularPainter commented 4 years ago

Hello, are you following any of vts-geospatial tutorials? I would be glad to help if provide some more context (what are you trying to achieve? The VTS Geospatial is a 3D virtual landscape streaming and rendering platform).

Depending on if you are using out C++ or JavaScript clients, you might consider posting issue there.

oh sorry, I put it in the wrong place, I focused on searching for the answer to the question