WEBGL Gradient Triangle 🔻 [solved] | Sololearn: Learn to code for FREE!

+2

WEBGL Gradient Triangle 🔻 [solved]

I wanna add gradient in triangle.

6/30/2022 9:28:09 AM

SAN

10 Answers

New Answer

+5

By applying I meant gl_FragColor = v_Color; Anyway I should give you few tips for your next WebGL codes: 1) create shaders only once in beginning of your code + save all attrib/uniform locations in variables 2) store buffers for each object, recreate buffer data only if they change https://code.sololearn.com/Wnlp95QD05gI/?ref=app

+2

you can also create a texture then stickit onto your shapes. you can even draw on a separate regular 2d context canvas and use that for a texture. ... so many possibilities.

+1

😑😵😵 Are you kidding me? Who can make triangle out of 6 vertices... I was trying to find the issue for 20 minutes. You need to assign same number of colors in your case 6 colors instead of 3

+1

And don't forget to apply v_Color in fragment shader

0

ChillPill 🌶

0

David (DonDejvo) I already added 3 colors in line 58, but it's not working

0

Here is 2 right angle triangle 🔺️

0

So working?

0

It's not working :(

0

Thank you 😊, now it's working fine.