Tchom

Members
  • Content count

    20
  • Joined

  • Last visited

  1. Day-night cycle colors

    Awesome. Thanks bid
  2. Day-night cycle colors

    I'm working on a 2d farming rpg and I've written a shader that tints the scene based on that time of day it is in the game. What I'm trying to work out is what RGB values should correspond to what time of day. Does anyone have any ideas or references?
  3. What Language Do I Use?

    FlashDevelop is an extemely useful and free editor for AS3 development (with rad code-hinting)
  4. The two languages aren't really comparable in that  way. AS3 is a high-level language, with very abstracted graphics drawing. If you're after a gentle transition from AS3 to something else, I'd suggest Java over C++ as its more similar (though, probably not quite as useful in the long run) and OpenGL. If you have an Android device, Java and OpenGL ES is a lot of  fun to learn. I'd also suggest OpenGL ES2 over OpenGl 1.x as well, because its almost the same standard as WebGL and writing your own shaders is a useful life-skill. I'm sure what I just said is probably a  lot to  take in, but just do some research  into the things I just mentioned and it might help you decide where to go next. I've been a Flash programmer for a couple of years and have been transitioning to other languages to make games and this was a comfortable road for me. Of course, if you're just trying to make a game as quickly as you can, Unity is a pretty neat engine with a lot in common with Flash.
  5.     Yeah, I worked that out with some experimentation .   Is there a more typical way to colour light?
  6. I implemented those suggestions and that helped heaps. I had my own brainwave (slapped myself for not thinking of it before), and added a limit to the distance from the light that attenuation and colour would be calculated at.   if(distance < limit) { diffuseDiff = clamp(dot(v_Normal, lightVector), 0.0, 1.0); diffuseDiff = diffuseDiff * (1.0 / (1.0 + (u_LightPower[i]* distanceSquared))); gl_FragColor.rgb *= vec3(1.0) / ((vec3(1.0) + ((vec3(1.0) - u_LightColours[i])*diffuseDiff))); } Hopefully that might help someone else
  7.   Oops, sorry about the confusion. I come from a Flash background, so I'm stuck in the habit of using FPS as a measurement of efficiency (I'll get better). My original and target speed was 16.6ms per frame, but it increase to 22.ms after three light, 33.3ms after four, etc etc.   What's the theory behind this line? Is it necessary?   This line determines how much to tint the fragment's rgb by each light's rgb. If 'diffuseDiff' is 0, then gl_FragColor.rgb would just be multiplied by vec3(1.0). If 'diffuseDiff' is 1, gl_FragColor.rgb is multiplied by the full value of vec3(u_LightColours[i]).   Thanks heaps guys. I'll try implementing this when I get home from work and report back on the difference. I really appreciate the help.
  8. Hey devs!   I've been working on a OpenGL ES 2.0 android engine and I have begun implementing some simple (point) lighting. I had something fairly simple working, so I tried to get fancy and added color-tinting light. And it works great... with only one or two lights. Any more than that, the application drops about 15 frames per light added (my ideal is at least 4 or 5). I know implementing lighting is expensive, I just didn't think it was that expensive. I'm fairly new to the world of OpenGL and GLSL, so there is a good chance I've written some crappy shader code. If anyone had any feedback or tips on how I can optimize this code, please let me know.   Vertex Shader uniform mat4 u_MVPMatrix; uniform mat4 u_MVMatrix; attribute vec4 a_Position; attribute vec3 a_Normal; attribute vec2 a_TexCoordinate; varying vec3 v_Position; varying vec3 v_Normal; varying vec2 v_TexCoordinate; void main() { v_Position = vec3(u_MVMatrix * a_Position); v_TexCoordinate = a_TexCoordinate; v_Normal = vec3(u_MVMatrix * vec4(a_Normal, 0.0)); gl_Position = u_MVPMatrix * a_Position; } Fragment Shader precision mediump float; uniform vec4 u_LightPos["+numLights+"]; uniform vec4 u_LightColours["+numLights+"]; uniform float u_LightPower["+numLights+"]; uniform sampler2D u_Texture; varying vec3 v_Position; varying vec3 v_Normal; varying vec2 v_TexCoordinate; void main() { gl_FragColor = (texture2D(u_Texture, v_TexCoordinate)); float diffuse = 0.0; vec4 colourSum = vec4(1.0); for (int i = 0; i < "+numLights+"; i++) { vec3 toPointLight = vec3(u_LightPos[i]); float distance = length(toPointLight - v_Position); vec3 lightVector = normalize(toPointLight - v_Position); float diffuseDiff = 0.0; // The diffuse difference contributed from current light diffuseDiff = max(dot(v_Normal, lightVector), 0.0); diffuseDiff = diffuseDiff * (1.0 / (1.0 + ((1.0-u_LightPower[i])* distance * distance))); //Determine attenuatio diffuse += diffuseDiff; gl_FragColor.rgb *= vec3(1.0) / ((vec3(1.0) + ((vec3(1.0) - vec3(u_LightColours[i]))*diffuseDiff))); //The expensive part } diffuse += 0.1; //Add ambient light gl_FragColor.rgb *= diffuse; } Am I making any rookie mistakes? Or am I just being unrealistic about what I can do? Thanks in advance
  9. Is it null when you pass it into the renderer? Or just after you call Render()?   It may be you're trying to render before the bitmap is finished loading. Try:   package { //import stuff public class Renderer { var mBitmapData:BitmapData; var mPoint:Point ; var mRect:Rectangle ; var mDisplayBD:BitmapData; public function Renderer(bitmapdata) { mBitmapData = bitmapdata; this.mDisplayBD = bitmapdata; mPoint = new Point(); mRect = new Rectangle(); mPoint.x = 0; mPoint.y = 0; } public function LoadBitmap(URL:String) { var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, OnComplete); loader.load(new URLRequest(URL)); } private function OnComplete(event:Event) { mBitmapData = event.target.content.bitmapData; } public function Render(posX,posY,clipX,clipY,width,height) { if(mBitmapData != null){ mDisplayBD.lock(); mPoint.x = posX; mPoint.y = posY; mRect.x = clipX; mRect.y = clipY; mRect.width = width; mRect.height = height; mDisplayBD.copyPixels(mBitmapData,mRect,mPoint); mDisplayBD.unlock(); } } } }
  10. I'd use a 3d-engine with orthographic projection. 
  11. I think class variables in AS3 are internal  by default.    have you tried:   public class Entity extends Sprite { protected var mPosX:Number; protected var mPosY:Number; public var renderer:Renderer; or use a getter function public class Entity extends Sprite { protected var mPosX:Number; protected var mPosY:Number; protected var mRenderer:Renderer; public function Entity():void{ ... } public function get renderer():Renderer{ return mRenderer; }         :
  12. @L.Spiro   Thank you! Great answer and a super helpful link! I really appreciate it!
  13. Hey guys, I looking for some advice/insights into render batching. I've been building my own game engine for Android (OpenGL ES 2.0) and at the moment, I feel like I am handling my game object rendering very inefficiently.   Currently, I have GameObjects that have are stored in a list in a GameWorld. GameObjects have a reference to a texture and a mesh. At the moment, all I do is loop through the GameObjects in my renderer, binding textures and unbinding them object by object. My understanding is that binding is quite an expensive process. So, I guess my question is... does anyone have an elegant way to handle this?   Some of the ideas I had were:   - Sort the GameObjects list on the texture id (possibly also expensive to do) so that objects with the same texture render together - Instead of an array with everything in it,  GameObjects of the same type are kept in their own arrays, and each one of those is looped through with only one 'bind' call required per group.   I hope I was clear enough to create some idea of where I'm at and what I'm trying to do, I can't wait to hear your feedback.
  14. New to Coding - Strategy Game

    For a browser based game, I'd suggest coding with Javascript/HTML5. There is a very strong course on Udacty (which is also free), that can teach you most of the stuff you'll need to know code-wise.