Shader profile and accessing normal map

Hello.

How to set Cg shader profile used when shader is being compiled? I’ve tried search - in one posts it is written that to set profile there is need to put these strings in the beginning of shader file -

//Cg profile vs_2_x fs_2_x

But in other threads it is written that it does not work and there is need to write so -

BumpMappingShaderTerrain      =  Shader.load ( "Resources\Shaders\\bumpMapper_Terrain.sha", "vs_2_x", "ps_2_x" )

but when I’m trying to run program it writes -

Traceback (most recent call last):
  File "panda_3d.py", line 46, in <module>
    BumpMappingShaderTerrain      =  Shader.load ( "Resources\Shaders\\bumpMapper_Terrain.sha", "vs_2_x", "ps_2_x" )
TypeError: an integer is required

The second question - I’ve specified normal map in egg file -

<Texture> tref1 {
  Resources\Models\Terrain\layingrock_2.dds
  <Scalar> minfilter { linear_mipmap_linear } 
  <Scalar> magfilter { linear }
}
<Texture> tref2 {
  Resources\Models\Terrain\layingrock_2_nh.dds
  <Scalar> format { rgba }
  <Scalar> minfilter { linear_mipmap_linear }
  <Scalar> magfilter { linear }
  <Scalar> envtype { normal }
}

how now access it in the shader?

And another one question - if I create mip maps in, for example, AMD Compressonator and save them in dds file - will Panda use them or it will recreate its own mip maps?

As for the first question, the way to do it is via the shader. The special Shader.load syntax where you can specify a profile no longer exists.
Note that you also need to place “basics-shaders-only #f” in Config.prc.

You mean
//Cg profile vs_2_x fs_2_x ?

Ok, I’ve done it already.

Oh, and another one question - is there ability to somehow specify to cgc.exe parameters -

-nofastmath -nofastprecision -bestprecision

with Panda?

So - nobody know how Panda works?

How at all can I pass normal map to shader? If I’m trying to do so -

texture g_nmhTexture;               // Normal map and height map texture pair

sampler tNormalHeightMap = 
sampler_state
{
    Texture = < g_nmhTexture >;
    MipFilter = LINEAR;
    MinFilter = PYRAMIDALQUAD; //-ANISOTROPIC, PYRAMIDALQUAD and GAUSSIANQUAD
    MagFilter = PYRAMIDALQUAD;
};

//In pixel shader
float4 NHMap               =  tex2D ( tNormalHeightMap, l_texcoord0 );
float4 texColor            =  tex2D ( tex_0, l_texcoord0 );
//...
o_color                    =  texColor;

And in script -

nm                           =  loader.loadTexture ( "Resources\Models\Terrain\layingrock_nh.dds" )
nm.setMinfilter ( Texture.FTLinearMipmapLinear )
nmts                         =  TextureStage ( "tex_1" )
environ.setTexture  ( nmts, nm )

#...

environ.setShaderInput ( "g_nmhTexture", nm )

It simply replaces default models texture.

Also when I’m trying to access tangents or binormals in shaders Panda simply freezes - stops responding on mouse and keyboard. It writes -

:display:gsg:dxgsg9(error): could not find matching vertex element data for vertex shader
:display:gsg:dxgsg9(error): unable to find a mapping for vertex shader input type=9 from vertex elements
:display:gsg:dxgsg9(error): could not find matching vertex element data for vertex shader
:display:gsg:dxgsg9(error): could not find matching vertex element data for vertex shader
:display:gsg:dxgsg9(error): could not find matching vertex element data for vertex shader
:display:gsg:dxgsg9(error): could not find matching vertex element data for vertex shader
:display:gsg:dxgsg9(error): could not find matching vertex element data for vertex shader

Tangents and binormals are calculated with -

egg-trans -tbnall -o output.egg input.egg

I’m using Direct3D render - if it matters.

Actually, it does–Panda’s support for shaders in DirectX is a little incomplete. Try using the OpenGL renderer instead.

David

When it will be completed for a working degree?

Are you volunteering to make the required fixes? :slight_smile:

David

No - I simply asking - are there any plans to make it working - and if I can help with the testing - I can participate.

I’m certainly in favor of making it working, but we need to find someone who can do the work to make it happen. Many of our developers here use Linux or Mac, or program exclusively in Python, so there’s not a long list of people willing to fix DirectX. I believe Gogg has expressed interest in improving things, but he’s only one guy and there’s only so much he can do, so another developer willing to help would go a long way towards making it happen sooner rather than later. :slight_smile:

David

Ok, understand.
I’m not very familiar with architecture of DirectX, so I will not be able to help in programming in this field. But if there will be need of testing - I can help.