I'm using the sunburn framework to test sunburn before I buy.
Im trying to use a custom effect and when I use it the shadows are not showing. Then I was able to show the shadows but then the textures stopped showing.
I'm using the 8th overload of the submitRederableObjet() method.......
I would be grateful if someone would be able to assist me with a solution to my above problem.
-Nisansa
Hi Nisansa,
Please note: this is a lot easier to do in the SunBurn Engine, as custom shaders / fx files can be loaded and used directly by the SunBurn Engine without having to write any code (and can be loaded / assigned to objects entirely within the SunBurn editor).
With the SunBurn Framework this is a lot more involved. You need to either create an effect class that derives from xna Effect and implements the IRenderableEffect interface (with the World, View, Projection properties setting the corresponding shader variables using EffectParameter.SetValue()). Or you need to set the effect's world, view, projection shader variables each frame and submit objects using the effect each frame using a Frame lifespan.
For lighting and shadow support the effect will need to implement ILightingEffect with the lighting properties setting the corresponding shader variables.
Again this is all automatic in the SunBurn Engine (and very easy to use - just drop your shader into the project's content folder, launch the editor, and assign the shader to an object).
Shaders do need to include some basic semantics, but these are often included in online samples and shaders generated with tools like RenderMonkey / FXComposer. An example of adding a semantic:
// original world matrix definition.float4x4 worldTransform;// same world matrix definition, but with common semantic.float4x4 worldTransform : WORLD;
Let me know if this helps!
Follow me on Twitter – development and personal tweetsAwesome XNA Videos – Lighting, Rendering, and game videos
Thank you very much. I was already trying the IRenderableEffect interface. The thing is the .fx file maintains its own World, view, projection matrices thus they are set separately so do I need to set them again using "SetWorldAndWorldToObject()" methods or not?
Your effect class should set the shader world, view, and projection matrices in the corresponding class properties and methods exposed through the IRenderableEffect interface.
This allows the render manager to handle all matrix manipulation for you. The view and projection will be set the view and projection given to the scene state, and the world will be set to the world passed into SubmitRenderableObject(). But all automatically, so you can focus on game level code and never have to worry about setting up effect parameters.
Thank you for being so tolerant of my questions. Can you please tell me of a sample where a similar task is done? (i.e: used a custom effect on a model that is rendered using sunburn). So that I can see how it is implemented. Because I think I may be doing some error in an important area such as extending the Effect class of implementing the IRenderableEffect interface or submitting the model to be rendered.
I tried searching the net but couldn't find any.
The Custom Effects example shows how to apply custom effects (*.fx) using the SunBurn Engine's built-in custom effect support.
There are no examples specifically for the Sunburn Framework, because this is not a supported feature of the Sunburn Framework.
Thank you. But it is for Pro or Higher!
I bought Sunburn using my other account "gamoslk"! :-D. Now I think I can try the example using the Editor and solve my problem. Thank you for helping me. I sincerely look forward for similar help if and when I get in to trouble again. (But most probably I'd use my"gamoslk" account. :-)
Oops! I was already using "gamoslk" account. Sorry for the confusion! [Better create a delete option for the forum posts ;-) ]
Hi. Now my question is further complicated. In the Custom Effects example *.mat file is assigned to a *.fbx file that really exists. But what I want to do is to apply a custom effect on a model that is created using the Height Map Collision Pipeline in XNA creators club. When it is used directly it does not receive shadows. so I've edited the line;
ModelContent model = context.Convert<MeshContent, ModelContent>(terrainMesh, "ModelProcessor");
to
ModelContent model = context.Convert<MeshContent, ModelContent>(terrainMesh, "LightingSystemModelProcessor");
now it receives shadows.
But still I cannot find a way to add a custom effect to it.
I've attached two screen shots showing how it gets rendered when I am using the normal draw method and how it gets rendered when I am using Sunburn
1. How the generic draw methods render the scene
2. How sunburn renders the scene
The effect should be visible in the SunBurn Editor - named Rocks or similar (the name of the texture originally assigned to the terrain mesh).
You can either apply textures directly to the SunBurn effect or right-click on it and select "Convert To...", then select your custom FX file (assuming it's somewhere within in the content folder). Once converted the effect shows up in the editor's Custom Effects group, and you can edit the shader variables in the editor (similar to how you're able to edit the SunBurn effect properties).
Btw: cool looking trees!
Hooray! I've succeeded in applying the effect. Well actually not using the effect file that I wanted to use but using the "blend.fx" file of your "CustomEffects" example.
And I think I know why my effect file does not work on Sunburn too! I see in to it update you.
P.S. : Honestly the trees were not created by me. They are the trees that are provided under the "foliage" category in 3DsMax. We've done some tweaks to those to look nice. but we are going to replace them with our own trees in near future.