Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Dark Shader / FX Shaders

Author
Message
Cryptic Dragon
16
Years of Service
User Offline
Joined: 7th Dec 2007
Location:
Posted: 23rd Feb 2009 05:04
I was just looking at the code for one of the included examples in the samples viewer.

FX - Shaders

The code for the example is as such...

// Dark GDK - The Game Creators - www.thegamecreators.com

// include Dark GDK header file
#include "DarkGDK.h"

// main entry point for program
void DarkGDK ( void )
{
// switch to the media directory
dbSetDir ( "media\\media" );

// set program properties
dbSyncOn ( );
dbSyncRate ( 0 );
dbAutoCamOff ( );

// load effects files with their objects
dbSetEffectOn ( 1, "bubble\\bubble.fx", 1 );
dbSetEffectOn ( 2, "aniso\\aniso.fx", 1 );
dbSetEffectOn ( 3, "cartoon\\cartoon.fx", 1 );
dbSetEffectOn ( 4, "rainbow\\rainbow.fx", 1 );

And so on...

Anyway after looking the .fx files such as bubble.fx it looked as the shader was applied directly to the .x mesh file with in the shader code. The code looks very much like C++.

I have Dark Shader installed and so here is my question. Were these files created with dark shader or is there another software program used to create them???

Thanks

You know for a fact that you have reached the edge when you can absolutely see sound!
Cryptic Dragon
16
Years of Service
User Offline
Joined: 7th Dec 2007
Location:
Posted: 23rd Feb 2009 05:09
Here is the bubble.fx code...

//
// Bubble
//

matrix worldi : WorldIT;
matrix wvp : WorldViewProjection;
matrix mworld : World;
matrix viewInv : ViewIT;
float4 lightPos : Position < string UIPosition = "Light Position"; >;
float ticks : Time;

string XFile = "sphere.x";
texture colorTexture < string Name = "blue.tga"; >;

pixelshader pNIL;

struct VS_INPUT
{
float3 Position : POSITION;
float4 UV : TEXCOORD0;
float3 Normal : NORMAL;
};

struct VS_OUTPUT
{
float4 HPosition : POSITION;
float4 TexCoord0 : TEXCOORD0;
float4 diffCol : COLOR0;
float4 specCol : COLOR1;
};

float4 ambiColor={0.2f, 0.2f, 0.2f, 1.0f};
float4 surfColor={0.8f, 0.8f, 0.8f, 1.0f};
float4 liteColor={1.0f, 1.0f, 1.0f, 1.0f};
float specExpon=22.0;
float horizontal=0.2;
float vertical=3.0;
float timeScale=0.005;

VS_OUTPUT VShade(VS_INPUT IN)
{
VS_OUTPUT OUT;

// world normal
float3 worldNormal = mul(IN.Normal, mworld).xyz;
worldNormal = normalize(worldNormal);
float timeNow = ((ticks/100.0)/timeScale);

//build float4
float4 tempPos;
tempPos.xyz = IN.Position.xyz;
tempPos.w = 1.0;

float iny = tempPos.y * vertical + timeNow;
float wiggleX = sin(iny) * horizontal;
float wiggleY = cos(iny) * horizontal; // deriv
worldNormal.y = worldNormal.y + wiggleY;
worldNormal = normalize(worldNormal);
tempPos.x = tempPos.x + wiggleX;

//compute worldspace position
float3 worldSpacePos = mul(tempPos,mworld).xyz;
float3 LightVec = normalize(lightPos - worldSpacePos);
float ldn = dot(LightVec,worldNormal);

float diffComp = max(0,ldn);
float4 diffContrib = surfColor * ( diffComp * liteColor + ambiColor);
OUT.diffCol = diffContrib;
OUT.diffCol.w = 1.0;
OUT.TexCoord0 = IN.UV;

float3 EyePos = viewInv[3].xyz;
float3 vertToEye = normalize(EyePos - worldSpacePos);
float3 halfAngle = normalize(vertToEye + LightVec);

float hdn = pow(max(0,dot(halfAngle,worldNormal)),specExpon);
OUT.specCol = hdn * liteColor;

// transform into homogeneous-clip space
OUT.HPosition = mul(tempPos, wvp);

return OUT;
}

uniform sampler sampler0 =
sampler_state
{
texture = <colorTexture>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Wrap;
AddressV = Wrap;
AddressW = Wrap;
};

struct PS_INPUT
{
float4 TexCoord0 : TEXCOORD0;
float4 diffCol : COLOR;
float4 specCol : SPECULAR;
};

struct pixelOutput
{
float4 col : COLOR;
};

pixelOutput MrWigglePS_t(PS_INPUT IN)
{
// Lookup the colorMap texture
pixelOutput OUT;
float4 result = IN.diffCol * tex2D( sampler0, IN.TexCoord0) + IN.specCol;
OUT.col = result;
return OUT;
}

//////////////////////////////////////
// Techniques specs follow
//////////////////////////////////////
technique t0
{
pass p0
{
VertexShader = compile vs_2_0 VShade();
PixelShader = compile ps_1_1 MrWigglePS_t();

// Z-buffering not to be used
ZEnable = false;
ZWriteEnable = false;
CullMode = CW;

// enable alpha blending
AlphaBlendEnable = TRUE;
SrcBlend = SRCALPHA;
DestBlend = INVSRCALPHA;

MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
}
pass p1
{
VertexShader = compile vs_2_0 VShade();
PixelShader = compile ps_1_1 MrWigglePS_t();

// Z-buffering not to be used
ZEnable = false;
ZWriteEnable = false;
CullMode = CCW;

// enable alpha blending
AlphaBlendEnable = TRUE;
SrcBlend = SRCALPHA;
DestBlend = INVSRCALPHA;

MinFilter[0] = Linear;
MagFilter[0] = Linear;
MipFilter[0] = Linear;
}
}

You know for a fact that you have reached the edge when you can absolutely see sound!
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 23rd Feb 2009 18:34
The language is called HLSL. You can create them in any text editor, or a special IDE. I use NVidia's FX Composer. search google for more info.
Cryptic Dragon
16
Years of Service
User Offline
Joined: 7th Dec 2007
Location:
Posted: 24th Feb 2009 00:28
Quote: "The language is called HLSL. You can create them in any text editor, or a special IDE. I use NVidia's FX Composer. search google for more info"


Thanks, I just installed NVidias FX composer. It will have a bit of a learning curve for me. I also noticed that there is pricy debugger named...

FX_Composer2_Shader_Debugger_Plugin_2.51.0827.1525.exe

...which is available on 30 day trial. Is it an absoloute requirement to make the .fx shaders or can I merely just forget about the debugger plugin from NVidia??

If I do not need the debugger then I guess a person could play around with the generated .fx script file to make modifications. If this is also true then a person could become a .fx scripting expert in a short time without the use of a graphics type program to generate the scripts.

Anyway in addition to the plugin question a couple of paragraphs back I had one other .fx question that is important to me. Are the scripts produced by NVidia's FX Composer DirectX based or are they NVidia specific meening Nvidia video cards only??

THANKS IN ADVANCE!

Cryptic Dragon

You know for a fact that you have reached the edge when you can absolutely see sound!
chunks chunks
17
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 24th Feb 2009 02:28
You should watch the video that mike did from the convention it gives a good insight on how to make shaders for dbpro .

By the way u dont need that debugger plugin to use fx composer .

chunks

nvidia geforce 8600gt + amd athlon 64
windows xp pro.
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 24th Feb 2009 18:19
HLSL is made by microsoft and ati actually, specifically for dx. Debugger is unnecessary, but cool. You will want to make a note of these:



because if they are the same in every file that means gdk sets them, and that you should sue those names. In proper directx you have to control all the var setting yourself, so TGC must have neatened it up a bit and done it for you.
Cryptic Dragon
16
Years of Service
User Offline
Joined: 7th Dec 2007
Location:
Posted: 27th Feb 2009 05:13
Quote: "You should watch the video that mike did from the convention it gives a good insight on how to make shaders for dbpro .

By the way u dont need that debugger plugin to use fx composer .

chunks"


Thanks chunks chunks,
BTW, do you have a link to the video you are speaking of?

THANKS IN ADVANCE

Cryptic Dragon

You know for a fact that you have reached the edge when you can absolutely see sound!
Cryptic Dragon
16
Years of Service
User Offline
Joined: 7th Dec 2007
Location:
Posted: 27th Feb 2009 05:16
Quote: "HLSL is made by microsoft and ati actually, specifically for dx. Debugger is unnecessary, but cool. You will want to make a note of these:

+ Code Snippet
matrix worldi : WorldIT;
matrix wvp : WorldViewProjection;
matrix mworld : World;
matrix viewInv : ViewIT;
float4 lightPos : Position < string UIPosition = "Light Position"; >;
float ticks : Time;

because if they are the same in every file that means gdk sets them, and that you should sue those names. In proper directx you have to control all the var setting yourself, so TGC must have neatened it up a bit and done it for you. "


Thanks for the code snip and the explanations. I have found scripting very easy so this should be relatively easy to pick up once I get a few of them that I modify and create to work perfectly.

Cryptic Dragon

You know for a fact that you have reached the edge when you can absolutely see sound!
Cryptic Dragon
16
Years of Service
User Offline
Joined: 7th Dec 2007
Location:
Posted: 27th Feb 2009 05:20
I know many computer programming languages. My scripting includes HTML including CSS, JavaScript, Perl, VBA and ASP, plus many Linux OS scripting methods. I think that I will catch onto HLSL pretty quickly.

CrypticDragon

You know for a fact that you have reached the edge when you can absolutely see sound!
Cryptic Dragon
16
Years of Service
User Offline
Joined: 7th Dec 2007
Location:
Posted: 8th Mar 2009 20:47
Quote: "Quote: "You should watch the video that mike did from the convention it gives a good insight on how to make shaders for dbpro .

By the way u dont need that debugger plugin to use fx composer .

chunks"

Thanks chunks chunks,
BTW, do you have a link to the video you are speaking of?

THANKS IN ADVANCE

Cryptic Dragon"


Never Mind, I Found It.

http://www.thegamecreators.com/?gf=convention2008

CrypticDragon

You know for a fact that you have reached the edge when you can absolutely see sound!

Login to post a reply

Server time is: 2024-09-30 19:23:42
Your offset time is: 2024-09-30 19:23:42