Texture Articfacts Realtime OpenGL

General questions and troubleshooting SOFTIMAGE©
Post Reply
User avatar
thefoofighter
Posts: 16
Joined: 21 Jan 2019, 16:56
Location: ZA

Texture Articfacts Realtime OpenGL

Post by thefoofighter » 17 Feb 2019, 10:20

Hi All,

I have a strange issue regarding the realtime rendering of a special image I made to ensure that my perspective camera has been setup as pixel perfect (which means 1 SI unit = 1 pixel)

I am using SI 2015 sp2

The image is 1920*720 and made up of a black and white checkerboard, and some text.

PP_Grid.png


This here shows the issue a little clearer.
Basically I have interpolate switched off on the image and OGL texture because I really want to see these pixels as they exist in the loaded PNG, exactly as the Clip Viewer displays them
I suspect that SI internally is doing something to the horizontal axis as the input image is not a power of 2..

texture_issue_si2015.png
When I preview my render to a set resolution of 1920*720 is see the same artifacts..

It is probably something super simple that I am missing or it is an issue I cannot work around.
Does anyone here have any clue what might be happening?

This here is the SI2015 Scene if you have a chance to look at it.
PixelPerfect.zip
(497.32 KiB) Downloaded 91 times

Thank you very much,
Foo

User avatar
FXDude
Posts: 1129
Joined: 19 Jun 2012, 21:59

Re: Texture Articfacts Realtime OpenGL

Post by FXDude » 18 Feb 2019, 06:30

Hi Foo,

There seems to be a res limit to the GLSL shader.

If you plug the texture in a constant it's 'fine', or rather as fine as it could get, because it's a grid pattern made of another pixel-level mini-grid pattern of almost white/black pixels
(litterally the worst conditions, or a nightmare to sample without 'moire' even if supersampled in a render) you'd have to be on a 1 to 1 (no zoom) perfectly perpendicular view to the grid for things to not come out horrible.

And Is there a specific reason why you'd want to use GLSL shaders?

best of luck,

User avatar
thefoofighter
Posts: 16
Joined: 21 Jan 2019, 16:56
Location: ZA

Re: Texture Articfacts Realtime OpenGL

Post by thefoofighter » 18 Feb 2019, 07:31

Hi FXDude,

I was suspecting as much and it is probably something i cannot work around unless maybe I use mixed display mode if that even works with constant & opengl together. I'll have to check.

The grid pattern is literally only to make sure that my camera settings are correct for working in pixel perfect conditions. I would only use the render/screenshot to check in PS that no pixels are being stretched.
I know though that the camera position is right as I use it in blender and other realtime applications and it works there too.
I prefer the modeling workflow in SI to blender so I wanted to stick with it :)

I work in automotive UI for realtime applications so we use glsl & 3D heavily to achieve affects that would otherwise need to be prerendered video/image sequences and memory bandwidth on these embedded chips is usually very limited.
I wanted to prototype my shaders & 3d objects first in SI before I export to our renderer.

I also know that i would have that nasty moire effect and that is part of the reason I use the grid because spotting that means I am not looking at my scene @ 100% zoom.

I was hoping to also figure out how to set my viewport to exactly 1920*720, The Clip view automatically shows my clip at 100% even if the window/viewport is stretched bigger and when the viewport is smaller it still remains at 100% and just tucks in underneath/clips the image.
If i could do the same for my main camera's viewport it would provide ideal conditions for moving and tweaking elements as they would finally look.

Any ideas on how i could achieve that?

Thank you :)

Foo

User avatar
thefoofighter
Posts: 16
Joined: 21 Jan 2019, 16:56
Location: ZA

Re: Texture Articfacts Realtime OpenGL

Post by thefoofighter » 18 Feb 2019, 08:22

Ok so yes it is a limitation to OGL Texture node. Seems like it is going by the old notion that textures must be powers of 2.

So the work around was to make the texture 2048*1024 (used blank white space to right and bottom of image) and use SI's pixel snapping in the Texture Editor to update the projection ^^

There may be some hidden setting for this somewhere but I have yet to find it. Until then this workaround will work fine. Most of the elements i build are very small and I was not going to export out this Grid anyway.

If anyone has any ideas as to how to create or set a viewport to a resolution please do let me know.
I was wondering if it would be possible to edit the "Floating camera view" Script you found FXDude to include some kind of viewport size/resolution?

I do not know the api well enough yet to know if it is possible.

Foo

User avatar
myara
Posts: 403
Joined: 28 Sep 2011, 10:33

Re: Texture Articfacts Realtime OpenGL

Post by myara » 18 Feb 2019, 11:25

You could try with this, to create a floating camera view, in JScript:

This will create a floating view of the camera you are selecting
If you are not selecting a camera it will create a floating view of the camera you are using in your current view
If your current view is the User camera it can't do it so it will create a new camera and copy your User Camera settings to this new camera and create a floating view.

You can set your floating view size, but it will be the floating view size, not the viewable size, including the view border, without the menu.
For the border it should be around 3 pix per side so I guess 1926x726 would give you 1920x720 view size.

Code: Select all

//JScript
sizeX = 1920
sizeY = 720

function CopyParams(source, target, propertyName){
    if (propertyName){
        target = target.Properties(propertyName)
        source = source.Properties(propertyName)
    }
        
    for ( var i=0, a = target.Parameters.Count; i < a; i++ ) {
		var tParam = target.Parameters(i)
		var tParamName = (tParam.FullName.substring(tParam.FullName.lastIndexOf(".")+1, tParam.FullName.length))
		var sParam = source.Parameters(tParamName)
		if ( sParam )	{
			if (sParam.value != undefined)	tParam.value = sParam.value
		}
	}
}

