2 registered members (TipmyPip, 1 invisible),
18,789
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Shader for Rock(ing)
#357738
02/08/11 16:16
02/08/11 16:16
|
Joined: Feb 2011
Posts: 44 UK, Aylesbury
AdrenalinMod
OP
Newbie
|
OP
Newbie
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: the_clown]
#357746
02/08/11 16:35
02/08/11 16:35
|
Joined: Feb 2011
Posts: 44 UK, Aylesbury
AdrenalinMod
OP
Newbie
|
OP
Newbie
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.
struct a2v {
half4 position : POSITION;
half2 texCoord : TEXCOORD0;
half3 tangent : TANGENT;
half3 binormal : BINORMAL;
half3 normal : NORMAL;
};
struct v2f {
half4 position : POSITION;
half2 texCoord : TEXCOORD0;
float3 eyeVec : TEXCOORD1;
half3 lightVec : TEXCOORD2;
};
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;
}
v2f v(a2v In,
uniform half4x4 worldViewProj, uniform half4x4 WorldIMatrix, uniform half4 lightPosition,
uniform half4x4 ViewInvTrans,
uniform half4x4 world )
{
v2f Out;
Out.position = mul(In.position, worldViewProj);
Out.texCoord = In.texCoord;
half3x3 objTangentXf;
objTangentXf[0] = In.binormal.xyz;
objTangentXf[1] = -In.tangent.xyz;
objTangentXf[2] = In.normal.xyz;
half4 objSpaceLightPos = mul(lightPosition, WorldIMatrix);
half3 objLightVec = objSpaceLightPos.xyz - In.position.xyz;
Out.lightVec = mul(objTangentXf, objLightVec );
half4 objSpaceEyePos = mul(ViewInvTrans[3], WorldIMatrix);
half3 objEyeVec = objSpaceEyePos.xyz - In.position.xyz;
Out.eyeVec = mul(objTangentXf, objEyeVec);
return Out;
}
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
{
half3 V = normalize(In.eyeVec);
half3 L = normalize(In.lightVec);
half2 newV = V.xy;
newV.y = -newV.y;
half height = tex2D(bumpTex, In.texCoord.xy).a;
half2 offset = newV * (height * 2.0 - 1.0) * offsetBias;
half2 newTexCoord = In.texCoord.xy + offset;
half4 colorMap = tex2D(colorTex, newTexCoord);
half3 normal = tex2D(bumpTex, newTexCoord).xyz * 2.0 - 1.0;
half3 N = normal;
half4 C = ambient*colorMap;
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
{
half3 V = normalize(In.eyeVec);
half3 L = normalize(In.lightVec);
half2 newV = V.xy;
newV.y = -newV.y;
half height = tex2D(bumpTex, In.texCoord.xy).r;
half2 offset = newV * (height * 2.0 - 1.0) * offsetBias;
half2 newTexCoord = In.texCoord.xy + offset;
half4 colorMap = tex2D(colorTex, newTexCoord);
half3 normal = tex2D(bumpTex, newTexCoord).wyz * 2.0 - 1.0;
normal.z = sqrt(1 - normal.x * normal.x - normal.y * normal.y);
half3 N = normal;
half4 C = ambient*colorMap;
C += light1Color * blinn2(N, L, V, colorMap*diffuseColor, specularColor*colorMap.a, shininess);
return C;
}
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;
};
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: SchokoKeks]
#357759
02/08/11 17:03
02/08/11 17:03
|
Joined: Apr 2008
Posts: 650
Sajeth
User
|
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.
|
|
|
|