Page 1 of 1

Normal Maps... how to add

Posted: 14 Jun 2011, 15:15
by aGorm
Hi guy's, how do you add normal maps to units? I can't find any info anywere (I know it's here somewhere from like years ago, but search isn't finding the right threads). Anyone able to link me to how you get it working?

aGorm

(What, me, units in game, no, never... :-) )

Re: Normal Maps... how to add

Posted: 14 Jun 2011, 15:33
by Beherith
Check out the BA remake from google code:
http://code.google.com/p/baremake/

You will need the following from it:

Everything from :
LuaRules\Configs\UnitMaterials

LuaRules\Gadgets\gfx_customUnitShaders.lua
LuaRules\UnitRendering.lua

You also need gadgets.lua and draw.lua from LuaRules.

Add the following to the unit's fbi/lua:

Code: Select all

  [customParams]{
		normaltex=unittextures/Core_normal.tga;
		normalmaps=yes;
	}
Additional info:
Texture 2 reflectivity and specular is separated into green/blue channels, respectively.
Normal map alpha is damage texture, glow is modulated. The rules for this is defined in:
LuaRules\Configs\UnitMaterials\1_normalmapping.lua

Code: Select all

local function DrawUnit(unitID, material)
  glUniform(material.frameLoc, maximum(0,sine(modulo(unitID,10)+GetGameFrame()/(modulo(unitID,7)+6))))
  health,maxhealth=GetUnitHealth(unitID)
  glUniform(material.healthLoc, 2*maximum(0, (-2*health)/(maxhealth)+1) )--inverse of health, 0 if health is 100%-50%, goes to 1 by 0 health
Enjoy! Feel free to ask more if above explanation is insufficient!

Also, thanks jK!

Re: Normal Maps... how to add

Posted: 14 Jun 2011, 15:47
by aGorm
Many thanks :-) (also, reflectivity and specular separated? Awesome)

Re: Normal Maps... how to add

Posted: 15 Jun 2011, 15:26
by aGorm
OK, the second I add in that custom pram line, the unit doesn't load... Have I done somthing wrong (obviosly I have, I mean, anything in the unitdef...)

Code: Select all

local unitName = "cyberlord"

local unitDef = {
name = "Cybernaut Lord",
Description = "Elite Ground Unit",
objectName = "cyberlord.s3o",
script = "cyberlord.lua",
buildPic = "placeholder.png",
--cost
buildCostMetal = 100,
buildCostEnergy = 100,
buildTime = 2,
--Health
maxDamage = 100,
idleAutoHeal = 0,

--Movement
Acceleration = 0.2,
MaxVelocity = 1.5,
BrakeRate = 0.3,
FootprintX = 1,
FootprintZ = 1,
MovementClass = "Default2x2",
TurnRate = 900,

sightDistance = 300,
Upright = 1,

Category = [[LAND]],

Builder = false,
CanAttack = true,
CanGuard = true,
CanMove = true,
CanPatrol = true,
CanStop = true,
LeaveTracks = false,
weapons = {
[1]={name  = "Tesla",
	onlyTargetCategory = [[LAND]],
	},
},

[customParams]{
	normaltex=unittextures/Core_normal.tga,
	normalmaps=yes,
  }
}

return lowerkeys({ [unitName] = unitDef })   


Re: Normal Maps... how to add

Posted: 15 Jun 2011, 15:30
by knorke
normaltex=unittextures/Core_normal.tga,
missing "" ?

Re: Normal Maps... how to add

Posted: 15 Jun 2011, 15:31
by Beherith
Indeed, you tried to add a def from a tdf file to a lua file.

Try this:

Code: Select all

  customParams           = {
    normaltex = [[unittextures/Core_normal.tga]],
   normalmaps=[[yes]],
  },

Re: Normal Maps... how to add

Posted: 15 Jun 2011, 15:36
by FLOZi
BA remake gadget a fork of ZK one or just up to date with latest changes?

S44 one probably needs updating...

(springcontent.sdz, anyone?)

(Also we should talk about lua-ing your gamedata/ files)

Re: Normal Maps... how to add

Posted: 15 Jun 2011, 15:46
by aGorm
Cool, unit now loads... can't see the normal map though... :-( but I'm out of time this lunch so I'll have to take anothe rcrack at it tomoz.

aGorm

Re: Normal Maps... how to add

Posted: 15 Jun 2011, 15:52
by Beherith
Fork, dunno from when though. I guess about a year.

Re: Normal Maps... how to add

Posted: 16 Jun 2011, 14:21
by aGorm

Code: Select all

LogOutput initialized.
Spring 0.82.7.1 (0.82.7.1)
Build date/time: Jan  8 2011 00:17:26
Available log subsystems: CollisionVolume, unit, ArchiveScanner, VFS-detail, VFS, Sound
Enabled log subsystems: Sound
Enable or disable log subsystems using the LogSubsystems configuration key
  or the SPRING_LOG_SUBSYSTEMS environment variable (both comma separated).
  Use "none" to disable the default log subsystems.
using default configuration source "C:\3D Work\Cyber_vs_Bears\Spring\spring-0.82.7.1\/springsettings.cfg"
[CMyMath::Init] CPU SSE mask: 127, flags:
	SSE 1.0:  1,  SSE 2.0:  1
	SSE 3.0:  1, SSSE 3.0:  1
	SSE 4.1:  1,  SSE 4.2:  1
	SSE 4.0A: 0,  SSE 5.0A: 0
	using streflop SSE FP-math mode, CPU supports SSE instructions
