🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Script language search: Speed and portability

Started by
5 comments, last by vajuras 19 years, 10 months ago
I know, when looking at script languages, speed normally isn't a big factor. But I've got a slightly different use for a script language in my engine, and speed is one of the top priorities. I'm hoping someone can help me thing of some good candidates. I'm designing the material/shader system for my engine, and I'd like each shader program to be a portable self-contained module, which can be loaded by the engine when needed. Since the shader program will be called many times per frame, speed is omportant. I know I could use DLLs for this task, and if all else fails I may have to, but I'd prefer to not have to recompile the shaders for each platform. End-users may be creating additional shaders in the future, and I want gamers on all platforms to be able to use them. As far as I can tell, this limits me to languages which have a JIT available. I'm really wanting the language to keep a C-like feel to it, so I (and others) don't have to learn something obscure in the process. I really had my eyes on Squirrel for my main engine scripting, as it is C-like and compiles to byte-code (therefore portable), but there doesn't appear to be a JIT available for it (I wonder how tough or effective it is to write JITs for these VM languages?). Anyone have ideas on some good language candidates for this task? EDIT: I seem to have overlooked the obvious: Writing the shaders in C, and just building a C compiler into my engine. Has anyone attempted something like this before? Any pros/cons?
Advertisement
me thinx mono (an open source clone of .Net) has a jit compiler.
Quote: Original post by Nairou

I seem to have overlooked the obvious: Writing the shaders in C, and just building a C compiler into my engine.
...or even more obvious, compiling them into your engine or as external DLLs and just executing them.
DLLs are probably what you need. I remember hearing somewhere you can use C# as a scripting language though, which would be a good solution.
Java. Call your java classes through the JNA. There's a JRE on any platform.
-- Single player is masturbation.
I know I could use DLLs, but as I said I'm trying to avoid that, since DLLs are platform-dependent. I would have to include a separate copy of each shader for each platform I target, as well as hope that anyone else making shaders does the same.

I'm trying to treat the shader programs as resources, part of my material system. Each one may or may not be used in a particular scene, and updated shaders may be created in the future to improve quality or performance on existing game installations, so they can't be built into the engine.
why don't you take a look at Cg by nvidia or HLSL fx files? if need be, i'm sure oyu could write your interpreter for the desired platform. they are straight forward c-like languages. But at least this way you can just start off coding shaders like everyone else and then expand later. additionally, this allows your artists to use render monkey, 3dsmax, etc to generate shaders.

This topic is closed to new replies.

Advertisement