Jump to content

Able to make light not penetrate thru?


Rick
 Share

Recommended Posts

Is there a way to have some kind of see thru model or something that prevents light from penetrating thru it?

 

I'm doing a top/down view game where I hide floors and roofs when the player enters buildings. My issue is that the directional light affects the inside of my buildings and I'd prefer if they didn't. I still, however, want them to affect the outside of my buildings. So ideally I would still be able to look into the building from above and see my character inside it, but not have the directional light affect the lighting inside.

 

I would think the ideal situation would be some kind of see thru mesh that blocks the light and isn't affected by the light.

Link to comment
Share on other sites

Paint the building parts with a transparent material.

 

Another way would be to not use Framework, because then you could hide the models before RenderWorld() and show them before RenderLights().

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Paint the building parts with a transparent material.

 

That would mean the models would need to be in the transparent world right? If that's the case would I need the models in both transparent and main world? The main world to get the physics and stuff to interact with the player, then hide the main world one and show the transparent world one? Does the physics in one world interact with the physics in another?

 

Would the invisible.mat that other models are painted with in the editor work? I assume light just goes through those models painted with that but maybe there is a setting in the mat file to change that? Also, if I can do that how do I apply that mat in code?

 

 

Another way would be to not use Framework, because then you could hide the models before RenderWorld() and show them before RenderLights().

 

Then I have to do the lua setup stuff myself though right? Could I still use the framework to get the lua stuff working but not call the frameworks RenderFramework(); but instead break that out? Is there a way to get the gbuffer from the framework?

 

I feel like this would probably be the best way to do it, just sucks the framework is not flexible enough to handle stuff like this.

Link to comment
Share on other sites

You need to keep the models in the normal world, since you explicitely want to see the shadows of transparent objects.

 

Framework should get a finer breakdown of the rendering controls, for example:

fw.Update()
// your main game code here, also hiding of invisible objects using entity.Hide()
fw.RenderWorld()
// code here to make the invisible objects visible again using entity.Show()
fw.RenderLights()
fw.Flip(0)

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

You need to keep the models in the normal world, since you explicitely want to see the shadows of transparent objects.

 

So would that invisible.mat material work for this? Also how do I apply that to models in code? I guess I would need to switch between the models currently material and this one since I need to show and hide them in realtime.

Link to comment
Share on other sites

So would that invisible.mat material work for this? Also how do I apply that to models in code? I guess I would need to switch between the models currently material and this one since I need to show and hide them in realtime.

No, you don't need invisible.mat. You need a transparent material. You can paint models with PaintEntity(entity,material) in realtime, so you don't have to have multiple models loaded.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

OK, I'll give that a try tonight. I'll make a transparent texture, and load that at runtime and paint it to the model's I need to be transparent. How can I get the current material on a model then? Ideally I would just be able to save the current materials off of the models so I can reapply them when I need to "show" them again. I didn't see a command for GetMaterial() though.

Link to comment
Share on other sites

This didn't seem to work for me at all.

 

Here is my mat file

 

texture0="abstract::transparent.dds"

shader="abstract::mesh_diffuse_bumpmap.vert","abstract::mesh_diffuse_bumpmap_specular.frag"

 

Here is transparent.dds

 

http://dl.dropbox.com/u/1293842/transparent.dds

 

Here is the code I use

 

TMaterial _transparentMat = LoadMaterial("abstract::transparent.mat");

//where ent is the model so it's child is the mesh. if I just try painting the model nothing changes so had to do this
PaintEntity(GetChild(ent, 1), _transparentMat);

 

Here is the before

 

http://dl.dropbox.com/u/1293842/Before.jpg

 

Here is the after

 

http://dl.dropbox.com/u/1293842/After.jpg

 

The strange thing is that if you look at the after, it's almost like it's putting the normal map for the swat guy. No clue why it's doing that.

 

 

Any ideas?

Link to comment
Share on other sites

This didn't seem to work for me at all.

 

Here is my mat file

 

texture0="abstract::transparent.dds"

shader="abstract::mesh_diffuse_bumpmap.vert","abstract::mesh_diffuse_bumpmap_specular.frag"

The strange thing is that if you look at the after, it's almost like it's putting the normal map for the swat guy. No clue why it's doing that.

Any ideas?

 

Without even looking at the pictures or anything else, your problem is your mat file. You are using a bumpmap shader but yet have no texture assigned to the bumpmap texture slot in the mat file which is typically texture1.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

OK, I have

 

texture0="abstract::transparent.dds"

castshadows=1
nodraw=1 
shader="abstract::mesh_diffuse_bumpmap.vert","abstract::mesh_diffuse_bumpmap_specular.frag"

 

But I get the same result.

 

 

 

If I make the material look like

 

texture0="abstract::transparent.dds"

castshadows=1
nodraw=1 
shader="abstract::mesh_diffuse.vert","abstract::mesh_diffuse.frag"

 

I don't get the roof looking like it has the swat bumpmap, but it's still shaded like my after picture above, and not see thru.

Link to comment
Share on other sites

blend=alpha only makes the material transparent when the texture has a transparent alpha channel, while blend=light makes everything transparent, but in a funny way which is affected by light a lot. There is a more technical explanation, but I'm too lazy to think about it now ;)

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Well it's getting closer but not 100% there. The mat file that looks like:

 

