[Video Tutorials] Introduction to shaders

yes, exacly. but for what is vec4 texCoord, even Lighting JME shader don’t use it…

1 Like

I think this this should be on the wiki too.



@wezrule : Great work man. :slight_smile:

1 Like
@wezrule said:
[java]color *= texture2D(m_ColorMap, vec2(texCoord));[/java]


Or you can be specific and use the right swizzle: texCoord.xy

@oxplay2 said:
yes, exacly. but for what is vec4 texCoord, even Lighting JME shader don't use it...


You only need a vec4 if you need all four. A common example is a sprite shader that needs them to know where the two corners of the texture are.
2 Likes

thank you :slight_smile:



can you also tell me how to make GLSL libs?



is it the same like in C? and files need to be in same folder?

1 Like
@oxplay2 said:
thank you :)

can you also tell me how to make GLSL libs?

is it the same like in C? and files need to be in same folder?


It's looked up like every other asset in JME.
1 Like

ok, i will try, thank you :slight_smile:

1 Like

@oxplay2 @wezrule

JME pass a vector2 as textcoord because texture coordinates are stored as 2 elements vector in the mesh.

Of course if you have you own mesh you can make texcoord whatever you want. feeding a vec2 to a vec4 will work but that’s a waste of gpu bandwidth.



also instead of doing texture2D(m_ColorMap, vec2(texCoord)); where texCoordis a vec4 you can go texture2D(m_ColorMap, texCoord.xy);



this is a powerful glsl feature any vector element can fetched like this

vec4 : myVec4.xyzw or myVec4.rgba. that does the same thing and return a vec4(x,y,z,w)

you can easily fetch a vec3 or 2 from a vec4 : myVec4.xyz returns a vec3(x,y,z).



But the most powerful thing about this is that you can go myVec4.agbr or even myVec4.aagg, and switching or duplicating the attributes.



It makes manipulating vectors very easy and swaping channels in colors for example is ubber simple.

3 Likes

wow, that is great, thanks for info! :o



so easy to flip data.

1 Like

Nice. I like that in video 3 there are some errors that are fixed. I think that is good in instructional videos, because you get to see the author solve actual problems and not just add stuff using a script.

1 Like

Really nice work, although watching 3 and 5 is painful, I saw the mistake as you made it then had to watch as you hunted for it :frowning:

2 Likes

cool thanks Paul and Remy <3, so i should always use vec2 unless I/someone explicity creates a vector4f texture coordinate for the mesh, thanks!



@zarch yeh but you a shader pro so :P, I agree with @androlo you pay more attention to something when it doesn’t work, regardless of what it is. And i never said these were good :slight_smile:



Gonna work on some networking video tutorials next, I will plan and prepare them a lot better than these! :stuck_out_tongue:



Thanks again guys! you rock <33



EDIT: and i updated the wiki to include them, as per request

2 Likes

Lol, I’m no Shader pro :slight_smile:



Just coder pro :smiley:





Good tutorials though, nice introduction to all the concepts.

1 Like

@wezrule would you take some of your time to start blocking out the tutorial page of “Rendering Buckets”? I hardly know anything about it.



Thank you for making these tutorials.

1 Like

hmmm best person for that is @nehon I think, best ask him nicely :stuck_out_tongue:

Just not very much to say about render buckets. All geometry gets sorted into render buckets. Render buckets are drawn in a particular order. Objects in a render bucket are also drawn in a particular order specific to the bucket.



What else is there?

2 Likes
@wezrule said:
hmmm best person for that is @nehon I think, best ask him nicely :P

He already did actually :p. My bad, I'll make that doc.
@pspeed not a lot more, but it can be explained a bit more in depth.
1 Like

@wezrule: Nice tuts, man! Keep it up.

1 Like
@androlo said:
Nice. I like that in video 3 there are some errors that are fixed. I think that is good in instructional videos, because you get to see the author solve actual problems and not just add stuff using a script.

I second this. Some of my best teachers would intentionally make mistakes to keep us on our toes. If you're not second guessing what you're being told, there's effectively much less processing going on, i.e. less efficient learning. Once you're a shader guru, you better learn how to make mistakes on purpose ;)

p.s. congrats on 100k total video views! Also, these videos don't seem to be tied into an actual series (playlist). Is that the case or is YouTube just being weird?
2 Likes

I did put them in a Playlist:

[jME Tutorial 2-1] Shaders in the jMonkeyEngine - YouTube



im not sure what happens, sometimes youtube never seems to like my playlists though



haha yeh and 69 subscribers, getting some lucky numbers these days :wink:

2 Likes
@nehon said:
He already did actually :p. My bad, I'll make that doc.


:) :) :)