Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Ayumi, 7th_zorro, 1 invisible), 1,060 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
normalmap is Shader Model 1.0 #227691
09/15/08 19:04
09/15/08 19:04
Joined: Jun 2007
Posts: 236
acknex.exe
ACKNEX007 Offline OP
Member
ACKNEX007  Offline OP
Member

Joined: Jun 2007
Posts: 236
acknex.exe
is there any way to get this normal mapping fx to work with Shader Model 1.0.

thanks.

/***********************************************************************************************
/ Global Variables:
/***********************************************************************************************/
// Tweakables:
static const float AmbientIntensity = 0.5f; // The intensity of the ambient light.
static const float DiffuseIntensity = 1.0f; // The intensity of the diffuse light.
static const float SpecularIntensity = 1.0f; // The intensity of the specular light.
static const float SpecularPower = 8.0f; // The specular power. Used as 'glossyness' factor.
static const float4 SunColor = {0.9f, 0.9f, 0.5f, 1.0f}; // Color vector of the sunlight.

// Application fed data:
const float4x4 matWorldViewProj; // World*view*projection matrix.
const float4x4 matWorld; // World matrix.
const float4 vecAmbient; // Ambient color.
const float4 vecSunDir; // The sun direction vector.
const float4 vecViewPos; // View position.

float3x3 matTangent;

texture entSkin1; // Color map.
sampler ColorMapSampler = sampler_state // Color map sampler.
{
Texture = <entSkin1>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = Wrap;
Addressv = Wrap;
};

texture entSkin2; // Normal map.
sampler NormalMapSampler = sampler_state // Normal map sampler.
{
Texture = <entSkin2>;
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = Wrap;
Addressv = Wrap;
};


/***********************************************************************************************
/ Vertex Shader:
/***********************************************************************************************/
void NormalMapVS( in float4 InPos : POSITION,
in float3 InNormal : NORMAL,
in float2 InTex : TEXCOORD0,
in float4 InTangent : TEXCOORD2,

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

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

// Compute 3x3 matrix to transform from world space to tangent space:
matTangent[0] = mul(InTangent.xyz, matWorld);
//matTangent[1] = mul(cross(InTangent.xyz,InNormal), matWorld);
matTangent[1] = mul(cross(InTangent.xyz,InNormal)*InTangent.w, matWorld);
matTangent[2] = mul(InNormal, matWorld);

// Calculate the view direction vector in tangent space:
OutViewDir = normalize(mul(matTangent, vecViewPos - mul(InPos, matWorld)));

// Calculate the light direction vector in tangent space:
OutSunDir = normalize(mul(matTangent, -vecSunDir));
}


/***********************************************************************************************
/ Pixel Shader:
/***********************************************************************************************/
float4 NormalMapPS( in float2 InTex : TEXCOORD0,
in float3 InViewDir : TEXCOORD1,
in float3 InSunDir : TEXCOORD2) : COLOR
{
// Read the normal from the normal map and convert from [0..1] to [-1..1] range
float3 BumpNormal = 2 * tex2D(NormalMapSampler, InTex) - 1;

// Calculate the ambient term:
float4 Ambient = AmbientIntensity * vecAmbient;

// Calculate the diffuse term:
float4 Diffuse = DiffuseIntensity * saturate(dot(InSunDir, BumpNormal));
Diffuse *= SunColor;

// Calculate the reflection vector:
float3 R = normalize(2 * dot(BumpNormal, InSunDir) * BumpNormal - InSunDir);

// Calculate the specular term:
InViewDir = normalize(InViewDir);
float Specular = pow(saturate(dot(R, InViewDir)), SpecularPower) * SpecularIntensity;

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

// Calculate final color:
return (Ambient + Diffuse + Specular) * Color;
}

/***********************************************************************************************
/ Technique:
/***********************************************************************************************/
technique SpecularTechnique
{
pass p0
{

CullMode = None;
VertexShader = compile vs_2_0 NormalMapVS();
PixelShader = compile ps_2_0 NormalMapPS();
}
pass p1
{
CULLMODE=CW;
vertexShaderConstant[0]=<matWorldViewProj>;
vertexShaderConstant[16]=0.05; // outline_thickness, def0.001 << CHANGE THIS TO CHANGE OUTLINE THICKNESS

vertexShader=asm
{
vs.1.1
dcl_position v0
dcl_normal v3
dcl_texcoord v7

mov r0,v0
mul r1,c16.x,v3 // Scale the normal
add r0.xyz,r0.xyz,r1.xyz // Shell offset (vertex pos + Scaled Normal)
m4x4 oPos,r0,c0 // Transorm position to clip space
};
pixelShader=asm
{
ps.1.1
def c0,0,0,0,1 // outline rgba << CHANGE THIS TO CHANGE OUTLINE COLOUR
mov r0,c0
};
}
}

Re: normalmap is Shader Model 1.0 [Re: ACKNEX007] #227695
09/15/08 19:11
09/15/08 19:11
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
There is no shadermodel 1.0...

Re: normalmap is Shader Model 1.0 [Re: Slin] #227697
09/15/08 19:15
09/15/08 19:15
Joined: Jun 2007
Posts: 236
acknex.exe
ACKNEX007 Offline OP
Member
ACKNEX007  Offline OP
Member

Joined: Jun 2007
Posts: 236
acknex.exe
its working in my pc & some other pc.
but in my other pc..which has old shader support(maybe 1.0) , its not working.

Re: normalmap is Shader Model 1.0 [Re: ACKNEX007] #227768
09/16/08 02:37
09/16/08 02:37
Joined: Oct 2005
Posts: 4,771
Bay City, MI
lostclimate Offline
Expert
lostclimate  Offline
Expert

Joined: Oct 2005
Posts: 4,771
Bay City, MI
1.4 is the shader model that is the weakest.

Re: normalmap is Shader Model 1.0 [Re: lostclimate] #227788
09/16/08 06:31
09/16/08 06:31
Joined: May 2005
Posts: 2,713
Lübeck
Slin Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
No,shadermodel 1.1 is the smallest supported by the dx version used by gamestudio. That normalmapping shader could may work with 1.4.

Re: normalmap is Shader Model 1.0 [Re: Slin] #227847
09/16/08 12:56
09/16/08 12:56
Joined: Oct 2005
Posts: 4,771
Bay City, MI
lostclimate Offline
Expert
lostclimate  Offline
Expert

Joined: Oct 2005
Posts: 4,771
Bay City, MI
wow 1.1? I never new it was a public version because I have never seen it used... Wierd. Sorry for the mis-information acknex007

Re: normalmap is Shader Model 1.0 [Re: lostclimate] #227863
09/16/08 14:31
09/16/08 14:31
Joined: Jun 2007
Posts: 236
acknex.exe
ACKNEX007 Offline OP
Member
ACKNEX007  Offline OP
Member

Joined: Jun 2007
Posts: 236
acknex.exe
No,shadermodel 1.1 is the smallest supported by the dx version used by gamestudio. That normalmapping shader could may work with 1.4.

can u tell me how to get that working in that 1.4 shader model VGA card ? which modifications need please ?

thanks you

lostclimate : thanks, yes i already checked that in Wikipedia.

Re: normalmap is Shader Model 1.0 [Re: ACKNEX007] #227931
09/16/08 21:15
09/16/08 21:15
Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
frazzle Offline
Expert
frazzle  Offline
Expert

Joined: Mar 2006
Posts: 2,758
Antwerp,Belgium
Try adjusting the normal map approach from Taco Cohen wink wink
Make the VS run on 1.1 but I think for a decent normal map effect, the PS should at least run on 2.0.

Thanks in progress

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

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