Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LOD’s not working as expected on plane’s or grid’s? #1278

Open
rossoe opened this issue May 21, 2019 · 2 comments
Open

LOD’s not working as expected on plane’s or grid’s? #1278

rossoe opened this issue May 21, 2019 · 2 comments
Labels
bug

Comments

@rossoe
Copy link

@rossoe rossoe commented May 21, 2019

SHORT DESCRIPTION:

Having opened the example - LOD blend file
I created both a Plane and a Grid But running Krom (Armory Player) I cannot seem to get materials against the various LOD's to cycle through their different states - as set up in properties.

EXPECTED RESULT:

As you move the camera away from Grid or Plane, the LOD & associated materials will cycle through whatever I've set against the object.

ACTUAL RESULT:

Objects like Monkey, Cube and Sphere work fine and switch through the various LOD’s & different materials applied as you move away. However the Plane and Grid does not change it’s material (colour)? It appears to only show in Krom the material from the last LOD for any given plane or grid?

image

STEPS TO REPRODUCE:

Steps:

  1. Create plane or grid
  2. Auto generate 2 LOD's tick 'Material Lod'
  3. Create material for original object - set colour
  4. Create materials for associated LOD's - set different colours
  5. Run Krom (Armory Player)

TECHNICAL SPECIFICATIONS:

What version(s) of the following did you try:
Blender: 2.8beta
Armory: 0.7.0 (recent git)
Operating system: Win 10
Graphics card & driver: GTX960 latest Nvidia

TEST FILE TO REPRODUCE:

https://1drv.ms/u/s!AjCedBZJ5Eh4jBAwxl0N1G9Cuvd-

@luboslenco luboslenco added the bug label May 31, 2019
@paxetgloria

This comment has been minimized.

Copy link

@paxetgloria paxetgloria commented Jul 27, 2019

Hi @rossoe, Miro here, I had a look at your file and it seems that it's mainly happening because of the fact those planes and grids have dimension Z = 0. I did a dirty trick and added a single vertex to each grid LOD's mesh and shifted it 2 meters above grid mesh, this way it becomes "volume"(dimensionZ=2) and LODing starts working.
Untitled-1

@MoritzBrueckner

This comment has been minimized.

Copy link
Contributor

@MoritzBrueckner MoritzBrueckner commented Jan 6, 2020

I think the issue is caused by iron.MeshObject.computeScreenSize(): https://github.com/armory3d/iron/blob/dd61dd852ac9995e1fba9e48c8110f906e6abca7/Sources/iron/object/MeshObject.hx#L342

public inline function computeScreenSize(camera: CameraObject) {
	// Approx..
	// var rp = camera.renderPath;
	// var screenVolume = rp.currentW * rp.currentH;
	var tr = transform;
	var volume = tr.dim.x * tr.dim.y * tr.dim.z;
	screenSize = volume * (1.0 / cameraDistance);
	screenSize = screenSize > 1.0 ? 1.0 : screenSize;
}

If at least one dimension equals 0, the volume is 0, thus the objects screenSize is 0 too. This is used at https://github.com/armory3d/iron/blob/master/Sources/iron/object/MeshObject.hx#L244.

Is there any advantage of using the screenSize for LOD over the distance of the object? It is more accurate if the "origin" of the visible mesh is not at the origin position of the object, but that could probably be achieved by calculating the center of the visible mesh and using that for distance calculation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.