C++ and Vulkan

14 views
Skip to first unread message

Bruce Brown

unread,
May 30, 2017, 7:27:34 AM5/30/17
to Philly Dev Night
Hello, I've been working on a from scratch 3d engine using Vulkan for giggles and education in my spare time.  I've hit a snag recently with organizing the shaders.  So I've got a model that has many objects -- and each Object could have zero or many textures.  So how does that translate to shaders?  I've got a basic phong shader that has a texture sampler in the fragment module.  Should I change it to a texture array and try to handle the 0 or many? What if I try to sample a texture that isn't present?

If anyone has any insight that would be awesome!
https://github.com/Drakoskai/vulkan-renderer


Bruce Brown

unread,
May 31, 2017, 1:44:21 PM5/31/17
to Philly Dev Night
Did some google-ing and re-read a couple chapters of my books.  It looks like the solution here is to either write a fragment shader for each potential combination of textures that has a number of samplers that correlates or, have 1 fragment shader that has all of the potential samplers and then push a uniform block indicating which of the samplers are populated.

Anyone have any better solutions?

PS my goal is to render the CryEngine updated sponza.obj from 2010 then maybe render some terrain from a height map and put them together.

So far the old old sponza loads now I'm getting hung up on some some vulkan resources that I seem to be mis-managing.
Reply all
Reply to author
Forward
0 new messages