learning shaders
-
- Posts: 275
- Joined: Fri May 12, 2006 6:37 pm
- Location: Germany
learning shaders
Hi all out there. reacently i decided, that i have to learn how to do shaders...
So i´ll going to learn HLSL...
Here i´ll post allt the shaders i do...
(and maybe some questions )
Greetz TGM
So i´ll going to learn HLSL...
Here i´ll post allt the shaders i do...
(and maybe some questions )
Greetz TGM
-
- Posts: 275
- Joined: Fri May 12, 2006 6:37 pm
- Location: Germany
ok.. here the first one i did:
Bloom
(i have to admit, that this screen is faked in Rendermonkey by using a screenshot as texture for a plane, but it will look the same way in irrlicht.)
Unfortunably DevC++ is unable to use Irrlicht with DX, so I couldn´t make a irrlicht shader out of it. Does somebody know a HLSL->GLSL converter??
or can Code::Blocks compile Irrlicht with DX??
so.. some new shader done by me:
A nice little on shild effec(looks much better in front of something else):
A bumpmap shader(Rendermonkey sampel), which I improved with Alpha+ specmap. The best thing about it is, that it only needs two textures, color+alpha in alphachanel and Normal+spec in alpha chanel:
and Realtime Enviorment distortion via render to tex and a distortion Normalmap:
Bloom
(i have to admit, that this screen is faked in Rendermonkey by using a screenshot as texture for a plane, but it will look the same way in irrlicht.)
Unfortunably DevC++ is unable to use Irrlicht with DX, so I couldn´t make a irrlicht shader out of it. Does somebody know a HLSL->GLSL converter??
or can Code::Blocks compile Irrlicht with DX??
so.. some new shader done by me:
A nice little on shild effec(looks much better in front of something else):
A bumpmap shader(Rendermonkey sampel), which I improved with Alpha+ specmap. The best thing about it is, that it only needs two textures, color+alpha in alphachanel and Normal+spec in alpha chanel:
and Realtime Enviorment distortion via render to tex and a distortion Normalmap:
Last edited by TheGameMaker on Thu Oct 19, 2006 6:31 pm, edited 1 time in total.
Just send me a PM, I can host it for you.
Nice work!
And here is the link: http://www.leidel.net/dl/irrlicht/bloom.rar
Regards - Xaron
Nice work!
And here is the link: http://www.leidel.net/dl/irrlicht/bloom.rar
Regards - Xaron
good job
good job with the shaders
just wondering why you pick HLSL instead of GLSL , we linux boy won't be able to use it
please keep posting your shaders, especially when you get to the water, irrlicht's water right now looks pretty fake
irrlicht game character project
http://picasaweb.google.com/juliusctw/FinishedArt
http://picasaweb.google.com/juliusctw/FinishedArt
-
- Posts: 40
- Joined: Mon Sep 11, 2006 1:06 pm
-
- Posts: 275
- Joined: Fri May 12, 2006 6:37 pm
- Location: Germany
well... i first really tried using GLSL, but as C++ Programmer I liked HLSL more.. but i definitiv will make a switch to GLSL if the time is come. Momentan I´m fokusing on understanding the way shaders work. (cause i can´t use them, too I´m working with DevC++ )
You linux guys can use them if you assemble them first. I think this should be no problem and shaderassembly should run in every system(just tell me if this isn´t corret.)
tuturials... i didn´t used much tuts.
this one,
http://www.facewound.com/tutorials/shader1/
and the free sample chapter of the X2 book which seems to be very good, maybe i´ll buy it. The rest I learned by looking at the very simpelst shaders in rendermonky (unshaded tex, pong with tex etc.)
Greetz TGM
You linux guys can use them if you assemble them first. I think this should be no problem and shaderassembly should run in every system(just tell me if this isn´t corret.)
tuturials... i didn´t used much tuts.
this one,
http://www.facewound.com/tutorials/shader1/
and the free sample chapter of the X2 book which seems to be very good, maybe i´ll buy it. The rest I learned by looking at the very simpelst shaders in rendermonky (unshaded tex, pong with tex etc.)
Greetz TGM
HLSL is easily switched over to GLSL. Instead of asking someone to do both for you, you should try it out yourself and learn shaders a bit more.
They are virtually the same. Some simple research will show you that GLSL uses float, vec2, vec3, vec4 whereas HLSL used float, float2, float3, float4.
Also, you'll find that the GLSL compiler is stricter than the HLSL compiler. For example, if you have a vec4 for a texture coord, and you want to do a 2d texture lookup, you have to explicitly cast the vec4 to a vec2.
That's honestly about it. GLSL can seem a little easier, because instead of having to set a shader constant for the WorldViewProjection as you do in HLSL, it's already set for you. And you can even go simpler by transforming your vertex position in your vertex shader by simply calling -
As well as many other things are automatically set for you. Some simple research will show you all these things.
I'll even help you from having to search the web. I have 2 basic files I used to learn GLSL( after of course already knowing HLSL and knowing shaders, but still, should be all you need ) I've found them on the web, and saved the pdf's, so no clue where I got them, but I've put them on my website here -
http://www.spintz.com/glsl_quickref.pdf
http://www.spintz.com/GLSLangSpec.Full.1.10.59.pdf
They are virtually the same. Some simple research will show you that GLSL uses float, vec2, vec3, vec4 whereas HLSL used float, float2, float3, float4.
Also, you'll find that the GLSL compiler is stricter than the HLSL compiler. For example, if you have a vec4 for a texture coord, and you want to do a 2d texture lookup, you have to explicitly cast the vec4 to a vec2.
That's honestly about it. GLSL can seem a little easier, because instead of having to set a shader constant for the WorldViewProjection as you do in HLSL, it's already set for you. And you can even go simpler by transforming your vertex position in your vertex shader by simply calling -
Code: Select all
gl_Position = ftransform();
I'll even help you from having to search the web. I have 2 basic files I used to learn GLSL( after of course already knowing HLSL and knowing shaders, but still, should be all you need ) I've found them on the web, and saved the pdf's, so no clue where I got them, but I've put them on my website here -
http://www.spintz.com/glsl_quickref.pdf
http://www.spintz.com/GLSLangSpec.Full.1.10.59.pdf
Last edited by Spintz on Thu Oct 19, 2006 2:12 pm, edited 1 time in total.
Yeah, looks verry nice !!!
For the DX support with MinGW/GCC (C::B, DevCpp) you'll have to recompile the Irrlicht dll (please search the forum for this) !!!
Or use my IrrExtensions, it will setup the Irrlicht project for recompiling with all drivers you want !!!
But you'll have to install the DX-Devpak (also for C::B), a link can be found on my site...
For the DX support with MinGW/GCC (C::B, DevCpp) you'll have to recompile the Irrlicht dll (please search the forum for this) !!!
Or use my IrrExtensions, it will setup the Irrlicht project for recompiling with all drivers you want !!!
But you'll have to install the DX-Devpak (also for C::B), a link can be found on my site...
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
-
- Posts: 275
- Joined: Fri May 12, 2006 6:37 pm
- Location: Germany
thx for the GLSL tuts.. i´ll have a look on them.
In my Opinion DX suxx, i don´t like the way its designed.. OGL is much more confortable... so I really want to switch to GLSL, but as already mentioned i felt more confortable with the HLSL layout..
but I got one question. I want to render the scence into a tex, and projekt thi tex onto a model (for desorstion). So its neccessary to get the texcoord by the position in Viewspace. I want the Rendered Texture to be Projekted onto the objekt as like as a video beamer would projekt it. I tried to set the texcoord to the pixelpos in viespace(x&y values). Unfortunably this doesn´t work as expected, because the texture scale remained constant relativ to the objekt. I want it to be streched about the whole screen... as like as this picture shows:
(both spheres are the same and the second one is only scaled/zoomed out. The grey patter is the rendered texture ) as you can see the pattern should allways fill the renderoutput without tiling/stretcheng. and so should the mapped&textured sphere be invisible(cause the background and the rendered&projekted Tex are seamles blending). What way can I achief this Planar mapping??
hope, that you understand what problems I got,
thx in advance TGM
hmm... I thought I wrote this a little bit above.HLSL is easily switched over to GLSL. Instead of asking someone to do both for you, you should try it out yourself and learn shaders a bit more.
In my Opinion DX suxx, i don´t like the way its designed.. OGL is much more confortable... so I really want to switch to GLSL, but as already mentioned i felt more confortable with the HLSL layout..
but I got one question. I want to render the scence into a tex, and projekt thi tex onto a model (for desorstion). So its neccessary to get the texcoord by the position in Viewspace. I want the Rendered Texture to be Projekted onto the objekt as like as a video beamer would projekt it. I tried to set the texcoord to the pixelpos in viespace(x&y values). Unfortunably this doesn´t work as expected, because the texture scale remained constant relativ to the objekt. I want it to be streched about the whole screen... as like as this picture shows:
(both spheres are the same and the second one is only scaled/zoomed out. The grey patter is the rendered texture ) as you can see the pattern should allways fill the renderoutput without tiling/stretcheng. and so should the mapped&textured sphere be invisible(cause the background and the rendered&projekted Tex are seamles blending). What way can I achief this Planar mapping??
hope, that you understand what problems I got,
thx in advance TGM
Linux wont be able to runs anything dx even dx assembly.
Nice work you can get visual studio for free from ms it runs dx fine, you can also ask me to help you convert the shaders.
But rember the .fx files dont just do the actual code, they also determine the rendering orders, passes, RTT's etc....
You will have to custom code all of that in irrlicht C++, so maybe trying to break down these shaders would help you in the c++ stage.
Also rember irrlicht doesnt load varaiables into hardware semantics
only the normals and texcoords are loaded so for the bumpmapping and maybe the other stuff you will have to load them via unused texcoords
render monkey uses
BINORMAL0;
TANGENT0;
or attribs in glsl
irr cant load them unless you modify the drivers(tri strip draw and stuff)
Nice work you can get visual studio for free from ms it runs dx fine, you can also ask me to help you convert the shaders.
But rember the .fx files dont just do the actual code, they also determine the rendering orders, passes, RTT's etc....
You will have to custom code all of that in irrlicht C++, so maybe trying to break down these shaders would help you in the c++ stage.
Also rember irrlicht doesnt load varaiables into hardware semantics
only the normals and texcoords are loaded so for the bumpmapping and maybe the other stuff you will have to load them via unused texcoords
render monkey uses
BINORMAL0;
TANGENT0;
or attribs in glsl
irr cant load them unless you modify the drivers(tri strip draw and stuff)
btw i encountered the same texture projection bug, to solve it you must use a
scaling matrix, since the matrix orders are diffrent for hlsl and glsl row order vs column order ill write the matrix operation as a linear algebra
remember POS is the vertex after it has been transformed, since it is transformed by the modelview,camera projection etcc... the camera would be the projector, to change the projector to something else load the projection matrix of the object instead of the camera's
projCoord =pos * 1.0 / pos.w
projCoord += (1,1,1,1)
projCoord *= (.5,.5,.5,.5)
you would then use texture 2d not texture proj (or texture proj if you miss out the first line in the equation i gave you)
you can do the above in the ps or vs but the texcoord must reach the ps.
scaling matrix, since the matrix orders are diffrent for hlsl and glsl row order vs column order ill write the matrix operation as a linear algebra
remember POS is the vertex after it has been transformed, since it is transformed by the modelview,camera projection etcc... the camera would be the projector, to change the projector to something else load the projection matrix of the object instead of the camera's
projCoord =pos * 1.0 / pos.w
projCoord += (1,1,1,1)
projCoord *= (.5,.5,.5,.5)
you would then use texture 2d not texture proj (or texture proj if you miss out the first line in the equation i gave you)
you can do the above in the ps or vs but the texcoord must reach the ps.
Sorry, wasn't intended for you. Was intended for i think julius that was saying "give us Linux users this stuff in GLSL" I think you're doing a fine jobTheGameMaker wrote:thx for the GLSL tuts.. i´ll have a look on them.
hmm... I thought I wrote this a little bit above.HLSL is easily switched over to GLSL. Instead of asking someone to do both for you, you should try it out yourself and learn shaders a bit more.