Skip to content

Reflect Glasses effect problem. #367

@Sol1vaN

Description

@Sol1vaN

This effect is present in Doom 3 Alpha Leaked, from 2002.
So I've found a file for materials to implement this effect into the game.

The file is implemented in:
materials\glass.mtr

Here's the code:

textures/glass/outdoor_glass1
 {
	noSelfShadow
	noshadows
	twosided
	translucent
	glass
	forceoverlays
	sort decal

	qer_editorimage textures/glass/glass1
	{
                Program           heatHaze.vfp
                vertexParm              0       time * 0 , time * 0 // texture scrolling
                vertexParm              1       .5        // magnitude of the distortion
                fragmentProgram			heatHaze.vfp
                fragmentMap             0       _currentRender
                fragmentMap             1       textures/sfx/vp1  // the normal map for distortion			
             
    }
	{	
		maskcolor				
	    map	makealpha(textures/glass/glass1)
	}	
	{
	    blend gl_dst_alpha, gl_one
	    maskalpha
       	cubeMap		env/gen2
			red		Parm0
	        green   Parm1
	        blue	Parm2
        texgen		reflect

	}
	{
     blend filter
	map textures/glass/outdoor_glass1fx
	}
//reflect stage
	{
		mirrorRenderMap 512 512		//detail of reflection, higher # = better
		blend blend
		alpha 0.3			//lower # = more transparent
		translate 0.5, 0.5
		scale 0.5, 0.5
	}
	
}

textures/glass/breakyglass3
 {
	noSelfShadow
	noshadows
	twosided
	translucent
	glass
	forceoverlays

	qer_editorimage textures/glass/breakyglass3
	{
                Program           heatHazeWithMaskAndVertex.vfp
                vertexParm              0       time * 0 , time * 0 // texture scrolling
                vertexParm              1       .5        // magnitude of the distortion
                fragmentMap             0       _currentRender
                fragmentMap             1       textures/glass/breakyglass3   // the normal map for distortion		
	            fragmentMap             2       textures/glass/4x4  // the normal map for distortion		
             
    }
	{	
		maskcolor				
	    map	makealpha(textures/glass/breakyglass3)
	}	
	{
	    blend gl_dst_alpha, gl_one
	    maskalpha
       	cubeMap		env/gen2
			red		Parm0
	        green   Parm1
	        blue	Parm2
        texgen		reflect
		vertexColor
	}
//reflect stage
	{
		mirrorRenderMap 512 512		//detail of reflection, higher # = better
		blend blend
		alpha 0.3			//lower # = more transparent
		translate 0.5, 0.5
		scale 0.5, 0.5
	}
	
}

textures/glass/breakyglass3_nvp
 {
	noSelfShadow
	noshadows
	twosided
	translucent
	glass
	forceoverlays

	qer_editorimage textures/glass/breakyglass3
	{	
		maskcolor				
	    map	makealpha(textures/glass/breakyglass3)
	}	
	{
	    blend gl_dst_alpha, gl_one
	    maskalpha
       	cubeMap		env/gen2
			red		Parm0
	        green   Parm1
	        blue	Parm2
        texgen		reflect
		vertexColor
	}
//reflect stage
	{
		mirrorRenderMap 512 512		//detail of reflection, higher # = better
		blend blend
		alpha 0.3			//lower # = more transparent
		translate 0.5, 0.5
		scale 0.5, 0.5
	}
	
}

textures/glass/breakyglass2
 {
	noSelfShadow
	noshadows
	twosided
	translucent
	glass
	forceoverlays

	qer_editorimage textures/glass/breakyglass2
	{
                Program           heatHazeWithMaskAndVertex.vfp
                vertexParm              0       time * 0 , time * 0 // texture scrolling
                vertexParm              1       .5        // magnitude of the distortion
                fragmentMap             0       _currentRender
                fragmentMap             1       textures/glass/breakyglass2   // the normal map for distortion		
	            fragmentMap             2       textures/glass/4x4  // the normal map for distortion		
             
    }
	{	
		maskcolor				
	    map	makealpha(textures/glass/breakyglass2)
	}	
	{
	    blend gl_dst_alpha, gl_one
	    maskalpha
       	cubeMap		env/gen2
			red		Parm0
	        green   Parm1
	        blue	Parm2
        texgen		reflect
		vertexColor
	}
//reflect stage
	{
		mirrorRenderMap 512 512		//detail of reflection, higher # = better
		blend blend
		alpha 0.3			//lower # = more transparent
		translate 0.5, 0.5
		scale 0.5, 0.5
	}
	
}

