Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • CreatiCode
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

CreatiCode Scratch Forum

  1. CreatiCode Forum
  2. Knowledge Base
  3. 3D Blocks
  4. Using Lights

Using Lights

Scheduled Pinned Locked Moved 3D Blocks
1 Posts 1 Posters 898 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CreatiCodeI Offline
    CreatiCodeI Offline
    CreatiCode
    wrote on last edited by admin
    #1

     

    Prerequisite

    • Initializing a 3D Scene

     

    Description

    All scenes must contain some light source. If there is no light, then everything would be pitch black, just like what you see when you walk into a dark room without light.

    Therefore, even the “empty” scene contains some light added for you, so it is not really empty.

     

    Removing All Lights

    If you want to change the lights in a scene, you often need to remove all the existing lights contained in the scene first. You can use this block to do that:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/d0b544cb-08e8-4c74-a269-5cef248f76ef.png" width="150" style="">

     
    For example, here is what happens when you remove all the lights in the “village” scene:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/0b457372-b819-4e32-915e-ae21607f5320.gif" width="750" style="">

     

    Removing One Light

    If you just want to remove one light from the scene, you can use this block instead:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/5f94dff5-48ab-4857-9880-71655f466b75.png" width="230" style="">

    Note that you can specify the name of the light when you create it.

     

    Ambient Lights

    In most projects, you just need to have normal lights we get in broad daylight. This is called “ambient light”, which means lights surrounding us. Ambient lights are added to all scenes by default.

    You can use the following block to add ambient lights to your scene:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/b3ff96e4-d5cd-4be1-9261-c10f5d58ac00.png" width="1000" style="">

    • Color: The color of the light will be added to all objects. For example, suppose you want to create a sunset scene, then the light color should be golden:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/574773f7-0d92-4404-acf7-a1f9fe47a2d4.gif" width="1000" style="margin-left: 40px; border-radius: 5px; border: 1px solid #29622d;">

     

    • Main Light Direction: The ambient lights simulate how the objects around us reflect lights back to the sky. So you need to specify the direction of the sky, which is usually “x = 0, y = 0, z = 1”.

    The scene will be light up in all directions, with the part facing the sky the brightness, and the side opposite to the sky darkest:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/12000cf1-2795-4f73-9326-377cb4bc61c8.gif" width="950" style="margin-left: 40px; border-radius: 5px; border: 1px solid #29622d;">

     

    • Intensity: the intensity value controls how bright the lights are. A value of 100 means the normal brightness. If you double that value, then the lights will double the brightness.

    • Light Name: You can name a light source and use this name to refer to the light later.

     

    Directional Lights (Sunlight)

    Sometimes you want the light to only come from one direction. For example, when lights from the Sun arrive on Earth, you can think of them as many parallel light rays going in one direction.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/83b7f9c6-001d-40ff-be0a-023a16fa332e.png" width="600" style="border-radius: 5px; border: 1px solid #29622d;">
    (image source: freepik)

     
    You can use the following block to add a directional light to your scene:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/be9b30eb-e35e-429c-8b2f-13a3f11e6634.png" width="1000" style="">

    • Color: Same as Ambient Light

    • Light Direction: The direction the light ray is pointing to, which is set to the “down direction” by default, with “x = 0, y = 0, z = 1”. Since the light is parallel, the opposite side of the object will not get any light:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/8f8db7de-447c-4c85-8954-6c50cccc9022.gif" width="850" style="margin-left: 40px; border-radius: 5px; border: 1px solid #29622d;">

     

    • Light Origin: You can also specify the origin point of the light source for directional lights. It will not affect the look of objects, but will be used for generating objects’ shadows.

    • Intensity: Same as Ambient Light

    • Light Name: Same as Ambient Light

     

    Point Lights

    A point light is a single point that emits light rays in all directions. Many light sources around us can be treated as point lights, such as a light bulb or a torch:

    You can use the following block to add a point light to your scene:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/de118972-8101-48d0-be39-c97597fa530c.png" width="1000" style="">

    • Color: Same as Ambient Light

    • Light Origin: You can also specify the position of the light source, so all the lights will be emitted from this point in all directions.

    • Intensity: Same as Ambient Light

    • Show Position: Although a point light emits light rays, normally you can not see it in the scene. To help you debug your program, you can set “show position” to “yes” temporarily, which will add a small shining sphere at the light source position. Of course, even when you are not debugging, you still can show this light sphere as part of your scene.

    • Light Name: Same as Ambient Light

     

    Demo

    In this demo, 4 point lights are added to the 4 top corners of the box:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/85b809ee-9c59-43c2-86d8-7a3ccf0eb011.gif" width="800" style="border-radius: 5px; border: 1px solid #29622d;">

     

    Spotlights

    The forth type of light is called “spotlight”. It also emits light rays from a single point. However, just like real-life spotlights, the light rays are limited within a certain direction.

    You can use the following block to add a spotlight to your scene. Note that by default, the direction of the spotlight will be the positive Y axis direction. You can rotate it to point to other directions.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/82fc13fd-a6ee-4daa-b6af-04676cd595dd.png" width="1000" style="">

    • Color: Same as Ambient Light

    • Light Origin: You can also specify the position of the light source, so all the lights will be emitted from this point.

    • Open Angle: This is the number of degrees for the emitting angle of the spotlight, which should be a value between 1 and 179.

    • Intensity: Same as Ambient Light

    • Blur: Justl like real-life lights, the further away you are from the light source, the more blurry the light becomes. You can control that effect using the “blur” parameter.

    • Show Position: When you set “show position” to “yes”, a shining cone will be added to the scene to represent the position and direction of the spotlight.

    • Light Name: Same as Ambient Light

     

    Demo

    In this demo, a spotlight is added right above the box on the Z-axis. It’s open angle is 60 degrees, and it rotates around the Z-axis.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/a1e25ea3-4fde-422a-be3a-906f002572ae.gif" width="1000" style="border-radius: 5px; border: 1px solid #29622d;">

    1 Reply Last reply
    0
    • CreatiCodeI CreatiCode pinned this topic on

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode