Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (TipmyPip, 1 invisible), 18,758 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 3 1 2 3
Re: Converting a "specular" shader [Re: mpdeveloper_B] #117233
03/31/07 04:26
03/31/07 04:26
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Check out the normalmapping shader I wrote in the other thread. Titles something similar to "[matt] normal-mapping shader 3 lights"...

It's a fast normal mapping shader that supports many features such as: 3 Dynamic lights, static lights, Sun light, specular highlights, etc.


xXxGuitar511
- Programmer
Re: Converting a "specular" shader [Re: xXxGuitar511] #117234
04/01/07 13:20
04/01/07 13:20
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
ehhh, the reason i didn't go with normal mapping is because it's more framerate heavy, we may have option shaders such as bloom and stuff, but i wanted a shader that's not too strenuous on an off the shelf pc, and this one isn't


- aka Manslayer101
Re: Converting a "specular" shader [Re: mpdeveloper_B] #117235
04/01/07 22:39
04/01/07 22:39
Joined: Oct 2005
Posts: 4,771
Bay City, MI
lostclimate Offline
Expert
lostclimate  Offline
Expert

Joined: Oct 2005
Posts: 4,771
Bay City, MI
well, you could just have a shader detail bar on your options menu, thats what im going with on the tank game im working on.

Re: Converting a "specular" shader [Re: lostclimate] #117236
04/02/07 14:29
04/02/07 14:29
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
i'll have that too


- aka Manslayer101
Re: Converting a "specular" shader [Re: mpdeveloper_B] #117237
04/17/07 14:21
04/17/07 14:21
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
sry, been sick, i'll try to make a video in the next week or so

Last edited by Manslayer101; 04/17/07 14:22.

- aka Manslayer101
Re: Converting a "specular" shader [Re: mpdeveloper_B] #117238
04/17/07 15:21
04/17/07 15:21
Joined: May 2002
Posts: 2,541
Berlin
EX Citer Offline
Expert
EX Citer  Offline
Expert

Joined: May 2002
Posts: 2,541
Berlin
hope you get better soon


:L
Re: Converting a "specular" shader [Re: EX Citer] #117239
05/15/07 20:36
05/15/07 20:36
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
well, it'll be another week before i can post the video, but i will still post it. the video card will be arriving next week anyway


- aka Manslayer101
Re: Converting a "specular" shader [Re: mpdeveloper_B] #117240
11/24/07 23:35
11/24/07 23:35
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
sorry, i was never able to post a video, if you want to see it though it's implemented in our game, PreVa, here's a video of the game that shows the shader off (on the mechs and some buildings)

Here is the video

to get a better understanding of the shader(s), just apply them to a model, the cubemapping shader is this one: Cube Mapping shader with Alpha as a glossmap

by the way here's the updated code (with the cubemapping shader using alpha as a gloss map):

Code:

float4 SpecularIntensity = {2.0f, 2.0f, 2.0f, 2.0f};

// Application fed data:
float4x4 matWorldViewProj;
float4x4 matWorld;
float4x4 matWorldInv;

float4 vecAmbient;
float4 vecLightPos;
float4 vecLight;
float vecLightColor;
float3 vecViewDir;
float3 vecViewPos;

float4 vecFog;

texture entSkin1;
texture entSkin2;

samplerCUBE CubeMapSampler = sampler_state
{
Texture=<entSkin2>;
};
sampler ColorMapSampler = sampler_state
{
Texture = <entSkin1>;
AddressU = Clamp;
AddressV = Clamp;
};

void SpecularCubeVS(in float4 InPos : POSITION,
in float3 InNormal : NORMAL,
in float2 InTex : TEXCOORD0,

out float4 OutPos : POSITION,
out float2 OutTex : TEXCOORD0,
out float3 OutTexCube : TEXCOORD1,
out float3 OutNormal: TEXCOORD2,
out float3 OutViewDir: TEXCOORD3,
out float Fog_out : FOG)
{
OutPos = mul(InPos, matWorldViewProj);

OutNormal = normalize(mul(InNormal,matWorld));

OutViewDir = mul(InPos, matWorld);

OutTex = InTex;

float3 V = normalize(vecViewDir);
float3 N = normalize(mul(InNormal, matWorld));
OutTexCube = reflect(V,N);

//Fog
Fog_out = 1 - (distance(OutViewDir, vecViewPos) - vecFog.x) * (vecFog.z);
}


