3D Rad - Free 3D game maker - Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

HOW TO POST TO THIS FORUM: after you have registered to the forum, please don't forget to send me an email with 'Please activate my forum account (e-mail: your-email-here)' as subject.

Pages: [1] 2

Author Topic: Shader Pak - 1 & 2  (Read 3069 times)

genetransfer

  • 3D Rad Guru
  • *****
  • Posts: 857
Shader Pak - 1 & 2
« on: December 04, 2009, 07:33:38 PM »
Hello Everyone!

Previously I used 3Impact and have written a vast amount of shaders and sold them for use with that engine. Being that I'm no longer developing with 3Impact engine, I thought I shouldn'y keep these shaders to myself and now that 3drad has the ability to write custom shaders I thought I put them here for the community to use free of charge and however you want. though if you do find them useful and would like to make a donation you can here.(but you don't have to, only if you want to )

I don't currently have the latest version of 3Drad but have looked at the 3drad shader notes and they use the same format so they should work easily with the engine.

to see these shader in action see here : video
note in video the sub uses a modified version of the cube shader to allow for volume in the light. will upload that when I get the latest version of rad(can't donate till pay day) as an extra asset is used.

you can down load the pak here : Cube_Light_Shader_Pak_1
you can down load the 2nd pak here : Shader_Pak_2

here is a link to a working cubelight example in the meantime

SHADER PAK 1 - included shaders:

Cube_Light_Bump.fx                       VS2_0,PS2_0
Cube_Light_Bump_Reflect.fx               VS2_0,PS2_0
Cube_Light_Bump_Reflect_Edge_Gloss.fx    VS2_0,PS2_0
Cube_Light_Bump_SS.fx                    VS2_0,PS2_0
Cube_Light_Smooth.fx                     VS2_0,PS2_0
Cube_Light_Smooth_Reflect.fx             VS2_0,PS2_0
Cube_Light_Smooth_Reflect_Edge_Gloss.fx  VS2_0,PS2_0
Cube_Light_Smooth_SS.fx                  VS2_0,PS2_0
Point_Light_Bump.fx                      VS2_0,PS2_0
Point_Light_Bump_Reflect.fx              VS2_0,PS2_0
Point_Light_Bump_Reflect_Edge_Gloss.fx   VS2_0,PS2_0
Point_Light_Bump_SS.fx                   VS2_0,PS2_0
Point_Light_Smooth.fx                    VS2_0,PS2_0
Point_Light_Smooth_Reflect.fx            VS2_0,PS2_0
Point_Light_Smooth_Reflect_Edge_Gloss.fx VS2_0,PS2_0
Point_Light_Smooth_SS.fx                 VS2_0,PS2_0
Volume_Fire.fx                           VS2_0,PS2_0
Volume_Fire_Sphere_A.fx                  VS2_0,PS2_0
Volume_Fire_Sphere_B.fx                  VS2_0,PS2_0
Volume_Fire_Sphere_C.fx                  VS2_0,PS2_0
No_Lighting_A.fx                         VS2_0,PS2_0
No_Lighting_B.fx                         VS2_0,PS2_0


SHADER PAK 2 - included shaders:

cloud dynamic sky shader                              VS2_0,PS2_0
glass - hollow/solid - fog/nofog - refraction/norefraction variations

documentation is included though the value and texture handlers that communicate with the engine->shader are 3Impacts(c++) set but looking at the scripting side of things converion will be easy.

a special note on cube shaders:

they need an extra function(below and in the docs), this converts the orientation (i.e body,camera,skinmesh etc...) to a float4x4matrix which is used to orientate the cube map in the shader to match the direction of the light source.

after calling below function you would use iShaderFloat4x4Set tio send the matrix info to the shader.

int the shader the handle for the atrix is called QuatOrientationMatrix

float MyQuatToMatrix[4][4];

iQuatToMatrix(&quat,MyQuatToMatrix);

so it would be iShaderFloat4x4Set (OBJ_X,"QuatOrientationMatrix",MyQuatToMatrix[0][0],MyQuatToMatrix[0][1] etc...
(not sure if colums or rows are processed first in 3drad but if it's like 3Impact it will work fine though if the cube light is rotateing opposite to the orientation reference quat) comment out the transpose line in the vertex shader)

c++ version:
Code: [Select]
void iQuatToMatrix(D3DXQUATERNION* quat,float QuatToMatrix[4][4])
{
   float wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2;
   // calculate coefficients
   x2 = quat->x + quat->x; y2 = quat->y + quat->y;
   z2 = quat->z + quat->z;
   xx = quat->x * x2; xy = quat->x * y2; xz = quat->x * z2;
   yy = quat->y * y2; yz = quat->y * z2; zz = quat->z * z2;
   wx = quat->w * x2; wy = quat->w * y2; wz = quat->w * z2;

   QuatToMatrix[0][0] = 1.0f - (yy + zz);
   QuatToMatrix[1][0] = xy - wz;
   QuatToMatrix[2][0] = xz + wy;
   QuatToMatrix[3][0] = 0.0f;
   QuatToMatrix[0][1] = xy + wz;
   QuatToMatrix[1][1] = 1.0f - (xx + zz);
   QuatToMatrix[2][1] = yz - wx;
   QuatToMatrix[3][1] = 0.0f;
   QuatToMatrix[0][2] = xz - wy;
   QuatToMatrix[1][2] = yz + wx;
   QuatToMatrix[2][2] = 1.0f - (xx + yy);
   QuatToMatrix[3][2] = 0.0f;
   QuatToMatrix[0][3] = 0.0f;
   QuatToMatrix[1][3] = 0.0f;
   QuatToMatrix[2][3] = 0.0f;
   QuatToMatrix[3][3] = 1.0f;

   //no return value needed as effecting parameter directly
}

Script version
Code: [Select]
void iQuatToMatrix(Quaternion quat,
                   float &out QuatToMatrix_00,float &out QuatToMatrix_10,float &out QuatToMatrix_20,float &out QuatToMatrix_30,
                   float &out QuatToMatrix_01,float &out QuatToMatrix_11,float &out QuatToMatrix_21,float &out QuatToMatrix_31,
                   float &out QuatToMatrix_02,float &out QuatToMatrix_12,float &out QuatToMatrix_22,float &out QuatToMatrix_32,
                   float &out QuatToMatrix_03,float &out QuatToMatrix_13,float &out QuatToMatrix_23,float &out QuatToMatrix_33)
{
   float wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2;
   // calculate coefficients
   x2 = quat.x + quat.x; y2 = quat.y + quat.y;
   z2 = quat.z + quat.z;
   xx = quat.x * x2; xy = quat.x * y2; xz = quat.x * z2;
   yy = quat.y * y2; yz = quat.y * z2; zz = quat.z * z2;
   wx = quat.w * x2; wy = quat.w * y2; wz = quat.w * z2;

   QuatToMatrix_00 = 1.0f - (yy + zz);
   QuatToMatrix_10 = xy - wz;
   QuatToMatrix_20 = xz + wy;
   QuatToMatrix_30 = 0.0f;
   QuatToMatrix_01 = xy + wz;
   QuatToMatrix_11 = 1.0f - (xx + zz);
   QuatToMatrix_21 = yz - wx;
   QuatToMatrix_31 = 0.0f;
   QuatToMatrix_02 = xz - wy;
   QuatToMatrix_12 = yz + wx;
   QuatToMatrix_22 = 1.0f - (xx + yy);
   QuatToMatrix_32 = 0.0f;
   QuatToMatrix_03 = 0.0f;
   QuatToMatrix_13 = 0.0f;
   QuatToMatrix_23 = 0.0f;
   QuatToMatrix_33 = 1.0f;

   //no return value needed as effecting parameter directly
}

a note on volume fire.

3drad doesn't support volume textures yet so although it will load in the .dds volume texture it will only use the first layer in it for the texture.

enjoy!

genetransfer.
« Last Edit: December 26, 2009, 05:01:19 PM by genetransfer »
Logged
using 3Drad 7.22

system specs:
Windows 7 Home Premium 64-bit
Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz (4 CPUs), ~3.2Ghz
8 gig ram
Geforce GTX 650 1024 MB GDDR5
DirectX 11

Sharp911

  • Sr. Member
  • ****
  • Posts: 371
Re: Shader Pak - 1 & 2
« Reply #1 on: December 04, 2009, 09:24:00 PM »
AWESOME!!! thanks for sharing.... downloading and testing right now :)

AllanF

  • Sr. Member
  • ****
  • Posts: 408
    • WWW
Re: Shader Pak - 1 & 2
« Reply #2 on: December 04, 2009, 10:07:09 PM »
Thanks a ton!

If your video is an indication of what can be done then we're off to a great start!
Logged
AKA: The 3D Raddict http://www.3draddict.com/

Weapon121

  • 3D Artist/Animator
  • Global Moderator
  • 3D Rad Guru
  • *****
  • Posts: 751
Re: Shader Pak - 1 & 2
« Reply #3 on: December 04, 2009, 10:45:05 PM »
Wow, Hopefully some of the great coders here will get this thing rolling! Thanks Genetransfer  ;)
Logged
Roll out!
http://www.youtube.com/watch?v=VD8MvMaPNO4

Do you have kids between the ages of 3 and 9?

http://www.amazon.com/dp/B007K1EFC6

genetransfer

  • 3D Rad Guru
  • *****
  • Posts: 857
Re: Shader Pak - 1 & 2
« Reply #4 on: December 05, 2009, 02:03:07 AM »
no problem people, if no one understands how to get them working I'll do it as soon as I get me a copy of the latest build. can't do it till next payday but I'l get em up and running for you.

but some quick tips:

the process goes app->vertex shader->pixelshader -> screen (or thereabouts anyway, I am celebrating tonight so forgive me if I'm a little out).

example - 3IDL_Bump_Gloss_Specular_Map.fx - from shader pak 2;

Below are the editables from the shader code, and 3drad will have to talk to them. this shader automatically will use 3drads directional light as the scemantics are the same.

float TileCount = 1.0f;<---------------------uv tileing
float bumpScale = 1.0f;<--------------------1.0 will read your normal map at default but increase/decrease to alter the bump effect
float SpecIntesity = 0.75f;<-----------------specularity between 0.0f and 1.0f
float PhongExp = 128.0f;<-------------------size of shinny spot will allow for sofening or hardening of the material
float EdgeGloss = 1.0f;<---------------------this shader has edge gloss but you can remove it if you want or I'll make one without it later.

below are the textures used by the shaders:

note things between <> are not needed to worry about it will compile fine they are lagacy from working with fx composer.
we have 3 textures used by this shader , a diffuse,norma,and specular map.so these have to be sent from 3drad too.
Note: diffuseMap is the default name for the texture that is applied to your mesh when converting to .x. so if you want to use a different diffuse map than the one applied you wil have to change 'texture diffuseMap' in the shader to say 'texture DiffuseMap'

texture diffuseMap : DIFFUSE <
    string ResourceName = "default_color.dds";
    string UIName =  "Color Texture";
    string ResourceType = "2D";
>;
texture NormalMap : NORMAL <
    string ResourceName = "default_bump_normal.dds";
    string UIName =  "Normal-Map Texture";
    string ResourceType = "2D";
>;
texture SpecularMap : DIFFUSE <
    string ResourceName = "default_color.dds";
    string UIName =  "Specular Texture";
    string ResourceType = "2D";
>;


ok calling them in the code remeber I'm flying blind but I see the similarities in the instruction between 3drad and 3Impact.

so.

the floats will translate easily.

float cTileCount = 1.0f;

iShaderFloatSet(OBJ_X,"TileCount",cTileCount );

we have our object -> the name of the value in the shader -> 3drad equivelent of the value;

and you would do the same for textures

int textureindex =  iShaderTextureCreate("somepath\\sometexture.dds");

iShaderTextureSet(OBJ_X,"diffuseMap",textureindex);

we have our object->texture name in the shader->our diffuseMap texture index.

Note: not sure if 3drad shader support cube textures(EnvMap's) so if it doesn't the cube lights and reflection shaders won't work, so Fernando will have to confirm.

anyway hope that gets you started, goodluck! :) (back to celebrating  ;D)

genetransfer.

Edit: just note that if useing the point light/cube light shaders unless you alter the names of the lights to 3drad equivelant you won't be able to control them in the editor but you will have to control the in the script.
also for cube shaders if you want the cube map projected onto anything, that thing will have to have the same shader applied.
when dealing with a particluar shader all objects that you want it to effect will have to have it applied, you can specify different values i.e. light positions for each object with the shader applied but iff you want it to effect all objects in your scene all your object will have to have the same shader applied and their light position values at the same lovation, hope that makes sense. ok really back to celebrating now :)
« Last Edit: December 05, 2009, 02:53:00 AM by genetransfer »
Logged
using 3Drad 7.22

system specs:
Windows 7 Home Premium 64-bit
Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz (4 CPUs), ~3.2Ghz
8 gig ram
Geforce GTX 650 1024 MB GDDR5
DirectX 11

3DSimulant

  • 3D Rad Guru
  • *****
  • Posts: 818
Re: Shader Pak - 1 & 2
« Reply #5 on: December 05, 2009, 03:00:32 AM »
Great Video !!!  Also ripple in Water vid is Nice

I Hope Fernando Donate on your page so you can donate back and have the Version 6.41 Today.
You're the only One at the Moment with this Know how.
I hope you can support the hlsl section of 3DRad.

 3DSim
Logged
new forum search:
http://www.google.com/ site:www.3drad.com searchword  ( <-- copy )

clandestine

  • Sr. Member
  • ****
  • Posts: 494
    • WWW
Re: Shader Pak - 1 & 2
« Reply #6 on: December 05, 2009, 04:08:02 AM »
i honestly didn't believe that 3Impact/3DRad is capable of what i see on the video... wow ... this is UDK quality guys!
Genetransfer, i would gladly donate a modest amount, if that would help you find the time/desire to write a small tutorial for artists on how to use your amazing shaders with 3D Rad!

thanks man!!!
« Last Edit: December 05, 2009, 04:11:00 AM by clandestine »
Logged

psikotropico

  • Guest
Re: Shader Pak - 1 & 2
« Reply #7 on: December 05, 2009, 04:33:00 AM »
really nice work...
Logged

shadmar

  • Global Moderator
  • 3D Rad Guru
  • *****
  • Posts: 2259
Re: Shader Pak - 1 & 2
« Reply #8 on: December 05, 2009, 05:29:52 AM »
Woow gene those look really really great, I must have a look at this. Thanks a  bunch :)
Logged

loop

  • 3D Rad Guru
  • *****
  • Posts: 1622
Re: Shader Pak - 1 & 2
« Reply #9 on: December 05, 2009, 07:14:59 AM »
absolutly incredible!

I love the lights, thought that I'd never see those lights here... what a beautiful surprise!
I really like the water ripples too (when the submarine goes forward in the surface), that's also a shader effect??

the scene overall looks fantastic  :)
Logged
Crashing Boxes - winner of the 3d games category at the 5th Uruguayan video game contest
get a copy for your iPad/iPhone!