OS: Microsoft Windows
Microsoft Windows 7 Business Edition, 64-bit (build 7600)
Intel(R) Core(TM) i7 CPU         870  @ 2.93GHz; 8151MB RAM, 16300MB pagefile
OS: emulated 32bit mode
Using read-write data directory: C:\3D Work\Cyber_vs_Bears\Spring\spring-0.82.7.1\
Scanning: C:\3D Work\Cyber_vs_Bears\Spring\spring-0.82.7.1\maps
Scanning: C:\3D Work\Cyber_vs_Bears\Spring\spring-0.82.7.1\base
Scanning: C:\3D Work\Cyber_vs_Bears\Spring\spring-0.82.7.1\games
Scanning: C:\3D Work\Cyber_vs_Bears\Spring\spring-0.82.7.1\mods
Supported Video modes: 1920x1080, 1680x1050, 1360x768, 1280x1024, 1280x960, 1280x800, 1280x768, 1280x720, 1152x864, 1024x768, 800x600, 720x576, 720x480, 640x480, 640x350
Video mode set to 1440x900/32bit (windowed)
[f=0000000] SDL:  1.2.10
[f=0000000] GL:   3.2.0
[f=0000000] GL:   NVIDIA Corporation
[f=0000000] GL:   GeForce 310/PCI/SSE2
[f=0000000] GLSL: 1.50 NVIDIA via Cg compiler
[f=0000000] GLEW: 1.5.4
[f=0000000] Joysticks found: 0
[f=0000000] Joystick 0 not found
[f=0000000] Connecting to local server
[f=0000000] Starting GameServer: 7 ms
[f=0000000] Starting demo recording
[f=0000000] Using map Mescaline_V2
[f=0000000] Recording demo demos/20110616_131645_Mescaline_V2_0.82.7.sdf
[f=0000000] Using mod MegaBears VS Cybernauts r1
[f=0000000] [Sound] OpenAL info:
[f=0000000] [Sound]   Vendor:     OpenAL Community
[f=0000000] [Sound]   Version:    1.1 ALSOFT 1.11.753
[f=0000000] [Sound]   Renderer:   OpenAL Soft
[f=0000000] [Sound]   AL Extensions: AL_EXTX_buffer_sub_data AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_OFFSET AL_EXTX_sample_buffer_object AL_EXT_source_distance_model AL_LOKI_quadriphonic
[f=0000000] [Sound]   ALC Extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_disconnect ALC_EXT_EFX ALC_EXTX_thread_local_context
[f=0000000] [Sound]                   ALC_EXT_EFX found (required for air absorption): yes
[f=0000000] [Sound]   Device:     DirectSound Software
[f=0000000] [Sound]   Available Devices:  
[f=0000000] [Sound]                       DirectSound Software
[f=0000000] [Sound] air absorption enabled: 0.1
[f=0000000] Using mod archive meagbears.sdd
[f=0000000] Loading client data: 64 ms
[f=0000000] User number 0 (team 0, allyteam 0)
[f=0000000] [Sound]  parsed 3 sounds from gamedata/sounds.lua
[f=0000000] [Sound] Unable to open audio file: sounds/incoming_chat.wav
[f=0000000] Loading sounds: 0 ms
[f=0000000] [Sound] Unable to open audio file: sounds/multiselect.wav
[f=0000000] Camera and mouse: 94 ms
[f=0000000] Parsing unit icons
[f=0000000] Loading GameData Definitions
[f=0000000] WARNING: removed the "cyberfac" entry from the "buildervehicle" build menu
[f=0000000] Loading all definitions:  0.010000
[f=0000000] Loading GameData Definitions: 11 ms
[f=0000000] Parsing Map Information
[f=0000000] Loading SMF
[f=0000000] Loading Map
[f=0000000] Calculating smooth height mesh
[f=0000000] Calculating smooth mesh: 134 ms
[f=0000000] Number of damage types: 2
[f=0000000] Creating unit textures
[f=0000000] Loading weapon definitions
[f=0000000] Loading unit definitions
[f=0000000] Loading feature definitions
[f=0000000] Initializing map features
[f=0000000] Unknown map feature type pedro7
[f=0000000] Reading Estimate PathCosts [8]
[f=0000000] Reading Estimate PathCosts [32]
[f=0000000] [CPathManager] pathing data checksum: 429b565b
[f=0000000] You are missing the "ARB_shadow_ambient" extension (this will probably make shadows darker than they should be)
[f=0000000] Loading .smt tile-file "maps/Mescaline_V2.smt"
[f=0000000] Loading 61429 tiles from file 1/1
[f=0000000] Reading tiles
[f=0000000] Reading tile map
[f=0000000] generating MipMaps: 7 ms
[f=0000000] Generating 3D trees
[f=0000000] [Sound] Unable to open audio file: sounds/mappoint.wav
[f=0000000] Creating Projectile Textures
[f=0000000] Creating sky
[f=0000000] Loading console: 0 ms
[f=0000000] [Sound] Unable to open audio file: FailedCommand
[f=0000000] [Sound] CSound::GetSoundId: could not find sound: FailedCommand
[f=0000000] Loading LuaRules
[f=0000000] Loading gadget: Lua unit script framework  <unit_script.lua>
[f=0000000]   Loading unit script: scripts/attackvehicledoublebarrel.lua
[f=0000000]   Loading unit script: scripts/attackvehiclemultimissile.lua
[f=0000000]   Loading unit script: scripts/simpleattackvehicle.lua
[f=0000000]   Loading unit script: scripts/buildervehicle.lua
[f=0000000]   Loading unit script: scripts/empty.lua
[f=0000000]   Loading unit script: scripts/cyberlord.lua
[f=0000000]   Loading unit script: scripts/helicopter.lua
[f=0000000]   Loading unit script: scripts/hovereffects.lua
[f=0000000]   Loading unit script: scripts/hoverweapon.lua
[f=0000000]   Loading unit script: scripts/cyberfac.lua
[f=0000000]   Loading unit script: scripts/simplehover.lua
[f=0000000] Loaded gadget:  Lua unit script framework  <unit_script.lua>
[f=0000000] Loaded gadget:  Spawn               <game_spawn.lua>
[f=0000000] Loaded gadget:  CustomUnitShaders   <gfx_customunitshaders.lua>
[f=0000000] Loading LuaGaia
[f=0000000] Loading LuaUI
[f=0000000] Using LUAUI_DIRNAME = LuaUI/
[f=0000000] Reloaded ctrlpanel with: LuaUI/ctrlpanel.txt
[f=0000000] LuaUI: bound F11 to the widget selector
[f=0000000] LuaUI: bound CTRL+F11 to tweak mode
[f=0000000] Loading widget from mod:   Spring Tanks | HealthBars  <unit_healthbars.lua> ...
[f=0000000] Loading widget from user:  Mouse Buildspacing  <gui_buildspacing.lua> ...
[f=0000000] LuaUI v0.3
[f=0000000] Finalizing...
[f=0000000] Connection attempt from UnnamedPlayer
[f=0000000]  -> Version: 0.82.7.1 (0.82.7.1)
[f=0000000]  -> Connection established (given id 0)
[f=0000000] Player UnnamedPlayer finished loading and is now ingame
[f=0000000] GameID: 3af4f94dfe46126ffa65624e1cdf4421
[f=0000000] UnnamedPlayer added point: Start 0
[f=0001815] Path cache hits 0 0%
[f=0001815] Path cache hits 0 0%
[f=0001815] Statistics for local connection:
Received: 3273 bytes
Sent: 17373 bytes
Still not working (I double checked everythign was copyd over correctly...) and the info log looks like it loads the gadget... any ideas?

