shaderfx?

Anyone worked with shaderfx and unity. Heard some rumours about support for unity in shaderfx but there is no unity export in shaderfx. any other export format suited for unity?

Maybe this belongs at the shaderfx forum but what the heck. I’m signed up here and thought maybe you have some experince with this?

there is an article about it in the wiki…
somebody succesfully got an shaderfx-shader working in unity… but it seems to be quite a workaround…
shaderfx->fxcomposer->unity and the need of rescripting some components (if i got that right, im just an artist, no scripter)

here is the link, maybe it helps:

cheers sinnlos

Thanks. will check it out!

hello guys 8)

i got a basic question :roll:

exported cgfx files from shaderfx usually have this section that uses a couple of semantics

float4x4 wvp : WORLDVIEWPROJECTION;
float4x4 worldI : WORLDINVERSE;
float4x4 worldIT : WORLDINVERSETRANSPOSE;
float4x4 viewInv : VIEWINVERSE;
float4x4 world : WORLD;

i understood that unity doesn’t support these semantics directly.

now, reading unity’s shaderlab built-in state variables i found these

glstate.matrix.mvp
Current modelviewprojection matrix
glstate.matrix.modelview[0]
Current modelview matrix
glstate.matrix.projection
Current projection matrix
glstate.matrix.transpose.modelview[0]
Transpose of model
view matrix
glstate.matrix.invtrans.modelview[0]
Inverse transpose of model*view matrix
glstate.matrix.texture[0] to glstate.matrix.texture[7]
Texture transformation matrices

ok, i’m interested to know how i can use the glstate model space matrices to get the aformentioned world view/projection matrices. or is there another way to do it?

i’m kinda new to this and i’m interested in porting a shaderfx exported cgfx file into unity.

i think i understood how to convert most of the shaderfx file for it to work in unity, but this section with lacking world matrix semantics and how to figure out a viable solution for them using built-in unity helper functions has given me some pause :shock:

anyone has an idea how i should do/write this little conversion ? thx

ps: i just found these variables too in the unity documention, still trying to figure how to use them

Transformations
Name
_Object2World float4x4
_World2Object float4x4
_ObjectSpaceCameraPos float3

this is pretty much a shot in the dark :smile:

wvp = glstate.matrix.mvp;
worldI = glstate.matrix.modelview[0];
viewInv = glstate.matrix.invtrans.modelview[0];
world = _Object2World;

so, how many of them did i get right/wrong :?:

so, after some headache but no answer, i think i need to know the following before proceeding.

in unity, what is the world matrix, how can i read it from cg?

is it _Object2World?

next, what is the view matrix ?

i have no idea here.

next, what is the projection matrix ?

is it glstate.matrix.projection ?

lastely, how can i get the inverse of each of these matrices if unity doesn’t have built in variables about them ?

Yes indeed, RedPhoenix questions are mine too!
Anyone who can answer?

To aNTeNNa trEE, Aras, HiggyB:

Yes, indeed, these are also mine questions. Would be nice to get some clarification from the programmers as YOU are the ones who should know which Shader Matrix contains which information.

Would be pretty cool use to all the wicked .fx shaders which float around…

please, thats really important.

thx,
Stefan

I’d love to see shaderFX support in Unity. Especially now that ShaderFX 3.x ia free so any Max user can use it.

I’ve used it quite a bit with ogre before coming here and it’s the one thing in my pipeline I really miss. The shaders that come with unity are decent but don’t produce as good results as some of my shaderFX made shaders.

i remember a post written by the ShaderFX programmer on a 3ds Max board, stating that he was looking into Unity support, but decided to not implement it, because shaderlab is a so total different and non-standard beast…

And since it’s free now, i don’t see unity support is coming anytime…

I guess the next best thing would be a FX composer 2 exporter. Both shaderFX and Mental mill are compatible and can produce HLSL or CGFX versions of shaders.

I’m missing something. Isn’t Shaderlab and HLSL entirely different or is it something similar?

HLSL is pretty similar to CG which is what you use to write shader code in unity.
The alternative is GLSL for opengl only naturally.

shaderlab is not related to any of that at all kind of as shaderlab is the “fixed function and pass pipeline setup”. you can’t define programmable gpu code in shaderlab thats cg