|
Re: Shade-C v0.91 BETA S1 RELEASED
[Re: Widi]
#319117
04/12/10 13:21
04/12/10 13:21
|
Joined: Nov 2007
Posts: 318 Brasil, Paraná
NeoNeper
Senior Member
|
Senior Member
Joined: Nov 2007
Posts: 318
Brasil, Paraná
|
Ohhhhhhh much much tankx havoc.. you is my IDOL m(^.^)m I am waiting Anxious for the update. thanks a lot havoc. Without you 3dgs would not be the same (^.^)
Please! Use easy words to be translated. because my English is not very good! Grateful. _______________________________________________________
|
|
|
Re: Shade-C v0.91 BETA S1 RELEASED
[Re: NeoNeper]
#319278
04/13/10 18:25
04/13/10 18:25
|
Joined: Dec 2009
Posts: 217 Italy
PietroNifosi
Member
|
Member
Joined: Dec 2009
Posts: 217
Italy
|
The fact that I have the opportunity of inputing a shadowmap on a second uv set solved all the problems with rendering speed and really does make the difference! Which is something that gamestudio's shadows can't do. The cool part is that it's a bitmap so i can draw whatever I like in it and in my case I do ambient occlusion, shadowmap, and lightmap all in one! Click to enlarge: http://www.themasquerade-guild.com/shadec.jpg
Last edited by PietroNifosi; 04/13/10 18:26.
|
|
|
Re: Shade-C v0.91 BETA S1 RELEASED
[Re: Fab4]
#319281
04/13/10 18:40
04/13/10 18:40
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Fab4, have you still got that problem with the seamless textures still?
Is your texture a "power of 8" in width and height? (Because the image youve posted isnt)
AFAIK, all textures need to be a power-of-eight in dimension for direct-x to handle them properly. eg sizes: 8x8, 16x64, 256x1024, 512x512. Them sort of numbers...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Shade-C v0.91 BETA S1 RELEASED
[Re: EvilSOB]
#319284
04/13/10 19:23
04/13/10 19:23
|
Joined: Nov 2007
Posts: 318 Brasil, Paraná
NeoNeper
Senior Member
|
Senior Member
Joined: Nov 2007
Posts: 318
Brasil, Paraná
|
How I make my dynamic light to influence my terrain:? see my image post. The light reaches the constructon model and the welded models however do not influence terrain. why???
Last edited by NeoNeper; 04/13/10 19:24.
Please! Use easy words to be translated. because my English is not very good! Grateful. _______________________________________________________
|
|
|
Re: Shade-C v0.91 BETA S1 RELEASED
[Re: PietroNifosi]
#319293
04/13/10 20:55
04/13/10 20:55
|
Joined: Jun 2004
Posts: 655 to your left
BoH_Havoc
OP
User
|
OP
User
Joined: Jun 2004
Posts: 655
to your left
|
PietroNifosi: Nice pics! Do you have any pics with shadows on the terrain, too? Also chances are high you won't need static shadowmaps anymore with the upcoming version... NeoNeper: Try this shader instead (will also automatically use the A7 shadowmap if it's a .hmp with shadows compiled in WED):
/*
Terrain-Shader by Wolfgang "BoH_Havoc" Reichardt
Automatically uses A7 lightmap if its a .hmp file instead of a .mdl
Entity Textures:
Skin1 = Global Colormap
Skin2 = Tile-Colormask (RGB) + Shadow (A)
Skin3 = Global Normalmap
Skin4 = Tile-Normalmap (RGB) + Specularmap (A) (Quad-Texture)
Material Textures:
Skin1 = Tile-Color (Quad-Texture @ DDS)
Usage:
*/
/***************************************TWEAKABLES*****************************************************/
float bumpStr = 2; //bump strength
float numTiles = 60; // number of tiles
float shadowAlpha = 0.5; //shadowalpha of bumpmapping
float texShadowAlpha = 0.25; //shadowalpha of shadowtexture
float velvStr = 0.4; //velvety strength
float specStr = 1.0; //specular Strength
float4 specPower = 10; //specular Sharpness, higher value = sharper specular lighting
//active dynamic shadows (shadowType = 0)
//#define DYNSHADOW
//activate velvety backlight
#define VELVETY
/***************************************SHADER*CODE****************************************************/
texture entSkin1; //colormap
texture entSkin2; //global normalmap + Shadow
texture entSkin3; //colormask
texture entSkin4; //normalmaps
texture mtlSkin1; //colormaps
texture LightMap; //lightmap passed by engine
matrix matWorld;
matrix matWorldInv;
matrix matViewInv;
matrix matWorldViewProj;
float4x4 matEffect1;
float4x4 matEffect2;
float4x4 matEffect3;
float4 vecSunDir;
float4 vecSunColor;
float4 vecLightPos[8];
float4 vecLightColor[8];
float4 vecViewPos;
float4 vecAmbient;
float fAmbient;
//do sunlight
#define DOSUN
sampler colorSampler = sampler_state
{
Texture = <entSkin1>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
sampler maskSampler = sampler_state
{
Texture = <entSkin2>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
sampler globalNormSampler = sampler_state
{
Texture = <entSkin3>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
sampler normSampler = sampler_state
{
Texture = <entSkin4>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
sampler tileColorSampler = sampler_state
{
Texture = <mtlSkin1>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
sampler2D lightmapSampler = sampler_state
{
Texture = <LightMap>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = WRAP;
AddressV = WRAP;
};
#ifdef DYNSHADOW
// ShadowDepth map sampler
texture sc_map_shadowDepthSun_bmap;
sampler ShadowMapSampler = sampler_state
{
Texture = <sc_map_shadowDepthSun_bmap>;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = CLAMP;
AddressV = CLAMP;
};
Texture sc_map_shadowAlpha_bmap;
sampler ShadowAlphaSampler = sampler_state
{
texture = <sc_map_shadowAlpha_bmap>;
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter=LINEAR;
AddressU = clamp;
AddressV = clamp;
};
#endif
///////////////////////HELPER FUNCTIONS///////////////////////////////////////
// calculate the light attenuation factor
float DoLightFactor(float4 Light,float3 Pos)
{
float fac = 0.f;
if (Light.w > 0.f) {
float LD = length(Light.xyz-Pos)/Light.w;
if (LD < 1.f)
fac = saturate(1.f - LD);
}
return fac; // get the distance factor
}
// calculate the light attenuation factor on the front side
float DoLightFactor(float4 Light,float3 P,float3 N)
{
float3 D = Light.xyz-P; // ray pointing from the light to the surface
float NdotL = dot(N,normalize(D)); // angle between surface and light ray
if (NdotL >= 0.f)
return saturate(NdotL*8)*DoLightFactor(Light,P);
else
return 0.f;
}
float DoLightFactorN(float4 Light,float3 P,float3 N)
{
float3 D = Light.xyz-P; // ray pointing from the light to the surface
float NdotL = dot(N,normalize(D)); // angle between surface and light ray
if (NdotL >= 0.f)
return 2 * NdotL * DoLightFactor(Light,P);
else
return 0.f;
}
float4 DoPointLight(float3 P, float3 N, float4 Light, float4 LightColor)
{
return LightColor * DoLightFactorN(Light,P,N);
}
float4 DoLight(float3 P, float3 N, int i)
{
if(vecLightPos[i].w < 100000) return DoPointLight(P,N,vecLightPos[i],vecLightColor[i]);
else return 0;
}
float4 doLighting(float3 P, float3 N, int i)
{
if(vecLightPos[i].w < 100000)
{
float4 lighting = 1;
lighting.xyz = clamp(1-distance(vecLightPos[i].xyz,P)/vecLightPos[i].w,0,1);
lighting.xyz *= dot(N,normalize(vecLightPos[i]-P))*vecLightColor[i].xyz;
return lighting;
}
else
{
return 0;
}
}
float light_vsm_epsilon = 0.00003;
float light_shadow_bias = 0.0025;
float doVSM(float2 depthmap, float lightDepth)
{
//depthmap.y = (depthmap.x * depthmap.x);
float lit_factor = (lightDepth <= depthmap.x);
// Variance shadow mapping
float E_x2 = depthmap.y;
float Ex_2 = depthmap.x * depthmap.x;
float variance = min(max(E_x2 - Ex_2, 0.0) + light_vsm_epsilon, 1.0);
float m_d = (depthmap.x - lightDepth);
float p = variance / (variance + m_d * m_d);
// Adjust the light color based on the shadow attenuation
return 1-max(lit_factor, p);
}
void terrain_VS(
in float4 InPos: POSITION,
in float3 InNormal: NORMAL,
in float2 InTex: TEXCOORD0,
in float3 InTangent : TEXCOORD0,
out float4 OutPos: POSITION,
out float4 OutColor : COLOR0,
out float2 OutTex: TEXCOORD0,
out float4 OutLight: TEXCOORD1,
out float3 OutViewDir: TEXCOORD2,
out float3 OutWorldNormal : TEXCOORD3,
out float3 OutWorldTangent : TEXCOORD4,
out float3 OutWorldBinorm : TEXCOORD5,
#ifdef DYNSHADOW
out float3 OutWorldPos : TEXCOORD6,
out float4 OutShadow : TEXCOORD7
#else
out float3 OutWorldPos : TEXCOORD6
#endif
)
{
// Transform the vertex from object space to clip space:
OutPos = mul(InPos, matWorldViewProj);
// Pass the texture coordinate to the pixel shader:
OutTex.xy = InTex.xy;
float3 PosWorld = mul(InPos, matWorld);
//Light
#ifdef DOSUN
OutLight.xyz = -vecSunDir.xyz;//vecSunPos - PosWorld;;
OutLight.w = 100000;//distance(PosWorld,vecLightPos[0])/vecLightPos[0].w;
#else
OutLight.xyz = vecLightPos[0] - PosWorld;
OutLight.w = 0;
if(vecLightPos[0].w < 100000) OutLight.w = 1-distance(PosWorld,vecLightPos[0])/vecLightPos[0].w;
#endif
//
//Specular Lighting
OutViewDir = matViewInv[3].xyz - PosWorld;
//
//Misc Output
float3 Binormal = cross(InNormal,InTangent);
OutWorldNormal.xyz = mul(InNormal, matWorld).xyz;
OutWorldTangent.xyz = mul(InTangent, matWorld).xyz;
OutWorldBinorm.xyz = mul(Binormal, matWorldInv).xyz;
OutWorldPos = PosWorld;
//
#ifdef DYNSHADOW
//Shadowmapping
float4 ShadowMapSamplingPos = mul(mul(InPos,matWorld), mul(matEffect3,matEffect1));
float4 RealDistance = mul(mul(InPos,matWorld), matEffect3).z/matEffect2[0].w;
OutShadow.x = ShadowMapSamplingPos.x;
OutShadow.y = ShadowMapSamplingPos.y;
OutShadow.z = ShadowMapSamplingPos.w;
OutShadow.w = RealDistance.x;
//
#endif
OutColor = fAmbient; // Add ambient and sun light
#ifdef DOSUN
for (int i=0; i<8; i++) // Add 8 dynamic lights
OutColor += DoLight(PosWorld,OutWorldNormal.xyz,i);
#else
for (int i=1; i<8; i++) // Add 7 dynamic lights
OutColor += DoLight(PosWorld,OutWorldNormal.xyz,i);
#endif
}
float4 terrain_PS(
uniform int inLM,
in float4 InColor : COLOR0,
float2 Tex : TEXCOORD0,
float4 InLight: TEXCOORD1,
float3 InViewDir: TEXCOORD2,
float3 InWorldNormal : TEXCOORD3,
float3 InWorldTangent : TEXCOORD4,
float3 InWorldBinorm : TEXCOORD5,
float3 InWorldPos : TEXCOORD6,
in float4 InShadow : TEXCOORD7
):COLOR0
{
float4 Color = tex2D(colorSampler, Tex.xy);
float4 colorMask = tex2D(maskSampler, Tex.xy);
float2 Tile = Tex.xy*numTiles;
Tile = frac(Tile)*(0.5-2*0.004)+0.004;
float4 color = tex2D(colorSampler, Tex.xy);
float4 color1 = tex2D(tileColorSampler, Tile)*colorMask.r;
float4 color2 = tex2D(tileColorSampler, Tile+float2(0.5, 0.0))*colorMask.g;
float4 color3 = tex2D(tileColorSampler, Tile+float2(0.0, 0.5))*colorMask.b;
float4 normal1 = tex2D(normSampler, Tile)*colorMask.r;
float4 normal2 = tex2D(normSampler, Tile+float2(0.5, 0.0))*colorMask.g;
float4 normal3 = tex2D(normSampler, Tile+float2(0.0, 0.5))*colorMask.b;
float3 Ln = normalize(InLight.xyz);
float3 Nn = normalize(InWorldNormal);
float3 Tn = normalize(InWorldTangent);
float3 Bn = normalize(InWorldBinorm);
float3 Nb = 0;
float3 Vn = 0;
float3 Hn = 0;
float4 lighting = 0;
float gloss = normal1.a + normal2.a + normal3.a;
float3 bumpNormal = ((normal1.rgb+normal2.rgb+normal3.rgb));
//bumpNormal += tex2D(globalNormSampler, Tex).xyz;
bumpNormal = lerp(bumpNormal, (tex2D(globalNormSampler, Tex.xy).xyz), 0.5);
bumpNormal = (bumpNormal-(0.5).xxx)*bumpStr;
//bumpNormal *= 2;
Nb = Nn + (bumpNormal.x * Tn + bumpNormal.y * Bn);
Nb = normalize(Nb);
Vn = normalize(InViewDir);
Hn = normalize(Vn + Ln);
lighting = lit(dot(Ln,Nb),dot(Hn,Nb),10);
#ifdef DYNSHADOW
float2 ProjectedTexCoords;
ProjectedTexCoords[0] = InShadow.x/InShadow.z/2.0f +0.5f;
ProjectedTexCoords[1] = -InShadow.y/InShadow.z/2.0f +0.5f;
float blurStr = matEffect2[1].x;
float shadowDepth = tex2D(ShadowMapSampler, ProjectedTexCoords).x;
float shadow1 = doVSM(float2(shadowDepth,shadowDepth*shadowDepth),InShadow.w);
shadow1 = (1-shadow1);
shadow1 *=(1-tex2D(ShadowAlphaSampler, ProjectedTexCoords));
shadow1 += tex2D(ShadowAlphaSampler, ProjectedTexCoords);
//shadow1 *= lighting.y;
shadow1 = clamp(shadow1,0,1);
#else
float shadow1 = 1;
#endif
lighting.y *= shadow1;
#ifdef VELVETY
float velvety1 = clamp(velvStr-dot(Vn,Nb),0,1);
#else
float velvety1 = 0;
#endif
Color.rgb = saturate(clamp(lighting.y, shadowAlpha, 1)*vecSunColor*2)+(InColor.rgb);
Color.rgb *= lerp(color, (color1+color2+color3), 0.5);
Color.rgb += (lighting.z+velvety1)*specStr*gloss*Color.rgb;
Color.rgb = clamp(Color.rgb, 0, 1);
//Color.rgb *= clamp(colorMask.a,texShadowAlpha,1);
if(inLM == 0) Color.rgb *= clamp(colorMask.a,texShadowAlpha,1);
else Color.rgb *= tex2D(lightmapSampler,Tex.xy).rgb;
Color.a = 1;
return float4(Color.rgb,1);
}
technique terrain
{
pass p0
{
//cullmode = none;
//zwriteenable = true;
//alphablendenable = true;
VertexShader = compile vs_2_0 terrain_VS();
PixelShader = compile ps_2_a terrain_PS(int(0));
}
}
technique terrain_lm
{
pass p0
{
//cullmode = none;
//zwriteenable = true;
//alphablendenable = true;
VertexShader = compile vs_2_0 terrain_VS();
PixelShader = compile ps_2_a terrain_PS(int(1));
}
}
|
|
|
Re: Shade-C v0.91 BETA S1 RELEASED
[Re: BoH_Havoc]
#319295
04/13/10 21:24
04/13/10 21:24
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
Serious User
|
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
PietroNifosi: Also chances are high you won't need static shadowmaps anymore with the upcoming version... You mean you have nice looking shadows o.O. CANT WAIT now, you shouldnt have mentioned this...now i am unpatient XD. Keep on the good work, iam a 100% shader noob and need those things^^ Greets Rackscha
MY Website with news of my projects: (for example my current Muliplayer Bomberman, GenesisPrecompiler for LiteC and TileMaster, an easy to use Tile editor) Sparetime-Development
|
|
|
Re: Shade-C v0.91 BETA S1 RELEASED
[Re: Rackscha]
#319304
04/13/10 22:39
04/13/10 22:39
|
Joined: Dec 2009
Posts: 217 Italy
PietroNifosi
Member
|
Member
Joined: Dec 2009
Posts: 217
Italy
|
BoH_Havoc: I'm still modeling architectures, I'm gonna need a few more of those before assembling a city/town. The idea is to have the scenario on 3dsmax, do a render to texture from there once again and print the shadowmap for the terrain as well. I'm glad you like my pictures. If you want I can show you more of what I've done with shade-c and my models so far, you can reach me at MSN pietronifosi@libero.it
Rackscha: Those shadows have been rendered to texture with mental ray.
Last edited by PietroNifosi; 04/13/10 22:42.
|
|
|
Shade-C EVO Radiosity
[Re: PietroNifosi]
#319319
04/14/10 02:12
04/14/10 02:12
|
Joined: Jun 2004
Posts: 655 to your left
BoH_Havoc
OP
User
|
OP
User
Joined: Jun 2004
Posts: 655
to your left
|
Rackscha: Well yes, dynamic shadowmapping from the sun is implemented (and has been optimized a lot since the last release). But i'm more thinking about interactive radiosity... Notice the soft selfshadows and caustics Currently it's for static geometry "only". So an actor moving about terrain/ground won't be affected. But for everything else this is kinda neat and makes dynamic relighting of the scene a piece of cake. Oh i so can't wait to see what you guys will do with this once it's released Hope you like it!
|
|
|
|