Beginner's shader tutorial (Panda3D but general)

Beginner's shader tutorial (Panda3D but general)

Postby Julius » 13 May 2019, 18:27

Might be interesting for some of the developers here:
https://github.com/lettier/3d-game-shad ... -beginners

3D Game Shaders For Beginners

Interested in adding textures, lighting, shadows, normal maps, glowing objects, ambient occlusion, and more to your 3D game? Great! Below is a collection of shading techniques that will take your game visuals to new heights. I've explained each technique in such a way that you can take what you learn here and apply/port it to whatever stack you use—be it Godot, Unity, or something else. For the glue in between the shaders, I've chosen the fabulous Panda3D game engine and the OpenGL Shading Language (GLSL). So if that is your stack, then you'll also get the benefit of learning how to use these shading techniques with Panda3D and OpenGL specifically.
User avatar
Julius
Community Moderator
 
Posts: 3297
Joined: 06 Dec 2009, 14:02

Re: Beginner's shader tutorial (Panda3D but general)

Postby fluffrabbit » 13 May 2019, 19:09

Neat! I'm not seeing anything about PBR/IBL or realistic rendering. My current quest is to find the best algorithms to bake an irradiance map for that (image related). My main sources are the OpenGL ES 3.0 Programming Guide and learnopengl.com, and my stack is SDL or SFML with header-only Glad 2 and linalg.h.

Where this guide really shines is with the effects. SSAO and Phong lighting may not be perfectly realistic, but add all those layers together with the bloom, outlining, and other effects, and it looks amaaazing. However, if you want pixel outlines, a better way to do it is shown here.

Note to self: learnopengl.com has the world's worst diffuse irradiance baker. Polar bias. Yuck. Ideally use pseudorandom sampling to use like 10% the number of texture lookups.

EDIT: According to the author, 20 or so texture lookups per fragment is fast enough to do in a defered renderer, but in a forward renderer like most people use (for the sake of multisampling, alpha transparency, and simplicity) it should really be used as a somewhat faster environment map baker, where the split sum approximation ruins grazing specular reflections and requires the developer to store multiple cubemaps. It's really frustrating that compromises have to made for the sake of efficiency.

EDIT 2: There is no way to sample realtime irradiance from a cubemap using current-gen hardware. The algorithms to get an irradiance map don't even function with fewer than 10 texture lookups per fragment due to the large area that must be sampled. Maybe importance sampling could get it down to 5 texture lookups, but then you have to do a different set of texture lookups to get the specular component, generally in the 12-20 range, so you're doing 17-30 or so texture lookups per fragment, and if you have layered objects some pixels could require 100 texture lookups. That's slideshow territory. I tested it. :(
Attachments
ibltest.png
fluffrabbit
 
Posts: 557
Joined: 11 Apr 2019, 11:17

Re: Beginner's shader tutorial (Panda3D but general)

Postby fluffrabbit » 21 May 2019, 05:44

Another interesting Panda3D project is Physically Based Panda. It only uses punctual lights, therefore failing visually. I am mainly interested in image based lighting as (IMHO) it gets you a lot closer to photorealism than any rendering technique other than raytracing.

I played some Rainbow Six Siege at a friend's house the other day and was very impressed with the grazing specular reflections. Upon reading about the game engine and deciding that the antialiasing technique must be MSAA, therefore making the game forward-rendered, and considering that the engine is made to work on a lot of old consoles, the PBR must use the split sum approximation. Yet somehow the specular reflections look really sharp at grazing angles. Either I'm not giving pre-filtered cubemaps enough credit or there is some other reflection technique at play (reflection planes or screen space reflections).

Is anybody else working on a custom 3D renderer?
Last edited by fluffrabbit on 21 May 2019, 21:48, edited 1 time in total.
fluffrabbit
 
Posts: 557
Joined: 11 Apr 2019, 11:17

Re: Beginner's shader tutorial (Panda3D but general)

Postby Julius » 21 May 2019, 10:57

Somewhat related, there is a temporary offer of graphic programming ebooks on humble bundle right now:
https://www.humblebundle.com/books/comp ... ress-books
User avatar
Julius
Community Moderator
 
Posts: 3297
Joined: 06 Dec 2009, 14:02

Re: Beginner's shader tutorial (Panda3D but general)

Postby fluffrabbit » 21 May 2019, 21:47

If I could afford the $15 I would probably get the full bundle. Maybe a free software high-end graphics programming course is a future FGD project.
fluffrabbit
 
Posts: 557
Joined: 11 Apr 2019, 11:17

Who is online

Users browsing this forum: No registered users and 1 guest