• Activity
  • Votes
  • Comments
  • New
  • All activity
  • Showing only topics in ~comp with the tag "beginners". Back to normal view / Search all groups
    1. Godot beginners: Here's how to fade in a 3D mesh

      I'm still a beginner at Godot. I've been playing with Godot and 3D scenes. It's great finally feeling comfortable enough to navigate the UI from watching the tutorials from Zenva/Humble Bundle....

      I'm still a beginner at Godot. I've been playing with Godot and 3D scenes. It's great finally feeling comfortable enough to navigate the UI from watching the tutorials from Zenva/Humble Bundle.

      Recently something that sounds straightforward took a long time for me to figure out: Fading in a 3D mesh. The solution is simple:

      @onready var mesh: MeshInstance3D = find_child("body-mesh")
      
      func _ready() -> void:
      	_set_material_alpha(0)
      	SomeSingleton.some_signal.connect(_fade_in)
      
      func _set_material_alpha(alpha: float) -> void:
      	var material: Material = mesh.get_active_material(0)
      	if material is StandardMaterial3D:
      		material.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA_DEPTH_PRE_PASS
      		material.depth_draw_mode = BaseMaterial3D.DEPTH_DRAW_ALWAYS
      		material.albedo_color.a = alpha
      
      func _fade_in() -> void:
      	var tween = create_tween()
      	tween.set_ease(Tween.EASE_IN)
      	tween.tween_method(_set_material_alpha, 0.0, 1.0, fade_in_duration_seconds)
      

      The key being setting the material properties and using its albedo color to update transparency. The depth draw mode is needed, otherwise the result is ugly with jagged pixels during the tween.

      Getting to the solution was the hard part. Searching forum posts I was led down some rabbit holes like using shaders—overkill for this situation. (There is a cool site though, for when I do end up needing custom shaders: https://godotshaders.com/.) Asking an LLM also didn't help much, probably because my prompt was wrong. I tried again just now and it gave me something closer to a correct solution, but missing some parts like the depth draw mode, which (by trial-and-error and reading the docs) I found is necessary for a good quality render, when using transparency.

      Another small pitfall I found was that trying to change the material.transparency caused stutter. I was trying to disable transparency when the mesh was at 100% alpha, since I figured opaque rendering is cheaper. However I speculate the engine recompiles the shader when I turn off transparency, which causes the stutter. So I don't modify the material.transparency beyond that initial setting.

      Also thought I'd mention, I'm using free placeholder art assets from https://kenney.nl/ - an amazing resource.

      Aside: Shaders

      During this I learned that adding shaders to an imported 3D model in Godot is somewhat convoluted:

      1. Import the .glb model
      2. Clone the auto-created scene to an inherited scene, because I'm not allowed to directly edit that auto-created scene
      3. Extract the material (UV colormap image) from the .glb by double-clicking it in the FileSystem tab
      4. Apply the extracted material to the mesh under Surface Material Override
      5. Add a "Next Pass" material, a ShaderMaterial, to that surface material override
      6. Create the shader script
      7. Pass in parameter values from the GDScript to the shader script using code like: shader_material.set_shader_parameter("color", Color(1.0, 1.0, 1.0, alpha))

      This didn't work so well for me though, because the shader I was using was changing the ALBEDO and turning things white. If I knew anything about 3D programming I'd probably find a way to update the existing color value at each pixel, instead of setting albedo white everywhere. The end result of the shader I was using was that the models were turning too white. So that was a dead end.

      Anyway mainly leaving this here as reference for posterity. Feel free to share a story or constructive feedback if there's anything.

      21 votes
    2. How hard would it be to learn to code a Discord bot?

      I've got a notion to put some of my extra energy into learning to code. I'm familiar with EXTREME basics - I did some coding in BASIC and Python when I was younger ("Hello world" type stuff, and...

      I've got a notion to put some of my extra energy into learning to code. I'm familiar with EXTREME basics - I did some coding in BASIC and Python when I was younger ("Hello world" type stuff, and some futzing around with my Ti calculators programming capabilities) and while I had a pretty good knack for it I never developed it further.

      I'd like to use this as a chance to create something useful for me - a discord bot for my server. We have a handful of bots doing a few odds and ends, and I'd like to try and work something out to consolidate things. That's getting a bit ahead of myself though - initial scope would be simple: have the bot do a simple task like counting +rep points, or something silly like telling a joke.

      I don't really have any idea of where to start - what resources I need, what language to use, or really anything about how this all works. Any assistance at all would be welcome!


      To be clear - I want to learn to code, and specifically I want to learn in a way where it is immediately applicable and useful in a context I care about.

      20 votes
    3. Python challenges or projects with just the standard library?

      I've been slowly learning python for some months already. I used the Python Crash Course book from No Starch Press, it teaches the basics and then goes on with some projects with pygame,...

      I've been slowly learning python for some months already. I used the Python Crash Course book from No Starch Press, it teaches the basics and then goes on with some projects with pygame, matplotlib, etc.

      However, I feel that my Python skills aren't very good yet, and before learning to use libraries I would like to have a better command of the standard library.

      I have been looking for some book with projects or, even better, challenges using just the standard library, but haven't found any good ones. Most of them either are for absolute beginners, or use additional libraries, or are very technical and without focus on practice.

      Do you know of any good book or resource with challenges or projects that don't depend on additional libraries? Or, do you have any idea for a project or challenge using just the standard library?

      Thanks in advance!

      14 votes