HLSL semantics

Started by
2 comments, last by ET3D 16 years, 1 month ago
This might be a stupid question, but I've been using FX Composer and RenderMonkey to experiment with some shaders. For simple constants like the World matrix, or View matrix, can these be set in a shader by specifying : float4x4 matWorld : WORLD; float4x4 matView: VIEW; or do you have to set them manually with the ID3DXEffect's SetMatrix() function? debugging into my program, it looks like the semantics have been set in the effect's ParamDescriptions, but the shader will not work correctly until I set them myself. Is there a way around this? Thanks a lot!
Advertisement
The effect does not know the world and view matrices automatically. You'll have to set them yourself.

I haven't got a lot of experience, but if I understand the documentation correctly (see HLSL Semantics), the "WORLD" and "VIEW" semantics are just arbitrary strings. The system does not interpret them or automatically set these values.
You can, however, use that semantics to access matWorld and matView in your application.
You can write into your effect something like this
uniform extern float4x4 matWVP;
and then you set the value manually with the ID3DXEffect's SetMatrix() function;

"WORLD" and "VIEW" are just ways for the programs you use (RenderMonkey...) to find which variables to set in the shader. They would then use SetMatrix for them, like you would do. They have no meaning for Direct3D itself.

This topic is closed to new replies.

Advertisement