From d6ebb8e21af1b4bfa6bc530fe3a1b3455d4a47b7 Mon Sep 17 00:00:00 2001 From: Daan Vanden Bosch Date: Sun, 27 Oct 2019 16:45:30 +0100 Subject: [PATCH] Added simple transparency to entities. Seems to work for most entities except for those that use translucent texture to emulate light rays etc. --- src/core/rendering/Renderer.ts | 4 ++-- src/quest_editor/rendering/conversion/areas.ts | 6 +++--- .../rendering/conversion/entities.ts | 18 +++++++++++++++--- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/core/rendering/Renderer.ts b/src/core/rendering/Renderer.ts index 38cde6ac..09b30813 100644 --- a/src/core/rendering/Renderer.ts +++ b/src/core/rendering/Renderer.ts @@ -38,10 +38,10 @@ export abstract class Renderer implements Disposable { readonly scene = new Scene(); readonly light_holder = new Group(); - private readonly renderer = new WebGLRenderer({ antialias: true }); + private readonly renderer = new WebGLRenderer({ antialias: true, alpha: true }); private render_scheduled = false; private animation_frame_handle?: number = undefined; - private readonly light = new HemisphereLight(0xffffff, 0x505050, 1.2); + private readonly light = new HemisphereLight(0xffffff, 0x505050, 1.0); private readonly controls_clock = new Clock(); private readonly size = new Vector2(); diff --git a/src/quest_editor/rendering/conversion/areas.ts b/src/quest_editor/rendering/conversion/areas.ts index 9d787419..67c19f83 100644 --- a/src/quest_editor/rendering/conversion/areas.ts +++ b/src/quest_editor/rendering/conversion/areas.ts @@ -29,17 +29,17 @@ const materials = [ }), // Ground new MeshLambertMaterial({ - color: 0xa0a0a0, + color: 0xc0c0c0, side: DoubleSide, }), // Vegetation new MeshLambertMaterial({ - color: 0x50b070, + color: 0x60c080, side: DoubleSide, }), // Section transition zone new MeshLambertMaterial({ - color: 0x604080, + color: 0x8040a0, side: DoubleSide, }), ]; diff --git a/src/quest_editor/rendering/conversion/entities.ts b/src/quest_editor/rendering/conversion/entities.ts index ca3dbf77..67cd23a5 100644 --- a/src/quest_editor/rendering/conversion/entities.ts +++ b/src/quest_editor/rendering/conversion/entities.ts @@ -1,11 +1,19 @@ import { QuestEntityModel } from "../../model/QuestEntityModel"; -import { BufferGeometry, DoubleSide, Mesh, MeshLambertMaterial, Texture } from "three"; +import { + BufferGeometry, + DoubleSide, + Mesh, + MeshBasicMaterial, + MeshLambertMaterial, + Texture, +} from "three"; import { create_mesh } from "../../../core/rendering/conversion/create_mesh"; import { entity_type_to_string, EntityType, is_npc_type, } from "../../../core/data_formats/parsing/quest/entities"; +import { NpcType } from "../../../core/data_formats/parsing/quest/npc_types"; export enum ColorType { Normal, @@ -42,10 +50,14 @@ export function create_entity_type_mesh( textures.length ? textures.map( tex => - new MeshLambertMaterial({ + new MeshBasicMaterial({ map: tex, side: DoubleSide, - alphaTest: 0.5, + // TODO: figure out why these NPC types don't render correctly when + // transparency is turned on. + transparent: + type !== NpcType.PofuillySlime && type !== NpcType.PouillySlime, + alphaTest: 0.01, }), ) : default_material,