Re: Normal Maps... how to add

Posted: 16 Jun 2011, 14:35
by FLOZi
Problem may be that BAR uses the CA gadgetHandler, you may have to pull all of that in.

Alternative is to try using S44 normal mapping gadget which works with base content gH.

Re: Normal Maps... how to add

Posted: 16 Jun 2011, 15:03
by aGorm
Tryed the S44 one to, but it's not playing ball... I know this PC displays the normal maps as there there in S44, but I must be missing somthing in what I've copyed. If I were to zip this up would anyone care to take a look?

aGorm

::EDIT Thanks Beherith ::

Re: Normal Maps... how to add

Posted: 16 Jun 2011, 17:08
by Beherith
You also need gadgets.lua and draw.lua from LuaRules.

Re: Normal Maps... how to add

Posted: 16 Jun 2011, 17:15
by aGorm
Bah, wood for trees... :evil: moral of teh story is... read carfully and dont delete things just because you can tell what they do.

aGorm

PS, it works and it looks great.

Re: Normal Maps... how to add

Posted: 23 Jun 2011, 15:19
by aGorm
OK, so you though the questions had stoped right? well your wrong.. I'm back with whole new problem!
error.jpg
(91.88 KiB) Downloaded 2 times
For some reason, after I converted the normal maps to dds, all the normals seem to be backwards... (See how the sunny side is the same as the side with shadows...)

I'm assumeing that it's somthing to do with dds' and normal maps, so does anyone know what settings I have to use? (I was unsing the nvidia photoshop plug in...)

aGorm

Re: Normal Maps... how to add

Posted: 23 Jun 2011, 19:36
by KaiserJ
not sure i understand 100% (looked at the pic, nice models dude btw) but what you're saying is that your normals are turning an inset area into an outset area?

i've never used photoshop normals for anything (played with the filters etc though) as i normally build normals directly from a cavity map or height map or mesh...

possible solution: convert your normals to a greyscale cavity map, invert the cavity map, then convert back to normals

also it might be a problem with your algorithm settings in photoshop, possibly just something to click ;)

Re: Normal Maps... how to add

Posted: 24 Jun 2011, 00:14
by aGorm
No, (I did have that but i dorted that out...)

This is that (if you look carfully) the bright side of the model (IE thats lit by the sun) is also the side with the shadows. IE, the lit source is on the left, but the light is showing on the right on the models.

aGorm

Re: Normal Maps... how to add

Posted: 24 Jun 2011, 00:37
by Beherith
Post normal map pls and dds too.

Re: Normal Maps... how to add

Posted: 24 Jun 2011, 12:04
by aGorm
No problem.

For some reason the dds one looks lighter, but otherwise the same... not sure why teh conversion would do that.

aGorm

::::EDIT:::: Thuther to this... I re-re-exported them adn now they work fine... must have been some weird glitch.