// Get Camera from Selected Camera:
if (Selection.Count!=0 && Selection(0).IsClassOf(siX3DObjectID)){
	mCamera = Selection(0).FindChildren("","camera")
}

// If can't get camera from selection
// Get Camera from View Port
if (mCamera == null) {
	var vw = GetFocusedViewport()
	var vwindex = [["A",0],["B",1],["C",2],["D",3]]
	switch(vw){
		case "A": var mCamera = GetViewCamera(0);break;
		case "B": var mCamera = GetViewCamera(1);break;
		case "C": var mCamera = GetViewCamera(2);break;
		case "D": var mCamera = GetViewCamera(3);break;
	}
}

// If No Cam detected, Get First camera found in Root
if (mCamera == null){
    mCamera = ActiveSceneRoot.FindChildren("","camera")(0)
}

// If Camera = UserCamera
// Since User Camera can't be attached to ObjectView, and we can't duplicate it,
// Create a new camera and make it look like the UserCamera
if (mCamera.name == "UserCamera"){
    if (! vw)        var vw = GetFocusedViewport()
	
    // Create the camera under a Model called ObjCam for easy recognition
	//-----
    root = ActiveSceneRoot
    modelName = "Views"+ vw + "_UserCamera"
    
	// If already exists, delete it
    if (root.Children(modelName)){
        DeleteObj("B:"+ root.Children( modelName ) )
    }
	
    camModel = root.AddModel( "", "Views"+ vw + "_UserCamera" )
    var NewCam = camModel.AddPrimitive( "Camera" );
    NewCam.Name = "UserCamera"
	//-----
	
	// Copy Camera parameters
    NewCam.Kinematics.Global.Transform = mCamera.Kinematics.Global.Transform
    CopyParams( mCamera, NewCam, "Camera Display" )
	CopyParams( mCamera, NewCam, "Camera Visibility" )
    CopyParams( mCamera, NewCam, "Camera Rotoscopy" )
    CopyParams( mCamera, NewCam, null )
	
	NewCam.fov = mCamera.fov.value
    NewCam.Properties("Visibility").viewvis = 0

	// Set new created camera as mCamera
	mCamera = NewCam
}


// Create View
var oLayout = Desktop.ActiveLayout;
var oView = oLayout.CreateView( "Object View", "OV" );

// Set Size and state
oView.BeginEdit();
oView.Resize( sizeX, sizeY );
oView.State = siNormal;
oView.EndEdit();

// Set ObjectView
oView.SetAttributeValue("displayall", "true")
oView.SetAttributeValue("camera", mCamera.FullName)
M.Yara
Character Modeler | Softimage Generalist (sort of)

User avatar
FXDude
Posts: 1129
Joined: 19 Jun 2012, 21:59

Re: Texture Articfacts Realtime OpenGL

Post by FXDude » 18 Feb 2019, 17:20

Hah, so the high contrast pattern which I thought was the main issue was actually the point lol.

You can indeed immediately tell where pixels either overlap anywhere or get muddled together anywhere.


Perhaps in addition to Myaras script, perhaps the following may be of help,
PixelPerfect--Views.zip
(184.01 KiB) Downloaded 100 times

In the zip file is an 'Application' folder (containing 2 views of preset sizes)
that you can drop directly under your profile's Softimage_2015xx folder,
Restart XSI, and open the included version of your scene.

You could later set myaras script to these same sizes.


For now 2 new views appear in View -> Others called '1 to 1 PixelView Big' and 'Small'

Open say the ' 1 to 1 PixelView Big' view, look through the camera of the same name through that ObjView

and Enable 'display all objects' in objViewfirst menu

The cam is saved in texture mode, so switch to HiQuality, (btw, HQ view should also display your GLSL code fine!)
already the view should be 1 to 1 but even if you loose synch with pixels, you can always reframe the sized grid.

(doing these things could also be added to myaras script)
(note here that there is a bug when you re-open a view in HQ mode, you need to switch to something else and switch back to HQ to see something)


There are 2 grids that you can frame, one for Big (full frame view) one for Small (cropped),
their sizes are based on the offset difference of cam angle margins when objects are framed
and that's it.

If you want to setup a new window size,
you can size an ObjView to desired size,
and These grids were sized using ObjView's tranform following feature with the sized grid selected, while the textured grid remained visible
So scaling the always framed grid would also zoom the camera, so then you can scale slowly around where pixels start to all line up near 1 to 1 .
(in the prefs temporalily set scaling transform increments to ultra low like 0.01)

so then anytime you frame that grid from that new view size, pixels would be 1 to 1.


Also thanks for making me learn about pixel grids, I'll keep this pic handy, and will prabably make a 1080p one!

Good luck & Hope it helps!

User avatar
thefoofighter
Posts: 16
Joined: 21 Jan 2019, 16:56
Location: ZA

Re: Texture Articfacts Realtime OpenGL

Post by thefoofighter » 19 Feb 2019, 08:29

@myara: Thank you for this script, its actually pretty straight forward reading through it and works as expected :)

@FXDude: Thank you for the views, i didn't know it was possible to add new ones like that :) Good thing you mentioned that HQ bug, i was scratching my head for a while ^^
Glad you learned something from it too. I was not explaining it very well but I see you figured out exactly the purpose for these grids and whats makes them super useful :)

I think I have almost everything I need no to start productively creating things through SI :)

I would still like to figure out if it is possible to load non power of 2 image as an OGLTexture some day ^^
Is it possible to develop custom nodes for the render tree / shader lib ?

Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests