Custom shaders
Are custom shaders possible in Cafu yet? I notice there's headings in the Wiki for shader authoring but no articles.
I'm assuming that Cafu uses Cg shaders (Judging by the cg dll file).
I cant actually program myself but I thought I'd try out some of the free ones lying around on the net.
I'm assuming that Cafu uses Cg shaders (Judging by the cg dll file).
I cant actually program myself but I thought I'd try out some of the free ones lying around on the net.
Re: Custom shaders
Dear Scott,
yes, two of the Cafu renderers use Cg shaders internally (one in the NV2X profile, the other in the NV3X profile), and one Cafu renderer uses OpenGL with the "ARB vertex and fragment programs" extension (and another one uses OpenGL 1.2, which works with no shaders at all).
Adding your own custom (Cg) shaders such as those described at Shader Specifications requires some C++ programming however. This is because shaders typically require custom, shader-specific setup of the OpenGL state that cannot be handled in shader or material scripts. You can see examples of such C++ shaders at e.g. http://trac.cafu.de/browser/cafu/trunk/ ... B1/Shaders
However, I hope and expect that the situation will improve soon: Implementing an OpenGL 4.0 renderer is among the future features, and then it will become possible to specify the entire GPU shader in script as well.
yes, two of the Cafu renderers use Cg shaders internally (one in the NV2X profile, the other in the NV3X profile), and one Cafu renderer uses OpenGL with the "ARB vertex and fragment programs" extension (and another one uses OpenGL 1.2, which works with no shaders at all).
Adding your own custom (Cg) shaders such as those described at Shader Specifications requires some C++ programming however. This is because shaders typically require custom, shader-specific setup of the OpenGL state that cannot be handled in shader or material scripts. You can see examples of such C++ shaders at e.g. http://trac.cafu.de/browser/cafu/trunk/ ... B1/Shaders
However, I hope and expect that the situation will improve soon: Implementing an OpenGL 4.0 renderer is among the future features, and then it will become possible to specify the entire GPU shader in script as well.
Best regards,
Carsten
Carsten
Re: Custom shaders
Ok thanks for the clarification Carsten, using c++ is just way over my head, one day I'll get off my lazy behind and learn some (I have 2 books on the subject, its just a matter of making the time).
Re: Custom shaders
Ok, great to know that. Let us know on your progress, and don't hesitate to ask if you have any questions! C++ can be overwhelming at first, but it's worthwhile to learn. ![Thumb Up :up:](./images/smilies/thumbup.gif)
![Thumb Up :up:](./images/smilies/thumbup.gif)
Best regards,
Carsten
Carsten
Re: Custom shaders
I want to make some custom shaders however it seem that i need to transcribe the shader for all renderers?
How can i force a renderer? Also, how to get from the code that set up a shader a camera/light position defined for example in CaWe?
How can i force a renderer? Also, how to get from the code that set up a shader a camera/light position defined for example in CaWe?
Re: Custom shaders
Hi afgho,
See the console log in order to learn which renderers are available and which one has been loaded automatically (if you're on Windows, where the console log is not shown at the Windows command prompt, use the
Here is an example session demonstrating this:
In the Cafu Engine itself, the position of the camera and the light source is automatically set up and passed to the shader code. The quickest way to see this is probably to check out a few of the example shaders of the CgARB1 or ARBprogs renderer.
For forcing a specific renderer, use theHow can i force a renderer?
-clRenderer
command line option.See the console log in order to learn which renderers are available and which one has been loaded automatically (if you're on Windows, where the console log is not shown at the Windows command prompt, use the
-log
command line option.Here is an example session demonstrating this:
Code: Select all
d:\Dev\Cafu> build\win32\vc10\x86\debug\Ca3DE\Cafu.exe --help
Usage: Cafu [-con <str>] [-svGame <str>] [-svWorld <str>] [-svPort <num>] [-noFS] [-clPort <num>] [-clRemoteName <str>] [-clRemotePort <num>] [-clTexDetail <num>] [-clWinSizeX <num>] [-clWinSizeY <num>] [-clRenderer <str>] [-clSoundSystem <str>] [-clPlayerName <str>] [-clModelName <str>] [-log <str>] [-h] [--verbose] [worldname]
-con:<str> Runs the given commands in the console. -con "x=3;" is equivalent to appending x=3; to the end of the config.lua file.
-svGame:<str> Name of the MOD / game the server should run [DeathMatch]. Case sensitive!
-svWorld:<str> Name of the world the server should run [TechDemo]. Case sensitive!
-svPort:<num> Server port number [30000].
-noFS, --clNoFullscreen Don't run full-screen, but rather in a window.
-clPort:<num> Client port number [33000].
-clRemoteName:<str> Name or IP of the server we connect to [192.168.1.1].
-clRemotePort:<num> Port number of the remote server [30000].
-clTexDetail:<num> 0 high detail, 1 medium detail, 2 low detail [0].
-clWinSizeX:<num> If not full-screen, this is the width of the window [1024].
-clWinSizeY:<num> If not full-screen, this is the height of the window [768].
-clRenderer:<str> Override the auto-selection of the best available renderer [auto].
-clSoundSystem:<str> Override the auto-selection of the best available sound system [auto].
-clPlayerName:<str> Player name [Player].
-clModelName:<str> Name of the players model [Punisher].
-log:<str> Logs all console message into the specified file.
-h, --help show this help message
--verbose generate verbose log messages
Default values are enclosed in [brackets].
It is also ok to omit the "-svWorld" option for specifying a world name: "Cafu MyWorld" is the same as "Cafu -svWorld MyWorld".
d:\Dev\Cafu> build\win32\vc10\x86\debug\Ca3DE\Cafu.exe -log console-log.txt
d:\Dev\Cafu> type console-log.txt
Cafu Engine, May 22 2012
config.lua processed.
Warning: Failed to open ZIP archive Games/DeathMatch/Textures/TechDemo.zip
Registering archive "Games/DeathMatch/Textures/SkyDomes.zip".
Scanning cwd for all available renderers...
Scanning Libs/build/win32/vc10/x86/debug/MaterialSystem for all available renderers...
Libs/build/win32/vc10/x86/debug/MaterialSystem/RendererARBprogs.dll ... SUCCESS - first supported renderer (Pref# 2200).
Libs/build/win32/vc10/x86/debug/MaterialSystem/RendererCgARB1.dll ... SUCCESS - but no higher preference (Pref# 2100).
Libs/build/win32/vc10/x86/debug/MaterialSystem/RendererCgNV2X.dll ... SUCCESS - but no higher preference (Pref# 2000).
Libs/build/win32/vc10/x86/debug/MaterialSystem/RendererNull.dll ... SUCCESS - but excluded from auto-selection (Pref# 1).
Libs/build/win32/vc10/x86/debug/MaterialSystem/RendererOpenGL12.dll ...
Libs\MaterialSystem\RendererOpenGL12\RendererImpl.cpp (90): Entering RendererImplT::IsSupported().
Libs\MaterialSystem\RendererOpenGL12\RendererImpl.cpp (106): GL_VERSION string is "4.2.0".
Libs\MaterialSystem\RendererOpenGL12\RendererImpl.cpp (114): GL_ARB_multitexture_AVAIL==1.
SUCCESS - but no higher preference (Pref# 1000).
Reloading previously auto-selected renderer Libs/build/win32/vc10/x86/debug/MaterialSystem/RendererARBprogs.dll ...
Scanning cwd for all available sound systems...
Scanning Libs/build/win32/vc10/x86/debug/SoundSystem for all available sound systems...
Libs/build/win32/vc10/x86/debug/SoundSystem/SoundSysFMOD3.dll ... SUCCESS - first supported sound system (Pref# 1000).
Libs/build/win32/vc10/x86/debug/SoundSystem/SoundSysNull.dll ... SUCCESS - but excluded from auto-selection (Pref# 1).
Libs/build/win32/vc10/x86/debug/SoundSystem/SoundSysOpenAL.dll ... SUCCESS - higher preference sound system (Pref# 1500).
Reloading previously auto-selected sound system Libs/build/win32/vc10/x86/debug/SoundSystem/SoundSysOpenAL.dll ...
Warning: The call to method OnKeyPress() of window with name "ReallyQuitDialog" yielded (expected return values matching signature "i>b" instead).
d:\Dev\Cafu> build\win32\vc10\x86\debug\Ca3DE\Cafu.exe -clRenderer Libs/build/win32/vc10/x86/debug/MaterialSystem/RendererARBprogs.dll
d:\Dev\Cafu>
We don't support dynamic lighting in CaWE at this time. (It's a real pity, of course, because we should. Any help with implementing this would very much be appreciated!)Also, how to get from the code that set up a shader a camera/light position defined for example in CaWe?
In the Cafu Engine itself, the position of the camera and the light source is automatically set up and passed to the shader code. The quickest way to see this is probably to check out a few of the example shaders of the CgARB1 or ARBprogs renderer.
Best regards,
Carsten
Carsten
Who is online
Users browsing this forum: No registered users and 7 guests