Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [LOCKED] [SOLVED] Lighting interiors w/ point lights in AGK not feasible

Author
Message
tarkusAB
4
Years of Service
User Offline
Joined: 15th May 2016
Location:
Posted: 12th Jul 2020 15:23 Edited at: 12th Jul 2020 17:11
Hi there

I believe lighting interiors with point lights without light bleed through is not achievable in AppGameKit currently.

The Problem:
See my current scene below.

There is no sun or ambient light here. There is one point light in the scene, directly in front of the window and piano. It is set to pixel lighting mode. There is a wall between that area of the room and the area with Jill standing on the red mat. Notice how the light travels through the wall to illuminate Jill and the objects near her. I don’t want that. I want that area to be unaffected by the light, or otherwise be in a “shadow”.

In AppGameKit, I don’t believe this is possible, in real-time, pre-rendering, or otherwise….let me explain the various methods I have attempted.

Real-time solutions.
Point light shadow mapping: As I understand it, AppGameKit currently does not support cube mapping. This is why shadows only work for the Sun and do not work with point lights. I am not very experienced with shaders, but my understanding is that since cube mapping is not supported by AppGameKit inherently, it is impossible to create a point light shadow mapping shader for AGK.

Pre-rendered solutions:
Lightmapping in a 3D modeling program: This 3D scene was built using a custom made scene editor by myself in AGK. It contains AppGameKit primitives and loaded models. I have not been able to find a way to export the scene to Blender or another modeling program to light it and then re-export. The SaveObject() command is currently non functional per the documentation. I tried making every object into a memblock, then writing those memblocks to files, and loading those files in Blender, but it was not functioning.

Lightmapping in AGK: This is the closest I’ve gotten. I was able to write a lightmapper for planes using raycasts shooting from the point light’s position to different spots on a plane. Then drawing a grayscale lightmap image based on distance. Great because it has the blocky look I’m going for. See this screenshot.

However, when trying to apply the same method to any other primitive object or unique object like the piano, it seems impossible. I theorized to perhaps get the UV data of each object’s vertices by turning the object into a memblock and shooting raycasts from the light to each vertex. I could then draw the lightmap for the object using the UV coordinates and save it as an image. However, for objects with long faces, or objects that use the same UV coordinates to texture different parts of the object, this would not work.

So with all that being said, I don’t believe rendering this scene to portray light more realistically is possible in AGK. I’m using AppGameKit Classic Tier 1, and developing the game for desktop platforms only, not mobile. Would upgrade to AppGameKit Studio in a heartbeat if something like this were possible. Does anyone have suggestions on how to get this working?

The author of this post has marked a post as an answer.

Go to answer

Santman
8
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 18th Jul 2020 22:52
I think you can do it with projection, and setting up a loghtmap from other software such as Blender, but I never got anywhere getting pint lights to work. I think the only way you could do it is in T2 by skipping AGKs render code and writing your own. I tried setting it up using a T2 plugin, but there are steps AppGameKit does that make it impossible I think.

So its T2 or nothing.
PSY
Valued Member
4
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 19th Jul 2020 00:43
Is it possible that point light shadow mapping ( cube mapping ) will be implemented some time in T1?


PSY LABS Games
Coders don't die, they just gosub without return
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 19th Jul 2020 01:51 Edited at: 19th Jul 2020 02:14
Lightmapping is fairly simple and AppGameKit has the facility to easily apply a texture to a lightmap texture slot so your scene can be lit realistically. Its built into AppGameKit and easy to do really if you know how to use your 3d modelling program. (this assume you can get your scene into a 3d modelling program or at least recreate it in the modelling program)

A quick thrown together example


This can make high quality lighting. It is static though - you cant move the lights of produce a shadow from a moving object. (Its Pre-rendered)

You CAN render cubemaps, thats not that hard but they are not OpenGL cubemaps.

You have to wrap your own in a normal 2d texture similar to how you would do reflection.

Since you can render cubemaps and render depth to a cubemap then doing dynamic lights is possible. (AGK makes this a little hard though)