textures/glass/breakyglass2_nvp
 {
	noSelfShadow
	noshadows
	twosided
	translucent
	glass
	forceoverlays

	qer_editorimage textures/glass/breakyglass2
	{	
		maskcolor				
	    map	makealpha(textures/glass/breakyglass2)
	}	
	{
	    blend gl_dst_alpha, gl_one
	    maskalpha
       	cubeMap		env/gen2
			red		Parm0
	        green   Parm1
	        blue	Parm2
        texgen		reflect
		vertexColor
	}
//reflect stage
	{
		mirrorRenderMap 512 512		//detail of reflection, higher # = better
		blend blend
		alpha 0.3			//lower # = more transparent
		translate 0.5, 0.5
		scale 0.5, 0.5
	}
	
}

textures/glass/breakyglass1_nvp
 {
	noSelfShadow
	noshadows
	twosided
	translucent
	glass
	forceoverlays

	qer_editorimage textures/glass/breakyglass1
	{	
		maskcolor				
	    map	makealpha(textures/glass/breakyglass1)
	}	
	{
	    blend gl_dst_alpha, gl_one
	    maskalpha
       	cubeMap		env/gen2
			red		Parm0
	        green   Parm1
	        blue	Parm2
        texgen		reflect
		vertexColor
	}
//reflect stage
	{
		mirrorRenderMap 512 512		//detail of reflection, higher # = better
		blend blend
		alpha 0.3			//lower # = more transparent
		translate 0.5, 0.5
		scale 0.5, 0.5
	}
	
}

textures/glass/breakyglass1
 {
	noSelfShadow
	noshadows
	twosided
	translucent
	glass
	forceoverlays

	qer_editorimage textures/glass/breakyglass1
	{
                Program           heatHazeWithMaskAndVertex.vfp
                vertexParm              0       time * 0 , time * 0 // texture scrolling
                vertexParm              1       .5        // magnitude of the distortion
                fragmentMap             0       _currentRender
                fragmentMap             1       textures/glass/breakyglass1   // the normal map for distortion		
	            fragmentMap             2       textures/glass/4x4  // the normal map for distortion		
             
    }
	{	
		maskcolor				
	    map	makealpha(textures/glass/breakyglass1)
	}	
	{
	    blend gl_dst_alpha, gl_one
	    maskalpha
       	cubeMap		env/gen2
			red		Parm0
	        green   Parm1
	        blue	Parm2
        texgen		reflect
		vertexColor
	}
//reflect stage
	{
		mirrorRenderMap 512 512		//detail of reflection, higher # = better
		blend blend
		alpha 0.3			//lower # = more transparent
		translate 0.5, 0.5
		scale 0.5, 0.5
	}
	
}



textures/glass/mc_scannerglass
 {
	noSelfShadow
	noshadows
	twosided
	translucent
	glass
	forceoverlays

	qer_editorimage textures/glass/mc_scannerglass


	{	
		maskcolor				
	    map	makealpha(textures/glass/mc_scannerglass)
	}
	
	{
	    blend gl_dst_alpha, gl_one
	    maskalpha
       	cubeMap		env/mc_scanner2
        texgen		reflect

	}
//reflect stage
	{
		mirrorRenderMap 512 512		//detail of reflection, higher # = better
		blend blend
		alpha 0.3			//lower # = more transparent
		translate 0.5, 0.5
		scale 0.5, 0.5
	}

		
}