texture0="abstract::transparent.dds"

castshadows=1
nodraw=1 
blend=light
shader="abstract::mesh_diffuse.vert","abstract::mesh_diffuse.frag"

 

produces http://dl.dropbox.com/u/1293842/after3.jpg

 

 

and the mat file that looks like:

 

texture0="abstract::transparent.dds"

castshadows=1
nodraw=1 
blend=alpha
shader="abstract::mesh_diffuse.vert","abstract::mesh_diffuse.frag"

 

produces http://dl.dropbox.com/u/1293842/after2.jpg

 

 

So it's not there because you can't see the inside of the building. I have no idea why I can see the player but not the inside of the building.

 

 

After thinking about this I'm not 100% sure it's possible to do this. I mean I would need the light on the inside of the building to be able to be seen so it's not pure black, but the light on the outside to stop at the transparent part, so it doesn't affect the inside. Even rendering the lights and hiding/showing models in a certain order would still give me the same black result.

 

So can anyone think of a way to do this. It's like popping the roof off a house but not having the sunlight affect the inside of the house, but now you see the light on the inside as if the roof was still there.

Link to comment
Share on other sites

I experimented ( a lot ) with it - keeping a barely visible roof with no direct lighting

 

texture0="abstract::dirtyglass2.dds"
clamp0=0,0,0

//seethrough
color=1,1,1,0.55
blend=1
//but cast shadow
//nodraw=1
castshadows=1

depthmask=1
depthtest=1
cullface=1
overlay=0
zsort=0

specular=0.4
bumpscale=0.1
gloss=0.4

shader="abstract::mesh_diffuse.vert","abstract::mesh_diffuse.frag"
shadowshader="abstract::mesh_shadow.vert",""

 

However, shadows casted in the house aint visible from outside too.

 

[edit] changed nodraw commnad

AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3

zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5

 

adv_banner-april2012_720x150_tex01.png

 

Xxploration FPS in progress ...

Link to comment
Share on other sites

That mat file didn't seem to work either. I get some very random color of the floor but it's still mostly black. Is my transparent image not correct? I linked it above in dds format. Maybe someone can check it out.

 

I wonder if an inverted mesh on the inside ceiling and a transparent mesh on the roof part would work. That should allow one to see inside and the light should still bounce off the ceiling mesh.

Link to comment
Share on other sites

Here is the lua render - and these are separate model, assembled witin a dummy lua model. In this case its only the roof texture which gets replaced by a glass texture after close enough to the object

 

	if fw~=nil then

		object.model:Hide()
		pick2 = CameraPick(camera,Vec3(GraphicsWidth()/2,GraphicsHeight()/2, 25.0),0,0)
		object.model:Show()

		if pick2~=nil then

			SetWorld(fw.transparency.world) 

				object.model:Paint(LoadMaterial("abstract::dirtyglass2.mat"), 1)

			SetWorld(fw.main.world)

		else
			-- [fixme] rePaint original material ...
			-- and scale materials alpha value by distance
			object.model:Paint(LoadMaterial("abstract::gTown_1_1024.mat"), 1)
		end
	end

 

http://www.devmex.com/leFiles/blendRoof.png

 

PS : lightmaps could be viewed from outside still.

AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3

zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5

 

adv_banner-april2012_720x150_tex01.png

 

Xxploration FPS in progress ...

Link to comment
Share on other sites

Ah, so you also mess around with the transparent world. Lum was saying that wasn't needed. Still that sucks that you aren't getting shadows too.

 

Why is it always something ><

 

I guess for now I'll just deal with the outside light affecting the inside.Frustrating.

 

I'm really thinking inverting the top part might work. I'll play around with that.

Link to comment
Share on other sites

So having a mesh that just has faces on the ceiling works for stopping the inside light from going outside the building, but not having a face on the top part still allows outside light to come in. So now I would think having a transparent top part of the roof could stop the outside light from coming in, but still see thru.

 

If we can figure that part out then this would be golden. That should allow shadows on the inside.

 

I could just hide the directional light when I go inside the building. That gives the look on the inside that I'm after but then the outside is kind of bland.

 

[edit]

Really what I need is a light stopping brush that can be see thru.

Link to comment
Share on other sites

For the preview i actually planned it that way, that the walls are removed too - where the walls where removed can be seen on the floor but i like the see-through idea. I just test in the editor - how one has to sort the transparency.world outside the editor i can only guess atm.

 

Another idea is to just hide the mesh - make it allways ambient_midnight or high noon, so the sun isnt in the way that much. I didnt played many such games ( only jagged alliance and fallout iirc - which are iso ) but i guess they had a lot of such issues in the design to solve.

AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3

zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5

 

adv_banner-april2012_720x150_tex01.png

 

Xxploration FPS in progress ...

Link to comment
Share on other sites

Yeah, the idea would be like in fallout 1 & 2, but like you said fallout is iso and was in 2D so they had finer control over every pixel.

 

I'm guessing a shader could be made that stops the light in it's tracks. Of course I don't know anything about coding shaders so that's out of the question for me. Then again if it stopped the light, I would assume that mesh would then turn black.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...