Page 1 of 1

LUA scripts and PBR material problems

Posted: Mon Mar 11, 2019 3:35 pm
by simskunkworks
Hi,
apologize for my weak english.
Below GinaTextureScript.lua lua scripts works nicely
!lua
--Get precip state.
local raining = 0x00000004
local precipState = varget("A:AMBIENT PRECIP STATE", "Mask")
precipState = math.floor(precipState)
--Define textures.
textureDry= "ssw_G91_R1_B_T_01_albedo.dds"
textureWet = "ssw_G91_R1_B_T_01_albedo_wet.dds"
if precipState == raining then
varset("T:DiffuseTexture", "string", textureWet)
else
varset("T:DiffuseTexture", "string", textureDry)
end
under these conditions:
- script resides on: <device>:\Program Files\Lockheed Martin\Prepar3D v4\Scripts
- material is NOT flagged as PBR materials
cmpiling the mdl it shows to have hard coded a link to GinaTextureScript.lua as expected.

changing the script:
if precipState == raining then
varset("T:AlbedoTexture", "string", textureWet)
else
varset("T:AlbedoTexture", "string", textureDry)
end
as reported on SDK and setting the PBR flag on material does not work, wet texture never shown.

2 questions:
- how to have the script in another folder other than <device>:\Program Files\Lockheed Martin\Prepar3D v4\Scripts ?
- there is some error in the code or lua does not work on PBR materials yet ?
TIA
/SSW

Re: LUA scripts and PBR material problems

Posted: Tue Mar 12, 2019 6:14 pm
by Clifton Crane
Hi SSW,

Lua scripting is supported by PBR materials. Do other PBR material properties work with your script? Does the PBR material itself render correctly?

Script locations can also be added by using the add-on.xml method. Also, if the script is being used on a SimObject the scripts can be added locally to that object similar to texture directories. You can reference the Learning Center articles for Aircraft Configuration Files and Simulation Object Configuration Files.

Thanks.

Re: LUA scripts and PBR material problems

Posted: Thu Mar 14, 2019 6:23 pm
by simskunkworks
Hi SSW,

Lua scripting is supported by PBR materials. Do other PBR material properties work with your script? Does the PBR material itself render correctly?

Script locations can also be added by using the add-on.xml method. Also, if the script is being used on a SimObject the scripts can be added locally to that object similar to texture directories. You can reference the Learning Center articles for Aircraft Configuration Files and Simulation Object Configuration Files.

Thanks.
Thanks for the answer,
yes PBR material renders ok, however texture does not switch from dry to wet.
I'm pretty sure that the scripts is running (debug), it works ok if diffuse are used, does not using albedo and material flagged ad PBR
Guess i may set the script link into texture.cfg, right ?
/SSW

Re: LUA scripts and PBR material problems

Posted: Fri Mar 15, 2019 2:24 pm
by Clifton Crane
For SimObjects you can add the .lua files to a directory named "script" in your SimObject's aircraft.cfg/sim.cfg directory. You do not need to add it to texture.cfg.

For example:

SimObjects\Airplanes\MyAirplane
SimObjects\Airplanes\MyAirplane\aircraft.cfg
SimObjects\Airplanes\MyAirplane\script\MyScript.lua

You can also specify custom script directories in your aircraft.cfg similar to sound, texture, and panel:

[fltsim.xx]
name=MyAirplane
script=custom

Then the directory structure would be:

SimObjects\Airplanes\MyAirplane
SimObjects\Airplanes\MyAirplane\aircraft.cfg
SimObjects\Airplanes\MyAirplane\script.custom\MyScript.lua

This allows developers to include scripts with the SimObject itself without having to manually add custom script locations via add-on method or install scripts to the default location.

Re: LUA scripts and PBR material problems

Posted: Fri Mar 15, 2019 2:50 pm
by Clifton Crane
Hi SSW,

I just did a quick test with our default F-16 which has PBR materials as well as lua scripts and albedo texture swapping seems to work. Do you have any content error reports?

Re: LUA scripts and PBR material problems

Posted: Fri Mar 15, 2019 5:52 pm
by simskunkworks
Hi SSW,

I just did a quick test with our default F-16 which has PBR materials as well as lua scripts and albedo texture swapping seems to work. Do you have any content error reports?
Hi,
unfortunately nothing related with albedo texture nor lua script.
Will continue to investigate.
Thanks for scripts cue, it's cool :-)
/Mario