Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: I cannot see this shader  (Read 606 times)
cristims
Community Member
*
Posts: 116


« on: April 30, 2008, 12:31:00 AM »

I am using a plugin for max to create shaders.
While in 3ds max works just fine, this shader doesn't work in tv3d.

Please help.
Thank you.
Here is the code:


#define DCC_MAX

texture TextureMap_9148 : DiffuseMap
<
   string Name = "D_cobblestones.dds";
   string UIName = "Diffuse Texture";
   string ResourceType = "2D";
>;
 
sampler2D TextureMap_9148Sampler = sampler_state
{
   Texture = <TextureMap_9148>;
   MinFilter = LINEAR;
   MagFilter = LINEAR;
   MipFilter = LINEAR;
};
 


/************** light info **************/

float4 light1Pos : POSITION
<
   string UIName = "Light 1 Position";
   string Object = "PointLight";
   string Space = "World";
   #ifdef DCC_MAX
      int refID = 1;
   #endif
> = {100.0f, 100.0f, 100.0f, 0.0f};

float4 light1Color : LIGHTCOLOR
<
   #ifdef DCC_MAX
      int LightRef = 1;
      string UIWidget = "None";
   #endif
> = { 1.0f, 1.0f, 1.0f, 1.0f};

//----------------------------------
float4x4 wvp : WorldViewProjection < string UIWidget = "None"; >; 
float4x4 worldI : WorldInverse < string UIWidget = "None"; >; 
float4x4 viewInv : ViewInverse < string UIWidget = "None"; >; 
float4x4 world : World < string UIWidget = "None"; >; 

// input from application
   struct a2v {
   float4 position      : POSITION;
   float2 texCoord      : TEXCOORD0;
   float2 texCoord1   : TEXCOORD1;
   float2 texCoord2   : TEXCOORD2;
   float3 vertcol      : TEXCOORD3;
   float vertalpha    : TEXCOORD4;
   float3 tangent      : TANGENT;
   float3 binormal      : BINORMAL;
   float3 normal      : NORMAL;
};

// output to fragment program
struct v2f {
        float4 position          : POSITION;
        float4 color          : COLOR;
        float2 texCoord          : TEXCOORD0;
        float2 texCoord1       : TEXCOORD1;
        float2 texCoord2         : TEXCOORD2;
        float3 eyeVec          : TEXCOORD3;
        float3 lightVec          : TEXCOORD4;
        float3 worldNormal      : TEXCOORD5;
        float3 worldTangent     : TEXCOORD6;
        float3 worldBinormal    : TEXCOORD7;
};

// blinn lighting with lit function
float3 blinn2(float3 N,
      float3 L,
      float3 V,
      uniform float3 diffuseColor,
      uniform float3 specularColor,
      uniform float shininess
      )
   {
   float3 H = normalize(V+L);
   float3 lighting = lit(dot(L,N), dot(H,N), shininess);
   return diffuseColor*lighting.y + specularColor*lighting.z;
   }

//Diffuse and Specular Pass Vertex Shader
v2f v(a2v In, uniform float4 lightPosition)
{
   v2f Out = (v2f)0;
    Out.position = mul(In.position, wvp);            //transform vert position to homogeneous clip space
    //this code was added by the standard material
    float3x3 objTangentXf;                        //build object to tangent space transform matrix
    #ifdef DCC_MAX                              //swap tangent and binormal, but only for 3ds Max
       objTangentXf[0] = In.binormal;
       objTangentXf[1] = -In.tangent;
       objTangentXf[2] = In.normal;
    #else
       objTangentXf[0] = In.tangent;
       objTangentXf[1] = -In.binormal;
       objTangentXf[2] = In.normal;
    #endif
    //this code was added by the standard material
    float4 osLPos = mul(lightPosition, worldI);         //put world space light position in object space
    float3 osLVec = osLPos.xyz - In.position.xyz;      //object space light vector
    Out.lightVec = mul(objTangentXf, osLVec);         //tangent space light vector passed out

    //this code was added by the standard material
    float4 osIPos = mul(viewInv[3], worldI);         //put world space eye position in object space
    float3 osIVec = osIPos.xyz - In.position.xyz;      //object space eye vector
    Out.eyeVec = mul(objTangentXf, osIVec);            //tangent space eye vector passed out


   //this code was added by the texture map Node
    Out.texCoord = In.texCoord;                  //pass through texture coordinates from channel 1

    return Out;
}

//Diffuse and Specular Pass Pixel Shader
float4 f(v2f In, uniform float4 lightColor) : COLOR
{
   float3 ret = float3(0,0,0);
   float3 V = normalize(In.eyeVec);      //creating the eye vector 
   float3 L = normalize(In.lightVec);      //creating the light vector 

   float4 TextureMap_9148 = tex2D(TextureMap_9148Sampler, In.texCoord.xy);
   float3 input2 = TextureMap_9148.rgb;

   float3 diffuseColor = input2;      //using the Diffuse Color socket 
   float specularColor = 0.0;            //the Specular Color and Specular Level sockets were empty
   float glossiness = 20;               //the Glossiness socket was empty - using default value
   float3 N = float3(0.0, 0.0, 1.0);      //the Normal socket was empty - using default value

   //the lighting equation
   ret += lightColor * blinn2(N, L, V, diffuseColor, specularColor, glossiness);
   float4 done = float4(ret, 1);
   return done;
}

technique Complete

   pass light1 
    {      
   VertexShader = compile vs_1_1 v(light1Pos);
   ZEnable = true;
   ZWriteEnable = true;
      CullMode = cw;
   AlphaBlendEnable = false;
   PixelShader = compile ps_2_0 f(light1Color);
   } 

Logged
serial
Customers
Community Member
*****
Posts: 299


« Reply #1 on: April 30, 2008, 12:59:36 AM »

While I'm not a shader expert you need to format the shader for use in TV

I don't think

Quote
texture TextureMap_9148 : DiffuseMap
<
   string Name = "D_cobblestones.dds";
   string UIName = "Diffuse Texture";
   string ResourceType = "2D";
>;

TV knows what to do with stuff like that since that stuff is really for shader editors.

I'm willing to bet if you look under c:\debug.txt   it will tell you exactly why the shader is not loading.

Logged
cristims
Community Member
*
Posts: 116


« Reply #2 on: April 30, 2008, 01:39:24 AM »

so far I get this in the debug file:

......
Mesh 'mesh1' successfully loaded in 0 ms. 960 faces, 559 vertices, 1 groups
04-30-2008 09:38:30 | TEXTURE MANAGER : Loading of 'ShaderFX_hair_texture_sample.tga' successful 'NONAME' on index 4
04-30-2008 09:38:30 | SHADER MANAGER : Shader 'shader1' successfully created.
04-30-2008 09:38:31 | START UNLOAD
04-30-2008 09:38:31 | RESSOURCE MANAGER : Engine successfully unloaded


If that is the problem, how can be solved?
Logged
DanDixon
Customers
Community Member
*****
Posts: 181


« Reply #3 on: April 30, 2008, 03:29:08 AM »

You need to provide more information:

  • What this this shader supposed to do?
  • Have you gotten any shaders to work in your project?

« Last Edit: April 30, 2008, 03:30:53 AM by DanDixon » Logged
cristims
Community Member
*
Posts: 116


« Reply #4 on: April 30, 2008, 08:03:18 AM »

This shader supose to place a texture on the difuse channelof the material and add a linear interpolation for the shadow.

Yes, from the same plugin I use in TV3D a far more complex shader (a hair shader) with good results.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks