Should Materials Contain Corresponding Shader Programs?

Started by
19 comments, last by Quat 12 years, 9 months ago
Thanks for the link to the Horde3D engine overview. I notice that they define standard shader inputs:


uniform vec4 shadowSplitDists
uniform mat4 shadowMats[4]
uniform float shadowMapSizeuniform sampler2D shadowMap
uniform mat4 worldMat
uniform vec4 skinMatRows[75*3]

That actually makes things a lot easier. I also see now that the generic memory blob in my Material structure just corresponds to a CBuffer that stores material shader inputs (but not all shader inputs). So now I am thinking each shader effect has three CBuffers:

// Only contains material specific info that would come from .mat script
cbuffer MatBuffer {};

// Per frame values that come from the engine (light position, view position, time, shadow map stuff, etc)
cbuffer systemPerFrame {};

// World matrix, bones, etc.
cbuffer systemPerObject {};


I would handle the MatBuffer generically as described in this thread (with a memcpy of my memory blob). The PerFrame and PerObject buffer layout would be the same for all shaders, and the engine can fill those out.
-----Quat

This topic is closed to new replies.

Advertisement