Hi
I'm trying to (properly) adjust diffuse and (possibly) normal textures on the fly in my latest game effort http://www.youtube.com/watch?v=mWuAUXJogD8 so that I can animate surfaces and vary the look of repeated object rendering. Can someone point me towards an example or perhaps post an answer to how this can be done using Sunburn? I'm keen to use proper methods if there is one.
You should take a look at the Reflection & Refraction sample. They use a list of Texture2D and feed them to the plane (the water surface)
A snippet I found in that sample:
// Apply the current water animation "frame" to the water effects.
for (int m = 0; m < water.RenderableMeshes.Count; m++)
{
RenderableMesh mesh = water.RenderableMeshes[m];
if (mesh.Effect is LightingEffect)
(mesh.Effect as LightingEffect).NormalMapTexture = waternormalmapframe;
}
where "waternormalmapframe" is the current texture you want applied to the mesh.
Contributor on the SunBurn sgMotion Animation Library open source project.
Thanks Tom, much appreciated ... That saved me digging around and (as ever) its always SO obvious when you read the answer :o)
No problem :) Looking forward to your next vid ;)
OK. So I got the texture swapping working. Next problem I have is that because I'm submitting the same object in many times (repeating objects), the last drawn texture (on the last object) is used for all the objects :(.
RenderManager.SubmitRenderableObject( modelEntries[ Hatch.HATCH_DOOR_RIGHT_ME_IDX].Model, rightmtx * world, ObjectVisibility.RenderedAndCastShadows, ObjectLifeSpan.Frame);
RenderManager.SubmitRenderableObject( modelEntries[
(apologies for formatting ... forum editor blues...)
Any thoughts how to correct (Do I need to clone the objects or is there a way of getting the render to pick up / cache the textures on submission?).
I'm interested to hear (read) any ideas people have for this deferred lighting issue. I've got around it by using a cache of quads (Sunburn Models) . That is, a collection of unique one sided quad Model's (pre-loaded via LoadContent) so that I can adjust texture properties in each unique DeferredLightingEffect effect of each quad accordingly. It's a bit of a faff to scale and orient the quads so that they fit scene and related model, but it does the trick for the moment. At least now I can have unique labels on the ship hatches !
:-)
You can create a new DeferredObjectEffect instance and assign it to the mesh/meshparts of your model. You can then loop through all the RenderableMeshes and call "mesh.CalculateMaterialInfo();"
I do this for easy model instance I have and allows me to assign different textures on each model (from the same *.fbx)
(There might be a cleaner/easier way, but it works for me. :) )
Hi guys,
You can clone SunBurn material effects to create a unique instance of them. Then using the Submit method (1.2.x) or SceneObject constructor (1.3.x) that accepts an overload effect, pass the cloned effect in to assign the unique material to that object.
Other objects submitted using the same Model will still use the model's original effects - only the object assigned the cloned effect will have that unique material.
Let me know if this helps!
Follow me on Twitter – development and personal tweetsAwesome XNA Videos – Lighting, Rendering, and game videos
Aha... Now I see :-) Thanks Bob. I'll give this ago (this evening hopfully)!
I've tried and Yes ... that worked a treat! All so easy when you see how. Great help, Thanks!