textures/glass/glass1
 {
	noSelfShadow
	noshadows
	twosided
	translucent
	glass
	forceoverlays

	qer_editorimage textures/glass/glass1
	{
                Program           heatHaze.vfp
                vertexParm              0       time * 0 , time * 0 // texture scrolling
                vertexParm              1       .4         // magnitude of the distortion
                fragmentProgram			heatHaze.vfp
                fragmentMap             0       _currentRender
                fragmentMap             1       textures/sfx/vp1   // the normal map for distortion			
             
    }
	{	
		maskcolor				
	    map	makealpha(textures/glass/glass1)
	}	
	{
	    blend gl_dst_alpha, gl_one
	    maskalpha
       	cubeMap		env/gen2
			red		Parm0
	        green   Parm1
	        blue	Parm2
        texgen		reflect

	}
//reflect stage
	{
		mirrorRenderMap 512 512		//detail of reflection, higher # = better
		blend blend
		alpha 0.3			//lower # = more transparent
		translate 0.5, 0.5
		scale 0.5, 0.5
	}
	
}

textures/glass/glass1_nvp
 {
	noSelfShadow
	noshadows
	twosided
	translucent
	glass
	forceoverlays

	qer_editorimage textures/glass/glass1
	{	
		maskcolor				
	    map	makealpha(textures/glass/glass1)
	}	
	{
	    blend gl_dst_alpha, gl_one
	    maskalpha
       	cubeMap		env/gen2
			red		Parm0
	        green   Parm1
	        blue	Parm2
        texgen		reflect

	}
//reflect stage
	{
		mirrorRenderMap 512 512		//detail of reflection, higher # = better
		blend blend
		alpha 0.3			//lower # = more transparent
		translate 0.5, 0.5
		scale 0.5, 0.5
	}
	
}

textures/glass/glass2_nvp
 {
	noSelfShadow
	noshadows
	twosided
	translucent
	glass
	forceoverlays

	qer_editorimage textures/glass/glass2

	{	
		maskcolor				
	    map	makealpha(textures/glass/glass2)
	}
	
	{
	    blend gl_dst_alpha, gl_one
	    maskalpha
       	cubeMap		env/gen2
			red		Parm0
	        green   Parm1
	        blue	Parm2
        texgen		reflect

	}
//reflect stage
	{
		mirrorRenderMap 512 512		//detail of reflection, higher # = better
		blend blend
		alpha 0.3			//lower # = more transparent
		translate 0.5, 0.5
		scale 0.5, 0.5
	}

		
}



textures/glass/glass2
 {
	noSelfShadow
	noshadows
	twosided
	translucent
	glass
	forceoverlays

	qer_editorimage textures/glass/glass2

	{
                Program           heatHaze.vfp
                vertexParm              0       time * 0 , time * 0 // texture scrolling
                vertexParm              1       .4         // magnitude of the distortion
                fragmentProgram			heatHaze.vfp
                fragmentMap             0       _currentRender
                fragmentMap             1       textures/sfx/vp1   // the normal map for distortion
             
    }

	{	
		maskcolor				
	    map	makealpha(textures/glass/glass2)
	}
	
	{
	    blend gl_dst_alpha, gl_one
	    maskalpha
       	cubeMap		env/gen2
			red		Parm0
	        green   Parm1
	        blue	Parm2
        texgen		reflect

	}
//reflect stage
	{
		mirrorRenderMap 512 512		//detail of reflection, higher # = better
		blend blend
		alpha 0.3			//lower # = more transparent
		translate 0.5, 0.5
		scale 0.5, 0.5
	}
	
}

However, this have a problems causing crash when there's more 1 windows/glasses in one scene.
So if anybody can suggest me a way to implement this, this will be great.

Also have a znear problem when you're close next to the windows, you can see how some part of the player model are cutting through the scene in the glass.

So, this have a lot of problems that need to be solved.

I'll make a MODDB channel to share this soon.

Take a look:
https://i.imgur.com/vAEvfda.jpg
https://i.imgur.com/kHRl2B7.jpg

Video:
https://www.youtube.com/watch?v=YeGRvsxSWG4

reflectglass.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions