Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Akow, degenerate_762), 1,430 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Shader for Rock(ing) #357738
02/08/11 16:16
02/08/11 16:16
Joined: Feb 2011
Posts: 44
UK, Aylesbury
A
AdrenalinMod Offline OP
Newbie
AdrenalinMod  Offline OP
Newbie
A

Joined: Feb 2011
Posts: 44
UK, Aylesbury

Hello!

Ma name is Adre but you can call me AdrenalinMod cause I like to be in charge of like everything HAHA. *kidding***
I wanted to know if a shader like this exists cause in the WIKI and the AUMS I do not find any. And all because this guy and this one too have so great a portfolio doesn't mean that Carisma Studios will not have one too, in the time to come!

AdrenalinMod

Re: Shader for Rock(ing) [Re: AdrenalinMod] #357741
02/08/11 16:21
02/08/11 16:21
Joined: Nov 2008
Posts: 946
T
the_clown Offline
User
the_clown  Offline
User
T

Joined: Nov 2008
Posts: 946
Uhm - WHAT?

Re: Shader for Rock(ing) [Re: the_clown] #357745
02/08/11 16:31
02/08/11 16:31
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Rei_Ayanami Offline
Expert
Rei_Ayanami  Offline
Expert

Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
Yeah, Felix and Frank are cool persons, so what^^?

Parallax Mapping?

Afaik, Hummel has created a nice shader for that, not sure, though.

Re: Shader for Rock(ing) [Re: the_clown] #357746
02/08/11 16:35
02/08/11 16:35
Joined: Feb 2011
Posts: 44
UK, Aylesbury
A
AdrenalinMod Offline OP
Newbie
AdrenalinMod  Offline OP
Newbie
A

