Cubemapping/Shaders and Sunburn Rendering

rated by 0 users
This post has 2 Replies | 2 Followers

Top 10 Contributor
Posts 221
SunBurn_Community_Licensee
SunBurn_Pro_Licensee
2.0 Studios Posted: 02-19-2010 2:24 AM

G'day,

I've managed to get a cube map rendering outside of sunburn onto a sphere. Now I want that sphere to cast shadows as well as be cube mapped.

But I am stumped, and I am using deferred lighting.

Currently I have 3 stages for rendering my cube map:

  1. Generate the map. I do this by rendering to a RenderTargetCube 6 times, and then extracting the TextureCube
  2. I update the shader, giving it the position of the cube mapped object, the TextureCube and some other stuff
  3. I render the object, using the CubeMappingEffect for each part in Meshes in Model

Now, for me to do this in suburn, I believe I must:

  1. Create a .Mat file with the path of the .fx file listed.
    EffectFile: "CubeMapping.fx"
  2. Load this .mat file into an effect object
  3. Submit a scene object containing the object I want to be shiny
  4. Look confused because there is nowhere to put my shader. Done automagically via material files.

    How the heck do I link my model to my shader? It's frustrating.

    EDIT: I dropped the windmill from the HDR sample into my scene. I replaced the roof's .mat file with my own, stating EffectFile: "CubeMapping.fx". The roof disappeared.
    EDIT2: Ok, I changed the semantics of the shader I'm using so that sunburn can magic it into using it. It worked. Now I have told it to be yellow via .mat file. It is yellow. New question:

    How do I update an automatically loaded shader that is being applied to an object?
Top 10 Contributor
Posts 4,546
Employee
SunBurn_Studio_Licensee

Hi 2.0,

Cool, looks like you got most of it figured out.

2.0 Studios:
How do I update an automatically loaded shader that is being applied to an object?

You can access the effect / material and set the cube map using the following code:


foreach
(ModelMesh mesh in <the model assigned your shader>.Meshes)
{
    foreach(Effect effect in mesh.Effects)
    {
        EffectParameter param = effect.Parameters["<name of your cube texture in the fx code>"];
        if(param  == null)
            continue;

        param.SetValue(<your cube texture object>);
    }
}


Let me know if this helps!

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

Top 10 Contributor
Posts 221
SunBurn_Community_Licensee
SunBurn_Pro_Licensee

Haha, I should have guessed that! My cube maps now work.

Although the fresnel effect dissapeared on the reflection. If I have trouble with it, I'll post seperately.

Thanks!

Page 1 of 1 (3 items) | RSS