[Source]
//Prefered method, bit of pseduo code.
//Load in model.3ds
model.Load()
if(diffusemap)
- bind shader1
if(specularmap)
- bind shader2
if(normalmap)
- bind shader3
//Want to avoid:
if(diffusemap && specularmap && normalmap)
- bind_fulldetail_shader
else if(diffusemap && specularmap)
- bind diffuse_specular_shader
else if(diffusemap)
- bind diffuse_shader
//...etc
[/Source]
shaders - multiple techniques in one pass
Hi, was wondering if anyone knew if it's possible (and could possibly explain how) to combine multiple seperate techniques into a single render pass with shaders, without writing a collection of shaders for different scenarios. I've had a fiddle with cgFX but as far as I can tell, it's not possible.
e.g.
Shader 1 - Diffuse map
Shader 2 - Specular map
Shader 3 - Normal map
thanks in advance.
You could send a uniform unsigned int to the shader and use that as a bit field to switch stuff on and off. That's what I usually do - it's not very pretty, but it's very simple and it works.
Ok, thanks.
I had considered that as an option, but I had read somewhere that conditional statements in shaders should be avoided like the plague. I might just do it anyway for the sake of getting things running.
Any one else have any variations?
I had considered that as an option, but I had read somewhere that conditional statements in shaders should be avoided like the plague. I might just do it anyway for the sake of getting things running.
Any one else have any variations?
GPU Gems has a good chapter entitled "An Introduction to Shader Interfaces" which may provide what you want. I haven't implemented any of it, I just read it after trying to find another chapter I thought was in GPU Gems 1/2 called something like "Composeable Shaders" which I was going to point you to. The shader interface solution sounds pretty neat, but it still requires some management on the client side.
Quote:Original post by bluntman
I haven't implemented any of it, I just read it after trying to find another chapter I thought was in GPU Gems 1/2 called something like "Composeable Shaders" which I was going to point you to.
I think you are referring to the "Recombinant shaders" article in Game Programming Gems 5 (Chapter 5.10). Even if you didn't have that in mind i suggest reading it (if you have the book), because i think it's pretty good, as the "shader interfaces" one.
HellRaiZer
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement