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
3 registered members (AndrewAMD, Ayumi, NewbieZorro), 13,972 guests, and 6 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 2 of 3 1 2 3
Re: Converting a "specular" shader [Re: mpdeveloper_B] #117223
03/15/07 20:21
03/15/07 20:21
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
a quick question, what is the equation for vecSunDir, would it be something like:

vecSunDir = normalize (vecSunPos *vecViewPos);

am i wrong or is this right?


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

Joined: May 2002
Posts: 2,541
Berlin
sounds interesting. Looking forward to some visual materials.


:L
Re: Converting a "specular" shader [Re: EX Citer] #117225
03/19/07 18:49
03/19/07 18:49
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
well, i've decided that what i have is sufficient for what i need for an anime style game, i'll post the code and a demo as soon as i can


- aka Manslayer101
Re: Converting a "specular" shader [Re: mpdeveloper_B] #117226
03/21/07 14:22
03/21/07 14:22
Joined: Nov 2006
Posts: 70
UK!
erbismi Offline
Junior Member
erbismi  Offline
Junior Member

Joined: Nov 2006
Posts: 70
UK!
I've trid the original shader in my fps project, and it seems to add a green tint to nything it is applied to, just wondering if this is the same for anyone else.


-www.llamastormgames.page.tl
Re: Converting a "specular" shader [Re: erbismi] #117227
03/25/07 03:32
03/25/07 03:32
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
sorry that it's taken longer than i thought, i am still getting over being sick, but i'll post it sometime this week when i'm at work


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

Joined: Feb 2006
Posts: 2,185
for anyone who was interested, here's the finished code:

Code:

/*

Code Created by Taco Cohen, and modified my Manga Page

*/

/***********************************************************************************************
/ Global Variables:
/***********************************************************************************************/
// Tweakables:
float4 SpecularIntensity = {2.0f, 2.0f, 2.0f, 2.0f}; // The intensity of the specular light.

// Application fed data:
float4x4 matWorldViewProj; // World view projection matrix.
float4x4 matWorld; // World matrix.
float4x4 matWorldInv;
float4 vecAmbient; // Ambient color.
float4 vecLightPos;
float4 vecLight;
float vecLightColor;

texture entSkin1; // Color map.
sampler ColorMapSampler = sampler_state // Color map sampler.
{
Texture = <entSkin1>;
AddressU = Clamp;
AddressV = Clamp;
};

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

out float4 OutPos : POSITION,
out float2 OutTex : TEXCOORD0,
out float3 OutNormal: TEXCOORD1,
out float3 OutViewDir: TEXCOORD2)
{
// Transform the vertex from object space to clip space:
OutPos = mul(InPos, matWorldViewProj);

// Transform the normal from object space to world space:
OutNormal = normalize(mul(InNormal,matWorldInv));

// Calculate a vector from the vertex to the view:
OutViewDir = vecLightPos - mul(InPos, matWorld);

// Pass the texture coordinate to the pixel shader:
OutTex = InTex;
}


/***********************************************************************************************
/ Pixel Shader:
/***********************************************************************************************/
float4 SpecularPS( in float2 InTex : TEXCOORD0,
in float3 InNormal : TEXCOORD1,
in float4 InViewDir : TEXCOORD2) : COLOR
{
//SpecularIntensity += vecLightColor;
InNormal = normalize(InNormal);
// Calculate the ambient term:
float4 Ambient = vecLight;

// Calculate the diffuse term:
float4 Diffuse = saturate(dot(vecLightColor, InNormal));

// Fetch the pixel color from the color map:
float4 Color = tex2D(ColorMapSampler, InTex);

// Calculate the reflection vector:
float3 R = normalize(2 * dot(InNormal, vecLightColor + SpecularIntensity) * InNormal - SpecularIntensity);

// Calculate the speculate component:
InViewDir = vecLightColor + SpecularIntensity *vecLight;

float Specular = saturate(dot(R, InViewDir));
// Calculate final color:
return (Ambient + Diffuse + Specular) * Color;
}

/***********************************************************************************************
/ Technique:
/***********************************************************************************************/
technique SpecularTechnique
{
pass P0
{
VertexShader = compile vs_2_0 SpecularVS();
PixelShader = compile ps_2_0 SpecularPS();
}
}




- aka Manslayer101
Re: Converting a "specular" shader [Re: mpdeveloper_B] #117229
03/27/07 06:49
03/27/07 06:49
Joined: May 2002
Posts: 2,541
Berlin
EX Citer Offline
Expert
EX Citer  Offline
Expert

Joined: May 2002
Posts: 2,541
Berlin
Can you upload a before and after screenshot? THat would be interesting.


:L
Re: Converting a "specular" shader [Re: EX Citer] #117230
03/27/07 16:07
03/27/07 16:07
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
ok, here's a few from one of PreVa's mecha:

Before:



After:



The lights move across the normals depending on the light and the model's rotation


- aka Manslayer101
Re: Converting a "specular" shader [Re: mpdeveloper_B] #117231
03/27/07 16:18
03/27/07 16:18
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
frazzle Offline
Expert
frazzle  Offline
Expert

Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
Looks quite interesting, maybe a video tells/shows more

Cheers

Frazzle


Antec® Case
Intel® X58 Chipset
Intel® i7 975 Quad Core
8 GB RAM DDR3
SSD OCZ®-VERTEX2 3.5 x4 ; HD 600 GB
NVIDIA® GeForce GTX 295 Memory 1795GB
Re: Converting a "specular" shader [Re: frazzle] #117232
03/30/07 21:36
03/30/07 21:36
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline OP
Expert
mpdeveloper_B  Offline OP
Expert

Joined: Feb 2006
Posts: 2,185
if i can get one for you soon i will, as soon as i get my new pc up and running i can make you a video


- aka Manslayer101
Page 2 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