Extension update: <3D Sprite>
Changes
Bug Fixes
Fixed Sudden Background Appearance Issue
- Resolved rendering artifacts where backgrounds would suddenly appear or flash during sprite rendering
- Improved depth buffer management with proper
depthWrite,depthTest, anddepthFuncsettings - Added polygon offset (
polygonOffsetFactor: -1,polygonOffsetUnits: -1) to prevent z-fighting between overlapping surfaces - Enhanced alpha testing with
alphaTest: 0.5threshold to eliminate semi-transparent pixel artifacts - Implemented premultiplied alpha blending for cleaner transparency handling
JavaScript Compatibility Fix
- Replaced optional chaining operator (
?.) with traditional null checking for better compatibility with GDevelop's JavaScript runtime - Ensures the extension works across all GDevelop versions without syntax errors
New Features
Advanced Material System
- Double-sided rendering - Sprites now render correctly from both front and back
- Enhanced shadow support - Objects can now cast and receive shadows properly
- Tone mapping integration - Improved color accuracy and lighting response
- Fog support - Sprites properly interact with scene fog effects
- Emissive lighting - Added subtle glow effect with configurable intensity
Dynamic Auto-Rotation System- Velocity-based pitch rotation - Sprites automatically tilt based on vertical movement speed (max 15°)
- Velocity-based yaw rotation - Sprites lean into horizontal movement direction (max 10°)
- Smooth interpolation - All rotations use lerp for fluid, natural motion
- Toggle support - Can be enabled/disabled via
setAutoRotation(bool)
Depth Perspective Effects
- Distance-based scaling - Objects automatically scale down as they move further away
- Height-based scaling - Additional scaling factor based on Y position for enhanced depth perception
- Realistic 3D feel - Creates convincing pseudo-3D perspective in 2D scenes
Dynamic Render Ordering
- Z-position based sorting - Automatic render order calculation using Z and Y coordinates
- Prevents visual layering issues - Ensures sprites render in correct depth order
- Manual depth offset - Additional control via
setDepthOffset(number)method
Enhanced Control Methods
setDepthOffset(offset)- Manually adjust sprite depth positionsetAutoRotation(enabled)- Toggle automatic rotation behavior on/offsetRotationAngle(axis, angle)- Set specific rotation angles on X, Y, or Z axis
Performance Optimizations
- Frustum culling enabled - Off-screen objects are automatically skipped
- Vertex color support - Added vertex color attributes for advanced rendering techniques
- Optimized rotation order - Using YXZ order for more natural sprite orientation
Technical Improvements
- Improved collision mask handling - Better support for custom collision shapes
- Enhanced AABB calculations - More accurate bounding box updates
- Material update optimization - Settings now properly sync on frame changes
- Better shadow rendering - Separated
castShadowandshadowSidecontrols
How to use the new features
Auto Rotation
Enable dynamic tilting based on movement:
sprite3DRenderer.setAutoRotation(true); // Enable (default)
sprite3DRenderer.setAutoRotation(false); // Disable
Manual Rotation
Set specific angles in degrees:
sprite3DRenderer.setRotationAngle('x', 45); // Pitch
sprite3DRenderer.setRotationAngle('y', 30); // Yaw
sprite3DRenderer.setRotationAngle('z', 90); // Roll
Depth Offset
Adjust sprite layering:
sprite3DRenderer.setDepthOffset(10); // Move forward
sprite3DRenderer.setDepthOffset(-10); // Move backward
sprite3DRenderer.setDepthOffset(0); // Reset
Automatic Features
These work automatically with no code needed:
- Depth-based scaling (distant objects appear smaller)
- Shadow casting and receiving
- Improved transparency rendering
- Z-fighting prevention
Checklist
- [x] I've followed all of the best practices.
- [x] I confirm that this extension can be integrated to this GitHub repository, distributed and MIT licensed.
- [x] I am aware that the extension may be updated by anyone, and do not need my explicit consent to do so.
Example file
Extension file
Extension by @Carrotstudio0
You can update the extension on this "Pull Request" by commenting the update command: in the comment field, type !update, then drag and drop a zip file with your extension file in the commenting field, like how you initially submitted the extension. It should look like this:
!update [MyExtension.zip](https://github.com/GDevelopApp/GDevelop-extensions/files/12709661/MyExtension.zip)
It can take a few seconds for the file to fully upload and show as the above. Once it is like shown above, click "Comment" and let the bot do the rest!
@Bouh I have a question because I am new to GitHub. Can you tell me what I should do now? I am a little confused.
@Carrotstudio0 Please take some time to familiarize yourself with GitHub and then answer the comment. Ask an AI if needed to explain you what it is :) This won't be difficult once you are used to it.
Also please rework the description to avoid any description generated by an AI as explain in another post. AI generated descriptions are counter productive.
@Bouh I have made the changes, but I don't know how to send them to you (since my ability to edit is limited). What should I do?
✅ Successfully updated the extension.