Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (580)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  GLSL and Shader-based Tutorials for LWJGL / LibGDX  (Read 6909 times)
0 Members and 1 Guest are viewing this topic.
Offline davedes
« Posted 2012-12-11 06:29:45 »

I'm writing a short tutorial series on GLSL and OpenGL programming in LWJGL and LibGDX. It's aimed at programmers with little or no OpenGL/GLSL experience, but it will also cover advanced topics.

You can see some of the GLSL lessons here:
https://github.com/mattdesl/lwjgl-basics/wiki/Shaders

The first three lessons should cover all the basics you need to start your own shader programming.

The tutorials use the minimal lwjgl-basics API, but the concepts can easily be applied to any OpenGL-based library (such as LibGDX, Love2D, Pyglet, MonoTouch, etc). Each GLSL lesson includes a LibGDX port at the end.

The wiki also includes other tutorials and code snippets for LWJGL/LibGDX/GLSL:
https://github.com/mattdesl/lwjgl-basics/wiki

Comments and criticisms are welcome.

Note: The API itself will continue to grow as a separate entity; however, this thread will be contained to the tutorial series.

Offline Roquen
« Reply #1 - Posted 2012-12-12 14:02:49 »


ShaderLesson3 : Step 2 : "If x is between the two values, it will linearly interpolate between zero and one."  Not linear..it's a cubic hermite (a la the noise wiki page), or s-curve or ease function. 
Offline StrideColossus
« Reply #2 - Posted 2012-12-12 18:18:11 »

Nice set of tutorials, simply written and nicely laid out.   Smiley

Couple of suggestions:

1. The tutorials are using attribute, varying, etc. rather than #version, vertex layout descriptors, in/out, etc.  Might be worth adding a more advanced lesson that covers layouts, uniform blocks, etc. and explains the differences between the core and compatibility profiles as far as shaders are concerned.

2. Explain the notion of the various built-in values, i.e. gl_Position, gl_FragColor, etc.
It's implicit and probably obvious to most people, but might be worth pointing them out.

Other than that looks very good to me, keep up the good work.  I'll be adding this to my personal list of tutorials.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline davedes
« Reply #3 - Posted 2012-12-12 19:58:11 »


ShaderLesson3 : Step 2 : "If x is between the two values, it will linearly interpolate between zero and one."  Not linear..it's a cubic hermite (a la the noise wiki page), or s-curve or ease function.  
Thanks, will fix.

Nice set of tutorials, simply written and nicely laid out.   Smiley

Couple of suggestions:

1. The tutorials are using attribute, varying, etc. rather than #version, vertex layout descriptors, in/out, etc.  Might be worth adding a more advanced lesson that covers layouts, uniform blocks, etc. and explains the differences between the core and compatibility profiles as far as shaders are concerned.

2. Explain the notion of the various built-in values, i.e. gl_Position, gl_FragColor, etc.
It's implicit and probably obvious to most people, but might be worth pointing them out.

Other than that looks very good to me, keep up the good work.  I'll be adding this to my personal list of tutorials.

1. My Mac Snow Leopard only supports GL 2.1 and thus GLSL 120, so that's all I can use.

It's more than sufficient for advanced 2D games (the focus of this series), and core profile doesn't add too many things that aren't already present in extensions (e.g. framebuffers). For maximum support across versions (see Mac versions here) you should not rely on the core profile. Minecraft stats at one point listed only 51% of all users running OpenGL 3+.

Also, OpenGL ES (Android, iOS, WebGL) doesn't use GLSL 330, and often doesn't even support #version 120. I'm aiming for cross-platform code rather than bleeding edge.  Smiley

At a later stage I may include an "appendix" that details some of the changes, such as in/out, "location" qualifier, etc.

2. Thanks, I will try to add more details on built-ins.

Offline matheus23

JGO Wizard


Medals: 97
Projects: 3


You think about my Avatar right now!


« Reply #4 - Posted 2012-12-12 21:04:48 »


ShaderLesson3 : Step 2 : "If x is between the two values, it will linearly interpolate between zero and one."  Not linear..it's a cubic hermite (a la the noise wiki page), or s-curve or ease function. 

As long as you've got a github account, you can edit the wiki yourself with a commit message Smiley
I fixed a typo from "Valuse" to "Values", for example.

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline badlogicgames
« Reply #5 - Posted 2012-12-13 10:15:10 »

Great stuff, something we can point our folks to to start learning GLSL. Nice that you keep it "crossplatform", wouldn't mind the appendix you talked about.

http://www.badlogicgames.com - musings on Android and Java game development
Offline davedes
« Reply #6 - Posted 2012-12-29 06:07:47 »

Thanks for the feedback.

Added several more articles:
I've also added basic BMFont support to the API. It already supports unicode strings and multiple texture pages, unlike Slick's AngelCodeFont utility. Smiley

Offline Sammyster

Senior Newbie


Medals: 1



« Reply #7 - Posted 2012-12-30 19:44:57 »

Really nice!
Easy to follow and well explained, going to learn alot from this Smiley
Offline davedes
« Reply #8 - Posted 2013-01-28 07:50:59 »

Another update: next lesson is finished.

Shader Lesson 6 - Normal Mapping for 2D Games

The tutorial takes a regular texture, like this:


And applies illumination to it in real-time:

Offline Danny02
« Reply #9 - Posted 2013-01-28 08:57:17 »

a quick note about light attenuation, the formular with constant linear and quadratic factors is of course right. But just using random values for them isn't that easy and right.

So for a  spherical area light the attenuation equation looks like this:
1  
2  
3  
4  
attenuation = 1 / (d / r + 1
=> constantFactor = 1;
     linearFactor = 2/r;
     quadraticFactor = 1/r²;


where d is the distance to the surface of the light sphere and r the radius of it.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (47 views)
2014-04-15 18:08:23

BurntPizza (43 views)
2014-04-15 03:46:01

UprightPath (59 views)
2014-04-14 17:39:50

UprightPath (41 views)
2014-04-14 17:35:47

Porlus (57 views)
2014-04-14 15:48:38

tom_mai78101 (80 views)
2014-04-10 04:04:31

BurntPizza (139 views)
2014-04-08 23:06:04

tom_mai78101 (239 views)
2014-04-05 13:34:39

trollwarrior1 (199 views)
2014-04-04 12:06:45

CJLetsGame (207 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!