Since the other "What do you need help with?" Thread remained in Software & Hardware and is now a general tech-questions thread, I wanted to post this one here just for coding questions

What do you need help with?
agree
2

Goldsrc hl1 playermodel compiling, porting from gmod source model

Recently I was updating some Python projects which use Bootstrap ([url href="https://pypi.org/project/buildout.bootstrap/"]https://pypi.org/project/buildout.bootstrap/[/url]) and Buildout ([url href="https://github.com/buildout/buildout"]https://github.com/buildout/buildout[/url])... but neither of these really seems to be maintained anymore and needed some hacking to keep using.

Is virtualenv now the way to do dependency management in Python? I can't really see any consensus as it looks like a few different people have a few different projects to do dependency management, but virtualenv still exists and seems to have survived for a while now.

Is it possible at all in OpenGL to "reinterpret" a sampler in a shader or to create a cubemap sampler given an index into a texture 2d array?

I want to store all my shadow textures in a single texture array object, but I have 2 different texture target types: GL_TEXTURE_2D_ARRAY, and GL_TEXTURE_CUBE_MAP_ARRAY.
They both use the same underlying storage: glTextureImage3DEXT.

If I were to pick say GL_TEXTURE_2D_ARRAY, I [i][b]could [/b][/i]update all the shadows in 1 render call using layered rendering to specify the correct layer for each shadow, but I don't know if it's possible to create a cubemap sampler given an index 'x' into a GL_TEXTURE_2D_ARRAY, where 'x' through 'x+5' are all faces of the cubemap.

IIRC opengl treats cubemap arrays as a special case of 2D texture arrays

[b]Edit:[/b]
It looks like opengl has some means of doing this ahead of time using texture views, but going that route would require me to manage the texture memory way more.

[b]Edit (2):[/b]
Hell, I guess what I really need is to manually do a cubemap texture lookup, which should be much more feasible.

[b]Final Edit:[/b]
Got some shader code to manually sample from 6 textures as if it were a cubemap.
I think I can now render my entire scene's shadows for all light types in a single glMultiDrawArraysIndirect

Well. i found this [url href="https://stackoverflow.com/questions/462721/rendering-to-cube-map"]https://stackoverflow.com/questions/462721/rendering-to-cube-map[/url]. This is the side of rendering it tho. I'm not sure what you mean you wanna render all light types into a cubemap. It's still a cube, a kinda point entity.

In terms of shader code. make sure you don't sample all 6. It should be arithmetic and conditional rather, with a single sample. Made this lil render yesterday. (My ban just didn't lift.)

[img]https://i.imgur.com/yFWtdgL.jpg[/img]

If you wanna go this way and just, say, put all you 2d shapowmaps into a stack you just index the layer by layer/z = 1.0/amount_of_layers+-interpolation threshold. In case of a volume/slice textures this should be done with the z interpolation kinda numbed, but i think ogl 2d arrays don't interpolated across layers.

Got it all figured out.
Basically all of my shadow types have the same fragment shader outputs, so I just made a shadowing shader that deals with all of them, and stored all my shadows into a single shadow map texture array.
My problem was that if I were to do the above approach, I wasn't sure how I could treat an arbitrary range of textures in the array as if it were a cubemap (so I could do omnidirectional shadows). So I figured out how the calculation was done in cubemap samplers and converted the view direction into a face index and uv coordinates.

With that approach, I could store directional shadow maps, spot shadow maps, and point shadow maps all in 1 place, fill the entire array in 1 draw call, with minimal changes to the lighting shader.

When rendering the shadows though, I use the extension
[code]#extension GL_ARB_shader_viewport_layer_array : enable[/code]
so I can have the output variable gl_Layer in the vertex shader, skipping the geometry shader stage because geometry shaders are terribly slow.

I'm learning programming with Python 3 on my own, and I finished my first project, a terminal based hangman game. I would be very thankful if someone could point out some of the larger errors I have made, or any fundamental problems with my programming:

[url href="https://pastebin.com/N2DtQsp8"]https://pastebin.com/N2DtQsp8[/url]

The largest lesson I learned from this myself is that I should use variables for basically all strings, and any other values I might want to edit later. Not using enough variables wasn't that bad with this project due to its small size, but I imagine that having to go through the logic code to fix a spelling error or something will be a massive pain in larger projects.
artistic
1


[quote username="Lolkork" threadId="1321" threadPage="1" postId="40537" mentionsUser="441"]I'm learning programming with Python 3 on my own, and I finished my first project, a terminal based hangman game. I would be very thankful if someone could point out some of the larger errors I have made, or any fundamental problems with my programming:[url href="https://pastebin.com/N2DtQsp8"]https://pastebin.com/N2DtQsp8[/url]The largest lesson I learned from this myself is that I should use variables for basically all strings, and any other values I might want to edit later. Not using enough variables wasn't that bad with this project due to its small size, but I imagine that having to go through the logic code to fix a spelling error or something will be a massive pain in larger projects.[/quote]