So you render your depth in all 6 directions from a light onto a texture and then you can apply dynamic point lights to a scene but every single item in the scene then needs to be rendered with your point light shadow shader to check if a pixel is lit by a specific light and if it is then you apply light from that specific light. Its not impossible to get this working at all. But, it is hard to do if you dont know shaders and it is not built in to the engine. I've managed to get it working ok with a linear and non linear depth buffers and Janbo has a working example too.

Janbo even showed his point light demo on here somewhere in a video I think. I assumed it would make its way into the shader pack (maybe it already has?).

EDIT: Update
Heres the video


Theres a a lot of tuning to be done on things like this and multisampling to avoid noise effects etc....
PSY
Valued Member
4
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 19th Jul 2020 12:59
Very nice stuff Bengismo.
Thanks for all the good info!

Unfortunately, I'm a total beginner regarding shaders Oo
I guess I'll have to dig into that subject some day.
I've always wanted to do a dungeon crawler, but without working point light shadows it's pretty much pointless ( lol ).
I wish AppGameKit would implement that stuff.

How fast is your custom shadow shader?


PSY


PSY LABS Games
Coders don't die, they just gosub without return
Santman
8
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 19th Jul 2020 15:54
That's a sweet shadow shader, I'm impressed Janbo got it working. I have his shader pack but dont use it as I find the overhead high and theres no real documentation that explains how anything works.....sure if I looked into it I could get my head round it, but getting my own shaders to work with would be an initial headache I think, so I've never really used it.

That looks sweet as anything though, I have to say. I wonder on T1 only performance though - that's A LOT of maths that is being done in T1.
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 19th Jul 2020 16:26 Edited at: 19th Jul 2020 16:33
lol, theres very little maths being done in T1 code. Its all rendering on the GPU which is very quick.

The existing built in shadow shader generates an orthographic depth buffer for the sun then compares a pixel depth when lighting objects. The point light shader does the same thing, but for each point light in the scene. So its similar speed to the existing shadow system but scaled up in terms of numbers of lights. You can optimize it by using dual hemispheric or lat long mappings as the lookups are quicker so its fast. Its how most modern game engines do it too. Half the problem is that even specifying a custom view matrix in Teir 1 is near impossible.

I can run reflections and shadows easily on my phone and tablet. Its obviously dependant on scene complexity like any rendering speed. Think of the PBR Shader shipped with AGK...its doing loads of calculations and using 4 textures but it still runs at over 1500fps as its optimized.
tarkusAB
4
Years of Service
User Offline
Joined: 15th May 2016
Location:
Posted: 19th Jul 2020 22:23
Thanks for the ideas everyone. It's great that someone has been able to get a prototype point light shader working. I ultimately ended up going with building the map in Blender, baking the textures and lights into one baked texture image, and importing it into AGK. Blender can be a little difficult to figure out, but here is how I did it.

How to build 3D maps with baked lights in Blender v2.83 for use of importing into AGK:

- Create the map itself. Just the polys first. Can consist of separate meshes. Use fewest faces as possible.
- Texture all the objects, mapping the UV data to achieve the appropriate look for each face. Different meshes can share the same material.
- Place the lights. Use the Eevee renderer to spot check how it will look.

--Save a backup file here, next is prep work for baking the lightmap--

