How to set variable on a effect (shader) ?

This post has 1 Reply | 2 Followers

Top 25 Contributor
Posts 232
SunBurn_Community_Licensee
SunBurn_Pro_Licensee
2.0 Studios Posted: 06-12-2012 1:24 PM

Ok lets say I have a shader that I have written (based on the custom shader in the sample) that is a deffered sas effect and I have a 150 to 400 dynamic meshes that use this shader.

Now I also have a variable in the shader called "RegionPostion" and "SectorPower"

For each of my meshes I want to set these values (and others) to different values. But I cannot figure out how to. Is there nowhere I can pass in these paramitors into sunburn by with a param string and value for the shader on the next frame (or until I set it again?)

This makes it impossible to do most of the things I want with custom shaders...

Also is transparency possible with a custom deffered sas shader? I return 0.4 for the alpha in one of my shaders (for water) that is being rendered in sunburn and also set (The Code Below™) in the shader which I thought should force alpha blending, I am assumeing that this is the wrong way to go about things? I thought sunburn added transparent mesh rendering support? Is the way to render things like water to still do them out of sunburn?

technique BlendMap_Final_Technique
{
  pass P0
  {
    AlphaBlendEnable = True;
    SrcBlend = SrcAlpha;
    DestBlend = One;
    VertexShader = compile vs_3_0 BlendMapVS();
    PixelShader = compile ps_3_0 BlendMapFinalPassPS();
  }
}

THANKS!

Top 10 Contributor
Posts 5,368
Employee
SunBurn_Studio_Licensee

Hi 2.0,

You can override rendering for specific objects and / or apply a custom rendering pass by overriding the SceneObject.RenderCustomPass() method.

Also you can set custom parameters on the shader at the material level.

But there is no mechanism at the moment for modifying material parameters per-object, per-pass in the rendering loop.

Transparency on custom effects is possible through code by setting the sas effect's TransparencyMode to Blend or Additive.

It should also be available via the editor, however that field is currently displaying as a checkbox (not a dropdown) and can't be set to a value higher than Clip.  We've fixed this in trunk and it will be in the next update.

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Page 1 of 1 (2 items) | RSS