Jump to content

Kamjam66xx

Member
  • Posts

    117
  • Joined

  • Last visited

Everything posted by Kamjam66xx

  1. Yee i think thats a bad route. Not only is there more competition, but there is little pay compared to other fields. If you want to be in the games industry and make good money, i recommend graphics programming. But you MUST take multivariate calculus and other math seriously.
  2. Does anyone have ImGui 1.69 working with font showing up in their openGL project? The default font isnt working for me and i cant seem to load fonts. Ive checked them and still trouble shooting. If anyone has a project with it that i can peak, id really appreciate it. Edit: i can load fonts, i check them and they arent null. I cant push fonts.
  3. @Unimportant Thanks! I really appreciate that. I definitely got my work cut out for me. But it pays off to make sure things are done right. Especially considering the functionality ill be adding in the future. Its a learning process. Ive been programming for like 6 months, and wasted a lot of time learning java, python, etc. Im trying to progress and specialize as fast as i can now! I actually didnt know you could get the pointer to the member char* via "std::string::c_str"
  4. Im working on a render engine and eventually a complete game engine. I put my project on github, and im ready for a code review if anyone wants to give me input! ? Thanks in advance https://github.com/Kamjam21xx/KameronsRenderEngine/tree/master/src/OpenGlCourseApp
  5. Hello, are there any fellow graphics programmers? i use openGL. im only asking because if not, i just wont ask for help with GP problems in here.
  6. Hello i really need help getting my lighting into tangent space to work with my shadows and all that. its straight up phong, not blinn-phong. im really confused, because my code does not reflect any tutorial since ive been trying to take the hard route. im completely for what to do. can anyone help? here are my shaders. you can ignore the messy parts. my phong lighting is neatly packed into functions. you can ignore the if statement at the end too. please help! Vertex Shader #version 330 layout (location = 0) in vec3 pos; layout (location = 1) in vec2 tex; layout (location = 2) in vec3 norm; layout (location = 3) in vec3 tang; layout (location = 4) in vec3 bitang; out vec2 TexCoord; out vec3 normal; out vec3 FragPos; out vec4 DirectionalLightSpacePos; out vec3 nTangent; out vec3 nBitangent uniform mat4 model; uniform mat4 projection; uniform mat4 view; uniform mat4 directionalLightTransform; void main() { gl_Position = projection * view * model * vec4(pos, 1.0f); DirectionalLightSpacePos = directionalLightTransform * model * vec4(pos, 1.0); TexCoord = tex; FragPos = (model * vec4(pos, 1.0f)).xyz; normal = norm; nTangent = tang; nBitangent = bitang; // normal = mat3(transpose(inverse(model))) * norm; } Fragment Shader #version 330 in vec2 TexCoord; in vec3 normal; in vec3 FragPos; in vec4 DirectionalLightSpacePos; in vec3 nTangent; in vec3 nBitangent; out vec4 colour; const int MAX_POINT_LIGHTS = 3; const int MAX_SPOT_LIGHTS = 3; struct Light { vec3 colour; float ambientIntensity; float diffuseIntensity; }; struct DirectionalLight { Light base; vec3 direction; }; struct PointLight { Light base; vec3 position; float constant; float linear; float exponent; }; struct SpotLight { PointLight base; vec3 direction; float edge; }; struct OmniShadowMap { samplerCube shadowMap; float farPlane; }; struct Material { float specularIntensity; float specularPower; }; uniform int pointLightCount; uniform int spotLightCount; uniform DirectionalLight directionalLight; uniform PointLight pointLights[MAX_POINT_LIGHTS]; uniform SpotLight spotLights[MAX_SPOT_LIGHTS]; uniform OmniShadowMap omniShadowMaps[MAX_POINT_LIGHTS + MAX_SPOT_LIGHTS]; // KEEP TEXTURE LAYOUTS EXPLICIT layout (binding = 1) uniform sampler2D theTextureDiffuse; layout (binding = 4) uniform sampler2D theTextureSpecular; layout (binding = 5) uniform sampler2D theTextureNormal; layout (binding = 2) uniform sampler2D directionalShadowMap; layout (binding = 6) uniform samplerCube skyBoxTexture; uniform Material material; uniform vec3 eyePosition; vec3 gridSamplingDisk[20] = vec3[] ( vec3(1, 1, 1), vec3( 1, -1, 1), vec3(-1, -1, 1), vec3(-1, 1, 1), vec3(1, 1, -1), vec3( 1, -1, -1), vec3(-1, -1, -1), vec3(-1, 1, -1), vec3(1, 1, 0), vec3( 1, -1, 0), vec3(-1, -1, 0), vec3(-1, 1, 0), vec3(1, 0, 1), vec3(-1, 0, 1), vec3( 1, 0, -1), vec3(-1, 0, -1), vec3(0, 1, 1), vec3( 0, -1, 1), vec3( 0, -1, -1), vec3( 0, 1, -1) ); vec4 AmbientColourG = vec4(0.0f, 0.0f, 0.0f, 0.0f); vec4 SpecularColourG = vec4(0.0f, 0.0f, 0.0f, 0.0f); vec4 DiffuseColourG = vec4(0.0f, 0.0f, 0.0f, 0.0f); vec3 Normal = vec3(0.0f, 0.0f, 0.0f); vec4 CalcLightByDirection(Light light, vec3 direction, float shadowFactor) { vec4 ambientColour = vec4(light.colour, 1.0f) * light.ambientIntensity; float diffuseFactor = max(dot(normalize(Normal), normalize(direction)), 0.0f); vec4 diffuseColour = vec4(light.colour * light.diffuseIntensity * diffuseFactor, 1.0f); vec4 specularColour = vec4(0, 0, 0, 0); if(diffuseFactor > 0.0f) { vec3 fragToEye = normalize(eyePosition - FragPos); vec3 reflectedVertex = normalize(reflect(direction, normalize(Normal))); float specularFactor = dot(fragToEye, reflectedVertex); if(specularFactor > 0.0f) { specularFactor = pow(specularFactor, material.specularPower); specularColour = vec4(light.colour * material.specularIntensity * specularFactor, 1.0f); } } SpecularColourG += specularColour; AmbientColourG += ambientColour; DiffuseColourG += diffuseColour; return vec4(1.0 - shadowFactor); // * (diffuseColour + specularColour)); } vec4 CalcPointLightByDirection(Light light, vec3 direction, float shadowFactor) { vec4 ambientColour = vec4(light.colour, 1.0f) * light.ambientIntensity; float diffuseFactor = max(dot(normalize(Normal), normalize(direction)), 0.0f); vec4 diffuseColour = vec4(light.colour * light.diffuseIntensity * diffuseFactor + diffuseFactor * 0.2, 1.0f); vec4 specularColour = vec4(0, 0, 0, 0); if(diffuseFactor > 0.0f) { vec3 fragToEye = normalize(eyePosition - FragPos); vec3 reflectedVertex = normalize(reflect(direction, normalize(Normal))); float specularFactor = dot(fragToEye, reflectedVertex); if(specularFactor > 0.0f) { specularFactor = pow(specularFactor, material.specularPower); specularColour = vec4(light.colour * material.specularIntensity * specularFactor, 1.0f); } } SpecularColourG += specularColour; AmbientColourG += ambientColour; DiffuseColourG += diffuseColour; // return ambientColour + (1.0 - shadowFactor) * (diffuseColour + specularColour)); return vec4(1.0 - shadowFactor); } float CalcPointShadowFactor(PointLight light, int shadowIndex) { vec3 fragToLight = FragPos - light.position; float currentDepth = length(fragToLight); float shadow = 0.0; float bias = 0.015; int samples = 20; float viewDistance = length(eyePosition - FragPos); float diskRadius = (1.0 + (viewDistance / omniShadowMaps[shadowIndex].farPlane)) / 85.0; for(int i = 0; i < samples; ++i) { float closestDepth = texture(omniShadowMaps[shadowIndex].shadowMap, fragToLight + gridSamplingDisk[i] * diskRadius).r; closestDepth *= omniShadowMaps[shadowIndex].farPlane; if(currentDepth - bias > closestDepth) shadow += 1.0; } shadow /= float(samples); return shadow; } float CalcShadowFactor(vec4 DirectionalLightSpacePos) { vec3 projCoords = DirectionalLightSpacePos.xyz / DirectionalLightSpacePos.w; projCoords = projCoords * 0.5 + 0.5; float closestDepth = texture(directionalShadowMap, projCoords.xy).r; float currentDepth = projCoords.z; vec3 normal = normalize(Normal); vec3 lightDir = normalize(directionalLight.direction); float bias = max(0.05 * (1.0 - dot(normal, lightDir)), 0.0005); float shadow = 0.0; vec2 texelSize = 1.0 / textureSize(directionalShadowMap, 0); for(int x = -1; x <= 1; ++x) { for(int y = -1; y <= 1; ++y) { float pcfDepth = texture(directionalShadowMap, projCoords.xy + vec2(x,y) * texelSize).r; shadow += currentDepth - bias > pcfDepth ? 1.0 : 0.0; } } shadow /= 9.0; if(projCoords.z > 1.0) { shadow = 0.0; } return shadow; } vec4 CalcDirectionalLight(vec4 DirectionalLightSpacePos) { float ShadowFactor = CalcShadowFactor(DirectionalLightSpacePos); return CalcLightByDirection(directionalLight.base, directionalLight.direction, ShadowFactor); } vec4 CalcPointLight(PointLight pLight, int shadowIndex) { vec3 direction = FragPos - pLight.position; float distance = length(direction); direction = normalize(direction); float shadowFactor = CalcPointShadowFactor(pLight, shadowIndex); vec4 colour = CalcPointLightByDirection(pLight.base, direction, shadowFactor); float attenuation = pLight.exponent * distance * distance + pLight.linear * distance + pLight.constant; return (colour / attenuation); } vec4 CalcSpotLight(SpotLight sLight, int shadowIndex) { vec3 rayDirection = normalize(FragPos - sLight.base.position); float slFactor = dot(rayDirection, sLight.direction); if(slFactor > sLight.edge) { vec4 colour = CalcPointLight(sLight.base, shadowIndex); return colour * (1.0f - (1.0f - slFactor)*(1.0f/(1.0f - sLight.edge))); } else { return vec4(0, 0, 0, 0); } } vec4 CalcPointLights() { vec4 totalColour = vec4(0, 0, 0, 0); for(int i = 0; i < pointLightCount; i++) { totalColour += CalcPointLight(pointLights[i], i); } return totalColour; } vec4 CalcSpotLights() { vec4 totalColour = vec4(0, 0, 0, 0); for(int i = 0; i < spotLightCount; i++) { totalColour += CalcSpotLight(spotLights[i], i + pointLightCount); } return totalColour; } void main() { vec3 Normal = normalize( mat3(nTangent, nBitangent, normal) * texture(theTextureNormal, TexCoord).rgb * 2.0f - 1.0f ); vec4 diffuse = texture(theTextureDiffuse, TexCoord); vec4 specular = texture(theTextureSpecular, TexCoord); //vec4 shadowFactor = CalcDirectionalLight(DirectionalLightSpacePos); vec4 shadowFactor = CalcPointLights(); //shadowFactor += CalcSpotLights(); float alpha = texture(theTextureDiffuse, TexCoord).a; vec4 finalColour = diffuse * ( AmbientColourG + ( shadowFactor * DiffuseColourG ) ) * ( ( AmbientColourG + shadowFactor ) * ( DiffuseColourG + ( 1.2f * (specular * SpecularColourG) / 32.0f) ) ); float exposure = 32.0f; vec3 I = normalize(FragPos - eyePosition); vec3 R = reflect(I, normalize(Normal)); vec4 reflectColor = texture(skyBoxTexture, R); float reflectStrength = 0.50f; vec4 noAlpha = vec4(exposure * (finalColour * finalColour)) + (0.5f * diffuse); colour = vec4(noAlpha.xyz, alpha); vec4 reflectionFinal = reflectColor * reflectStrength * specular * shadowFactor; colour *= (reflectionFinal + 0.01f); if(gl_FragCoord.y > 0) { colour.rgb = Normal; } else { colour.rgb = normal.rgb; } // if(gl_FragCoord.y > 0) { colour *= (reflectionFinal + 0.01f); } // if(gl_FragCoord.y < 0) { colour *= (reflectionFinal + 0.01f); } float gamma = 0.819; colour.rgb = pow(colour.rgb, vec3(1.0/gamma)); } it wont compile as is. im interested in the math.
  7. c++ is my favorite. i dislike generics, and the chains of not having pointers or stuff like java. c++ is great. but i hear a lot of people arguing about c++ vs rust
  8. This qoute is something i needed^ It certainly feels like a hard field. My cousins husband does it professionally, and he said they have had people with masters that dont do so great. Thanks for the insight. Ill have to study more to really understand, but i know a good place to start now.
  9. Wow... that kinda describes my path, except im learning 3D graphics programming and multivariate calculus now too. except i literally did the map wrong... lol 1. doesnt matter i just want the money 2. get a job 3. im interested & its fun 4. just want to get started 5. the really hard way Result: c++ but i started with c++ then c & java, then python, then openGL & glsl. i would %100 percent recommend the hard way. ive been going at it for 4.5 ish months now. I constantly want to give up, it constantly feels too hard, it constantly feels like ill never be good enough, but i do it anyways. It just really shows me my power to choose to have my brain and body do whatever i decide it will do. My feelings are irrational, and i can handle anything in tech. plus its kinda fun. plus, if you dont have the motivation to do things the hard way and solve problems, apparently you dont have the attitude to be a software engineer. ( atleast from what ive been told ) @wasab I dont understand why java is so popular. The only thing that felt streamlined and easy with java, was threading. everything else is a high level memorization game, and it just feels like a prison. Generics in java are kind of nice. I'm on the fence about them.
  10. i'm trying to optimize my shaders while im adding to them. Is there a way to avoid "if" statements in calculating shadow maps? I know "if" statements could be taxing in the past, and dont have a clear answer to if they should be avoided now days. I just know they were a big problem for older cards. For example: my code below.. vec4 CalcLightByDirection(Light light, vec3 direction, float shadowFactor) { vec4 ambientColour = vec4(light.colour, 1.0f) * light.ambientIntensity; float diffuseFactor = max(dot(normalize(Normal), normalize(direction)), 0.0f); vec4 diffuseColour = vec4(light.colour * light.diffuseIntensity * diffuseFactor, 1.0f); vec4 specularColour = vec4(0, 0, 0, 0); if(diffuseFactor > 0.0f) // <-- <-- <-- <-- <-- // { vec3 fragToEye = normalize(eyePosition - FragPos); vec3 reflectedVertex = normalize(reflect(direction, normalize(Normal))); float specularFactor = dot(fragToEye, reflectedVertex); if(specularFactor > 0.0f) { specularFactor = pow(specularFactor, material.specularPower); specularColour = vec4(light.colour * material.specularIntensity * specularFactor, 1.0f); } } return (ambientColour + (1.0 - shadowFactor) * (diffuseColour + specularColour)); }
  11. So i was using c4d and i had 2 points i needed to move... well ive been learning software engineering and figured " hey i would add this feature if i made c4d , lets try it. " and sure enough.... you can do this for you variables. i was blown away, i thought i knew every trick lol. you can type math problems into your variable values spot, and itll solve em and apply em. maybe im just dumb, idk. thought it was cool
  12. Oh sorry, this is a picture inside of C4D! My render engine is openGL entirely, i have textures, lighting, camera, mouse control, movement keys, specular, diffuse, a skybox, and some neat things similar to PCF. I still have a ways to go on that. Im planning on learning Vulkan too, and started with openGL because the transition isnt suppose to he hard. But i was told openGL is easier to start with. Like i have to add animations, bump maps, reflection, transparency, etc.
  13. I dont think you have to be amatuer to have the full array of digital media production skills. I already made my own 3D graphics engine, im improving it and using it to make a side scrolling 2 player arena game like super smash bros (but with droids and guns). I honestly hate uv wrapping & unwrapping + texutring (however it feels awesome to actually have good texturing on your 3D models). But ill do it, and ive been 3D modeling all of this for it. But i honestly started when i was 6, so most of it is second nature to me. Programming im newer to the professional side. My game/render engine is written in c++ and openGL, and i still have quite a bit left to do on it. Edit: i think the first 3D software i used was MilkShape3D when i was about 8 or 9.
  14. I added "pixel art" & "sprites" to my linked in.
  15. i didnt start taking it seriously until 4 or 5 months ago. But now i posses pretty much every skill under the sun in digital-multimedia. I maxed out my linked in with 50 skills , softwares, and programming languages. Edit: im 24 now.
  16. Anyone else play with "The Games Factory" when they were a little kid? I loved it. It exposed me to digital media production when i was 6. But the best thing i ever made was a gta2 clone where you could drive a car and run people over, and walk, but no guns to shoot or anything. I learned the long lost art of pixel by pixel sprites from that great piece of software. Edit: what do you call the skill of pixel by pixel sprites? I want to add it to my resume now lol.
  17. @straight_stewie regardless, people have given me great input and things to think about. i'm hung up on getting my multivariate calculus down for now, put multi-threading on the back burner until i learn Vulkan. (except for non opengl stuff) I personally always seem to choose the hardest route i can, this graphics stuff sure is rewarding when you make it do what you want though. @Mira Yurizaki I should probably dig into a book specifically on multi-threading. My solutions are probably put to shame by ones id learn from a few quick reads.
  18. Ill have to look into that. I've just been making educated guesses based on what i know of modern compilers, testing execution time of tiny programs, and the specifics i know of c++. however i did cut my loading time in half at least when i start my application. Thanks!
  19. Thanks for steering me clear. idk how, but graphics stuff just seems to get more and more fun to program.
  20. The end game is to learn Vulkan for a job that a family member can get me in for a chance to prove myself, since i dont even have a GED. But he said to stick with openGL for now and practice shaders, multivariate calculus, and a few other things. my little renderer thing is about 2,500 lines including my shaders, its all intertwined so idk. I guess ill save any serious attempts at multi-threading for Vulkan then, is that the conclusion i should be leaving with? glad the forum has knowledgeable people on this. it feels like a lonely unsupported niche a lot of the time haha.
  21. Thanks, thats some good info to look through. A lot of what i have been doing is trial and error. my application start is a lot faster, and ive managed to get a few improvements. mouse input is smoother and less buggy, etc. what do you mean by profiled? sorry im self taught, and this is really only my 4th or 5th month programming. right. I had to figure out nifty tricks to get it working right. but only a few GLFW functions let me just throw em in a lambda thread or something. -- sorry im both new to threading, and new to openGL and threading.
  22. I'm kind of new to actually using threads in c++, and openGL is an added complication. Its a minefield to work around, but i still got user input and a few other things into separate threads. I figured a pretty clever way to throw my buffer swapping into its own thread. what you just said went over my head. GLFW is not thread friendly at all ive come to find. edit: I dont know the technical terms for threading stuff yet.
  23. maybe its a personal preference, but anything besides instant response is basically equal. so id rather use vs2017 over vsCode, but.... that said. I use eclipes, notepad++, visualstudio code, vs2017, and even just notepad, and further more... ill have them all open at the same time. So i would really suggest not limiting yourself to any tool. But still take the time to learn a good one like vs2017. EDIT: not you directly, i mean the guy who asked lol.
×