float4 SpecularCubePS( in float2 InTex : TEXCOORD0,
in float3 InTexCube : TEXCOORD1,
in float3 InNormal : TEXCOORD2,
in float4 InViewDir : TEXCOORD3) : COLOR
{
InNormal = normalize(InNormal);
float4 Ambient = vecLight;

float4 Diffuse = saturate(dot(vecLightColor, InNormal));

float4 texColor = tex2D(ColorMapSampler, InTex);
float4 cubeColor = texCUBE(CubeMapSampler, InTexCube);
float4 Color = lerp(texColor, cubeColor, 1 - texColor.a);

float3 R = normalize(2 * dot(InNormal, vecLightColor + SpecularIntensity) * InNormal - SpecularIntensity);

InViewDir = vecLightColor + SpecularIntensity *vecLight;

float Specular = saturate(dot(R, InViewDir));
return (Ambient + Diffuse + Specular) * Color;
}

technique SpecularCubeTechnique
{
pass P0
{
AlphaBlendEnable = False;
ZWriteEnable = True;
VertexShader = compile vs_2_0 SpecularCubeVS();
PixelShader = compile ps_2_0 SpecularCubePS();
}
}



here's the one without the cube mapping:

Code:

float4 SpecularIntensity = {2.0f, 2.0f, 2.0f, 2.0f};

// Application fed data:
float4x4 matWorldViewProj;
float4x4 matWorld;
float4x4 matWorldInv;

float4 vecAmbient;
float4 vecLightPos;
float4 vecLight;
float vecLightColor;
float3 vecViewDir;
float3 vecViewPos;

float4 vecFog;

texture entSkin1;

sampler ColorMapSampler = sampler_state
{
Texture = <entSkin1>;
AddressU = Clamp;
AddressV = Clamp;
};

void SpecularCubeVS(in float4 InPos : POSITION,
in float3 InNormal : NORMAL,
in float2 InTex : TEXCOORD0,

out float4 OutPos : POSITION,
out float2 OutTex : TEXCOORD0,
out float3 OutNormal: TEXCOORD2,
out float3 OutViewDir: TEXCOORD3,
out float Fog_out : FOG)
{
OutPos = mul(InPos, matWorldViewProj);

OutNormal = normalize(mul(InNormal,matWorld));

OutViewDir = mul(InPos, matWorld);

OutTex = InTex;

float3 V = normalize(vecViewDir);
float3 N = normalize(mul(InNormal, matWorld));

//Fog
Fog_out = 1 - (distance(OutViewDir, vecViewPos) - vecFog.x) * (vecFog.z);
}


float4 SpecularCubePS( in float2 InTex : TEXCOORD0,
in float3 InTexCube : TEXCOORD1,
in float3 InNormal : TEXCOORD2,
in float4 InViewDir : TEXCOORD3) : COLOR
{
InNormal = normalize(InNormal);
float4 Ambient = vecLight;

float4 Diffuse = saturate(dot(vecLightColor, InNormal));

float4 Color = tex2D(ColorMapSampler, InTex);

float3 R = normalize(2 * dot(InNormal, vecLightColor + SpecularIntensity) * InNormal - SpecularIntensity);

InViewDir = vecLightColor + SpecularIntensity *vecLight;

float Specular = saturate(dot(R, InViewDir));
return (Ambient + Diffuse + Specular) * Color;
}

technique SpecularTechnique
{
pass P0
{
VertexShader = compile vs_2_0 SpecularCubeVS();
PixelShader = compile ps_2_0 SpecularCubePS();
}
}



i regret that i never got it working with dynamic lights as i wanted...


- aka Manslayer101
Page 3 of 3 1 2 3

Moderated by  Blink, Hummel, Superku 

Gamestudio download | 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