DarkRadiant shader system: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
mNo edit summary
mNo edit summary
Line 4: Line 4:
The DarkRadiant shader system module is initialised during DarkRadiant startup and parses the material files during this phase.
The DarkRadiant shader system module is initialised during DarkRadiant startup and parses the material files during this phase.


It consists of several vital components:
It consists of a few components:
* The [[DarkRadiant ShaderLibrary|ShaderLibrary]] which holds all the named [[ShaderDefinition|ShaderDefinitions]] and named Shader objects.
* The [[DarkRadiant ShaderLibrary|ShaderLibrary]] which holds all the named [[ShaderDefinition|ShaderDefinitions]] and named Shader objects. It gets populated by the ShaderFileParser during startup or when the user requests a shader refresh.
* The [[DarkRadiant GLTextureManager|GLTextureManager]], responsible for "realising" the actual Texture objects (this includes image post-processing like gamma-adjustment and resampling).
* The [[DarkRadiant GLTextureManager|GLTextureManager]], responsible for "realising" the actual Texture objects (this includes image post-processing like gamma-adjustment and resampling).
* The actual [[DarkRadiant Shader|Shader]] objects.
* The actual [[DarkRadiant Shader|Shader]] objects.


The [[DarkRadiant Shader|Shader]] and [[DarkRadiant Texture|Texture]] objects are allocated on the heap using boost::shared_ptrs.
The [[DarkRadiant Shader|Shader]] and [[DarkRadiant Texture|Texture]] objects are allocated on the heap using boost::shared_ptrs.
Note that the actual image data isn't loaded until they are requested by the render system. If the latter requests a TexturePtr by calling Shader::getDiffuse(), the Shader object checks the contained TexturePtr for realisation. If the TexturePtr is still NULL, it sends a request to the [[DarkRadiant GLTextureManager|GLTextureManager]] for the Texture to be realised. This happens by passing the [[DarkRadiant TextureConstructor|TextureConstructor]] to the GLTextureManager, which can be used to retrieve an Image object containing the raw pixel data.


[[Category:DarkRadiant]]
[[Category:DarkRadiant]]
[[Category:Coding]]
[[Category:Coding]]

Revision as of 17:02, 7 February 2007

shadersystemzh6.th.jpg

The DarkRadiant shader system module is initialised during DarkRadiant startup and parses the material files during this phase.

It consists of a few components:

  • The ShaderLibrary which holds all the named ShaderDefinitions and named Shader objects. It gets populated by the ShaderFileParser during startup or when the user requests a shader refresh.
  • The GLTextureManager, responsible for "realising" the actual Texture objects (this includes image post-processing like gamma-adjustment and resampling).
  • The actual Shader objects.

The Shader and Texture objects are allocated on the heap using boost::shared_ptrs.

Note that the actual image data isn't loaded until they are requested by the render system. If the latter requests a TexturePtr by calling Shader::getDiffuse(), the Shader object checks the contained TexturePtr for realisation. If the TexturePtr is still NULL, it sends a request to the GLTextureManager for the Texture to be realised. This happens by passing the TextureConstructor to the GLTextureManager, which can be used to retrieve an Image object containing the raw pixel data.