SDK Question Change Material setting

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
I got a question. On the Artemis1 I have the skin as reflective set in the GC cfg.

BUT after it reenters the atmosphere. I want the texture to change to a blacken one. I did that:
case 2: if (!(int)h1) if (h < 82000) { ReloadMeshes(); // to show the burnt heatshield h1 = 1; if (MainExternalMeshVisual = 0) oapiSetTexture(MainExternalMeshVisual, 26, BURNT_tex); }

But how to make it not reflective?
MATERIAL 32 REFLECT 0.800000 0.800000 0.800000 ROUGHNESS 1.000000
 

BrianJ

Addon Developer
Addon Developer
Joined
Apr 19, 2008
Messages
1,676
Reaction score
900
Points
128
Location
Code 347
Hi,
have a look at this function in gcAPI.h
Code:
gcMeshMaterial(DEVMESHHANDLE hMesh, DWORD idx, int prop, COLOUR4 *value, bool bSet);
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
I think I can change the material but how to make it not reflective
 

BrianJ

Addon Developer
Addon Developer
Joined
Apr 19, 2008
Messages
1,676
Reaction score
900
Points
128
Location
Code 347
I've never used this function, so I'm not sure but......
I think you need to use
Code:
MESHM_REFLECT
as the "material property identifier"
Look in gcConst.h
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
Thanks
so in the gcConst:
#define MESHM_REFLECT 0x20 ///< D3D9 material
gcapi.
int gcMeshMaterial(DEVMESHHANDLE hMesh, DWORD idx, int prop, COLOUR4 *value, bool bSet); /** * \brief A Function to get a mesh transformation/animation matrix. * \param matrix_id Id of the matrix to get. One of gcMatrix::xxx datatypes. * \param hVessel Vessel object handle. * \param mesh Mesh index * \param group Group index * \param pMat A pointer to FMATRIX4 struct for receiving the data. * \return 0 = on Success, or error code. */

What I want is the mesh to reflective but then under certain conditions the mesh changes texture and not reflective.

I think I could not that by replacing the meshes. But that seems a lot of work.
 

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,651
Reaction score
785
Points
128
If you provide a roughness map and a metalness map to make it reflective then a simple change of texture should disable it. Which would mean no reflective material setup. The material can be changed with "int SetMeshMaterial(DEVMESHHANDLE hMesh, DWORD idx, MatProp prop, const FVECTOR4* value)" Function declared in gcCoreAPI.h Also note that gcAPI.h is obsolete. (Still works for a backward compatibility)

It's recommended to use the texture approach. We may need to rearrange and cleanup the gcCoreAPI when the DX7 engine is removed. It's likely that all material parameters will be written in mesh files them selves (no more gc.cfg files) and some functions from gcCoreAPI are likely integrated to OrbiterAPI.

EDIT: Also it's recommended to use the Metalness shader for any new works.
 
Last edited:

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
Thanks.
oapiSetTexture(MainExternalMeshVisual, 26, BURNT_tex);
The artemis skin is texture 26. But even though it changes the blue skin to black. It is still reflective. The reflectiveness is set in the gc files


Here is made the change in the mesh but the skin is still reflective
 

Attachments

  • artemisburnt.jpg
    artemisburnt.jpg
    40.4 KB · Views: 11
Last edited:

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,651
Reaction score
785
Points
128
Yes, if there's no texture to define reflectiveness then a material value is being used. One way to disable it is to provide a dummy BURNT_tex_refl.dds with black content. Texture will override marerial making it non-reflective.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
Ok not sure if I did this correctly.
then saved as dds.
artemisskinBURNT.dds
artemisskinBURNT_refl.dds
 

Attachments

  • artemisskinBURNT.jpg
    artemisskinBURNT.jpg
    52.5 KB · Views: 3
  • artemisskinBURNTr.jpg
    artemisskinBURNTr.jpg
    5.7 KB · Views: 2

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
As I understand it.
if (h < 82000) { ReloadMeshes(); // to show the burnt heatshield h1 = 1; oapiSetTexture(hOrbiterMAINMesh, 26, BURNT_tex);
the main mesh is mesh 0

This is the trigger to change texture 26 to the BURNT_tex, correct?

it does NOT change.

And then have a black reflective texture. named BURNT_refl.dds

ARTEMISCAPSULE/artemisskin5.dds is texture #26. this is what I need to change to brown non reflective.
 
Last edited:

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,651
Reaction score
785
Points
128
Yes, the textures seems to be correct for the "Old PBR" shader but I haven't tested.

Could you confirm which shader is being used "PBR (Old)" or "Metalness PBR" ?

They use different textures and configurations.
Old PBR has three main textures:
MainTex.dds // color and alpha (rgba)
MainTex_refl.dds // reflection color (rgb)
MainTex_rghn.dds // greyscale texture, smoothness, 255 = mirror crisp, 0 = very rough

Metalness PBR has also three main textures:
MainTex.dds // color and alpha (rgba)
MainTex_metal.dds // greyscale texture "white" for metallic surface, "black" for non-metallic surface
MainTex_rghn.dds // greyscale texture, smoothness, 255 = mirros crisp, 0 = very rough (If the material is rough enough no reflection exists)

EDIT: Also note that if you control everything with textures you don't need to touch materials at all.

Here is a configuration example for Metalness PBR
Default "METALNESS" = 0
Default "SMOOTHNESS" = 1.0 1.0 (Main value) (Texture Gamma if texture exists)

Code:
CONFIG_VERSION 3
; =============================================
MESH DG\deltaglider_ns
SHADER Metalness
; ---------------------------------------------
MATERIAL 10
SMOOTHNESS 0.498039 1.000000
METALNESS 1.000000
; ---------------------------------------------
MATERIAL 11
SMOOTHNESS 0.000000 1.000000
; ---------------------------------------------
MATERIAL 12
SMOOTHNESS 0.576471 1.000000
METALNESS 1.000000
; ---------------------------------------------
MATERIAL 14
SMOOTHNESS 0.000000 1.000000
; ---------------------------------------------
MATERIAL 15
SMOOTHNESS 0.000000 1.000000
; ---------------------------------------------
MATERIAL 16
SMOOTHNESS 0.501961 1.000000
METALNESS 1.000000
; ---------------------------------------------
MATERIAL 17
SMOOTHNESS 0.000000 1.000000
; ---------------------------------------------
MATERIAL 18
SMOOTHNESS 0.000000 1.000000
; ---------------------------------------------
MATERIAL 24
SMOOTHNESS 0.933333 1.000000
 
Last edited:

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
I get this:
CONFIG_VERSION 3
; =============================================
MESH ARTEMIS\ARTEMISCOVER
; ---------------------------------------------
MATERIAL 1
REFLECT 0.800000 0.800000 0.800000
SMOOTHNESS 0.498039 1.000000
METALNESS 1.000000
; =============================================
MESH ARTEMIS\NEWARTEMIS
; ---------------------------------------------
MATERIAL 32
REFLECT 0.800000 0.800000 0.800000
SMOOTHNESS 0.498039 1.000000
METALNESS 1.000000
; ---------------------------------------------
MATERIAL 33
REFLECT 0.800000 0.800000 0.800000
SMOOTHNESS 0.498039 1.000000
METALNESS 1.000000

It is texture 26

SURFHANDLE BURNT_tex = oapiLoadTexture("Textures/ARTEMISCAPSULE/ARTEMISSKINBURNT.dds");
 

Attachments

  • reflecpropr1.jpg
    reflecpropr1.jpg
    53.4 KB · Views: 3
Last edited:

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
Ok. I am not sure what is going on.
if (key == OAPI_KEY_G) { RevertHATCH(); oapiSetTexture(hmesh1, 26, BURNT_tex); return 1; }
this is the texture I what to change

ARTEMISCAPSULE/artemisskin5.dds d

void TALON::clbkVisualCreated(VISHANDLE vis, int refcount) { MainExternalMeshVisual = GetMesh(vis, 0); //hmesh1 = GetDevMesh(vis, 0); hmesh1 = GetDevMesh(vis, 0); // I assume capsule mesh index is 0 }

no change
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
I ran this in default graphics and the texture changed to a blank texture. But nothing in the log.
oapiSetTexture(MainExternalMeshVisual, 26, BURNT_tex);
But if I ran in d3d9 I get a ctd
000000.000: Module ARTEMIS1.dll .......... [Build 230323, API 160828] 000000.000: --------------------------------------------------------------- 000000.000: >>> WARNING: Obsolete API function used: VESSEL::SetBankMomentScale 000000.000: At least one active module is accessing an obsolete interface function. 000000.000: Addons which rely on obsolete functions may not be compatible with 000000.000: future versions of Orbiter. 000000.000: --------------------------------------------------------------- 000000.000: Finished initialising status 000000.000: Finished initialising camera 000000.000: Finished setting up render state D3D9: ERROR: Base Object 0x251B740 = 'J2LPAD' not cataloged D3D9: ERROR: Base Object 0x16EFD638 = 'Tranquility Base' not cataloged D3D9: ERROR: Base Object 0x16EFC818 = 'MoonbaseAlpha1' not cataloged D3D9: ERROR: Base Object 0x16EFBD80 = 'Preary Base' not cataloged D3D9: ERROR: Base Object 0x16F07940 = 'UCGO Base Europa' not cataloged 000000.000: D3D9: [Scene Initialized] 000000.000: Finished initialising panels D3D9: NewShader [MeshIdx-1]=4

if (key == OAPI_KEY_G) { RevertHATCH(); //oapiSetTexture(hOrbiterMAINMesh, 26, BURNT_tex);//no change oapiSetTexture(hmesh1, 26, BURNT_tex); //no change //oapiSetTexture(MainExternalMeshVisual, 26, BURNT_tex); CTD }
void TALON::clbkVisualCreated(VISHANDLE vis, int refcount) { MainExternalMeshVisual = GetMesh(vis, 0); hmesh1 = GetDevMesh(vis, 0); // I assume capsule mesh index is 0 }
no change or ctd using hmesh1
000000.000: Module ARTEMIS1.dll .......... [Build 230323, API 160828] 000000.000: Finished initialising status 000000.000: Finished initialising camera 000000.000: Finished setting up render state D3D9: ERROR: Base Object 0x1CB0B280 = 'J2LPAD' not cataloged D3D9: ERROR: Base Object 0x298A20A0 = 'Tranquility Base' not cataloged D3D9: ERROR: Base Object 0x298A07E8 = 'MoonbaseAlpha1' not cataloged D3D9: ERROR: Base Object 0x298A3CE0 = 'Preary Base' not cataloged D3D9: ERROR: Base Object 0x1FCCD648 = 'UCGO Base Europa' not cataloged 000000.000: D3D9: [Scene Initialized] 000000.000: Finished initialising panels D3D9: NewShader [MeshIdx-1]=4 000021.447: D3D9: [Session Closed. Scene deleted.] 000021.447: D3D9: [Destroy Render Window Called] 000021.447: **** Closing simulation session

mesh is 0 and texture is 26
 

Attachments

  • meshindex.jpg
    meshindex.jpg
    52.8 KB · Views: 0

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
I followed Brians code but no change
I put a break and dhmesh0-0
Document [TABLE] [TR] [TH][/TH] [TH]Name[/TH] [TH]Value[/TH] [TH]Type[/TH] [/TR] [TR] [TD]▶[/TD] [TD]dhMesh0[/TD] [TD]0x00000000 {???}[/TD] [TD]int *[/TD] [/TR] [/TABLE]
if (key == OAPI_KEY_G) { RevertHATCH(); //oapiSetTexture(hOrbiterMAINMesh, 26, BURNT_tex);//no change //oapiSetTexture(dhMesh0, 26, BURNT_tex); //no change //oapiSetTexture(MainExternalMeshVisual, 26, BURNT_tex); CTD //oapiSetTexture(dhMesh2, 8, bs1); oapiSetTexture(dhMesh0, 26, bs1); }
void TALON::clbkVisualCreated(VISHANDLE vis, int refcount) { MainExternalMeshVisual = GetMesh(vis, 0); //hmesh1 = GetDevMesh(vis, 0); //hmesh1 = GetDevMesh(vis, 0); // I assume capsule mesh index is 0 dhMesh0 = GetDevMesh(vis, 0); // mains cover }

The main capsule is mesh 0
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
I wonder if it has to do with this:
void TALON::ReloadMeshes(void) { //UINT meshidx; double dz; // z-offset for various configs ClearMeshes(TRUE); switch (mode) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: //Fcapsule config case 10: case 11: dz = 0; break; case 12: dz = -2; break; } ofs = _V(0, 0, 0 + dz); //ofs_camera = _V(-0.30, 1.368, 2.3 + dz); // left hand seat, eye-point of docking window ofs_camera = _V(-0.41, 2, 2.241); // left hand seat, eye-point of docking window _V(-0.41, 1.6, 2.2+dz); //ofs_hud = _V(0, 1.6, 2.5 + dz); SetCameraOffset(ofs_camera); hOrbiterMAINMesh = oapiLoadMeshGlobal("ARTEMIS\\NEWARTEMIS"); //hOrbiterMAINMesh = oapiLoadMeshGlobal("TALON\\orioncm1"); hOrbiterVCMesh = oapiLoadMeshGlobal("ARTEMIS\\NEWARTEMISVC"); //hsmMeshUINT = oapiLoadMeshGlobal("TALON\\NEWSM"); SetMeshVisibilityMode(mesh_idx[1] = AddMesh(hOrbiterMAINMesh), MESHVIS_ALWAYS);//MESH 0 SetMeshVisibilityMode(mesh_idx[2] = AddMesh(hOrbiterVCMesh), MESHVIS_VC | MESHVIS_ALWAYS);//MESH 1 switch (mode) { case 0: //AddMesh(coverMesh, &ofs); SetMeshVisibilityMode(coverMeshUINT, MESHVIS_EXTERNAL | MESHVIS_VC); SetMeshVisibilityMode(smMeshUINT, MESHVIS_EXTERNAL | MESHVIS_VC); //AddMesh(smMesh, &ofs); // AddMesh(solar0Mesh, &ofs); break;

it clears the meshes and then based on cases the correct mesh is seen? BUT the main mesh and VC are seen all times
 
Last edited:

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
Out of ideas:( not sure why the texture is not changing.
redid the mesh locations
void TALON::clbkSetClassCaps(FILEHANDLE cfg) { texture_switch = 0; gcInitialize(); SetSize(3); SetEmptyMass(500.0); SetCW(0.09, 0.09, 2, 1.4); SetWingAspect(0.7); SetWingEffectiveness(2.5); SetCrossSections(_V(710.54, 2159.34, 207.95)); SetSurfaceFrictionCoeff(0.07, 0.3); SetRotDrag(_V(0.10, 0.13, 0.04)); SetMaxWheelbrakeForce(5e5); SetPMI(_V(743.84, 872.38, 148.19)); SetTrimScale(0.1); SetCameraOffset(arm_tip[0]); SetTouchdownPoints(_V(0, .0001, 10), _V(-1.6, .0001, -10), _V(1.6, .0001, -10));; EnableTransponder(true); //new MAINMeshUINT = AddMesh(oapiLoadMeshGlobal("ARTEMIS\\NEWARTEMIS")); SetMeshVisibilityMode(MAINMeshUINT, MESHVIS_VC | MESHVIS_ALWAYS);//MESH 0 VCMeshUINT = AddMesh(oapiLoadMeshGlobal("ARTEMIS\\NEWARTEMISVC")); SetMeshVisibilityMode(VCMeshUINT, MESHVIS_VC | MESHVIS_ALWAYS);//MESH 1 smMeshUINT = AddMesh(oapiLoadMeshGlobal("ARTEMIS\\NEWSM1")); SetMeshVisibilityMode(smMeshUINT, MESHVIS_VC | MESHVIS_ALWAYS);//MESH 2 coverMeshUINT = AddMesh(oapiLoadMeshGlobal("ARTEMIS\\ARTEMISCOVER"));// m SetMeshVisibilityMode(coverMeshUINT, MESHVIS_VC | MESHVIS_ALWAYS);//MESH 3 CHAIRDEPLOY4MeshUINT = AddMesh(oapiLoadMeshGlobal("ARTEMIS\\ARTEMIS4CHAIRDEPLOY"));// mesh4 SetMeshVisibilityMode(CHAIRDEPLOY4MeshUINT, MESHVIS_EXTERNAL | MESHVIS_VC);
press G hatch opens and texture should change
if (key == OAPI_KEY_G) { RevertHATCH(); //oapiSetTexture(hOrbiterMAINMesh, 26, BURNT_tex);//no change //oapiSetTexture(dhMesh0, 26, BURNT_tex); //no change //oapiSetTexture(MainExternalMeshVisual, 26, BURNT_tex); CTD //oapiSetTexture(dhMesh2, 8, bs1); oapiSetTexture(dhMesh0, 26, BURNT_tex); }
void TALON::clbkVisualCreated(VISHANDLE vis, int refcount) { MainExternalMeshVisual = GetMesh(vis, 0); //hmesh1 = GetDevMesh(vis, 0); //hmesh1 = GetDevMesh(vis, 0); // I assume capsule mesh index is 0 dhMesh0 = GetDevMesh(vis, 0); // mains cover }
DEVMESHHANDLE dhMesh0;

And the texture is set as dynamic.
 

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,651
Reaction score
785
Points
128
I searched the source codes and found a problem. When using oapiLoadTexture() it's loaded in a DX7 compatibility mode and it doesn't support additional texture maps. It will typically decompress the texture or load it as a render target. OpenOrbiter has a function oapiLoadSurfaceEx() which will load all additional texture maps when using only OAPISURFACE_TEXTURE flag, nothing else. The feature exists in Orbiter 2016 via gcCore::LoadSurface() function when using only OAPISURFACE_TEXTURE flag. Also, @DaveS has raised an issue regarding some problems on loading additional texture maps, which are going to be addressed.

Since the shader name is not defined in the configuration file, I would expect it to default on Old PBR shader unless a Metalness map exists.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
Thanks
I get this:
MESH MeshIdx-0
; ---------------------------------------------
MATERIAL 32
REFLECT 0.800000 0.800000 0.800000
SMOOTHNESS 0.100000 0.100000
; ---------------------------------------------
MATERIAL 33
REFLECT 0.800000 0.800000 0.800000
SMOOTHNESS 0.100000 0.100000
; =============================================
MESH MeshIdx-3
; ---------------------------------------------
MATERIAL 1
REFLECT 0.800000 0.800000 0.800000
SMOOTHNESS 0.100000 0.100000

not very reflective though

But how to make it very dull with a new texture? I got the brown burnt tex to show but it needs to be dull
 

Attachments

  • TEXCHANGEARTEMIS4.jpg
    TEXCHANGEARTEMIS4.jpg
    69.8 KB · Views: 2
  • TEXCHANGEARTEMIS5.jpg
    TEXCHANGEARTEMIS5.jpg
    55.5 KB · Views: 0
Last edited:
Top