Hie,

I am doing a small tutorial on shaders in order to show how an 'hilite'
functionality could be done. Now, I have a 'behavior' I did'nt expect.

In order for me to get an understanding, I modified the 'std_lighting.xml' to
support a new uniform input called 'hilite_color' which is simply added to the
final fragment color calculation. This is to get a taste of the system.
I did write it this way, in a non conditional way:

    // Add hilite.
    color.rgb += V2F.surfClassic.GetHilite();


GetHilite simply returning my uniform value declared in
cg-surface-classic.inc:
struct Frag_SurfaceClassic
{
  uniform sampler2D texture;
  uniform float4 flatColor;
  uniform float4 hiliteColor;
};
Frag_SurfaceClassic surfaceClassicFrag;


And what is happening is that when I add to one of the
gen mesh materials the shader variable 'mat hilitecolor'
and set it to some value which cause the mesh to be hilited,
all gen mesh are hilited, even those not sharing the
same material. I am not sure this is what should happen, but
my understanding is that after the variable is set once, it is never
reset to the original value because the variable does not exist
on the other gen mesh materials.
I will fix that by using an existance check on the hilite color.
But that does not sound like the right way in general.
I am not up to speed on modern GPU speed optimisation, but
in term of functionality, would'nt it be better to allow some shader
vars to be initialised to some default value when the material referencing it
is created ?
This could be a specific statement in the shader like :
<variablemap variable="mat hilitecolor"
     destination="surfaceClassicFrag.hiliteColor"
     defaultvalue="0.0,0.0,0.0" />

Best regards,

Sebastien.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Crystal-main mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/crystal-main
Unsubscribe: mailto:[EMAIL PROTECTED]

Reply via email to