- Delete any objects you won’t need in the final map, like those used to carve holes in other objects.
- Apply all scale changes permanently. Do this by selecting all objects, hitting CTRL+A and clicking Scale. Needed so the UV you create for the lightmap is generated at correct ratio.
- While all objects are still selected, R-Click on an object -> then click Join. This joins all meshes into one mesh. This is optional but makes following steps easier.
- With the map mesh selected. In the mesh tab, Create a new UV map, let's call it LMUV.
- Select LMUV in the UV box but do not click the camera next to it, just highlight the row, keep the camera lit on the default UVMap.
- Change to Edit Mode, select All Faces in Scene with ‘A’ then, R-Click -> UV Unpack -> Smart UV Pack (Angle Limit 89, Island Margin 1, Area Weight 1, Check both boxes)
- Create a new image (let's call it LMimage) in the image editor. Make it relatively large so the lightmap UVs will not overlap. Max is 5000x5000. Keep it square.
- On each material in the shader node map:
- Turn specular down to 0 in Principled BSDF
- Add -> Texture -> Image Texture and in the new node open the image you just created, LMimage. Don’t connect it to anything. You can copy and paste the node to each material. When you do this, make sure to deselect it and select it again to make sure the node is selected.
- Under render tab, change render engine to Cycles
- Scroll down to Bake. I recommend unchecking Indirect but this is optional.

--Save a separate backup file here, about to bake--

- Now hit Bake
To review the bake:
- Change the rendering UV map to LMUV by selecting the camera icon next to it in the mesh tab for our map mesh.
- Connect the LMimage node in the shader node map as the base color to the main shader node for each material.
- When finished reviewing, export the map as a .DAE file. Make sure to have the option selected to only use current UV map. Make sure to also save the lightmap image separately as a PNG.
Santman
8
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 21st Jul 2020 19:55
Bengismo - yes, I understand how it works, but janbo was kind enough to share his original shadow code on the forums...there were hundreds of lines of maths.
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 21st Jul 2020 22:10 Edited at: 21st Jul 2020 22:38
Santman wrote: " I think the only way you could do it is in T2 by skipping AGKs render code and writing your own. I tried setting it up using a T2 plugin, but there are steps AppGameKit does that make it impossible I think.

So its T2 or nothing."


It was "impossible" and "Teir 2 or nothing" was what you posted days ago and so I wasnt so sure you knew how it worked.

In any case... The maths involved in getting a depth buffer comparison in a shader isnt that bad but I've not seen Janbo's code so I cant say how fast or how complex his code is. (I didn't even know he had shared it - i just remembered a video being posted)

I found looking at the agk source helped me a lot so its easier to see how to get teir 1 to do this without a huge amount of maths. I use world space aligned cubemaps which possibly relieves a lot of the direction conversions and as I mentioned above, using a simpler mapping rather than the cube look up also makes it simpler and potentially faster too. Yes there is some maths but there always is in 3d, but nothing that takes too much time.
Santman
8
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 22nd Jul 2020 14:55 Edited at: 22nd Jul 2020 14:56
I created a post for it - got the depth image done no bother, but it was the converting back the coords for the shadow mapping that was the issue - I did all the code in a T2 plugin but for some reason the result just wasn't working, even though I tested and the out put seemed ok....I assume there is something in the AppGameKit sync routine that stops the conversation matrice from functioning for some reason.

It may well be that I just had some slight thing wrong, but spent about 10 days on it and even Janbo though everything looked ok, so I gave up.

EDIT: I also didn't realise Janbo got point shadows working - very impressed.
janbo
11
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 24th Jul 2020 14:03 Edited at: 24th Jul 2020 14:12
Hiho,

some calrification:
Quote: "but janbo was kind enough to share his original shadow code on the forums"

Yeah I posted my code for the Directional shadow shader, where I used a Vectror Library from the comunity.

Quote: "Half the problem is that even specifying a custom view matrix in Teir 1 is near impossible"

You probably know one doesn't need custom view matrices for Point lights and you can just pass an vec3 array with 4 elements to build a mat4, like I have done 3 jeahrs ago for my shadow shader, just before TGC implemented sun shadows into AGKC
I wonder if TGC implement point light shadows if I share my code for it

The point Light shadow isn't in the Shader Pack. It also needs some refinement work.

Quote: "for objects with long faces, or objects that use the same UV coordinates to texture different parts of the object"

what do you think about adding second uv coordinates spread uniform over the mesh ?

Im interested in the "lightmapper for planes" as I might get it to work with any mesh:
PSY
Valued Member
4
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 24th Jul 2020 14:41
Quote: "I wonder if TGC implement point light shadows if I share my code for it"

Share the code share the code

Quote: "It also needs some refinement work."

A stitch in time saves nine

No, seriously, a point light shadow shader would be awesome. I really really need to learn more about shaders. Can't do it myself with my current shader knowledge :/



PSY LABS Games
Coders don't die, they just gosub without return
janbo
11
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 24th Jul 2020 17:11 Edited at: 24th Jul 2020 17:49
Quote: "A stitch in time saves nine "

I just might have fixed it.
I have Code for PCF, but the video is showing hard shadows.
It supports AGK's point lights and directional light + shadows.

PSY
Valued Member
4
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 24th Jul 2020 18:13
Holy Moly,

that looks awesome

Very well done. I hope this is going to be implemented soon some way or the other.


Respect!


PSY LABS Games
Coders don't die, they just gosub without return
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 24th Jul 2020 18:34 Edited at: 26th Jul 2020 01:10
That looks good janbo.

I only coded in hard shadows myself. (Never went as far as a percentage closer filtering)




I had hoped to just multisample the light position multiple times and average based on that to get smoother edges but I never got round to trying it out. I was wondering if I could try working in area lights too.
Santman
8
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 24th Jul 2020 19:06
Amazing results both.

Shame we cant actually use them. How did you get the reverse camera position working in T1? I assume this is T1?
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 24th Jul 2020 19:59 Edited at: 24th Jul 2020 20:01
I'm guessing that question is aimed at Janbo as I'm not sure what a reverse camera position is? I dont use one that i know of? Its quite likely im using a slightly different method to do this then you were trying. I dont know.
janbo
11
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 24th Jul 2020 21:23 Edited at: 24th Jul 2020 21:40
@Santman: for point lights you don't need inverse matrices. It's all Fragment position - Light Position.
if you really want to: https://github.com/glslify/glsl-inverse/blob/master/index.glsl

@Bengismo: what type of environment mapping do you use Cube,Panorama,DualParabolic ?
And do you use a color render image or Depth Image ?
For PCF just add some predefined offsets to your UV coordinate to sample the Depth map. do this inside a for loop and you are done pretty much.

I have the code for all this so using a color image works for divices without depth support too(some mobile phones) ...but I wondering what works the best.
Santman
8
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 24th Jul 2020 22:14
Janbo, if I can figure it put are you ok if I turn it I to a plugin and fire it up on the forum? Or are you planning to add to the shader pack?

Bengismo, you must be using a different method. The one I was following rendered a depth map from the light perspective, then you compared its depth to the camera scene....it was the depth comparrison that failed. That was a directional light, the next tutorial was point lights but I assumed it wouldnt be possible without getting the first working....first. lol.
janbo
11
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 25th Jul 2020 10:36 Edited at: 25th Jul 2020 10:36
@Santman: not sure, actually.
I probably try to get spotlights and spotlight shadows working too and then putting it into my pack maybe.
tarkusAB
4
Years of Service
User Offline
Joined: 15th May 2016
Location:
Posted: 25th Jul 2020 12:44
@Janbo. Nice point lights. Your demo of drawing on a mesh is also very fascinating.

Since you asked, this is the code for baking a light onto a plane in my original post. I felt reluctant to share because I never finished it or cleaned it up. It only works if the light is above the plane. It does not work if you rotate the plane or move it elsewhere in the scene.

It works by measuring the plane's width and height, splitting it apart into a grid of user-specified size, and then getting the raycast distance from the light's position to each of the four corners of every quadrant on that grid. It then takes the average of those four points to set a value to paint to an image for that quadrant. Excuse the long input functions which I share between my projects.



And the companion AGC file with related functions

janbo
11
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 26th Jul 2020 14:49 Edited at: 26th Jul 2020 15:26
Ah I see you are scanning from above and render boxes for every texel on the target object.
You could color the objects black and render them directly into the image which is much faster.

I always wondered how the professionals do this ?
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 26th Jul 2020 15:23 Edited at: 26th Jul 2020 15:44
Im sure you know but, for the lightmapping in most 3d editors it simply runs a raytracer so that you can get a realistic light level at every point on a surface texture. That way you can include ambient occlusion, global illumination, reflection, specular and all the other real life effects that make it look really good plus you can have hundreds of static lights with no slowdown in the final rendering. It just looks good but with no dynamic lighting in AGK....or at least, the dynamic lighting has to be added on top.

Janbo wrote: "I probably try to get spotlights and spotlight shadows working too and then putting it into my pack maybe. "


Good idea!


Yeah, you can make some cool silent hill type torch games in 3d with nice spotlight type effects.

Im considering adding it into the PBR shader, that would be really cool.

janbo wrote: "what type of environment mapping do you use Cube,Panorama,DualParabolic ?
And do you use a color render image or Depth Image ?"


It depends - some are good for certain things and bad for others... I started with cubemapping and it works great, but the other two are quicker for me but only slightly as they involve fewer render passes in generating the depth map. There are less render calls with lat/long (Panoramic) than with cubemap but more shader swapping as part of the depth render. Plus they all have there drawbacks. I like cubemapping as it doesnt require any specific shader for the depth pass on the lights and is simple enough so no need to pass view/proj matrix to the shader. The panoramic render loses details at the poles(+y,-y) so if it isnt rotated the shadows directly up or down can be rendered ugly. Dual parabolic is good too especially if you split it on the Y axis and just render downwards!....then its just one depth render per light for the whole scene! As most lights dont need to light upwards then its a nice speed up (half the work). Ive not done too much testing really.

I do really think AppGameKit teir 1 needs true cubemap support. The amount of time lost in shaders to just to cube lookups is wasteful plus being able to mipmap cubemaps properly would be really nice for quality.

Im using true depth images as they work on PC and all my android devices currently. Any device not supporting them probably isnt going to be good at real time lighting anyway. Rendering depth to a colour image would of course be easily possible (encoding depth into the 3 channels for accuracy) but I think its a lot slower than using the true depth buffer and decoding depth from RGB (yuck)

For spotlights a single depth render in the direction of the spotlight is super quick and gives good results. Since it only lights whats in its cone it doesnt matter if you have depth for the whole scene as your only lighting up the area in front of the spotlight.

Its a case of mixing and matching for the best results...All good fun
Santman
8
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 27th Jul 2020 00:30
This post has been marked by the post author as the answer.
So it's possible then.....if you're a genius or a shader expert, seems to be the answer to this thread.
janbo
11
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 29th Jul 2020 13:23 Edited at: 29th Jul 2020 13:27
@Bengismo: I know the pros and cons I was interested at what you have settled to use.
And you actually want to use 4 channels RGB and Alpha to decode the Depth value.

Quote: "it doesnt require any specific shader for the depth pass on the lights and is simple enough so no need to pass view/proj matrix"

How do you linearize the depth ? (like I do in my shader pack ?) respectively how do you compare the fragment and depth map values ? and why do you need to pass extra matrices to make use of other environment mapping types ?
Also do you combine the cube maps images into one single cube atlas image like i do ?
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 29th Jul 2020 15:51 Edited at: 29th Jul 2020 15:58
janbo wrote: "I was interested at what you have settled to use."

I use which one best fits the need....so spotlights need one depth image (no need for cube,panoramic or dual hemispheric.
Point lights can use any of the 3 methods depending on the accuracy you want.
Eg...If its a downward facing ceiling light then a single hemispheric render works well.
If its a parallel light similar to agk's sun, then a single orthographic depth render is used. In my code I can specify light types.....Point, spotlight, parrallel, single sided, texture based (where a texture specifies the light source in given directions)

janbo wrote: "How do you linearize the depth ? (like I do in my shader pack ?)"

I dont use the shader pack. So I dont know how you linearize your depth?

I have shader code for a non linear depth buffer (using stock shader depths which I convert to a linear distance in the shader). I also have a linear depth shader where the depth is stored in the depth buffer as linear between near and far values. Id use a linear depth buffer if I wanted more accurate shadow depth at far distances rather than the near skewed GL depth standard.

janbo wrote: "respectively how do you compare the fragment and depth map values ?"

lol.....with depth<(lightdepth+bias) in the shader.

janbo wrote: "Also do you combine the cube maps images into one single cube atlas image like i do ?"

I only have one depth image which I render to. I dont have to combine any images.

Looking at your renders...we layout our cubemaps differently so the shaders would be slightly different for the cube lookups.
blink0k
Moderator
7
Years of Service
Recently Online
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 29th Jul 2020 22:46
Some code to detail the high level descriptions would be nice
janbo
11
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 30th Jul 2020 09:00 Edited at: 30th Jul 2020 09:18
Quote: "I only have one depth image which I render to. I dont have to combine any images"

how do you create a cubemap with one depth image ?
I can only think of an object shader that renders to 6 parts of one depth image, but you also wrote:
Quote: "using stock shader depths which I convert to a linear distance in the shader"
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 30th Jul 2020 09:13 Edited at: 30th Jul 2020 09:14
One depth image.... render one image to a spotlight or render each face of a cubemap to it....Use SetCameraBounds( cameraID, left, right, top, bottom )

Not complicated
janbo
11
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 30th Jul 2020 09:17 Edited at: 30th Jul 2020 09:19
Quote: "Use SetCameraBounds( cameraID, left, right, top, bottom )"

Ah true, I didn't think of that. I wanted to do it manually again. Well sometimes AppGameKit does have the right commands

Quote: "lol.....with depth<(lightdepth+bias) in the shader."

You know one could convert the lightdepth into nonlinear distance
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 30th Jul 2020 09:18 Edited at: 30th Jul 2020 09:21
Its much quicker then other methods using the one image.


And i do convert to the non linear distance if needed. One can also convert the non linear to linear distance.

Look slike we are using a very similar function:
janbo
11
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 30th Jul 2020 09:20 Edited at: 30th Jul 2020 09:22
It would be exact the same ?! ...if i'd do the camerabounds manually..
Quote: "And i do convert to the non linear distance if needed. One can also convert the non linear to linear distance"

yeah like in the code i posted.
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 30th Jul 2020 09:22 Edited at: 30th Jul 2020 09:24
Depends whats stored in your depth buffer....linear on non linear.


Or like the code I posted Or like in the codes shared online with any shadow shader...lol
janbo
11
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 30th Jul 2020 10:04
Please stay professional, I never Used SetCameraBounds and I can't see how I'd render the faces into an eighth of the depth image with it.
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 30th Jul 2020 10:08 Edited at: 30th Jul 2020 10:11
Janob wrote: "Please stay professional, I never Used SetCameraBounds and I can't see how I'd render the faces into an eighth of the depth image with it."


I will leave you to work out how to do that rather then be unprofessional ...
janbo
11
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 30th Jul 2020 10:12 Edited at: 30th Jul 2020 13:15
Hm okay, well there must be a way and you directet me to use SetCameraBounds.
Thanks I'll work that out

[Edit]Ah stupid me didn't think of SetScissor() at first It works now had to look into perspective projection again[/Edit]
Xaby
FPSC Reloaded TGC Backer
13
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 30th Jul 2020 13:22 Edited at: 30th Jul 2020 13:25
Maybe this could help
https://forum.thegamecreators.com/thread/223477

some code from PartTimeCoder, I asked how to use a second camera or have multiple viewports.
The solution is to use SetScissor(l#,t#,r#,b#) and SetCameraBounds(1,lb#,rb#,tb#, bb#)



Funny thing
I guess, Bengismo used that code as well here
https://forum.thegamecreators.com/thread/222064
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 30th Jul 2020 13:30
Quote: "I guess, Bengismo used that code as well here"

If you read the thread....I wrote that code.

PartTimeCoder just posted it again.
janbo
11
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 30th Jul 2020 15:46 Edited at: 30th Jul 2020 15:56
I'd say (r#-l#)/(b#-t#) is the wrong aspectratio you probably want Width#/Height#
nevermind wasn't that but something is wrong with it.
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 30th Jul 2020 16:44 Edited at: 30th Jul 2020 16:53
It works fine as you can see from the images I posted above - regardless of aspect ratios or image sizes. I suppose if you dont know how to use it, then you would have problems.

Theres a simpler way of getting the values to pass to setcamerabounds() but i included the camera FOV calc and pixel dimensions so anyone can see where its come from and use it with any size or aspect or camera fov.

Obs...cube maps just need 90 degree FOV

Why would you be interested Janbo as you you already got this working already ?
Quote: " It works now had to look into perspective projection again"


I assume you were previously copying depth and colour images onto a cubemap after rendering each one separately before?
janbo
11
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 30th Jul 2020 17:05 Edited at: 30th Jul 2020 17:07
I didn't calculate the bounds in runtime, I had them as constants (0.5 steps). Now trying your code... am I not allowed ?
I had an atlas shader which combined the face images into my CubeImage.
I could use decoded depth and use color images for devices without depth support or not.
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 30th Jul 2020 17:18 Edited at: 30th Jul 2020 17:20
janbo wrote: "I didn't calculate the bounds in runtime,"


I dont for the cubemap...its hardcoded with the angle and aspect being fixed for that application. The example posted 2 years ago was for people to see where those numbers came from. (Projection matrix - Camera FOV, Aspect ratio and image area in pixels)

I need to calculate those values for spotlights which could have any FOV where im storing different lights in a single image so I do at runtime for those.

Quote: "I had an atlas shader which combined the face images into my CubeImage."
Yeah, i so was at first before moving to doing it with the camerabounds which means no copying necessary...Yay! It was also faster that way for me too.

janbo
11
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 30th Jul 2020 17:25 Edited at: 30th Jul 2020 17:29
Yeah and using camerabounds is a relly good idea.

Quote: "I dont for the cubemap"

Now are you sure this works flawlessly ? Cause if I put it into my cube rendering code I get this

Attachments

Login to view attachments
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 30th Jul 2020 17:29
Yes... as the images showing my cubemaps above in this thread prove...looks like you are putting some wrong values in somewhere.
janbo
11
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 30th Jul 2020 17:37 Edited at: 30th Jul 2020 18:22
I'll investigate
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 30th Jul 2020 18:27 Edited at: 30th Jul 2020 18:37
lol....quite a bit of editing your doing there ^^


Bear in mind I dont use your shader pack so somethings you are used to being setup wont be....and some things I will do that you dont.

Its quite likely your not passing the image size in the current virtual resolution or something similar thats causing an odd look on your renders. I was doing that in the example I think....it will be something obvious like that.



I dont see any seams or issues here ^^^ but obviously my cubemap layout is different to yours. Probably quite a lot that is different in reality.
janbo
11
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 30th Jul 2020 18:40 Edited at: 30th Jul 2020 18:45
Good so you saw what I did ^^ you are editing also quite a bit
I now tested it with the following setup and it doesn't work...well I belive that it works for you i just cant find the culprit.


Why should one use a renderimage thats the same size as the virtual resolution, it's rally bad actually no one wants a 10k cubeimage if he decides for some reason to choos that virtual resolution and vice versa.
How about chatting over Discord later...or maybe even tomorow ?
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 30th Jul 2020 18:46 Edited at: 30th Jul 2020 18:49
lol....I dont set the cubemap image to be the same as my screen resolution or virtual resolution.

I temporarily set the virtual resolution to that of the cubemap (typically 512,256 for a cubemap) as I do a few extra things which wont have been obvious. Plus if I want to add sprites or text...it doesnt have to be resized then.

I dont just render one cubemap to an image.... If I want to render 8 lights to a depth map I render all 8 lights 8x6 faces onto the one image so i store the image size so that it doesnt attempt to store the cubemap over the whole image.... Like I said... we do things differently and for a reason. Sometimes I want to write a cubeface to a smaller part of the final image for example.

That way...8 point lights can be rendered from one single depth image....no running out of texture slots.

Ive already proved it works ...the images show that as does the example from 2 years ago....if you cnt get it to work then thats on you.
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 30th Jul 2020 18:50 Edited at: 30th Jul 2020 18:51
I think people will be very tired of this thread by now.... chatting about this in messages or discord is a good idea so people can use the forum as it was intended and not just have to put up with the Ben and Janbo thread lolz

Login to post a reply

Server time is: 2020-08-04 04:22:20
Your offset time is: 2020-08-04 04:22:20