Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - lawless_c

Pages: 1 ... 3 4 [5] 6 7
61
Support / Shaders, possible optimization?
« on: September 08, 2014, 03:28:42 pm »
This is just thought i haven't had a chance to try yet.

But i have multiple floats being sent to a shader, at the moment i do them one at a time.
Would it make more sense to simply add all these floats to an array and send them in one setUniform command?

So instead of using

setUniform(String name, float val) ;
setUniform(String name, float val) ;
setUniform(String name, float val) ;
setUniform(String name, float val) ;


I would use setUniform(String name, float[] val) ;

62
Support / Re: Shifting an objects position in shaders
« on: August 28, 2014, 10:56:23 am »
 :) Thanks, i'll try casting them when i get the chance.




I wanted to because i figured if i get this right https://www.youtube.com/watch?v=CGZRHJvJYIg  it will give me much more control. I would only have to use one texture containing the characters, I would be able to use this at various sizes.and things like borders and glow effect on text could be done in the shaders too.

I've already created a factory too that parses the data and creates the strings, my intention was to make it as it's own package and leave on it github for people here to use, improve , fork etc.

63
Support / Re: Shifting an objects position in shaders
« on: August 28, 2014, 02:39:14 am »
I'm taking in the offsets and advance floats that are usually numbers like 48.0 , 52.1 etc
I think i may need to modify to work with "clip space" which seems to be -1.0 to 1.0 (not sure how though)

If you're wondering what it's for im attempting to implement signed distance field fonts. I actually managed to get it working with multiple overlays, one per each character but im trying to do it with a single one now. The repeat rendering sort of works in that it will draw each character in a string, however they all end up in single spot.

The uniforms bottomleftx and bottomlefty are finding where in the texture a character is before it's rendered(this works) though some characters end up being skewed
as the overlay dimensions don't match the character.

Code: [Select]
   @Override
   public boolean repeatRendering() {
      renderingIndex++;
     
      if(renderingIndex < charactersList.length && renderingIndex > 0)
      {
         
      advances = advances + charactersList[renderingIndex].advanceX;
   
     
      Overlayshader_.setUniform("a_colour",new SimpleVector(1,(renderingIndex*0.1f),0));
      Overlayshader_.setUniform("bottomLeftx",charactersList[renderingIndex].bottomLeftx);
      Overlayshader_.setUniform("bottomLefty", charactersList[renderingIndex].bottomLefty);   
      Overlayshader_.setUniform("width",charactersList[renderingIndex].width);
      Overlayshader_.setUniform("height",charactersList[renderingIndex].height);
     
      Overlayshader_.setUniform("offestx",renderingIndex);
      Overlayshader_.setUniform("offesty",0);
     
     
      return true;
      }
     
     
     
      setUpOverlayStart();
      renderingIndex=0;
      advances=0;
      return false;
   }


This is an example show three different strings i've added, the bottom one demonstrates a single character string a skewed zero.





And my vertex shader code


Code: [Select]

precision highp float;
// VERTEX SHADER


uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;

uniform float bottomLeftx;
uniform float bottomLefty;

uniform float width;
uniform float height;
uniform vec3 a_colour;

uniform float offsetx;
uniform float offsety;

attribute vec2 texture0;
attribute vec4 position;



varying vec4 v_color;
varying vec2 v_texCoord;

void main()
{
v_color = vec4(a_colour.x,a_colour.y,a_colour.z,1.0);

v_texCoord.x = bottomLeftx + (texture0.x/width);
v_texCoord.y = bottomLefty + (texture0.y/height);


vec4 newpos = vec4(offsetx,offsety,0,0);

gl_Position = projectionMatrix*((modelViewMatrix  * position) +newpos);

}

64
Support / Re: Shifting an objects position in shaders
« on: August 27, 2014, 01:55:42 am »
Actually is it possible to update gl_position in repeatRendering()for a renderhook?? or even an Overlays coordinates? I cant seem to change these past when they are first set.

65
Support / Re: Shifting an objects position in shaders
« on: August 22, 2014, 02:32:23 pm »
I'll give that a shot, would gl_FragCoord work too? maybe if i altered that instead of naively thinking i could alter gl_position.

66
Support / Shifting an objects position in shaders
« on: August 22, 2014, 01:08:14 pm »
Is it possible to shift the position of pixels being drawn in JPCT? im trying to render something and im using IRenderHooks repeatRendering method with an overlay and i want to shift it to the right on each rendering.

I've tried changing the overlay position itself in the repeatRendering method , that doesn't work however because of the way rendering all those objects remain in the same place.

The only way i can think is perhaps with pixel shaders, which i dont believe JPCT supports.


edit:  I may be misunderstanding how the shaders work but so far attempts to sue gl_position to shift the position of where i want a pixel to appear have failed.

67
What is it doing?

68
Support / Re: Can shaders be applied to textures?
« on: June 19, 2014, 02:30:58 am »
I'll give that shot , if I find something that works I'll report back what I got working here.

70
Support / Can shaders be applied to textures?
« on: June 16, 2014, 11:24:28 pm »
I wanted to know this as id like to know if i't possible to apply shaders to textures such as for a UI, or something that will get placed on the framebuffer. The only way i can currently think of doing this might be to apply it to a flat mesh and have against the camera.

71
Support / Re: Multiple shared shaders
« on: June 03, 2014, 01:06:46 am »
oh yes  ;D ;D ;D ;D

For some silly reason i thought IrenderHook could only be implemented with via a shader object.

It works perfectly now with the IrenderHook implemented by entities themselves. (hopefully this wont bite in the ass later but it seems to work  ;D)

72
Support / Re: Multiple shared shaders
« on: June 01, 2014, 04:22:51 pm »
How exactly is this used?

hmm http://www.jpct.net/wiki/index.php/Shaders looking at the example here it may not work for me.
Would their be a way to call the uniforms i need to set before each rendering?
The only way i can think of doing this for now is to add some sort of list/vector to the class that holds the set uniforms for each object as they are updated.
and gets called and iterated through during the rendering.

73
Support / Multiple shared shaders
« on: May 15, 2014, 10:56:02 pm »
Is there a way to quickly copy or share GLSLShader objects. I incorrectly assumed that using one shader among many objects would be ok but ive only just copped it that you need a shader for every instance, otherwise the uniforms will be set to those of the very last item updated before rendering.

74
Support / Re: Scale many objects together
« on: April 25, 2014, 04:04:08 pm »
okay i think i have it.

Consider scaling as a percentage.
get the offset of each object from the centre object and divide by 100.
multiply that answer by the percentage change in scale.
Add that answer to the position of the object.

75
I think you want the invert function for Object3d?

http://www.jpct.net/doc/com/threed/jpct/Object3D.html#invert()

Pages: 1 ... 3 4 [5] 6 7