Level Block shader

Posted By: DLively

Level Block shader - 08/15/14 03:07

Hi, I am in need of a shader that works with BLOCKS and MAP ENTS, thus to keep the color for both the world and the ents the same.

If I say ents, I mean MAP ENTS. But my entities use the same shader as the MAP ENTS right now..

More indepth:
When I compile the blocks, they render in different colors due to the sunlights position (90 Degrees on top) and the ents are slightly darker (actually a lot darker) than the world blocks. I require them to be all the same brightness / color. If I apply a basic shader to blocks it just smudges them and the texture is not present.

Here is the shader.fx I use (Thank you Superku) It worked fine if my level blocks were a solid color - But that didn't look good enough, so I added a texture to them and got the explained result above.

Can some shader expert make this shader work with Blocks, display the texture and behave the same as if it were attached to an entity. (Either in the same shader, or two different ones) But it must work with blocks and ents. This would be really appreciated laugh

Code:
float4x4 matWorldViewProj;
float4x4 matWorld;
float4 vecAmbient;
float4 vecSunDir;

texture entSkin1;

sampler ColorMapSampler = sampler_state 
{ 
   Texture = <entSkin1>; 
   AddressU  = Clamp; 
   AddressV  = Clamp; 
}; 
    
void DiffuseVS( 
   in float4 InPos: POSITION, 
   in float3 InNormal: NORMAL, 
   in float2 InTex: TEXCOORD0, 
   out float4 OutPos: POSITION, 
   out float2 OutTex: TEXCOORD0, 
   out float3 OutNormal: TEXCOORD1) 
{ 
   OutPos = mul(InPos, matWorldViewProj); 
   OutNormal = normalize(mul(InNormal, matWorld));
   OutTex = InTex; 
} 
    
float4 DiffusePS( 
   in float2 InTex: TEXCOORD0, 
   in float3 InNormal: TEXCOORD1): COLOR 
{ 
   float4 Color = tex2D(ColorMapSampler, InTex); 
   float Diffuse = 0.5+0.5*saturate(dot(-vecSunDir, normalize(InNormal))); 
   float4 final = Color*Diffuse;
   
   return final;
} 
 
technique DiffuseTechnique 
{ 
   pass P0 
   { 
      VertexShader = compile vs_3_0 DiffuseVS(); 
      PixelShader  = compile ps_3_0 DiffusePS(); 
   } 
}



Thank you Much Much laugh
Posted By: txesmi

Re: Level Block shader - 08/15/14 09:58

Hi,
Code:
AddressU = Wrap;
AddressV = Wrap;


I think this should solve the presence of the textures.
Posted By: DLively

Re: Level Block shader - 08/15/14 14:19

Thank you lots lots Txesmi laugh That solved it! And, Really? I spent hours looking into this... and thats all it took? *Face Palm*

Thanks again friend laugh
Posted By: txesmi

Re: Level Block shader - 08/15/14 19:12

Glad to help laugh
© 2024 lite-C Forums