Hi there and thanks for the reply. <br><br>I think that your approach is very alike to what I want to achieve here but... I've got variable backgrounds and tile textures, actually. <br><br>So I can not color-mask those out ( it will require too much of uniforms or a fixed pallete within my assets ).<br><br>But the basic idea is the same, yes. <br><br>Thats why I'm thinking of creating a framebuffer with a bw mask in it - like it would be possible in a normal OpenGL application, for example. <br><br>Such technique would allow to get rid of the color variations inside the tiles.<br><br>And only then I'll be able to apply the same logic as you have prestented in your colormasking shader.<br>
Ssyskrank
- Mar 19, 2021
- Joined Aug 17, 2016
- 0 best answers
Hello everyone.<br><br>I want to do something like this [ open spoiler ]:<br><br>
<img title="Image: http://s22.postimg.org/cts0om77l/final.png" alt="" src="http://s22.postimg.org/cts0om77l/final.png"><br>
<br>where level geometry is on the left, and the desired effect is on the right<br><br>So AFAIK I need to setup some texture buffer and shader for the "splatter" thing:<br><br>1) render my visible geometry ( TileMap ) to specific framebuffer as bw mask<br>2) then render the game level normally<br>3) use prev. created framebuffer to do some simple math in shaders to achieve "overlay" effect with decals.<br><br>Is that possible?<br><br>P.S. <br>Maybe it's a general shader question, but I'll post into 2D because I'm dealing with orthogonal stuff.<br><br>
Just to confirm: I'veI tried to export the 3D platformer example project with all the default settings. Some textures are missing on my device too.
Hi again to everyone :)<br><br>To not to break the establishing tradition of self-answering... I've found the solution to the aforementioned problem :)<br><br>While looking into adb logcat I've stumbled across the following things:<br><br>
I/godot ( 419): ERROR: 0:124:5 color containing two consecutive underscores () is reserved as possible future keyword.<br>I/godot ( 419): ERROR: 0:125:5 bw_mult containing two consecutive underscores () is reserved as possible future keyword.<br>I/godot ( 419): ERROR: 0:126:1 bw_mult containing two consecutive underscores () is reserved as possible future keyword.<br>I/godot ( 419): ERROR: 0:127:1 color containing two consecutive underscores () is reserved as possible future keyword.<br>I/godot ( 419): ERROR: 0:128:17 color containing two consecutive underscores () is reserved as possible future keyword.<br>I/godot ( 419): ERROR: 0:128:30 bw_mult containing two consecutive underscores () is reserved as possible future keyword.<br>I/godot ( 419): ERROR: 6 compilation errors. No code generated.<br>Which are the shader compilation errors. Strange thing that I didn't use the two consecutive underscores, but I guess the names of the variables ( both local scope and uniform ) where the cause of all the mess.<br><br>After renaming 'tex' to 'textureColor' and 'bw_mult' to 'modulate' ( and so on ), I've managed to get shaders work on Android.<br><br>P.S.<br>Btw, anyone knows what is the purpose of the 'Use driver GLES2' option within the project settings? It seems that GLES2 is used anyway, regardless to the checkbox state.
Hi everyone.
<br>
I'm making a 2D platformer and quite fascinated with what Godot engine is capable of.
<br>But now I'm on a struggle bus with some shading issues.
<br>
On desktop my 2D shaders seems to work quite well.
<br>
However, when I'm running my game on Android device they are gone.
<br>
I'm receiving the following messages from ADB whenever my shader should activate itself:
<br>I/godot (13606): ERROR: set_custom_uniform: Index p_idx out of size (version->custom_uniform_locations.size()).<br>I/godot (13606): At: ./drivers/gles2/shader_gles2.h:329.<br>I/godot (13606): ERROR: set_custom_uniform: Index p_idx out of size (version->custom_uniform_locations.size()).<br>I/godot (13606): At: ./drivers/gles2/shader_gles2.h:329.<br>I/godot (13606): ERROR: get_custom_uniform_location: Index p_idx out of size (version->custom_uniform_locations.size()).<br>I/godot (13606): At: ./drivers/gles2/shader_gles2.h:336.<br>V/AudioTrack(13606): obtainBuffer(1536) returned 1536 = 1536 + 0 err 0<br>V/AudioTrack(13606): obtainBuffer(1024) returned 1024 = 1024 + 0 err 0<br>I/godot (13606): ERROR: set_custom_uniform: Index p_idx out of size (version->custom_uniform_locations.size()).<br>I/godot (13606): At: ./drivers/gles2/shader_gles2.h:329.<br>I/godot (13606): ERROR: set_custom_uniform: Index p_idx out of size (version->custom_uniform_locations.size()).<br>I/godot (13606): At: ./drivers/gles2/shader_gles2.h:329.<br>I/godot (13606): ERROR: get_custom_uniform_location: Index p_idx out of size (version->custom_uniform_locations.size()).<br>I/godot (13606): At: ./drivers/gles2/shader_gles2.h:336.<br>
All shaders are implemented within materials for the TextureFrame nodes.
<br>
Here's the example of one that doesn't work:
<br>// this is a simple texture-based Vignette modulated shader<br>uniform texture vignette;<br>uniform float lightness;<br>uniform vec3 modulate;<br>vec3 screen = texscreen( SCREEN_UV ).rgb;<br>vec4 tex = tex(vignette, UV) lightness;<br>// combine final color<br>color res = color( tex.r, tex.g, tex.b, tex.a);<br>res.rgb = mix( res.rgb, _screen.rgb, lightness );<br>res.rgb = modulate;<br>COLOR = res;<br>
<br>
I've found the cause and the solution. <br><br>The platform/character "vibration" is caused by move() function, which can not translate the physical body through the other one. So the platform goes up, bumps into the character, stops there, character goes up, platform catches up and so on. <br><br>So, to remove this effect, we should follow these few steps:<br><br>1) Move platforms with velocity, not with animation ( yeah, not so neat, but you could expand the idea by path following and LERP ); <br><br>2) Keep track of the platform inside the character script ( register/unregister platform the character contacted with ), so you could do something like this:<br><br>var p_vel = platform.velocity<br><br>3) Apply gravity to the character only when it is in the air ( do not apply gravity when character is on the ground OR on the platform )<br><br>
4) If character is on the platform - reset vertical velocity to zero ( this is important )<br><br>5) After character's force was integrated and velocity with motion were updated - move character with the tracked platform. Simple like this:<br><br>
# move with platform
if ( null != platform ):
move ( platform.velocity * delta )<br>
Hello.<br><br>
I'm making a platformer game and utilizing the KinematicBody2D as a base for my character controller.
<br>
The problem is that when character is on the moving platform, the whole thing jitters.
<br>
I mean that when the platform is moving up, character makes micro-jumps or just having tiny moments of free flight.
Same thing goes for the downward movement, but the gaps between the character and kinematic platform are much bigger.
<br>
Platform is moved by animation from the level scene ( as it is in the demos ).
<br>
I'm pretty much following the KinematicCharacter tutorial & demo but with a few changes.
<br>
Also, I'm using Area2D to create a "feet" of my character to precisely determine ( and count ) ground contacts and can't get rid of collisions between the character and it's Area2D.
<br>
The structure is:<br><br> <img alt="" src="https://s4.postimg.org/i3o7w5xdp/char_struct_screenshot.png" title="Image: https://s4.postimg.org/i3o7w5xdp/char_struct_screenshot.png"><br><br>My code for the character.<br><br>
<p>Console output:</p><p><img src="https://s4.postimg.org/fnszu8899/char_collision_output.png" alt=""><br></p><p>I believe that the solution for removing the jitter may reside in somehow "attaching" the character to the moving platform, but the "floor_velocity" approach from the demos doesn't work quite well ( jitter persists ).</p>