Creating spotlight shader in Cocos2d-x 3.0


I’ve been working on a game project with Cocos2d-x 3.0. From time to time as I’m searching for documentation I can’t find any clear examples of how thing x works. So for now I decided to write simple samples/tutorials for such topics. The first one will be creating light shader for a dark scene.

Instead of going through the code line by line here, I will publish all the examples to Github with comments. Example of light shader can be found here:


10 thoughts on “Creating spotlight shader in Cocos2d-x 3.0

  1. Hey! Thanks for the Code, but I think it is much more helpful to have a full tutorial on that. I wanted to create a spotlight in my game, which always is centred on the player. I can’t get it to work. For once the position is off and the shader doesn’t darken the screen – it makes it yellow. I think I don’t fully understand the code. It would be really could if you consider creating a full tutorial.


    1. Hi! thanks for the feedback. At first I thought about writing a full tutorial on this, but then I was lazy and just tried to comment the code enough. I will consider writing more lengthy tutorial in future.

      Hard to say what’s wrong with your code from the description. If you could share it somehow I could take a look.

Leave a Reply

Your email address will not be published. Required fields are marked *

Begin typing your search term above and press enter to search. Press ESC to cancel.