Objects turn black with shader variation (oFusion/ShaderFX)

PDX

18-03-2008 16:36:19

(I also made this post over at the Lumonix forums:

http://lumonixsoftware.com/yabb/YaBB.pl ... 815569/0#0

Sort of a double post, but I'm absolutely stumped, and need to find some answers quick. With the oFusion / ShaderFX crossover, we've got the potential for an insanely powerful pipeline, but I'm not sure where to go for support. I've found the latest oFusion install affects ShaderFX slightly, and I'd assume the reverse is true. In the off chance that oFusion has something to do with this problem, I'm posting here.)


Hello,

I've been using ShaderFX more these days, now that I've got the version of oFusion Pro that supports ShaderFX. (And btw, I can't say this enough: this crossover functionality is FANTASTIC. It's really bringing both oFusion and ShaderFX alive for me.)

I'm having a problem with ShaderFX that's cropped up as I've tried to make shaders for some terrain meshes. I started off making one shader for one terrain mesh. The shader is moderately complex, with diffuse and normal, and lerp + alpha for placement of terrain textures. Also, there's a lightmap layered over the entire terrain. This shader works fine, and I use it as a base for creating a second shader, for a second mesh. I just save the first shader under a different name, then swap in new textures for it, then apply this second shader to the second mesh.

That's when the trouble starts: The second mesh receives the second shader OK, but then the first mesh turns black! So I reload the first shader, apply it to the first mesh again. The first mesh receives the shader OK, but then the second mesh turns black (!). This can go on indefinitely: reload shader, reapply to mesh, other mesh turns black.

At one point I speculated that, because my copied shader has identically named nodes as the original shader, it might be causing a conflict that causes the shader to go black. So I created a new shader from scratch, and that seemed to help... for a while. Then very recently, creating the second shader from scratch didn't even help: even with two shaders build from the ground up, I still get the other shader turning black.

Any thoughts?

Evak

18-03-2008 16:46:17

OK I think I know whats wrong, ShaderFX only works with one shader at a time and keeps the current shader in a temp file till you start a new shader.

The minute that you create a new shader in shaderFX the original one is lost, since Ofusion doesn't save any shader materials till you export a scene, Ofusion loses the original shader when you create a new one in shaderFX, thats why your old shader mesh goes black.

You have to export your shader after you create it, its best to convert the .material it creates into a .program file (VERY easy to do) and create a ofusion material using your new shader, this can be done quickly by using the Ofusion Material Evaluate tool.

PDX

18-03-2008 22:48:23

Evak,

I think it was something like what you said, though my fix had more to do with simply setting up a path for exporting the .fx in ShaderFX. For details check out that thread, but basically I found setting up that export path anti-intuitive, didn't do it, then found out it was kind of an important step :).

Thanks!

Evak

18-03-2008 22:59:18

oh thanks for making me check that thread again :). Looks like I did the same as you with the path. I just assumed I could only make one shader at a time :).

It's still good practice to make the ogre shader materials into .program and Ofusion materials if your going to keep them and use multiple copied of materials with different texture units though.

Lioric

19-03-2008 04:20:58

Yes, this is because of the way shaderFX handles files internally, it would be good to add multiple material support to shaderFX (probably a MDI/Tab system to have several different shader materials each in its own window)

PDX

25-03-2008 00:25:26

Hi Evak,

You said above:


You have to export your shader after you create it, its best to convert the .material it creates into a .program file (VERY easy to do) and create a ofusion material using your new shader, this can be done quickly by using the Ofusion Material Evaluate tool.


Can you go through the steps to do this? I tried, with something similar to the ShaderFX detail normal example, and got weird results. What I tried was:

- create a ShaderFX material,

- apply it to a scene mesh (making sure it looks good in oFusion)

- going to the Max Material Editor and hitting Get Material, which loads a directx shader into the material editor

- clicking "directx shader" and selecting ofusion material. Then evaluating the material.

This causes the material to look completely different in the oFusion viewport, though it stays looking fine in Max's viewport.

Is that anything like what you mean when you say to use the, "Ofusion Material Evaluate tool"?

Thanks!

Evak

25-03-2008 04:13:23

Hi, I'm practicing capturing video at the mo for some basic flowED tutorials. So I figured I'd make something for the shaderFX bridge quickly.

create your shader, apply it to your max scene. make sure you saved your .sfx because you will need it later. Export your ofusion scene.

From the ofusion exported files it's best to make a .program file to compliment your shaders and ignore your material file. Load up the .material file ofusion created into a text editor.

Just follow the example in the video. copying the parameters from the actual material script to the shader parameters at the top. Make sure Vs and Ps are copied over the right parts. Delete the .material script and save the file as a .program.

http://www.flow3d.org/ad/makeprogram/makeprogram.swf

copy the source and .program to your shaders folder in \Autodesk\3ds Max 2008\oFusion\Media\shaders

Next I'll show you quickly how to do the 3dsmax part.

NOTE: You probably don't really need to make a .program file. But it does add some extra flexibility with the ofusion parameter editor if you reuse the same shaders a lot in your materials.

Evak

25-03-2008 04:21:54

This next video shows you how to convert your loaded shaderFX file into a ofusion material.

I try and show you the whole process from assigning the shaderfx material, to creating the Ofusion material using the ofusion material evaluate tool.

One thing I did that might be confusing but I felt was necessary to show that the conversion worked. I went back to the DX material after evaluating the material and showing you the texture units. I converted the DX material to a standard material so you could see the DX material was destroyed and the Ofusion material worked.

You don't have to do this step, I just wanted to prove that the ofusion material worked. The funny bright colors are the vertex colors when no material is applied.

http://www.flow3d.org/AD/makeOmat/makeOmat.swf

One thing you will notice is that the ofusion material didn't work straight away, I had to hold the scene and fetch it again so the whole scene and media files were reloaded into max. Then the ofusion material worked just fine.

Hope the video helps :) I recommend saving to HD and viewing the flash videos with a media player. That way you can pause where necessary.

PDX

25-03-2008 04:31:05

Hi Evak,

Thanks so much for the tutorial!

I'm wondering, you say:

So you to your scene and load up your .material file.

Did you mean to say, "export to your scene"?

Evak

25-03-2008 04:56:49

lol, not sure what I was trying to say there, I changed it to something that makes more sense.

PDX

03-04-2008 20:10:04

Evak,

Can you suggest a media player that will allow me to scrub a .swf animation? I'm finding I can only play the tutorial in Firefox, but not in Windows Media or anything.

Thanks!

Lioric

03-04-2008 22:29:41

Note that automatic upgrade from shader materials to oFusion Materials is currently implemented and will be provided in the next hotfix