I’m trying to get a shader work. But alpha value is not applied despite I set the value to 0 (or any other value). There probably some setting (blend setting?) that I need to enable but could not find where I can do it so I would appreciate it if. I can show it with this minimal code
Thank you for the answer. But, I have already seen it, just could not figure out where or how to apply it. Do I modify the builtin renderer?
I’m relatively new to Defold so there are many things I’m unfamiliar with. I can handle game logic part but shaders are a mystery to me so I’d appreciate if you could give some tips on it
You can’t modify things inside the built-ins. You need to make your own copy of anything you need from them and place it outside the built-ins. In your case, make a copy of the renderer folder. Then, go to game.project > Bootstrap > Render and set it to the new copy of default.render. Also, modify your default.render to reference the new default.render_script. Once you do that, you’ll be ready to use what @selimanac mentioned inside your own default.render_script.
Yes, you have to modify the builtin renderer.
Copy, paste the build-in .render_script and .render to your project folder and set it .
You can place your model predicated after the sprites, tilemaps section.
Something like this:
(You might want to use graphics.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA instead of BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA)
-- render the other components: sprites, tilemaps, particles etc
--
render.enable_state(graphics.STATE_BLEND)
render.draw(predicates.tile, draw_options_world)
render.draw(predicates.particle)
--render.disable_state(graphics.STATE_DEPTH_TEST)
-- render last
render.set_blend_func(graphics.BLEND_FACTOR_SRC_ALPHA, graphics.BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA) -- <- You might want to use graphics.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
render.draw(predicates.model_transparent, draw_options_world) -- <- model_transparent predicated
render.disable_state(graphics.STATE_DEPTH_TEST)
Edit: You can set predicates in the init() function of the render script. Also, don’t forget to set the TAG to model_transparent in the .material file of the model.
It worked! Thank you so much. I wish there would be an easier way of doing thing with Defold, but at least its community makes things easier for newcomers