Skip to content

Commit

Permalink
fixes for A Short Hike v2019
Browse files Browse the repository at this point in the history
  • Loading branch information
magcius committed Nov 12, 2024
1 parent 8542e08 commit 08003e6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
11 changes: 7 additions & 4 deletions rust/src/unity/types/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub struct Material {
pub lightmap_flags: u32,
pub enable_instancing_variants: u8,
pub double_sided_gi: u8,
#[deku(count = "(4 - deku::byte_offset % 4) % 4")] _alignment: Vec<u8>,
pub custom_render_queue: u32,
pub string_tag_map: Map<CharArray, CharArray>,
pub disabled_shader_passes: UnityArray<CharArray>,
Expand Down Expand Up @@ -70,13 +71,13 @@ pub struct MeshRenderer {
pub cast_shadows: u8,
pub receive_shadows: u8,
pub dynamic_occludee: u8,
#[deku(cond = "version > UnityVersion::V2021_3_27f1")]
#[deku(cond = "version >= UnityVersion::V2021_3_27f1")]
pub static_shadow_caster: Option<u8>,
pub motion_vectors: u8,
pub light_probe_usage: u8,
pub reflection_probe_usage: u8,
pub ray_tracing_mode: u8,
#[deku(cond = "version > UnityVersion::V2021_3_27f1")]
#[deku(cond = "version >= UnityVersion::V2020_3_16f1")]
pub ray_trace_procedural: Option<u8>,
#[deku(count = "(4 - deku::byte_offset % 4) % 4")] _alignment: Vec<u8>,
pub rendering_layer_mask: u32,
Expand Down Expand Up @@ -214,10 +215,10 @@ pub struct ChannelInfo {
pub stream: u8,
pub offset: u8,
pub format: VertexFormat,
#[deku(bits = "1", pad_bits_before = "4")]
pub instance_data: u8,
#[deku(bits = "3")]
pub dimension: u8,
#[deku(bits = "1", pad_bits_after = "4")]
pub instance_data: u8,
}

#[derive(DekuRead, Clone, Debug)]
Expand Down Expand Up @@ -282,6 +283,8 @@ pub struct Texture2D {
pub name: CharArray,
pub forced_fallback_format: i32,
pub downscale_fallback: u8,
pub is_alpha_channel_optional: u8,
#[deku(count = "(4 - deku::byte_offset % 4) % 4")] _alignment: Vec<u8>,
pub width: i32,
pub height: i32,
pub complete_image_size: i32,
Expand Down
5 changes: 2 additions & 3 deletions src/AShortHike/Scenes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ class TerrainMaterial extends UnityMaterialInstance {

class AShortHikeMaterialFactory extends UnityMaterialFactory {
public createMaterialInstance(runtime: UnityRuntime, materialData: UnityMaterialData): UnityMaterialInstance {
debugger;
// TODO(jstpierre): Pull out serialized shader data
if (materialData.name.includes('_Splat3'))
return new TerrainMaterial(runtime, materialData);
Expand All @@ -229,7 +228,7 @@ class UnityRenderer implements Viewer.SceneGfx {
const template = this.renderHelper.pushTemplateRenderInst();
template.setBindingLayouts(bindingLayouts);

let offs = template.allocateUniformBuffer(0, 32);
let offs = template.allocateUniformBuffer(0, 16);
const mapped = template.mapUniformBufferF32(0);
offs += fillMatrix4x4(mapped, offs, viewerInput.camera.clipFromWorldMatrix);

Expand Down Expand Up @@ -277,7 +276,7 @@ class AShortHikeSceneDesc implements Viewer.SceneDesc {
}

public async createScene(device: GfxDevice, context: SceneContext): Promise<Viewer.SceneGfx> {
const runtime = await createUnityRuntime(context, `AShortHike`, UnityVersion.V2021_3_27f1);
const runtime = await createUnityRuntime(context, `AShortHike`, UnityVersion.V2019_4_39f1);
runtime.materialFactory = new AShortHikeMaterialFactory();
await runtime.loadLevel(this.id);

Expand Down
2 changes: 1 addition & 1 deletion src/Common/Unity/AssetManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ export class UnityMaterialData {
public fillTexEnvScaleBias(d: Float32Array, offs: number, name: string): number {
const texture = this.texturesByName.get(name);
if (texture !== undefined) {
return fillVec4(d, texture.scale[0], texture.scale[1], texture.offset[0], texture.offset[1]);
return fillVec4(d, offs, texture.scale[0], texture.scale[1], texture.offset[0], texture.offset[1]);
} else {
return fillVec4(d, offs, 1, 1, 0, 0);
}
Expand Down

0 comments on commit 08003e6

Please sign in to comment.