Sign in to follow this  

Bypassing FX files

This topic is 3110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to use the programmable pipeline, but I don't want FX files laying around in my data folder where anyone can modify them. I'm pretty sure I can store them in the exe's resource file, but even more preferable would be the ability to load a custom file format and generate HLSL from that, and then compile the HLSL (this is what I've been doing for other things. I hate leaving X files and FX files and other "newbie formats" laying around in a data folder where anyone can access them. I want to use my own file format that requires an editor to modify) I have already done this with meshes and want to be able to do it with HLSL. Any hints as to what course of action to take?

Share this post


Link to post
Share on other sites
Oh right, forgot I could do that. What's the function for loading a precompiled shader?
EDIT:
Also, one of the reasons I object to using a predetermined file format is because anyone can 'steal' the file and use it in their own project. What I'd really prefer to do is have my own Flag-based file format for shaders that generates HLSL data when loaded.

Share this post


Link to post
Share on other sites
Quote:
Original post by Super Llama
but even more preferable would be the ability to load a custom file format and generate HLSL from that, and then compile the HLSL (this is what I've been


You could link your fx files to your exe file as resources files, then extract them to a temporary .tmp file.
Once this .tmp file has been loaded it can be deleted from hard-drive

Quote:

I hate leaving X files and FX files and other "newbie formats" laying around in a data folder where anyone can access them.

This is the problem.
One solution is to make your own 3d object custom format

Share this post


Link to post
Share on other sites
Quote:
Original post by Super Llama
Oh right, forgot I could do that. What's the function for loading a precompiled shader?


D3DXCreateEffectFromFile


Quote:
Original post by Super Llama
Also, one of the reasons I object to using a predetermined file format is because anyone can 'steal' the file and use it in their own project. What I'd really prefer to do is have my own Flag-based file format for shaders that generates HLSL data when loaded.


I really don't see why you'd bother. An obfuscation technique like that can be easily deciphered by anyone who really wants to get at it, and in the end all they're going to get is a bunch of HLSL...something that's completely useless without all of the supporting app code and assets to go with it.

Share this post


Link to post
Share on other sites
Quote:
One solution is to make your own 3d object custom format

I did make my own custom 3d format, and now I want to make my own custom shader format. But on the exe level, everything has to be passed to DX eventually. For my mesh format, I converted it to a vertexbuffer. What I'm asking is: Is there a shader equivalent to a VertexBuffer, something that can be passed to DX that is fully contained in binary, or do I have to export a temp file and load that to use HLSL?

Looking at D3DXCompileShader, I see the argument:
pSrcData
[in] Pointer to a string that contains the shader.

Does this mean I can have HLSL in a string and compile a working shader from here?
Its output is a D3DXBUFFER, which looks like it could be passed to D3DXCreateEffect's
pSrcData
[in] Pointer to a buffer containing an effect description.

EDIT:


Basically, will the following work?


D3DXCompileShader(strHLSLexport, strlen(strHLSLexport), 0, 0,
"ShadeVert", LPCSTR D3DXGetVertexShaderProfile(&ddev), 0,
&out, NULL, &consttbl);

D3DXCreateEffect(&ddev, &out,
sizeof(out),
0, 0, 0, NULL,
&outEffect,
NULL);


Share this post


Link to post
Share on other sites
No shaders and Effect's are different. You can't compile a shader, and then create an effect from it. You have to create an effect from your .fx source.

If you just want to compile an effect from a string, just use D3DXCreateEffect and pass it the string containing your ASCII source code.

Share this post


Link to post
Share on other sites

This topic is 3110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this