6
2015
Doom Style Billboard Shader
Testing Doom style billboard shader, where you can look sprite from different angles, still not completely finished but enough for testing..
* Note: I have no idea how the doom billboards work, just looking for similar style
Related forum post: http://forum.unity3d.com/threads/relative-position-for-changing-2d-graphics-in-3d-environment.307086/
WebGL player:
*coming later*
Sources:
* Shader still has few problems (like overlapping other billboards, could be optimized/cleaned up etc), feel free to post improvements here or to github
* Unity 5.1 used
https://github.com/unitycoder/DoomStyleBillboardTest
—
Updates:
– 08.09.2015: Added animated frames test
—
Resources:
– Getting viewdir in shader: http://forum.unity3d.com/threads/viewdir-up-vector.173549/
– Should actually check how they do it in Unity Daggerfall : http://www.dfworkshop.net/?cat=17
—
Image#2: Dynamic batching seems to work
Related Posts
23 Comments + Add Comment
Leave a comment
Recent posts
- MotionVector Effect: Object “disappears” when paused
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
Recent Comments
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
Just wondering, why not solve this with a script?
Script properties:
List of [ AngleRange -> Sprite ]
Main Camera (camera to compare the “Forward” of with the object’s forward
The script checks the angle between the camera’s forward and the object’s forward, and decides which sprite to use
~120 to -120 = Front (both objects are facing each other)
cam=> /|\ obj
~ -120 to -60 = Side (left)
cam=> \|/ obj
-60 -> 60 = Rear
cam=> obj=>
That way we can even define much more refined angles (4, directions, 8 directions, 12 directions, etc..)
Yes, that would work nicely, just wanted to try it inside shader 🙂 and it should be faster with shader, if you have lots of objects
Thanks for the reply 🙂
A shader is pretty cool indeed
Hi,
we are interested in a fully working shader version of this: http://unitycoder.com/blog/2015/04/06/doom-style-billboard-shader/
Also animation etc. would be important.
Are you interested in this aswell and can we support you in any way (with a donation or soemthing like this)?
Thank you.
Regards
André
..You could donate extra ~2hrs per day, thx 🙂
I do plan to update this more, but just no time yet..
If anyone has ideas for anim support etc. do post here, even if its just reference links.
Also, should check daggerfal & all those doom port shaders how they do it.
One basic way to play “idle” animations per direction could be placing the frames below (in Y direction) and then display those frames at given speed..
notch’ doom sprite shader:
https://github.com/xNotch/dark/tree/master/web/shader
Hey mGear I’ve been looking into making some doom styled billboard enemies in my game I’ve been looking at many options and from what I can tell using a shader would be best for performance related issues.
However I’ve never experimented or played with making shaders before. Can this be used to make animated enemies or does it just only work for objects?
I will of course not wait on your answer alone to figure this out, but just wondering if you have any recommendations for where I should go to learn more about making shaders/shaders for unity/improving on this shader.
I would first look how its done in that unity daggerfall package, since they seem to have animated billboard enemies.
I think theres also some package in asset store for doom style sprites, cant remember the name though..
Billboard Shader
“Includes a powerful geometry shader billboard system for rendering vast forests of retro-styled trees and other billboards. It even supports animated billboards like animals and flickering torches.”
http://www.dfworkshop.net/daggerfall-tools-for-unity/features/
Not sure if you check this anymore but I will try. I’m trying to achieve this same thing as you do with the difference that I just need the billboard in shader, the rest I do trough a custom animation system.
I wanted to ask if your shader is batched correctly when more than 1 of the same sprites are on screen or if every single new sprite will generate a new drawcall.
I have beeen trying to solve this problem by ages and I would like to keep batching while having the billboard on a shader isntead of forcing things by script, which can be performance demanding with too mcuh stuff on screen.
Thanks for your time.
Yes, it seems to batch with [x] Dynamic Batching enabled.
tested just by duplicating the example billboard multiple times:
http://unitycoder.com/blog/wp-content/uploads/2015/04/doomspritebatching1.jpg
Then thiss is perfect. Would you mind If I adapt your shader to work with Unity SpriteRenderer?
One note, it seems in Deferred the dynamic batching is broken, not sure if is a unity 5 thing or has anything to do with the shader.
yeah go ahead. hmm.. yes batching seems to work only in Forward, would be nice to know why.
tried:
– Disable transparency from shader
– Disable shadows and light
– Set object scale to 1,1,1
– Decrease Quality settings
– Disabling most of the code from shader
– Setting renderqueue : http://www.scrapsgame.com/scraps-performance-draw-call-batching/
– DX11/DX9
Checking Daggerfall tools to see what they did to batch in deferred, honestly there is stuff there I never saw, it will be a trial and error work.
added animated frames test to github
Fixed several issues and added optimized shaders, see latest version here:
https://github.com/unitycoder/DoomStyleBillboardTest
Hello, I tried the project with the newest Unity, and I got this problem.
http://s785.photobucket.com/user/razor21xyz/media/braerbeab.png.html
I am not sure what caused it, any clues how to fix?
Tested with 5.4b24, didn’t have the same problem.. maybe you can export unitypackage for testing.
I managed to fix this by a simple re-importing, thanks!
Is there a further plan to improve this system?
I rotated the front facing of the object, and it didn’t change the sprite’s view in relation to the object’s facing, which I find quite weird.
And animation is currently very complicated to do, as there is no dynamic way to figure out how many frames do you have for each animation.
For example, attack have 12 frames, and death have 6 frames.
I hope this project will get more love and practical implementation method!
Yes, definitely want to improve it, just no time at the moment. Also adding the new 5.4 instancing support would be great, if want to have hundreds of sprites.. feel free to post issues/requests here also, so they will stay noticed: https://github.com/unitycoder/DoomStyleBillboardTest/issues
Can I open up a link to this blog post in the Unity forums?
It might be a good idea as it will open up a whole new possible range of solutions from the community.
For example, this thread gain a huge popularity, and is now the best open source node editor solution out there, with a lot of contributors.
http://forum.unity3d.com/threads/simple-node-editor.189230/
https://github.com/Baste-RainGames/Node_Editor
I wanted to see this project into a success, people interested in the same result might work better when rallied into one project.
More examples of people looking for the same results :
This one have a working animation solution
https://www.youtube.com/watch?v=SlAmrJUAcIk
This one have a working object facing solution
https://www.youtube.com/watch?v=WwwjTPA03R4
Others
https://www.youtube.com/watch?v=9ki2p8fk1HM
https://www.youtube.com/watch?v=PF0Yx_Z-SSc
yes go ahead posting it