shadmar

  • Global Moderator
  • 3D Rad Guru
  • *****
  • Posts: 2259
Re: Shader Pak - 1 & 2
« Reply #10 on: December 05, 2009, 07:50:43 AM »
i honestly didn't believe that 3Impact/3DRad is capable of what i see on the video... wow ... this is UDK quality guys!
Genetransfer, i would gladly donate a modest amount, if that would help you find the time/desire to write a small tutorial for artists on how to use your amazing shaders with 3D Rad!

thanks man!!!

I would chip in too.
Haven't had the time to try anything yet, but I will give tit a try later :)
Logged

3D Rad Developer - Fernando

  • Administrator
  • 3D Rad Guru
  • *****
  • Posts: 5229
Re: Shader Pak - 1 & 2
« Reply #11 on: December 05, 2009, 03:31:45 PM »
That's really HUGE genetransfer, thanx a ton  :)

genetransfer

  • 3D Rad Guru
  • *****
  • Posts: 857
Re: Shader Pak - 1 & 2
« Reply #12 on: December 05, 2009, 06:23:25 PM »
thanks for the kind words everyone, I hope they will be a great help in the future. I have some free time over the next few week while I'm learning some new tools, so once I get a copy I'll put a few scenes together and tutorial unless someone else figures it all out before I get a chance to do it. but that won't be a problem to make a tutorial for the community :) and if you want to donate that's a bonus and appreciated but I won't worry if no one does it's all cool.
Logged
using 3Drad 7.22