Joined: Feb 2011
Posts: 44
UK, Aylesbury
See, I don't want to argue with you clown I just wanted to know for sure if there is such a thing which we could incoorporate. We're planning a great Online Multiplayer Game (MMORPG: Massive Multiplayer Online Role Playing Game for those of you which don't know). We also need a great Modeler and a Storyboard Writer (SW) for our budget. I'm fundraising ATM but this is not for this thread.

Php Code:
// input from application
	struct a2v {
	half4 position		: POSITION;
	half2 texCoord		: TEXCOORD0;
	half3 tangent		: TANGENT;
	half3 binormal		: BINORMAL;
	half3 normal		: NORMAL;
};

// output to fragment program
struct v2f {
		half4 position		: POSITION;
		half2 texCoord		: TEXCOORD0;
		float3 eyeVec		 : TEXCOORD1;
		half3 lightVec	   : TEXCOORD2;
};

// blinn lighting with lit function
half4 blinn2(half3 N,
		half3 L,
		half3 V,
		uniform half4 diffuseColor,
		uniform half4 specularColor,
		uniform half shininess
		)
	{
	half3 H = normalize(V+L);
	half4 lighting = lit(dot(L,N), dot(H,N), shininess);
	return diffuseColor*lighting.y + specularColor*lighting.z;
	}

/**************************************/
/***** VERTEX SHADER ******************/
/**************************************/

v2f v(a2v In,
		uniform half4x4 worldViewProj, // object to clip space
		uniform half4x4 WorldIMatrix,  //world to object space
		uniform half4 lightPosition,
		uniform half4x4 ViewInvTrans,
		uniform half4x4 world		// object to world space
		)
{
	v2f Out;

  // transform vertex position to homogeneous clip space
	Out.position = mul(In.position, worldViewProj);
  
  //pass texture coordinates
	Out.texCoord = In.texCoord;

  // compute the 3x3 tranform from tangent space to object space
	half3x3 objTangentXf;

	objTangentXf[0] = In.binormal.xyz;
	objTangentXf[1] = -In.tangent.xyz;
	objTangentXf[2] = In.normal.xyz;

   //put the world space light position in object space
	   half4 objSpaceLightPos = mul(lightPosition, WorldIMatrix);
	   half3 objLightVec = objSpaceLightPos.xyz - In.position.xyz;
   // xform light vector from obj space to tangent space
	   Out.lightVec = mul(objTangentXf, objLightVec );
	
  //compute the eye vector in world space and put it in object space
	  half4 objSpaceEyePos = mul(ViewInvTrans[3], WorldIMatrix);
  // xform eye vector from obj space to tangent space
	  half3 objEyeVec = objSpaceEyePos.xyz - In.position.xyz;
	  Out.eyeVec = mul(objTangentXf, objEyeVec);

	return Out;
}

/**************************************/
/***** FRAGMENT PROGRAM ***************/
/**************************************/

float4 f(v2f In,
			uniform sampler2D colorTex,
			uniform sampler2D bumpTex,
			uniform half4 ambient,
			uniform half4 diffuseColor,
			uniform half4 specularColor,
			uniform half shininess,
			uniform half4 light1Color,
			uniform float offsetBias
			) : COLOR
{  
  // calculate lighting vectors
  half3 V = normalize(In.eyeVec);
  half3 L = normalize(In.lightVec);

  //I have to do this take make it look right - don't know why
  half2 newV = V.xy;
  newV.y = -newV.y;
  
  //offset the texture coords based on the view vector
  half height = tex2D(bumpTex, In.texCoord.xy).a;
  half2 offset = newV * (height * 2.0 - 1.0) * offsetBias;
  half2 newTexCoord = In.texCoord.xy + offset;

  //fetch the diffuse map
  half4 colorMap = tex2D(colorTex, newTexCoord);

  
  // fetch the bump normal from the normal map
  half3 normal = tex2D(bumpTex, newTexCoord).xyz * 2.0 - 1.0;

  half3 N = normal;
  
  //lighting
  
  //ambient light
  half4 C = ambient*colorMap;
  
  //diffuse light
  C += light1Color * blinn2(N, L, V, colorMap*diffuseColor, specularColor*colorMap.a, shininess);

  return C;
}

float4 f2(v2f In,
			uniform sampler2D colorTex,
			uniform sampler2D bumpTex,
			uniform half4 ambient,
			uniform half4 diffuseColor,
			uniform half4 specularColor,
			uniform half shininess,
			uniform half4 light1Color,
			uniform float offsetBias
			) : COLOR
{  
  // calculate lighting vectors
  half3 V = normalize(In.eyeVec);
  half3 L = normalize(In.lightVec);

  //I have to do this take make it look right - don't know why
  half2 newV = V.xy;
  newV.y = -newV.y;
  
  //offset the texture coords based on the view vector
  //height value is stored in the red channel of compressed normal maps
  half height = tex2D(bumpTex, In.texCoord.xy).r;
  half2 offset = newV * (height * 2.0 - 1.0) * offsetBias;
  half2 newTexCoord = In.texCoord.xy + offset;

  //fetch the diffuse map
  half4 colorMap = tex2D(colorTex, newTexCoord);

  
  // fetch the bump normal from the normal map
  //swizzle the compressed dxt5 format
  half3 normal = tex2D(bumpTex, newTexCoord).wyz * 2.0 - 1.0;
  //generate the z component of the vector
  normal.z = sqrt(1 - normal.x * normal.x - normal.y * normal.y);

  half3 N = normal;
  
  //lighting
  
  //ambient light
  half4 C = ambient*colorMap;
  
  //diffuse light
  C += light1Color * blinn2(N, L, V, colorMap*diffuseColor, specularColor*colorMap.a, shininess);

  return C;
}

/****************************************************/
/********** SAMPLERS ********************************/
/****************************************************/

sampler2D colorTextureSampler = sampler_state
{
	Texture = <colorTexture>;
	MinFilter = Linear;
	MagFilter = Linear;
	MipFilter = Anisotropic;
	AddressU = Wrap;
	AddressV = Wrap;
};

sampler2D normalMapSampler = sampler_state
{
	Texture = <normalMap>;
	MinFilter = Linear;
	MagFilter = Linear;
	MipFilter = Anisotropic;
	AddressU = Wrap;
	AddressV = Wrap;
};

sampler2D CnormalMapSampler = sampler_state
{
	Texture = <CnormalMap>;
	MinFilter = Linear;
	MagFilter = Linear;
	MipFilter = Anisotropic;
	AddressU = Wrap;
	AddressV = Wrap;
};

/****************************************************/
/********** TECHNIQUES ******************************/
/****************************************************/

technique Complete
{ 
	pass envPass 
	{		
	VertexShader = compile vs_1_1 v(wvp,worldI,light1Pos,viewInvTrans,world);
	ZEnable = true;
	ZWriteEnable = true;
	CullMode = CW;
	AlphaBlendEnable = false; 
	PixelShader = compile ps_2_0 f(colorTextureSampler,normalMapSampler,ambient,surfColor,specularColor,shininess,light1Color,offset);
	}
}

technique Compressed
{ 
	pass envPass 
	{		
	VertexShader = compile vs_1_1 v(wvp,worldI,light1Pos,viewInvTrans,world);
	ZEnable = true;
	ZWriteEnable = true;
	CullMode = CW;
	AlphaBlendEnable = false; 
	PixelShader = compile ps_2_0 f2(colorTextureSampler,CnormalMapSampler,ambient,surfColor,specularColor,shininess,light1Color,offset);
	}
} 



This code is one I modified but does not work. I get a "unknown modifier" error. Anyone knows what that means? 3run or fogman?

Re: Shader for Rock(ing) [Re: AdrenalinMod] #357747
02/08/11 16:39
02/08/11 16:39
Joined: Nov 2008
Posts: 946
T
the_clown Offline
User
the_clown  Offline
User
T

Joined: Nov 2008
Posts: 946
Oh, no problem, didnt want to argue or something. Was just a bit confused by your posting style. A bit chaotic.
However, if you have a problem with a shader, ask somebody like Hummel or Slin - they are the shader gods here at the forums. grin

Re: Shader for Rock(ing) [Re: the_clown] #357754
02/08/11 16:50
02/08/11 16:50
Joined: Feb 2011
Posts: 44
UK, Aylesbury
A
AdrenalinMod Offline OP
Newbie
AdrenalinMod  Offline OP
Newbie
A

Joined: Feb 2011
Posts: 44
UK, Aylesbury
Maybe this guy does not respond immeadiately without answering?

Re: Shader for Rock(ing) [Re: AdrenalinMod] #357756
02/08/11 16:52
02/08/11 16:52
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
Would you mind to behave less childish?

Re: Shader for Rock(ing) [Re: Slin] #357758
02/08/11 17:00
02/08/11 17:00
Joined: Nov 2002
Posts: 913
Berlin, Germany
S
SchokoKeks Offline
User
SchokoKeks  Offline
User
S

Joined: Nov 2002
Posts: 913
Berlin, Germany
Just be prepared for more people asking "WHAT?" if you tell them you are creating a great MMORPG... Who is going to be the programmer for this game?

Re: Shader for Rock(ing) [Re: SchokoKeks] #357759
02/08/11 17:03
02/08/11 17:03
Joined: Apr 2008
Posts: 650
Sajeth Offline
User
Sajeth  Offline
User

Joined: Apr 2008
Posts: 650
It could be YOU!



Also, what GameStudio Version are you guys using?

Last edited by Sajeth; 02/08/11 17:04.

Teleschrott-Fan.
Re: Shader for Rock(ing) [Re: Sajeth] #357833
02/08/11 21:31
02/08/11 21:31
Joined: Feb 2011
Posts: 44
UK, Aylesbury
A
AdrenalinMod Offline OP
Newbie
AdrenalinMod  Offline OP
Newbie
A

Joined: Feb 2011
Posts: 44
UK, Aylesbury
A8. As noone posts here I will not give you my results but I am disappointed. A bit. At least it's a forum here so we're all brothers in design in principle grin grin

Page 1 of 2 1 2

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1