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

Textures of RenderModels are black when using .NET 4.6 scripting runtime version #78

Closed
JashanChittesh opened this issue Apr 23, 2018 · 4 comments

Comments

@JashanChittesh
Copy link

Since Unity 2017.1, there is an option in the Player Settings under "Other Settings" to switch from "Stable (.NET 3.5 Equivalent)" to "Experimental (.NET 4.6 Equivalent)". This mostly works really well - but apparently there is a change that causes the textures to load all black. It's very easy to reproduce when using one of the custom models with colorful textures (like the half-life one ;-) ). With 3.5 active, it works flawlessly. With 4.6, the controllers are all black. At first, I thought loading the custom models was the problem - but reviewing the loaded texture in Unity reveals that it's all black.

This could also be a bug in Unity's 4.6 implementation - I'll file a report with them, too.

@JashanChittesh
Copy link
Author

JashanChittesh commented Apr 23, 2018

Upon further investigation, I was able to fix this - the problem is that "char" behaves differently in the .NET 4.6 implementation than in the 3.5 implementation. Not sure why char was used but replacing it with ushort fixes the issue (that's in openvr_api.cs):

[StructLayout(LayoutKind.Sequential)] public struct RenderModel_TextureMap_t
{
	public ushort unWidth; // this was char before
	public ushort unHeight; // this was char before
	public IntPtr rubTextureMapData; // const uint8_t *
}
// This structure is for backwards binary compatibility on Linux and OSX only
[StructLayout(LayoutKind.Sequential, Pack = 4)] public struct RenderModel_TextureMap_t_Packed
{
	public ushort unWidth; // this was char before
	public ushort unHeight; // this was char before
	public IntPtr rubTextureMapData; // const uint8_t *
	public RenderModel_TextureMap_t_Packed(RenderModel_TextureMap_t unpacked)
	{
		this.unWidth = unpacked.unWidth;
		this.unHeight = unpacked.unHeight;
		this.rubTextureMapData = unpacked.rubTextureMapData;
	}
	public void Unpack(ref RenderModel_TextureMap_t unpacked)
	{
		unpacked.unWidth = this.unWidth; 
		unpacked.unHeight = this.unHeight;
		unpacked.rubTextureMapData = this.rubTextureMapData;
	}
}

@JashanChittesh
Copy link
Author

JashanChittesh commented Apr 23, 2018

This is fixed by Pull Request: #79

While fixing it, I saw that TriggerHapticPulse also uses char as parameter, so this may also be broken when .NET 4.6 is activated but I haven't tested this. EDIT: It seems like TriggerHapticPulse does not break. Still might be worth a consideration to change this to ushort. char seems like a misleading type here because it's not a char but a number.

@bddckr
Copy link

bddckr commented Apr 25, 2018

For more info see
ValveSoftware/openvr#638

(There's multiple others on the OpenVR repo, too. Example: ValveSoftware/openvr#469 (comment))

zite added a commit that referenced this issue Jun 21, 2018
Changes for v1.3b06:

* Added some flower and planting stuff for the tutorial

* Updating knuckles actions and binding jsons

* Added code solution for blending skeleton animations to mechanim, no example yet though

* Updated some helper components to utilize Unity Events properly

* Updated skeleton hierarchy


Changes for v1.3b05:

* Added a knuckles binding for the Grab mode

* Fixed some bugs around skeleton updates and GC alloc

* Fixed a pretty significant perf hit

* Added a blending option to skeletons

* Added some ui to try out skeleton options

* Added a target for the throwing examples

* Updated longbow to only fire arrows with the pinch action

* Updated other interactable examples

* Added some helper methods to hand around showing / hiding controller or the whole hand.

* Fixed some of the throwing examples


Changes for v1.3b04:

* Added some more extensive velocity and angular velocity estimation based on positions and rotations per frame. Normalizing for time between frames.

* Cleaned out and updated the actions + bindings for knuckles/wands/touch.

* Fixed a bug with newly created actions not having a set type

* Updated extra scenes to use the new input system


Changes for v1.3b03:

* Fixed some warnings for unity 2017 / 2018.

* Fixed some editor UI issues for 2018

* Fixed issues with Unity 2017+ not wanting to open scenes from a script reloaded callback


Changes for v1.3b02:

* Added DefaultInputAction attribute to automatically assign actions during action generation.

* Updated default CameraRig prefab to use the new input system and components


Changes for v1.3b01:

* Integrated SteamVR Input System.
https://steamcommunity.com/games/250820/announcements/detail/3809361199426010680

* [InteractionSystem] Added basic examples of the Skeletal API

* [InteractionSystem] Integrated SteamVR Input System. Actions and Action Sets instead of buttons.

* [InteractionSystem] Added Velocity style object interaction

* [InteractionSystem] Fixed some issues from github. Took some pull requests.
#79
#73
#72
#71
#67
#64
#84
#78
@zite
Copy link
Collaborator

zite commented Aug 22, 2018

Thanks for the report and fix guys. I've fixed this in the beta and will close when I merge beta to main. You can check it out on the releases page.

@zite zite closed this as completed Sep 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants