[SOLVED] Deferred shading sample HLSL

Problems building or running the engine, queries about how to use features etc.
Post Reply
KnightPista
Gnoblar
Posts: 10
Joined: Tue Jun 24, 2014 9:16 am
x 2

[SOLVED] Deferred shading sample HLSL

Post by KnightPista »

Hi all,

The deferred shading demo uses CG/GLSL shaders. I've started rewritting the code to use HLSL shaders instead of CG. I was in the illusion that the code of CG vs HLSL is somewhat identical, but there is serious graphical problem that came after changing the CG shaders to HLSL (see attached image).

What I have done:
- rename all *.cg shaders to *.hlsl
- in the sample, all 'createProgram' functions now use "hlsl" as language
- all setParameter("profiles","ps_2_x arbfp1"); changed to setParameter("target", "ps_3_0");
- all references to the .cg files changed to .hlsl
- in some shaders, there were some unsupported codes (in Ambient_ps and LightMaterial_ps), but these were commented out and used the ones just under them
- in 'deferred_post.program', I have just replaced all 'cg' with 'hlsl' and all 'profile..." to "target vs_3_0 or ps_3_0"

The demo loads ok, but there is graphical corruption all over the place.
My question is, has anyone converted deferred sample to HLSL and found what was the problem that caused this? Or any ideas what can cause this problem?

==============================
EDIT:

The preprocessor defines for shaders were originally defined from code (LightMaterialGenerator.cpp) using "compile_arguments" parameter to the gpu program. But that is valid only for CG shaders, for HLSL, it's called "preprocessor_defines" and has slightly different syntax.
Now is everything running and the deferred sample is ported to HLSL.
Attachments
ogre_deferred_hlsl_error.jpg
Post Reply