system specs:
Windows 7 Home Premium 64-bit
Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz (4 CPUs), ~3.2Ghz
8 gig ram
Geforce GTX 650 1024 MB GDDR5
DirectX 11

genetransfer

  • 3D Rad Guru
  • *****
  • Posts: 857
Re: Shader Pak - 1 & 2
« Reply #13 on: December 06, 2009, 09:17:22 PM »
ok thanks To Fernando's generosity I am now doing a tutorial on getting the shader from the packs to work with 3drad. Very simple to work with, great job Fernando!
the first one will deal with a simple shader bump gloss, 3 versions (sm 1.1,2.0 and 3.0); it will show how to deal with loading the shaders and selecting quality for each one. it also has the abitly to force test your selected shader model and to prevent shaders not supported by hardware. the script isn't overly big at all. just note though when looking at the script you will say holly macadolly, but that just because the source for each shader is placed first in the script and there are 3 shaders so it make look like a massive script but the actual game code is minisquel. anyway give me till this afternoon to get this up as I have to get some excercise and go for a walk. the code side of things is done but I need to explain what it's all doing. alright enough of me going on, bye. Thanks again Fernando!
Logged
using 3Drad 7.22

system specs:
Windows 7 Home Premium 64-bit
Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz (4 CPUs), ~3.2Ghz
8 gig ram
Geforce GTX 650 1024 MB GDDR5
DirectX 11

3D Rad Developer - Fernando

  • Administrator
  • 3D Rad Guru
  • *****
  • Posts: 5229
Re: Shader Pak - 1 & 2
« Reply #14 on: December 07, 2009, 03:24:39 AM »
You are very welcome genetransfer!
Pages: [1] 2
« previous next »