Game Development Community

Shader dev workfow question

by Kevin Johnson · in Torque Game Engine Advanced · 01/13/2005 (9:44 am) · 15 replies

Ok i have a question about the workflow..

Is there any way without reloading the mission to recompile .hlsl files?

And is every one tweaking the shader then reloading a mision, tweaking, reloading..there must be a better way..

#1
01/13/2005 (4:31 pm)
Well eventually it would be nice to have an art interface to tweak the constants, but the hlsl file itself, should not have to e manipulated. If you want realtime tweaking for improving the algorithm, download rendermonkey, I do all my prepwork there, the port it in to TSE.
#2
01/13/2005 (4:52 pm)
You could use another tool, but ideally it would be nice to be able to force the engine to "reload" art assets on command. Automatic detection of art asset changes on the file system would be even better. I'm thinking about this now with respect to interior editing. I suppose some client server sync stuff makes this more complex than it should be.
#3
01/13/2005 (6:09 pm)
@anthony - tried rendermonkey..but i just get black textures in tse so somethings jacked.:)
is there are chart or something like:
modelViewProjection = VC_WORLD_PROJ etc??

and this may sound stupid but are these registers standardized across HLSL??


@tom ya think its too late to stick that bug in someones ear.??
#4
01/13/2005 (6:16 pm)
@Kevin - It's never too late around here as you can always get to the code yourself. I've put this issue on my wishlist of things i'd like to get to for our own art pipeline. If i get something working i'll be sure to post patches and lobby Ben and Brian to get it into HEAD.

My problem is i don't know squat about the resource system at the moment.
#5
01/13/2005 (6:22 pm)
@Kevin, I do think
modelViewProjection = VC_WORLD_PROJ
but I don't have my code with me, check shdrCnst.cpp (or something like that) ins the shader folder of the example game/demo for a referance to all the constnt registeries. Also check the source to see how/where these constants are initalized.

PS. check the forums extensively, I had posted similar questions when TSE was first released.
#6
01/13/2005 (7:17 pm)
Kewl.. i've just gotten a toon shader from shaderworksXT into tse... Thanx for the advice... I'll dig in..I think im starting to catch on..
#7
01/15/2005 (3:21 pm)
@Tom - Would love to have that. The ResManager is pretty easy to understand, I'd suggesting reading through, ah, core/resManager.cc I think.
#8
01/15/2005 (3:58 pm)
@Ben - I'm thinking the resource manager should keep track if a resource on disk has "changed". Still at a higher level something would have to take notice of these changes and instigate the reload. The notice should probably be some sort of callback per resource type which knows how to safely update things. The updates would have to be dealt with on a case by case basis. All this would be disabled if not in a "dev mode"... ummm... does Torque have a dev running mode?
#9
01/15/2005 (6:40 pm)
There's a TORQUE_DEBUG macro you could try.

I've thought about this a fair amount. The best approach IMO is to add an update method to the ResourceInstance class that is called when the asset on disk changes. If the object knows how to reload itself, it does, otherwise, nothing happens. Then the resource manager just periodically polls through all of its assets and checks to see if the modified time has changed. You'll have to do a bit of skullduggery to make sure the internal state of the ResourceManager and things like textures doesn't get clobbered.

All the rest is window dressing and easily controlled by a macro or console flag.
#10
01/15/2005 (6:44 pm)
Interesting. I'll take a look at this next week. If i get something working you can expect a patch for TSE from me.
#11
01/17/2005 (1:24 pm)
I think having the user poll for new updates would be much better than the engine constantly checked the disk for changed assets.
#12
01/17/2005 (1:43 pm)
Well it wouldn't be constantly checking the disk. WinNT/2K/XP has an API which can fire your callback function when a change occurs under a path that you specify (ReadDirectoryChangesW). So it doesn't have as much overhead as if i were really polling for changes every frame (this is how it would need to be done on *nix).

Still your right. It would be compatible across all platforms to have a function you can bind to a key which recurses all the resources and update ones that have changed. No OS dependencies there and it can be useful to have it done on demand than automatically.

This is probably the direction i should pursue with this.
#13
01/18/2005 (12:40 am)
Remember the key problem here. The rest really, really is window dressing. ;)
#14
01/24/2005 (3:33 am)
I've got the low level system for this working now... resources have the option to obey requests to be reloaded.

My new challenge is the higher level stuff. For example... GBitmap is a resource and will be reloaded, but GFXTextureObject which holds the pointer to it is not a resource. What elegant way is there to let the GFXTextureObject object know to reload the GBitmap into the video texture. The ugliest way would be to force a reload of all all texture resources. Or i could compare the new GBitmap->mSourceResource->crc to the last one to trigger a reload.

Now this may be the only case where this happens as i'm just getting into it now. Anyone have any better ideas?
#15
07/19/2006 (5:42 pm)
This resource will allow you to reload/recompile ShaderData shaders while in-game via script.

www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=10891