howto get started with shaders?

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
Post Reply
LaKing
Kobold
Posts: 26
Joined: Sat Jan 01, 2005 9:38 pm
Location: Hungary
Contact:

howto get started with shaders?

Post by LaKing »

Hi all ..

Sorry for asking thing wich may be already on the forums, but i was searching readiing, and didnt have much success. and also, i need to be up to date, and many threads are old.

As we all know shaders are the trend for getting the best looking graphics.

If i wouldnt require crossplatform things i would say i go with RenderMonkey, and the RmOgre exporter, but i cant use those shaders in OpenGL, so Linux/Mac clients would have a problem.

No problem, we have GLSL.

Ok, but howto start?
Any IDE recommended for OGRE and GLSL?
How do i develope .material files with many shaders?

Or do i need to wait for a new RmOgre Exporter supporting OpenGL?
The site of the plugins developer is down, and they sad they are busy with their commercial project. Is anyone doing that already or is that a new project?

thx
LaKing
Kobold
Posts: 26
Joined: Sat Jan 01, 2005 9:38 pm
Location: Hungary
Contact:

Post by LaKing »

... Cg is platform independent, so may be an alternative to glsl

more questions:

How do i create .cg files?
Any IDE for it? Can i create .cg files from FX Composer?

How are the example .cg files created?
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 8
Contact:

Post by haffax »

GLSL is platform independent too, but not render system independent. If you want platform independency both are fine, but if you want to use features that go beyond arbfp1 and arbvp1, cg is not an option, as ATI cards don't support nvidia's extended assember versions. I don't know a visual cg creation tool, but changes to HLSL are small.

As for shader development, I use vim, a simple text editor and my own sample app for the shader. You don't necessarily need a visual IDE for it. If you use RenderMonkey, then you don't need an explicit Ogre material exporter. The Ogre manual tells you all there is to know about how to bind a shader and the example shaders help too. Simply create the shader in the tool and then manually create the material file for it.
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
Yaniv
Halfling
Posts: 65
Joined: Thu Mar 02, 2006 1:28 am
Location: Israel
Contact:

Post by Yaniv »

There are a bunch of books on GLSL around you can order online (or if you're lucky, get them at the store). Or google around for tutorials I'm sure there are enough to get you started.
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 8
Contact:

Post by haffax »

I did my first steps in shader programming with this tutorial: http://www.lighthouse3d.com/opengl/glsl/ in conjunction with the language specification: http://www.opengl.org/documentation/oglsl.html

If you want to spend money, the orange book looked good when I skimmed it: http://www.3dshaders.com/joomla/
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

Advanced Lighting and Materials with Shaders:
http://www.amazon.com/gp/product/155622 ... oding=UTF8

MSDN HLSL Programming Guide
http://msdn.microsoft.com/library/defau ... haders.asp

Both of these will walk you through the "why" of shaders as well as spoon-feeding you shader code if you like.
LaKing
Kobold
Posts: 26
Joined: Sat Jan 01, 2005 9:38 pm
Location: Hungary
Contact:

Post by LaKing »

arbfp1 and arbvp1
Ok, then i need glsl. I want to try as photo realistic things as possible with the newest Hadware i have. (Wich is an X800 now on an X2)

Simply create the shader in the tool and then manually create the material file for it.
Do i need to get the .fx file, and then manually convert to a .material and a program? Or i convert the Vertex and Fragment Program source? Or does it need to be compiled or translated to another form? .. hmm .. would it be possible to write a programm wich does that?
or is it simpler to write the Ogre RenderMonkey exporter? Or do i need to be creative, and not just to do an algorithm manually?
I dont see any examples for GLSL in the Ogre Demos, only for Cg and asm. (can anyone post something wich uses glsl?) So i feel like searching in the dark :( , but maybe i just dont see, as i sit too much infront of the monitor and my eyes got damaged :shock:
my own sample app for the shader
Only for visualisation? or with some sliders .. etc?

Sorry i dont buy/read books :) but i will chack the tutoirials.
I already took a look on the GLSL spec.

I feel a lack here, and im ready to write some code.
(I need to write a parser or compiler for school in the next moths)


by the way, do i need to UV map all my models to use properly with shaders? i have a very complicated model, wich doesent need a texture placed right on its place just like dropped over. I really would love to use just shaders and only UV map minimal, where i know i need a picture on my modell exactly there.
(I have a tank i would like to camoflage, maybe a callsign UV maped, but not more)

thanx
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

LaKing wrote:Sorry i dont buy/read books :)
The MSDN HLSL articles will get you a LONG way on their own...and the MSDN itself has tons of HLSL examples and tutorials.
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 8
Contact:

Post by haffax »

LaKing the demo_ocean and demo_compositor use GLSL. They are part of the coming Ogre version (release candidate coming this very weekend (if nothing unexpected happens))

For how to integrate the programs with Ogre material files see manual section 3.1. GLSL is especially easy, as you don't need to bind any auto_params. This all happens internally.

As for my own testing app, no it doesn't have nifty sliders. If there is a param to change, I simply use keys like 1/2 for first param up/down, 2/3 for second and so on.. Really, really simple.
team-pantheon programmer
creators of Rastullahs Lockenpracht
nfz
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 1263
Joined: Wed Sep 24, 2003 4:00 pm
Location: Halifax, Nova Scotia, Canada

Post by nfz »

There is the GLSL demo floating around here somewhere that has about 12 GLSL shaders and there are sliders that allow you to play with each of the shader parameters in real time.
nfz
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 1263
Joined: Wed Sep 24, 2003 4:00 pm
Location: Halifax, Nova Scotia, Canada

Post by nfz »

Found it: http://sourceforge.net/project/showfile ... _id=171338

The executable is only for windows platform but includes source code and should build on linux without to much effort.
LaKing
Kobold
Posts: 26
Joined: Sat Jan 01, 2005 9:38 pm
Location: Hungary
Contact:

Post by LaKing »

On the first look this is a very nice example. It does almost all i wanted.

However still some questions open.
- if i look in the source and into the media folders there are much more things what i see wby starting the exe file. Why i dont see them in the exe?

- I tryed to compile from source, i use MSVC2005, and have the sdk in another library. Aafter turning on the Fat32 workaround thingie i get in runtime:
The procedure enty point ??1KeyListener@Ogre@@UAE@XZ could not be located in the dynamic link library OgreMain.dll.
I use the files from the zip only, and the SDK is installed. Maybe this source is for an older version of Ogre? 10 Jun 2005 - updated to work with Ogre SDK 1.0.2 .. Can i update it somehow to 1.0.7?


- Why is this example not under the demos? :)
nfz
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 1263
Joined: Wed Sep 24, 2003 4:00 pm
Location: Halifax, Nova Scotia, Canada

Post by nfz »

I tested the GLSL demo with 1.0.7 vc8 SDK about a week ago and it built and ran with no problems. The error you are getting at runtime implies that you are not using the correct dll ie if you rebuilt the demo with 1.0.7 import libs then make sure the dlls in the exe directory are for 1.0.7.

The GLSL demo is going to be included with the release of Ogre 1.2 RC2. It didn't make it into RC1 because I totally forgot about it until tonight when I was talking to Sinbad about the demos for 1.2 RC1 release.
Post Reply