Issues with vertex shaders: Failed to compile vertex shader


Im trying to figure out how to do vertex shaders when I hit a snag! (Thank you @devMidgard :wink:)

ERROR: 0:49: 'getPosition' : no matching overloaded function found
ERROR: 0:49: '=' : dimension mismatch
ERROR: 0:49: 'assign' : cannot convert from 'const mediump float' to 'Position highp 4-component vector of float'
ERROR: 0:50: 'getWorldPosition' : no matching overloaded function found
ERROR: 0:50: '=' : dimension mismatch
ERROR: 0:50: 'assign' : cannot convert from 'const mediump float' to 'out highp 3-component vector of float'

[[playcanvas-stable.dbg.js:6035]]( Cannot read property 'samplers' of null

Heres a link to my project:

Hi @Scottss,

You will have to study GLSL on how to write valid shader code in Playcanvas.

Regarding your project, both the grass.vert and grass.frag files are empty, you will have to write some GLSL to get started with.

@Leonidas :man_facepalming: it might help if there is code in the shader files! I added the code from devMidgards Grass Project WebGL 1 project but I am still having issues.

I’ve researched Shaders a lot but they seem really hard to comprehend, do you have a recommended starting point? Shaders seem like they aren’t for the faint of heart, which I am.

Thank you for you reply!

@Scottss sadly there’s not a lot of documentation on how to write shaders using PlayCanvas’ shader chunks to take advantage of lighting, shadows, etc.

When I wrote the simple grass you’re trying to use, I was basically doing trial & error, but the starting point was

This thread also helped a lot: Custom vertex attributes in chunk

And finally, @Leonidas put this together as well:

Which basically walks you through how shaders work and gives you examples.

I still have pending writing a new grass system which is easy to implement & actually performant & with more features than what I had shared around here. Someday i’ll do it when I have some time.

1 Like

Thank you for your response, i will give those a thorough read-through!

1 Like