Looks okay.
I'd consider putting some things in functions, like loop_count < 9 - wrong_guesses_allowed + wrong_guesses (which I assume is guesses left) could be put in a function, as could the if guess in word stuff.
for letter in word:
if letter == guess: can be simplified to in if guess in word: I think?


[img]https://cdn.discordapp.com/attachments/231376069339512832/597415070699618314/unknown.png[/img]
Is there a better way to check what index your for loop is on than counting like this?


[quote username="Lolkork" threadId="1321" threadPage="1" postId="41989" mentionsUser="441"]\[image: https://cdn.discordapp.com/attachments/231376069339512832/597415070699618314/unknown.png\]Is there a better way to check what index your for loop is on than counting like this?[/quote]

[img]https://i.imgur.com/Gyt6Me3.png[/img]
?

Or use [code]i = sprite_list.index(sprite_string)[/code], but that might be slower
friendly
1


I have no idea how easy or hard this is, but I would like advice or tutorials on how to texture a model. I've wanted to try my hand at retexturing the Combine Soldier for awhile, since nobody ever has, but I have absolutely no idea where to start.

I can't provide links right now, but first you're going to have to rip the material from Half life 2. Source games have models and textures in separate folders, but both folders kind of mirror each other iirc.
You need the soldier vtf file specifically, but it would probably help to have the vmt file so you can pair them up when putting them into whatever source game.

With a program like vtfedit you can export the texture out of the vtf file, and edit it in your choice of image editors, and then after you can import it back into the vtf file.


Optionally, you might want to see what it looks like while you're working on it, so you might want to get blender and some valve format importers like mdl, which if done right would hopefully also import the texture too. If you go this route you would need to rip the model as well.


This is how I would have done it a decade ago.

[url href="https://steamcommunity.com/groups/CrowbarTool"]https://steamcommunity.com/groups/CrowbarTool[/url]
[url href="https://store.steampowered.com/app/365670/Blender/"]https://store.steampowered.com/app/365670/Blender/[/url]
[url href="https://steamcommunity.com/groups/BlenderSourceTools"]https://steamcommunity.com/groups/BlenderSourceTools[/url]
[url href="https://github.com/Artfunkel/gimp-vtf/releases"]https://github.com/Artfunkel/gimp-vtf/releases[/url]
[url href="https://developer.valvesoftware.com/wiki/Photoshop_VTF_Plugin"]https://developer.valvesoftware.com/wiki/Photoshop_VTF_Plugin[/url]

For the sake of working/painting on it in 3D you might wanna decompile the model using Crowbar or use the native mdl importer. Blender (with BleST) is the common and stable tool to import and mod source models. Crowbar is just necessary if you wanna/gotta mod the mesh.

Your choice if you wanna use Gimp or Photoshop to work on or export the textures to a intermediate format for painting in Blender. Just paint the texture and re-export it to vtf. That is the quick way.

Edit: Link for the native mdl importer for Blender.

[url href="https://github.com/REDxEYE/io_mesh_SourceMDL"]https://github.com/REDxEYE/io_mesh_SourceMDL[/url]

[quote username="Karmah" threadId="1321" threadPage="1" postId="42407" mentionsUser="860"]I can't provide links right now, but first you're going to have to rip the material from Half life 2. Source games have models and textures in separate folders, but both folders kind of mirror each other iirc.You need the soldier vtf file specifically, but it would probably help to have the vmt file so you can pair them up when putting them into whatever source game.With a program like vtfedit you can export the texture out of the vtf file, and edit it in your choice of image editors, and then after you can import it back into the vtf file.Optionally, you might want to see what it looks like while you're working on it, so you might want to get blender and some valve format importers like mdl, which if done right would hopefully also import the texture too. If you go this route you would need to rip the model as well.This is how I would have done it a decade ago.[/quote]
I should have mentioned that I already have novice experience with vtf edit, mostly for personal use. But making a ragdoll texture from scrap is considerably harder than recolours or painting lines. [url href="https://steamuserimages-a.akamaihd.net/ugc/448491511234033814/DBB0A53B788701CFF72D754D773650A4D8FB6840/"]https://steamuserimages-a.akamaihd.net/ugc/448491511234033814/DBB0A53B788701CFF72D754D773650A4D8FB6840/[/url] (although they are very nice lines).
Where I get clueless is texturing for human models, it's easy to open Paint.NET and add some cropped plywood texture, or make some minor alterations to an existing models. Making something from scratch, especially something like clothing that isn't flat and will have to have colours edited, is what I'm thinking of doing.

[quote username="dlight" threadId="1321" threadPage="1" postId="42421" mentionsUser="3588"][url href="https://steamcommunity.com/groups/CrowbarTool"]https://steamcommunity.com/groups/CrowbarTool[/url][url href="https://store.steampowered.com/app/365670/Blender/"]https://store.steampowered.com/app/365670/Blender/[/url][url href="https://steamcommunity.com/groups/BlenderSourceTools"]https://steamcommunity.com/groups/BlenderSourceTools[/url][url href="https://github.com/Artfunkel/gimp-vtf/releases"]https://github.com/Artfunkel/gimp-vtf/releases[/url][url href="https://developer.valvesoftware.com/wiki/Photoshop_VTF_Plugin"]https://developer.valvesoftware.com/wiki/Photoshop_VTF_Plugin[/url]For the sake of working/painting on it in 3D you should decompile the model using crowbar. Blender is the common and stable tool to import and mod source models. Your choice if you wanna use Gimp or Photshop to work on or export the textures to a intermediate format for blender. Just paint the texture and re-export it to vtf. That is the quick way.[/quote]
I have blender installed on my other harddrive from when I thought about getting into modelling a few years ago. That was on a different OS install so I might have to reinstall it. I couldn't figure out even a single tool and ended up crashing the program, and going no further. Is a modelling program really reccommended for more advanced texture work?

Recommended? It's for sure easier to manage if you can watch it in realtime or export/use the uvlayout, to properly paint the correct regions in the texture. So, Yes.

If you do textures from scratch, working with layers and selection regions will really help you too. I haven't done much detailed texturing from scratch. Just some tf2 assets, but i really used a basic material texture layer and painted the color ontop in another layer with multiplication. That is a common technique. The tricky part is to work with the direction of the uv layout and eventually rotate the underlying base material to get the correct look. That's all i can tell.

Is it a bad idea to try learning threading when I'm just a few weeks in to learning programming? Threading seems a lot harder than the stuff I have already learned.

I'm making a simple game engine and I want to decouple the graphics framerate from the game logic tick rate. Should I just not bother attempting this?


[quote username="Lolkork" threadId="1321" threadPage="1" postId="43137" mentionsUser="441"]Is it a bad idea to try learning threading when I'm just a few weeks in to learning programming? Threading seems a lot harder than the stuff I have already learned.I'm making a simple game engine and I want to decouple the graphics framerate from the game logic tick rate. Should I just not bother attempting this?[/quote]
You mean decouple physics of something moving from the framerate? You want to store a diff of time since the last frame and multiply your physics calculations by that.


[quote username="Lolkork" threadId="1321" threadPage="1" postId="43137" mentionsUser="441"]Is it a bad idea to try learning threading when I'm just a few weeks in to learning programming? Threading seems a lot harder than the stuff I have already learned.I'm making a simple game engine and I want to decouple the graphics framerate from the game logic tick rate. Should I just not bother attempting this?[/quote]

tamschi had some good points on this but i'm not sure if his @ is precisely the same.

learning threading early is fine: when it comes to learning programming there's no such thing as too early or too late imo. if you enter into a new topic with a genuine interest and desire to apply it, you'll come out the other side just fine. my entire programming career has been a lot of "well this seems interesting" followed by me falling into deep topics lol.

threading is tough because it requires thinking in a different mode of thought sorta but also not? imo it's mostly a matter of learning what [i]not [/i]to do too. one of the easiest ways to make things multithreading-friendly is to have your functions and such be things that can potentially take in state data for a thread, do work on that thread's state data [i]from what is passed in[/i], then move on. not having functions or objects manipulate state data that [i]could [/i]be seen by multiple threads helps a ton, as it's easy to forget once your codebase grows that "oh shit this function modifies non thread-local state". task-based programming, i guess.

i'm really bad at expressing this stuff articulately, sorry haha

A tick rate? Like fixed 30 fps or something? Well. That would make the timing predictable and possible to decouple the graphics thread to run entirely independent. The thing that complicates it is how you transfer data to the graphics thread to update. You'd need a duplicate data set for the visual elements. But you should not lock the entire "scenegraph" to update it, rather update the singular elements in it whenever you done computing them, so the graphics thread can access and render elements that are not accessed to update.

The problem at hand with fixed rate ticks is compensation of the motion anyway. That means the inbetween prediction. If you'd tick at 30 fps and render 60 your object would natively jump every 2nd frame. Tricky.

Thanks all of you for writing such great replies. After thinking about it some more I don't think threading will help me much.

I think multi-threading could be pretty easy to add though, the part I would want to multithread only takes one input (a list of the things I want to draw) and doesn't return anything to the main program, it prints it on its own.

Edit:
Or no I think I also misunderstood multithreading.

Edit:
multithread drifting
[video]https://cdn.discordapp.com/attachments/231376069339512832/597914656606126099/2019-07-09_00-18-20.mp4[/video]